Skip to content

Commit

Permalink
feat: allow deployment confirmation to be skipped
Browse files Browse the repository at this point in the history
  • Loading branch information
MakiseKurisu committed Mar 1, 2025
1 parent b58ceee commit 5706276
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
10 changes: 7 additions & 3 deletions openwrt/config_generation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ commit() {
touch /tmp/.abort-rollback
}

yolo() {
touch /etc/.abort-rollback
}

start() {
[ -d /overlay/upper.prev ] || {
echo 'no configuration reload in progress. rollback service might be left enabled by accident. clean up ...'
Expand All @@ -142,11 +146,11 @@ start() {

while [ $timeout -gt 0 ]; do
timeout=$(( timeout - 1 ))
[ -e /tmp/.abort-rollback ] && {
if [ -e /tmp/.abort-rollback ] || [ -e /etc/.abort-rollback ]; then
needs_rollback=false
rm /tmp/.abort-rollback
rm -f /tmp/.abort-rollback /etc/.abort-rollback
break
}
fi
sleep 1
done

Expand Down
21 changes: 16 additions & 5 deletions openwrt/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ let
main() {
RELOAD_ONLY=false
DEPLOY_CONFIRMATION=true
TIMEOUT=${toString rebootTimeout}s
for arg in "$@"; do
Expand All @@ -225,6 +227,9 @@ let
RELOAD_ONLY=true
TIMEOUT=${toString reloadTimeout}s
;;
--yolo|--no-confirmation)
DEPLOY_CONFIRMATION=false
;;
*)
echo "error: unknown argument: $arg" >&2
echo >&2
Expand Down Expand Up @@ -252,6 +257,10 @@ let
# timeout.
log 'applying config'
ssh -Nf
if !$DEPLOY_CONFIRMATION; then
log 'disabling deployment confirmation'
ssh '/etc/init.d/config_generation yolo'
fi
if $RELOAD_ONLY; then
ssh 'logread -l9999 -f' &
ssh '/etc/init.d/config_generation prepare_reload'
Expand All @@ -269,11 +278,13 @@ let
$2 { print $2 }
'
log 'waiting for device to return'
__DO_WAIT=1 timeout --foreground $TIMEOUT "$0" || {
log_err 'configuration change failed, device will roll back and reboot'
exit 1
}
if $DEPLOY_CONFIRMATION; then
log 'waiting for device to return'
__DO_WAIT=1 timeout --foreground $TIMEOUT "$0" || {
log_err 'configuration change failed, device will roll back and reboot'
exit 1
}
fi
log 'new configuration applied'
}
Expand Down

0 comments on commit 5706276

Please sign in to comment.