mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-21 22:47:49 +00:00
Added stage2 tasks to initialize the user's git repo
This commit is contained in:
parent
8b2d7289d6
commit
98891f4ba5
28
app.coffee
28
app.coffee
@ -4,6 +4,7 @@ request = require('request')
|
||||
{exec} = require('child_process')
|
||||
|
||||
API_ENDPOINT = 'http://paras.rulemotion.com:1337'
|
||||
HOME_PATH = '/home/haki'
|
||||
|
||||
try
|
||||
state = require('./state.json')
|
||||
@ -27,12 +28,16 @@ bootstrapTasks = [
|
||||
return callback(error)
|
||||
|
||||
try
|
||||
if typeof body isnt 'object'
|
||||
throw new Error(body)
|
||||
|
||||
body = JSON.parse(body)
|
||||
catch error
|
||||
callback(error)
|
||||
|
||||
|
||||
state.virgin = false
|
||||
state.uuid = body.uuid
|
||||
state.giturl = body.giturl
|
||||
|
||||
fs.writeFileSync('state.json', JSON.stringify(state))
|
||||
|
||||
@ -51,6 +56,25 @@ stage1Tasks = [
|
||||
(callback) -> exec('systemctl enable openvpn@client', callback)
|
||||
]
|
||||
|
||||
stage2Tasks = [
|
||||
(callback) -> process.chdir("#{HOME_PATH}/hakiapp")
|
||||
(callback) -> exec('npm install', callback)
|
||||
(callback) -> exec('foreman start', callback)
|
||||
]
|
||||
|
||||
async.series(stage1Tasks, ->
|
||||
console.log('Bootstrapped')
|
||||
)
|
||||
|
||||
async.doUntil(
|
||||
-> fs.existsSync('hakiapp')
|
||||
(callback) ->
|
||||
process.chdir(HOME_PATH)
|
||||
console.log('git clone')
|
||||
exec("git clone #{state.giturl}")
|
||||
setTimeout(callback, 1000)
|
||||
(error) ->
|
||||
if error?
|
||||
console.error(error)
|
||||
else
|
||||
console.log('Initialized')
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user