# # # add_file "update-policy.sh" # content [0087dede16e0fcb24282fb693a06f85b12a8f0a9] # # patch "policy.lua" # from [36b9cce55e1d7eb142ea730c6dbd342681018b9d] # to [69469449c77c4ec97c050b841060390988eb0557] # ============================================================ --- update-policy.sh 0087dede16e0fcb24282fb693a06f85b12a8f0a9 +++ update-policy.sh 0087dede16e0fcb24282fb693a06f85b12a8f0a9 @@ -0,0 +1,42 @@ +#!/bin/sh + +do_work() { +# The local server, that this is pulling from +# and updating the configuration of. +SERVER="localhost" + +BRANCHES="$1" + +[ -f policy.mtn ] || mtn -d policy.mtn db init + +DB="--db $(pwd)/policy.mtn" +CONFDIR="--confdir $(pwd)" +RCFILE="--rcfile $(pwd)/update-policy.lua" +CLIENTCONF="${DB} ${CONFDIR} ${RCFILE}" + +mtn $CLIENTCONF pull $SERVER $(cat serverctl-branch) --quiet || exit $? + +if [ -d serverctl ] +then + (cd serverctl && mtn $CLIENTCONF update) +else + mtn $CLIENTCONF checkout -b $(cat serverctl-branch) serverctl +fi + +mtn $CLIENTCONF pull $SERVER '' --exclude 'policy-branches-updated' --quiet +} + +run() { +cd $1 + +while ! mkdir update-policy.lock +do + sleep 1 +done + +do_work $2 + +rmdir update-policy.lock +} + +run "$@" & ============================================================ --- policy.lua 36b9cce55e1d7eb142ea730c6dbd342681018b9d +++ policy.lua 69469449c77c4ec97c050b841060390988eb0557 @@ -156,7 +156,7 @@ function note_netsync_end(sid, status, b if ci > 0 or ri > 0 or ki > 0 then server_maybe_request_sync(sessions[sid].key, sessions[sid].branches) elseif sessions[sid].include == '' and - sessions[sid].exclude == 'ctl-branch-updated' then + sessions[sid].exclude == 'policy-branches-updated' then log("resyncing after a config update...") server_maybe_request_sync('') end @@ -164,8 +164,7 @@ function note_netsync_end(sid, status, b -- Do we update the control checkout? local ctlbranch = trim(read_conffile("serverctl-branch")) if ctlbranch and sessions[sid].branches[ctlbranch] then - log("updating configuration...") - execute(get_confdir() .. "/serverctl-update.sh", get_confdir()) + execute(get_confdir() .. "/update-policy.sh", get_confdir()) end sessions[sid] = nil end