summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO1
-rwxr-xr-xmake-boot-image.sh68
-rwxr-xr-xnfs/autorun.sh18
3 files changed, 39 insertions, 48 deletions
diff --git a/TODO b/TODO
index e69de29..2806dbe 100644
--- a/TODO
+++ b/TODO
@@ -0,0 +1 @@
+mpstat segfaults
diff --git a/make-boot-image.sh b/make-boot-image.sh
index cdce898..e4042c3 100755
--- a/make-boot-image.sh
+++ b/make-boot-image.sh
@@ -156,8 +156,8 @@ while more_work and i < 10:
if name in ['INITRAMFS_SOURCE']:
more_work = sset(sym, '../initrd/') or more_work
- # Make kernel directly loadable by EFI, add USB3, Dell flash
- if name in ['EFI_STUB', 'EFI_VARS', 'DELL_RBU', 'USB_XHCI_HCD', 'IKCONFIG']:
+ # Make kernel directly loadable by EFI, add Dell flash, USB3, PC Speaker
+ if name in ['EFI_STUB', 'EFI_VARS', 'DELL_RBU', 'USB_XHCI_HCD', 'IKCONFIG', 'INPUT_PCSPKR']:
more_work = sset(sym) or more_work
# Support FUSE for ntfs-3g
@@ -347,15 +347,16 @@ echo_color() {
# if no args, print colored message, wait 1 minute and reboot
eficast_end() {
echo_color white green "----- EFICAST end of execution ------"
- read -t10 -p 'Ctrl+C to have a shell, Enter to skip wait time...'
+ sfx_success ; touch /run/nosound
+ read -t60 -p 'Ctrl+C to have a shell, Enter to skip wait time...'
reboot
}
-# note : rcS rescue_shell is slighly different because 'sh' and 'reboot' need cautions to work
+# note : rcS rescue_shell is slighly different because most of the env is not ready in rcS
rescue_shell() {
echo
echo_color white red "Something went wrong. Dropping to a shell."
- sfx_failure
+ sfx_failure ; touch /run/nosound
PS1='\h:\w# ' HOME='/root/' /bin/busybox sh
}
@@ -389,13 +390,15 @@ network_show() {
}
nfs_autorun() {
- if [ -x /mnt/nfs/autorun.sh ]
- then echo_color white green "----- NFS server ready ------"
- echo_color green black "autorun.sh script will run on tty1 now"
- autorun.sh
- else
+ if [ ! -x /mnt/nfs/autorun.sh ]
echo_color white red "----- NFS server NOT ready ------"
+ return 1
fi
+ echo_color white green "----- NFS server ready ------"
+ echo_color green black "autorun.sh script will run on tty1 now"
+ cd /mnt/nfs
+ source autorun.sh
+ # Returns last result command from autorun.sh, used to go on rescue or on normal end
}
notes() {
@@ -406,6 +409,7 @@ notes() {
}
sound() {
+ [ -f /run/nosound ] && return 0
mode=$1; dur=$2; shift 2; args="-l0"
while [ -n "$1" ]; do
case $mode in
@@ -434,10 +438,9 @@ cat > "$WORKDIR/initrd/etc/inittab" <<"EOF"
::shutdown:/sbin/swapoff -a
::shutdown:/bin/umount -a -r
::restart:/sbin/init
-tty1::respawn:/etc/rc.d/rc2_once.sh
+tty1::respawn:/etc/rc.d/rc2_or_rescue
tty2::askfirst:/bin/sh
tty3::askfirst:/bin/sh
-tty4::askfirst:/bin/sh
EOF
add_initrd_script "/etc/rc.d/rcS" <<"EOF"
echo -e '\033[37;43m'----- rcS script started -----'\033[0m' # Hint for user about boot steps if its hangs
@@ -445,10 +448,11 @@ echo -e '\033[37;43m'----- rcS script started -----'\033[0m' # Hint for user abo
# Declare some funcs to have a tidy output with trace mode
# note : rc.d/funcs rescue_shell is slighly different the environnement is ready to go
rescue_shell() {
- echo_color white red "Something went wrong. Dropping to a shell."
- PS1='\h:\w# ' setsid cttyhack /bin/busybox sh
- /bin/busybox sync; /bin/busybox umount /dev/pts /dev /sys /proc
- /bin/busybox reboot -f
+ busybox echo -e '\033[37;41m'Something went wrong. Dropping to a shell.'\033[0m'
+ busybox beep
+ PS1='\h:\w# ' busybox setsid busybox cttyhack busybox sh
+ busybox sync; busybox umount /dev/pts /dev /sys /proc
+ busybox reboot -f
}
mount_pseudofilesystems() {
@@ -462,7 +466,6 @@ mount_pseudofilesystems() {
return 0
}
-
network_up() {
ip -oneline link | grep DOWN | cut -d: -f2 | grep -v sit | while read iface
do
@@ -496,8 +499,7 @@ network_show
machine_info
mount -v -t nfs -o nolock 172.16.2.28:/masters /mnt/nfs
-nfs_autorun || rescue_shell
-eficast_end
+nfs_autorun && eficast_end
set +v
echo -e '\033[37;43m'----- rc2 script ended -----'\033[0m' # Hint for user about boot steps if its hangs
@@ -524,23 +526,18 @@ case $1 in
leasefail | nak) echo "configuration failed: $1: $message" >&2 ;;
esac
EOF
-add_initrd_script "/etc/rc.d/rc2_once.sh" <<"EOF"
-if [ -f /run/rc2_once ]
-then source /etc/rc.d/funcs
+add_initrd_script "/etc/rc.d/rc2_or_rescue" <<"EOF"
+if [ -f /run/rescue ]
+then rm /run/rescue
+ source /etc/rc.d/funcs # TODO : this probably don't work
rescue_shell
-else touch /run/rc2_once
- /etc/rc.d/rc2
+else touch /run/rescue
+ source /etc/rc.d/rc2
fi
EOF
-add_initrd_script "/bin/autorun.sh" <<"EOF"
-# Helper script to have retries handy
-cd /mnt/nfs
-./autorun.sh
-EOF
add_initrd_script "/bin/restore-script" <<"EOF"
-# Dummy restore script for testing the tmux inegration
-pigz -dc testimg.partclone.gz | partclone.restore -o /dev/sda1
-sleep 60
+# Dummy restore script for testing the tmux integration
+dd if=/dev/urandom | gzip | pigz -dc > /dev/null
EOF
add_initrd_script "/bin/iftop-watch" <<"EOF"
printf '\033]2;'"$*"'\033\\' # Term title (tmux)
@@ -554,10 +551,9 @@ EOF
add_initrd_script "/bin/pigz-watch" <<"EOF"
# Emulate watch command using pipeview (pv) for a running pigz
printf '\033]2;'"$*"'\033\\' # Term title (tmux)
-while true
-do
+while true; do
pid=$(pidof -s pigz)
- [ -n "$pid" ] && pv -D5 -F "%N %b %T %t %r %a %p %I" -d $pid
+ [ -n "$pid" ] && pv -F "%N %b %T %t %r %a %p %I" -d $pid
sleep 1
done
EOF
@@ -566,7 +562,7 @@ printf '\033]2;'"$*"'\033\\' # Term title (tmux)
watch -t pstree -p
EOF
add_initrd_script "/bin/tmux-wrap" <<"EOF"
-tmux new-session -d "if $* ; then tmux kill-server; else tmux select-pane -P bg=red; rescue_shell ; fi" \; \
+tmux new-session -d "$@; res=$?; tmux kill-server; exit $res" \; \
set-window-option status off \; \
split-window -t %0 -l1 pigz-watch \; \
split-window -t %0 -l5 iftop-watch \; \
diff --git a/nfs/autorun.sh b/nfs/autorun.sh
index a998b13..ad99a8e 100755
--- a/nfs/autorun.sh
+++ b/nfs/autorun.sh
@@ -2,7 +2,7 @@
rest10() {
# Let the user read machine_info and other usefull informations on console (or skip with Enter)
- read -t10 -p 'Press Enter or wait 10 sec...'
+ sfx_question ; read -t10 -p 'Press Enter or wait 10 sec...'
# Make some blank lines on console
echo -e '\n\n\n\n\n'
}
@@ -22,16 +22,10 @@ firstdisk_test || exit 2
# Run the main action script
if nfswrite_test
-then rest10 # Let user cancel it
- source $scriptdir/image_deploy.sh # Start deploy script
+then # Start deploy script after letting a chance to cancel it
+ rest10 ; source $scriptdir/image_deploy.sh
-else # Start capture script if all it needs is available
- if scriptavailability_test image_capture_${hostname}.sh
- then rest10 # Let user cancel it
- source $scriptdir/image_capture.sh
- # else No wait, nothing to do, go to eficast_end directly
- fi
+else scriptavailability_test image_capture_${hostname}.sh || exit 3
+ # Start capture script if all it needs is available
+ rest10 ; source $scriptdir/image_capture.sh
fi
-
-# Display ending message then reboot
-eficast_end