summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpennae <pennae.git@eno.space>2023-09-27 17:50:01 +0200
committerpennae <pennae.git@eno.space>2023-09-27 21:41:25 +0200
commit01e776a5c3d6e4929e9fd7c65e6c328519040810 (patch)
tree08d8411b594c7a28fb0d70a0fdf99814ff589a7a
parent277569bfc04a577a189e87b82ef78a51e8f988ee (diff)
downloaddewclaw-01e776a5c3d6e4929e9fd7c65e6c328519040810.tar.gz
dewclaw-01e776a5c3d6e4929e9fd7c65e6c328519040810.tar.xz
dewclaw-01e776a5c3d6e4929e9fd7c65e6c328519040810.zip
improve on-device logging slightly
tell the user that a deployment has failed and log reboot messages from the device, just in case the network broke before the reboot (in which case logging the reboot event from the deploying host would be misleading)
-rw-r--r--openwrt/config_generation.sh15
-rw-r--r--openwrt/default.nix2
2 files changed, 12 insertions, 5 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() {
diff --git a/openwrt/default.nix b/openwrt/default.nix
index d609760..47f2946 100644
--- a/openwrt/default.nix
+++ b/openwrt/default.nix
@@ -100,8 +100,6 @@ let
${s.apply}
'')
steps}
-
- log 'rebooting device ...'
'';
rollback_timeout = config.deploy.rollbackTimeout;
} ''