summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2017-10-22 20:14:16 +0200
committerLudovic Pouzenc <ludovic@pouzenc.fr>2017-10-22 20:14:16 +0200
commitc6af909787ba0256b9f09903d9274acf0cd6aeaf (patch)
tree758979051b65d085e4986466df84587043b419f6
parent8142ffde3037976e152711f902ad9622aa1b7cba (diff)
downloadeficast-c6af909787ba0256b9f09903d9274acf0cd6aeaf.tar.gz
eficast-c6af909787ba0256b9f09903d9274acf0cd6aeaf.tar.bz2
eficast-c6af909787ba0256b9f09903d9274acf0cd6aeaf.zip
^C abort in tmux. More polishing.
-rwxr-xr-xmake-boot-image.sh34
-rwxr-xr-xnfs/nfs-autorun.sh6
2 files changed, 30 insertions, 10 deletions
diff --git a/make-boot-image.sh b/make-boot-image.sh
index 17baf51..93a2d1d 100755
--- a/make-boot-image.sh
+++ b/make-boot-image.sh
@@ -1,6 +1,6 @@
#!/bin/bash -xe
PS4='+ ($LINENO) ' # To ease debugging
-VERSION="1.0"
+VERSION="1.0rc1"
# Config #
##########
@@ -387,7 +387,7 @@ machine_info() {
}
network_conf() {
- killall udhcpc # Reap background udhcpc in case of rc2 retry
+ pidof udhcpc >/dev/null && killall udhcpc # Reap background udhcpc in case of rc2 retry
ip -oneline link | grep LOWER_UP | cut -d: -f2 | grep -v sit | grep -v lo | while read iface
do
udhcpc -b $iface -t 15
@@ -426,6 +426,7 @@ autorun() {
rm /run/autorun_res
else res=1
fi
+ echo_color green black "tmux-main-pane exit code : $res"
return $res
}
@@ -554,8 +555,22 @@ fi
EOF
add_initrd_script "/etc/rc.d/tmux-main-pane" <<"EOF"
# Drop a in-tmux rescue shell in case of failure, prevents clearing screen with valuable informations
-trap 'res=$?; echo $res > /run/autorun_res ; [ "$res" -eq 0 ] || rescue_shell; tmux kill-server' EXIT
. /etc/rc.d/funcs # Load helper functions
+# Helper to trap user interruption and error cases
+# Will exit the entire tmux, leaving last error code availble in a file
+cleanup() {
+ res=$?
+ echo $res > /run/autorun_res
+ if [ $res -ne 0 ]
+ then rm /run/rescue
+ echo_color green black "/etc/rc.d/tmux-main-pane is exiting. Spawn rescue_shell in tmux now"
+ rescue_shell
+ fi
+ tmux kill-server
+ exit
+}
+trap cleanup INT TERM
+
case $1 in
initrd) echo -ne "\e]2;initrd-autorun.sh\007" # Term title (tmux)
message initrd autorun
@@ -564,23 +579,26 @@ case $1 in
nfs) source nfs-mount
if [ $? -ne 0 ]
then echo_color white red "----- NFS server : not mounted ------"
- echo_color green black "Check for failure above. Exiting rescue shell twice will retry mount"
- return 1
+ echo_color green black "Check for failure above. Exiting rescue shell will retry everything"
+ false; cleanup
fi
if ! [ -x /mnt/nfs/nfs-autorun.sh ]
then echo_color white red "----- NFS server : missing script ------"
echo_color green black "Check nfs-autorun.sh : should be present, readable and executable"
ls -l /mnt/nfs
- return 2
+ false; cleanup
fi
echo_color white green "----- NFS server ready ------"
message nfs autorun
echo -ne "\e]2;nfs-autorun.sh\007" # Term title (tmux)
- cd /mnt/nfs && source ./nfs-autorun.sh
+ cd /mnt/nfs
+ source ./nfs-autorun.sh
;;
*) echo "Usage : $0 (nfs|initrd)"
- return 1 ;;
+ false; cleanup ;;
esac
+# Don't add code here, $? from source ...-autorun.sh is used in cleanup
+cleanup
EOF
add_initrd_script "/bin/nfs-mount" <<"EOF"
echo -ne "\e]2;$0\007" # Term title (tmux)
diff --git a/nfs/nfs-autorun.sh b/nfs/nfs-autorun.sh
index b2be8b2..3a0df2f 100755
--- a/nfs/nfs-autorun.sh
+++ b/nfs/nfs-autorun.sh
@@ -15,9 +15,11 @@ firstdisk_test || exit 2
# Run the main action script
if nfswrite_test
then # Start deploy script after letting a chance to cancel it
- pause10s ; source $scriptdir/image_deploy.sh
+ message deploy ; pause10s; sfx_starting
+ source $scriptdir/image_deploy.sh
else scriptavailability_test image_capture_${hostname}.sh || exit 3
# Start capture script if all it needs is available
- pause10s ; source $scriptdir/image_capture.sh
+ message capture ; pause10s; sfx_starting
+ source $scriptdir/image_capture.sh
fi