From 53a903b27dcd81eb5342b4785db9fb81ea5110e3 Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Sat, 21 Oct 2017 11:53:36 +0200 Subject: rc scripts moved from /etc/init.d to rc.d, integrate SFX --- make-boot-image.sh | 96 +++++++++++++++++++++++++----------------------------- nfs/autorun.sh | 2 +- 2 files changed, 46 insertions(+), 52 deletions(-) diff --git a/make-boot-image.sh b/make-boot-image.sh index 5f79b5b..cdce898 100755 --- a/make-boot-image.sh +++ b/make-boot-image.sh @@ -232,7 +232,7 @@ fi # Initial Ram Disk building (embed in kernel) # ############################################### if [ ! -d "$WORKDIR/initrd" ] -then mkdir -p "$WORKDIR/initrd/"{bin,dev,etc/init.d,mnt/nfs,root,proc,root,sbin,sys,run/lock,run,tmp,usr/share/udhcpc,var/log} +then mkdir -p "$WORKDIR/initrd/"{bin,dev,etc/rc.d,mnt/nfs,root,proc,root,sbin,sys,run/lock,run,tmp,usr/share/udhcpc,var/log} $ROOTCMD cp -a /dev/{null,console,tty1} "$WORKDIR/initrd/dev/" $ROOTCMD chmod 1777 "$WORKDIR/initrd/run/lock" ln -s "/proc/mounts" "$WORKDIR/initrd/etc/mtab" @@ -334,7 +334,7 @@ fi echo $VERSION > "$WORKDIR/initrd/etc/eficast_version" -cat > "$WORKDIR/initrd/etc/init.d/funcs" <<"EOF" +cat > "$WORKDIR/initrd/etc/rc.d/funcs" <<"EOF" # echo_color [prefix_string] echo_color() { [ $# -eq 4 ] && echo -n "$3" @@ -355,8 +355,8 @@ eficast_end() { rescue_shell() { echo echo_color white red "Something went wrong. Dropping to a shell." + sfx_failure PS1='\h:\w# ' HOME='/root/' /bin/busybox sh - eficast_end } machine_info() { @@ -397,32 +397,58 @@ nfs_autorun() { echo_color white red "----- NFS server NOT ready ------" fi } + +notes() { + echo 'print "n=CCDEEFFGAABB\na=nsnbnnsnbnbn\n(\n"; for (d=21;d<109;d++) { + scale=20; f=440*e((d-69)/12*l(2)); fr=f+0.5; scale=0; fr=fr/1; o=d/12-1; t=d%12; + print "echo ${n:",t,":1}${a:",t,":1}",o,"=",fr,"\n" + }; print ") | tr -d n"' | bc -l | busybox sh +} + +sound() { + mode=$1; dur=$2; shift 2; args="-l0" + while [ -n "$1" ]; do + case $mode in + 1) args="$args -n -f$1 -l$dur";; + 2) args="$args -n -f$1 -l$(($2*dur))";; + 3) args="$args -n -f$1 -l$(($2*dur)) -D$(($3*dur))";; + esac + shift $mode + done + beep $args +} + +sfx_question() { sound 2 50 $E7 2 $C7 2 $E7 2 $C7 3; } +sfx_success() { sound 1 140 $E6 $G6 $E7 $C7 $D7 $G7 ; } +sfx_failure() { sound 3 100 $C5 1 3 $G4 1 3 $E4 3 0 $A4 2 0 $B4 2 0 $A4 2 0 $Ab4 3 0 $Bb4 3 0 $Ab4 3 0 $G4 6 0 ; } +sfx_starting() { sound 1 25 $C5 $G4 $C5 $E5 $G5 $C6 $G5 $Ab4 $C5 $Eb5 $Ab5 $Eb5 $Ab5 $C6 $Eb6 $Ab6 $Eb6 $Bb4 $D5 $F5 $Bb5 $D6 $F6 $Bb6 $F6 ; } + +eval $(notes) EOF cat > "$WORKDIR/initrd/etc/inittab" <<"EOF" # Custom init scripts -::sysinit:/etc/init.d/rcS +::sysinit:/etc/rc.d/rcS # Standard things follow ::ctrlaltdel:/sbin/reboot -f ::shutdown:/sbin/swapoff -a ::shutdown:/bin/umount -a -r ::restart:/sbin/init -tty1::respawn:/bin/rc2_once.sh +tty1::respawn:/etc/rc.d/rc2_once.sh tty2::askfirst:/bin/sh tty3::askfirst:/bin/sh tty4::askfirst:/bin/sh EOF -add_initrd_script "/etc/init.d/rcS" <<"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 # Declare some funcs to have a tidy output with trace mode -# note : init.d/funcs rescue_shell is slighly different the environnement is ready to go +# 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 - sync - umount /dev/pts /dev /sys /proc - reboot -f + /bin/busybox sync; /bin/busybox umount /dev/pts /dev /sys /proc + /bin/busybox reboot -f } mount_pseudofilesystems() { @@ -447,25 +473,20 @@ network_up() { # Trace execution set -v - /bin/busybox --install -s||rescue_shell # Setup busybox symlinks for all applets mount_pseudofilesystems || rescue_shell # Setup /dev, /proc, /sys and so - loadkmap < /etc/keys.bmap # Load keyboard layout - mount -o remount -o size=80% / # Allow using most of RAM for rootfs - network_up # Bring net interfaces up (no config) - sleep 5 # Wait for physical link detection + STP + IPv6 DAD & Autoconf - set +v -echo -e '\033[32m/etc/init.d/rc2 script will run on tty1 now\033[0m' -echo -e '\033[37;43m----- rcS script ended -----\033[0m' # Hint for user about boot steps if its hangs +# 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' EOF -add_initrd_script "/etc/init.d/rc2" <<"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 -. /etc/init.d/funcs # Load helper functions +. /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 set -v # Trace execution @@ -474,7 +495,7 @@ network_conf network_show machine_info -mount -v -t nfs -o nolock 172.16.2.28:/masters /mnt/nfs || rescue_shell +mount -v -t nfs -o nolock 172.16.2.28:/masters /mnt/nfs nfs_autorun || rescue_shell eficast_end @@ -503,12 +524,12 @@ case $1 in leasefail | nak) echo "configuration failed: $1: $message" >&2 ;; esac EOF -add_initrd_script "/bin/rc2_once.sh" <<"EOF" +add_initrd_script "/etc/rc.d/rc2_once.sh" <<"EOF" if [ -f /run/rc2_once ] -then source /etc/init.d/funcs +then source /etc/rc.d/funcs rescue_shell else touch /run/rc2_once - /etc/init.d/rc2 + /etc/rc.d/rc2 fi EOF add_initrd_script "/bin/autorun.sh" <<"EOF" @@ -554,33 +575,6 @@ tmux new-session -d "if $* ; then tmux kill-server; else tmux select-pane -P bg= select-pane -t:.0 \; \ attach EOF -add_initrd_script "/bin/sfx-load" <<"EOF" -notes() { - echo 'print "n=CCDEEFFGAABB\na=nsnbnnsnbnbn\n(\n"; for (d=21;d<109;d++) { - scale=20; f=440*e((d-69)/12*l(2)); fr=f+0.5; scale=0; fr=fr/1; o=d/12-1; t=d%12; - print "echo ${n:",t,":1}${a:",t,":1}",o,"=",fr,"\n" - }; print ") | tr -d n"' | bc -l | busybox sh -} - -sound() { - mode=$1; dur=$2; shift 2; args="-l0" - while [ -n "$1" ]; do - case $mode in - 1) args="$args -n -f$1 -l$dur";; - 2) args="$args -n -f$1 -l$(($2*dur))";; - 3) args="$args -n -f$1 -l$(($2*dur)) -D$(($3*dur))";; - esac - shift $mode - done - beep $args -} - -eval $(notes) -alias sfx-question="sound 2 50 $E7 2 $C7 2 $E7 2 $C7 3" -alias sfx-success="sound 1 140 $E6 $G6 $E7 $C7 $D7 $G7" -alias sfx-failure="sound 3 100 $C5 1 3 $G4 1 3 $E4 3 0 $A4 2 0 $B4 2 0 $A4 2 0 $Ab4 3 0 $Bb4 3 0 $Ab4 3 0 $G4 6 0" -alias sfx-starting="sound 1 25 $C5 $G4 $C5 $E5 $G5 $C6 $G5 $Ab4 $C5 $Eb5 $Ab5 $Eb5 $Ab5 $C6 $Eb6 $Ab6 $Eb6 $Bb4 $D5 $F5 $Bb5 $D6 $F6 $Bb6 $F6" -EOF add_initrd_script "/bin/message" <<"EOF" # Output some center ASCII-art text, one line per argument printf '\033]2;'"$*"'\033\\' # Term title (tmux) diff --git a/nfs/autorun.sh b/nfs/autorun.sh index 7c642d1..a998b13 100755 --- a/nfs/autorun.sh +++ b/nfs/autorun.sh @@ -14,7 +14,7 @@ hostname=$(hostname) # Load helper functions source $scriptdir/funcs.sh # Load some autorun.sh specific helper functions -source /etc/init.d/funcs # Reload init help functions +source /etc/rc.d/funcs # Reload init help functions # Check all prerequisites and exit if it fail hostname_test || exit 1 -- cgit v1.2.3