summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmake-boot-image.sh100
1 files changed, 68 insertions, 32 deletions
diff --git a/make-boot-image.sh b/make-boot-image.sh
index e4042c3..afcdb89 100755
--- a/make-boot-image.sh
+++ b/make-boot-image.sh
@@ -77,7 +77,11 @@ fi
[ -d "$OUTDIR" ] || mkdir "$OUTDIR"
if [ ! -e "$WORKDIR/apt-done" ]
-then $ROOTCMD apt-get update
+then if ! ls /var/lib/apt/lists/*_jessie-backports_* >/dev/null
+ then echo 'deb http://ftp.debian.org/debian jessie-backports main' \
+ | $ROOTCMD tee /etc/apt/sources.list.d/backports.list
+ fi
+ $ROOTCMD apt-get update
# Dependencies of this script (assuming default debian install or live)
$ROOTCMD apt-get install wget libncurses5-dev coreutils
[ "x$LEGACY" == "xy" ] && $ROOTCMD apt-get install mbr syslinux
@@ -89,11 +93,12 @@ then $ROOTCMD apt-get update
# Optionnally qemu to run the result for santity checking
[ "x$DEVEL_MODE" = "xy" ] && $ROOTCMD apt-get install qemu-system-x86
# Dependencies to put into the initrd
- $ROOTCMD apt-get install dmidecode pciutils usbutils lshw sysstat iftop strace tmux \
+ $ROOTCMD apt-get install dmidecode pciutils usbutils lshw sysstat iftop strace \
ntfs-3g e2fsprogs partclone util-linux udpcast gdisk efibootmgr pigz \
pv bc figlet toilet-fonts ncurses-bin beep
# util-linux : fdisk, sfdisk, lsblk, setterm
# ncurses-bin : tput
+ $ROOTCMD apt-get -t jessie-backports install tmux
> "$WORKDIR/apt-done"
fi
@@ -277,7 +282,10 @@ then (
# Some dyn-loaded libraries (ldd will not display them)
mkchroot "$WORKDIR/initrd" /lib/x86_64-linux-gnu/libusb-1.0.so.0
# Some needed data files
- cp -ar /lib/terminfo "$WORKDIR/initrd/lib/"
+ cp -ra /lib/terminfo "$WORKDIR"/initrd/lib/
+ mkdir -p "$WORKDIR"/initrd/usr/lib/locale "$WORKDIR"/initrd/usr/share/figlet
+ cp -ra /usr/lib/locale/C.UTF-8 "$WORKDIR"/initrd/usr/lib/locale/
+ cp -a /usr/share/figlet/{standard,mono12}* "$WORKDIR"/initrd/usr/share/figlet/
)
fi
@@ -295,7 +303,7 @@ fi
if [ ! -d "$WORKDIR/initrd/usr/man" ]
then mkdir -p "$WORKDIR"/initrd/usr/man/man{1,6,8} "$WORKDIR"/initrd/usr/share/groff/current/font
- mkdir -p "$WORKDIR"/initrd/etc/groff/ "$WORKDIR"/initrd/usr/share/figlet/
+ mkdir -p "$WORKDIR"/initrd/etc/groff/
cp -a /usr/share/man/man1/{beep,iostat,lshw,mpstat,setterm,bc,pv,strace,tmux,pigz,udp-receiver}* "$WORKDIR"/initrd/usr/man/man1/
cp -a /usr/share/man/man6/figlet* "$WORKDIR"/initrd/usr/man/man6/
@@ -305,8 +313,7 @@ then mkdir -p "$WORKDIR"/initrd/usr/man/man{1,6,8} "$WORKDIR"/initrd/usr/share/g
cp -ra /usr/share/groff/current/font/devascii "$WORKDIR"/initrd/usr/share/groff/current/font/
cp -ra /usr/share/groff/current/tmac "$WORKDIR"/initrd/usr/share/groff/current/
- cp -a /usr/share/figlet/{standard,mono12}* "$WORKDIR"/initrd/usr/share/figlet/
- cp -a /etc/groff/man.local "$WORKDIR"/initrd/usr/share/groff/current/
+ cp -a /etc/groff/man.local "$WORKDIR"/initrd/etc/groff/
fi
p="$WORKDIR/kernel/tools/perf/perf"
@@ -347,7 +354,7 @@ echo_color() {
# if no args, print colored message, wait 1 minute and reboot
eficast_end() {
echo_color white green "----- EFICAST end of execution ------"
- sfx_success ; touch /run/nosound
+ ( sfx_success ; touch /run/nosound ) &
read -t60 -p 'Ctrl+C to have a shell, Enter to skip wait time...'
reboot
}
@@ -356,7 +363,7 @@ eficast_end() {
rescue_shell() {
echo
echo_color white red "Something went wrong. Dropping to a shell."
- sfx_failure ; touch /run/nosound
+ ( sfx_failure ; touch /run/nosound ) &
PS1='\h:\w# ' HOME='/root/' /bin/busybox sh
}
@@ -377,6 +384,7 @@ machine_info() {
}
network_conf() {
+ 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
@@ -391,14 +399,31 @@ network_show() {
nfs_autorun() {
if [ ! -x /mnt/nfs/autorun.sh ]
- echo_color white red "----- NFS server NOT ready ------"
+ then 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
+# tmux since 2.x absolutly wants a working UTF-8 locale
+# pane-border-* is supported since tmux 2.3
+ LC_ALL=C.UTF-8 tmux \
+ new-session -d 'tmux-main-pane main' \; \
+ set -g pane-border-status top \; \
+ set -g pane-border-format " #T " \; \
+ set-window-option status off \; \
+ split-window -t %0 -l1 pigz-watch progression \; \
+ split-window -t %0 -l5 iftop-watch network \; \
+ split-window -t %0 -l6 iostat-watch disk \; \
+ split-window -h -p40 pstree-watch processes \; \
+ select-pane -t:.0 \; \
+ attach
+ # Hack to keep the error flow intact
+ if [ -r /run/autorun_res ]
+ then res=$(cat /run/autorun_res)
+ rm /run/autorun_res
+ else res=1
+ fi
+ return $res
}
notes() {
@@ -443,12 +468,12 @@ tty2::askfirst:/bin/sh
tty3::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
+echo -e '\e[37;43m'----- rcS script started -----'\e[0m' # Hint for user about boot steps if its hangs
# 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() {
- busybox echo -e '\033[37;41m'Something went wrong. Dropping to a shell.'\033[0m'
+ busybox echo -e '\e[37;41m'Something went wrong. Dropping to a shell.'\e[0m'
busybox beep
PS1='\h:\w# ' busybox setsid busybox cttyhack busybox sh
busybox sync; busybox umount /dev/pts /dev /sys /proc
@@ -484,11 +509,11 @@ network_up # Bring net interfaces up (no config)
sleep 5 # Wait for physical link detection + STP + IPv6 DAD & Autoconf
set +v
# Hint users about boot steps to help them if it hangs
-echo -e '\033[32m/etc/rc.d/rc2 script will run on tty1 now\033[0m'
-echo -e '\033[37;43m----- rcS script ended -----\033[0m'
+echo -e '\e[32m/etc/rc.d/rc2 script will run on tty1 now\e[0m'
+echo -e '\e[37;43m----- rcS script ended -----\e[0m'
EOF
add_initrd_script "/etc/rc.d/rc2" <<"EOF"
-echo -e '\033[37;43m'----- rc2 script started -----'\033[0m' # Hint for user about boot steps if its hangs
+echo -e '\e[37;43m'----- rc2 script started -----'\e[0m' # Hint for user about boot steps if its hangs
. /etc/rc.d/funcs # Load helper functions
export TERM=linux # FIXME: wrong default TERM=vt102, why?
setterm -blank 60 # screen sleep mode after 60 minutes
@@ -502,7 +527,7 @@ mount -v -t nfs -o nolock 172.16.2.28:/masters /mnt/nfs
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
+echo -e '\e[37;43m'----- rc2 script ended -----'\e[0m' # Hint for user about boot steps if its hangs
EOF
add_initrd_script "/usr/share/udhcpc/default.script" <<"EOF"
#!/bin/sh
@@ -535,22 +560,24 @@ else touch /run/rescue
source /etc/rc.d/rc2
fi
EOF
-add_initrd_script "/bin/restore-script" <<"EOF"
-# Dummy restore script for testing the tmux integration
-dd if=/dev/urandom | gzip | pigz -dc > /dev/null
+add_initrd_script "/bin/tmux-main-pane" <<"EOF"
+echo -ne "\e]2;$*\007" # Term title (tmux)
+trap 'echo $? > /run/autorun_res ; tmux kill-server' EXIT
+cd /mnt/nfs
+./autorun.sh
EOF
add_initrd_script "/bin/iftop-watch" <<"EOF"
-printf '\033]2;'"$*"'\033\\' # Term title (tmux)
+echo -ne "\e]2;$*\007" # Term title (tmux)
iftop -nNl
EOF
add_initrd_script "/bin/iostat-watch" <<"EOF"
# Emulates watch command with iostat (filtered info, minimal height)
-printf '\033]2;'"$*"'\033\\' # Term title (tmux)
+echo -ne "\e]2;$*\007" # Term title (tmux)
iostat -cdmz 1 | awk '$1=="avg-cpu:" { system("clear"); } length($0) > 0 { print $0; }'
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)
+echo -ne "\e]2;$*\007" # Term title (tmux)
while true; do
pid=$(pidof -s pigz)
[ -n "$pid" ] && pv -F "%N %b %T %t %r %a %p %I" -d $pid
@@ -558,22 +585,31 @@ while true; do
done
EOF
add_initrd_script "/bin/pstree-watch" <<"EOF"
-printf '\033]2;'"$*"'\033\\' # Term title (tmux)
-watch -t pstree -p
+echo -ne "\e]2;$*\007" # Term title (tmux)
+while true; do
+ pid=$(pidof tmux-main-pane)
+ [ -n "$pid" ] && watch -t pstree -p $pid
+ sleep 1
+done
EOF
add_initrd_script "/bin/tmux-wrap" <<"EOF"
-tmux new-session -d "$@; res=$?; tmux kill-server; exit $res" \; \
+# tmux since 2.x absolutly wants a working UTF-8 locale
+# pane-border-* is supported since tmux 2.3
+LC_ALL=C.UTF-8 tmux \
+ new-session -d 'tmux-main-pane main' \; \
+ set -g pane-border-status top \; \
+ set -g pane-border-format " #T " \; \
set-window-option status off \; \
- split-window -t %0 -l1 pigz-watch \; \
- split-window -t %0 -l5 iftop-watch \; \
- split-window -t %0 -l6 iostat-watch \; \
- split-window -h -p30 pstree-watch \; \
+ split-window -t %0 -l1 pigz-watch progression \; \
+ split-window -t %0 -l5 iftop-watch network \; \
+ split-window -t %0 -l6 iostat-watch disk \; \
+ split-window -h -p40 pstree-watch processes \; \
select-pane -t:.0 \; \
attach
EOF
add_initrd_script "/bin/message" <<"EOF"
# Output some center ASCII-art text, one line per argument
-printf '\033]2;'"$*"'\033\\' # Term title (tmux)
+printf '\e]2;'"$*"'\e\\' # Term title (tmux)
CMDFIG="figlet -t -f mono12"
while [ -n "$1" ]; do
termwidth=$(tput cols)