mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-01-18 02:40:03 +00:00
Added stage2 tasks to initialize the user's git repo
This commit is contained in:
parent
8b2d7289d6
commit
98891f4ba5
24
app.coffee
24
app.coffee
@ -4,6 +4,7 @@ request = require('request')
|
|||||||
{exec} = require('child_process')
|
{exec} = require('child_process')
|
||||||
|
|
||||||
API_ENDPOINT = 'http://paras.rulemotion.com:1337'
|
API_ENDPOINT = 'http://paras.rulemotion.com:1337'
|
||||||
|
HOME_PATH = '/home/haki'
|
||||||
|
|
||||||
try
|
try
|
||||||
state = require('./state.json')
|
state = require('./state.json')
|
||||||
@ -27,12 +28,16 @@ bootstrapTasks = [
|
|||||||
return callback(error)
|
return callback(error)
|
||||||
|
|
||||||
try
|
try
|
||||||
|
if typeof body isnt 'object'
|
||||||
|
throw new Error(body)
|
||||||
|
|
||||||
body = JSON.parse(body)
|
body = JSON.parse(body)
|
||||||
catch error
|
catch error
|
||||||
callback(error)
|
callback(error)
|
||||||
|
|
||||||
state.virgin = false
|
state.virgin = false
|
||||||
state.uuid = body.uuid
|
state.uuid = body.uuid
|
||||||
|
state.giturl = body.giturl
|
||||||
|
|
||||||
fs.writeFileSync('state.json', JSON.stringify(state))
|
fs.writeFileSync('state.json', JSON.stringify(state))
|
||||||
|
|
||||||
@ -51,6 +56,25 @@ stage1Tasks = [
|
|||||||
(callback) -> exec('systemctl enable openvpn@client', callback)
|
(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, ->
|
async.series(stage1Tasks, ->
|
||||||
console.log('Bootstrapped')
|
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