 	)
 
 stage2Tasks = [
-	setHakiEnv
 	(callback) -> async.forever(updateRepo, callback)
 ]
 

		)
]

setHakiEnv = (callback) ->
	process.setuid(posix.getpwnam('haki').uid)
	process.chdir(HAKI_PATH)
	callback()

stage1Tasks = [
	(callback) -> async.waterfall(bootstrapTasks, callback)
	(callback) -> fs.writeFileSync(STATE_FILE, JSON.stringify(state)) ; callback()
	(callback) -> exec('systemctl start openvpn@client', callback)
	(callback) -> exec('systemctl enable openvpn@client', callback)
	setHakiEnv
	(callback) -> fs.mkdir('hakiapp', callback)
	(callback) -> exec('git init', cwd: 'hakiapp', callback)
	(callback) -> exec("git remote add origin #{state.gitUrl}", cwd: 'hakiapp', callback)
	(callback) -> console.log('Bootstrapped') ; callback()
]

updateRepo = (callback) ->
	tasks1 = [
		(callback) -> exec('git pull origin master', cwd: 'hakiapp', callback)
		(stdout, stderr, callback) -> exec('git rev-parse HEAD', cwd: 'hakiapp', callback)
		(stdout, stderr, callback) -> callback(null, stdout.trim())
	]


async = require('async')
request = require('request')
posix = require('posix')
{exec, spawn} = require('child_process')

STATE_FILE = '/opt/ewa-client-bootstrap/state.json'
API_ENDPOINT = 'http://paras.rulemotion.com:1337'
