diff options
Diffstat (limited to 'openwrt/config_generation.sh')
-rw-r--r-- | openwrt/config_generation.sh | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/openwrt/config_generation.sh b/openwrt/config_generation.sh index e119608..a442863 100644 --- a/openwrt/config_generation.sh +++ b/openwrt/config_generation.sh @@ -16,32 +16,37 @@ _rollback() { if mv -T /overlay/upper.prev /overlay/upper; then rm -rf /overlay/upper.dead else - echo "rollback failed, check /overlay/upper.dead and recover!" >&2 + echo "rollback failed, manual recovery needed. check /overlay/upper.dead!" >&2 exit 1 fi } apply() { CYAN='\e[36m' + RED='\e[31m' NORMAL='\e[0m' log() { printf "$CYAN>> %s$NORMAL\n" "$*" } + log_err() { + printf "$RED>> %s$NORMAL\n" "$*" + } + if ! rm -rf /overlay/upper.prev/ \ || ! cp -al /overlay/upper/ /overlay/upper.prev/ \ || ! rm -rf /overlay/upper.prev/etc/ \ || ! cp -a /overlay/upper/etc/ /overlay/upper.prev/ then - echo "failed to snapshot old config" + log_err "failed to snapshot old config" rm -rf /overlay/upper.prev exit 1 fi if ! /etc/init.d/config_generation enable then - echo "failed to schedule rollback" + log_err "failed to schedule rollback" rm -rf /overlay/upper.prev exit 1 fi @@ -57,8 +62,12 @@ apply() { @deploy_steps@ ) then + log_err 'deployment failed, rolling back and rebooting ...' _rollback + exit 1 fi + + log 'rebooting device ...' } commit() { |