diff --git a/Makefile b/Makefile index c56df20..8c8e313 100644 --- a/Makefile +++ b/Makefile @@ -93,25 +93,26 @@ bootstrap-clean: host-bootstrap-clean # Finalize: reconect admin port/bridge correctly... -.PHONY: _finalize -_finalize: bootstrap-clean gate-bootstrap-clean +.PHONY: finalize +finalize: gate-bootstrap-clean + make host-bootstrap-clean make host-bootstrap-clean -.PHONY: finalize -finalize: - ### - ### This will break the connection to the server, to continue: - ### - Detach the ADMIN port, - ### - Connect the WAN port, - ### - $ ssh @ - ### from there: - ### $ ssh root@pve - ### then: - ### # tmux a - ### - When done this will reboot the system. - ### - tmux new-session 'make _finalize' +#.PHONY: finalize +#finalize: +# ### +# ### This will break the connection to the server, to continue: +# ### - Detach the ADMIN port, +# ### - Connect the WAN port, +# ### - $ ssh @ +# ### from there: +# ### $ ssh root@pve +# ### then: +# ### # tmux a +# ### - When done this will reboot the system. +# ### +# tmux new-session 'make _finalize' diff --git a/host/make.sh b/host/make.sh index 8c459eb..673a5a4 100755 --- a/host/make.sh +++ b/host/make.sh @@ -52,6 +52,18 @@ BRIDGES_TPL=${BRIDGES_TPL:-bridges.tpl} if ! [ -z $BOOTSTRAP_CLEAN ] ; then @ cp "$INTERFACES"{,.bak} + __finalize(){ + if reviewApplyChanges "$INTERFACES" ; then + # XXX this must be done in nohup to avoid breaking on connection lost... + if ! @ ifreload -a ; then + # reset settings back if ifreload fails... + @ cp "$INTERFACES"{.bak,} + @ ifreload -a + fi + fi + unset -f __finalize + } + # stage 1: bootstrap -> clean if [ -e "$INTERFACES".clean ] ; then @ mv "$INTERFACES"{.clean,.new} @@ -62,6 +74,8 @@ if ! [ -z $BOOTSTRAP_CLEAN ] ; then DFL_DNS=1 DFL_FIREWALL=SKIP + __finalize + # stage 2: clean -> final elif [ -e "$INTERFACES".final ] ; then @ mv "$INTERFACES"{.final,.new} @@ -79,15 +93,6 @@ if ! [ -z $BOOTSTRAP_CLEAN ] ; then exit fi - if reviewApplyChanges "$INTERFACES" ; then - # XXX this must be done in nohup to avoid breaking on connection lost... - if ! @ ifreload -a ; then - # reset settings back if ifreload fails... - @ cp "$INTERFACES"{.bak,} - @ ifreload -a - fi - fi - # Bootstrap... elif ! [ -z $BOOTSTRAP ] ; then DFL_BOOTSTRAP_PORT=${DFL_BOOTSTRAP_PORT:-none} @@ -257,6 +262,11 @@ showNotes echo "# Done." +if [[ $( type -t __finalize ) == function ]] ; then + __finalize +fi + + if ! [ -z $REBOOT ] ; then echo "# Rebooting..." @ reboot