mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-04-16 23:38:52 +00:00
added bootstrap and stage1 procedures
This commit is contained in:
parent
6effb8b053
commit
84e0273e8a
18
app.coffee
18
app.coffee
@ -1,10 +1,10 @@
|
||||
fs = require('fs')
|
||||
async = require('async')
|
||||
request = require('request')
|
||||
{exec} = require('child_process')
|
||||
|
||||
API_ENDPOINT = 'http://paras.rulemotion.com:1337'
|
||||
|
||||
|
||||
try
|
||||
state = require('state.json')
|
||||
catch e
|
||||
@ -12,11 +12,13 @@ catch e
|
||||
process.exit()
|
||||
|
||||
bootstrapTasks = [
|
||||
# get config from extra partition
|
||||
(callback) ->
|
||||
try
|
||||
callback(null, require('/mnt/config.json'))
|
||||
catch error
|
||||
callback(error)
|
||||
# bootstraping
|
||||
(config, callback) ->
|
||||
request.post("#{API_ENDPOINT}/associate", {
|
||||
user: config.id
|
||||
@ -33,9 +35,21 @@ bootstrapTasks = [
|
||||
state.uuid = body.uuid
|
||||
|
||||
fs.writeFileSync('state.json', JSON.strigify(state))
|
||||
|
||||
|
||||
fs.writeFileSync('/etc/openvpn/ca.crt', body.ca)
|
||||
fs.writeFileSync('/etc/openvpn/client.crt', body.cert)
|
||||
fs.writeFileSync('/etc/openvpn/client.key', body.key)
|
||||
|
||||
callback(null)
|
||||
)
|
||||
]
|
||||
|
||||
stage1Tasks = [
|
||||
(callback) -> async.waterfall(bootstrapTasks, callback)
|
||||
(callback) -> exec('systemctl start openvpn@client', callback)
|
||||
(callback) -> exec('systemctl enable openvpn@client', callback)
|
||||
]
|
||||
|
||||
async.series(stage1Tasks, ->
|
||||
console.log('Bootstrapped')
|
||||
)
|
||||
|
@ -1,4 +1,5 @@
|
||||
{
|
||||
"virgin": true,
|
||||
"uuid": null
|
||||
"uuid": null,
|
||||
"giturl": null
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user