summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic.pouzenc@mines-albi.fr>2017-07-21 17:12:01 +0200
committerLudovic Pouzenc <ludovic.pouzenc@mines-albi.fr>2017-07-21 17:12:01 +0200
commitafb7ee8cc6232ceda7a5810b9d285ceff857b0b6 (patch)
tree4d3c913c7d1b5b2502428b03e0cf70fc5903bc82
parent5ff2742d228ce3ae54a969b98867b1abac25dad0 (diff)
downloadeficast-afb7ee8cc6232ceda7a5810b9d285ceff857b0b6.tar.gz
eficast-afb7ee8cc6232ceda7a5810b9d285ceff857b0b6.tar.bz2
eficast-afb7ee8cc6232ceda7a5810b9d285ceff857b0b6.zip
Add some toosl and checks
-rwxr-xr-xmake-boot-image.sh35
1 files changed, 26 insertions, 9 deletions
diff --git a/make-boot-image.sh b/make-boot-image.sh
index ed1c35d..470eeed 100755
--- a/make-boot-image.sh
+++ b/make-boot-image.sh
@@ -83,8 +83,8 @@ then $ROOTCMD apt-get update
[ "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 \
- partclone util-linux udpcast gdisk efibootmgr tcpdump
- # util-linux : sfdisk, lsblk, setterm
+ ntfs-3g e2fsprogs partclone util-linux udpcast gdisk efibootmgr tcpdump pigz
+ # util-linux : fdisk, sfdisk, lsblk, setterm
> "$WORKDIR/apt-done"
fi
@@ -252,10 +252,13 @@ then (
mkchroot "$WORKDIR/initrd" dmidecode iftop iostat lshw lspci lsblk lsusb mpstat tcpdump
# Console tools and manpages display
mkchroot "$WORKDIR/initrd" setterm strace groff nroff troff grotty gtbl
+ # Disk tools
+ mkchroot "$WORKDIR/initrd" fdisk gdisk sfdisk sgdisk /sbin/mkfs*
# Cloning tools
- mkchroot "$WORKDIR/initrd" /usr/sbin/partclone* efibootmgr sfdisk gdisk sgdisk udp-receiver
+ mkchroot "$WORKDIR/initrd" /usr/sbin/partclone* efibootmgr pigz udp-receiver
# 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/"
)
fi
@@ -312,7 +315,7 @@ echo_color() {
}
rescue_shell() {
- echo "Something went wrong. Dropping to a shell."
+ echo_color white red "Something went wrong. Dropping to a shell."
PS1='\h:\w# ' setsid cttyhack /bin/busybox sh
sync
umount /dev /sys /proc
@@ -384,7 +387,8 @@ nfs_check() {
}
nfs_autorun() {
- PS1='\h:\w#' setsid cttyhack /mnt/nfs/autorun.sh
+ # Run it in background, so busybox will see rcS ending and will allow others consoles to spawn
+ PS1='\h:\w#' exec setsid cttyhack /mnt/nfs/autorun.sh &
}
# no args, print colored message, wait 1 minute and reboot
@@ -403,6 +407,7 @@ cat > "$WORKDIR/initrd/etc/inittab" <<"EOF"
::shutdown:/sbin/swapoff -a
::shutdown:/bin/umount -a -r
::restart:/sbin/init
+tty1::respawn:/bin/autorun_once.sh
tty2::askfirst:/bin/sh
tty3::askfirst:/bin/sh
tty4::askfirst:/bin/sh
@@ -427,16 +432,18 @@ setterm -blank 60
network_up
# Wait for physical link detection + STP + IPv6 DAD & Autoconf
-sleep 8
+sleep 15
-machine_info
network_conf
network_show
+machine_info
mount -v -t nfs -o nolock 172.16.2.28:/masters /mnt/nfs || rescue_shell
nfs_check || rescue_shell
-nfs_autorun # /mnt/nfs/autorun.sh should never give back control to /etc/init.d/rcS (poweroff or reboot...)
-rescue_shell
+
+set +v
+echo -e '\033[37;43m'----- rcS script ended -----'\033[0m' # Hint for user about boot steps if its hangs
+echo_color green black "autorun.sh script will run on tty1 now"
EOF
chmod +x "$WORKDIR/initrd/etc/init.d/rcS"
@@ -465,6 +472,16 @@ esac
EOF
chmod +x "$WORKDIR/initrd/usr/share/udhcpc/default.script"
+cat > "$WORKDIR/initrd/bin/autorun_once.sh" <<"EOF"
+#!/bin/busybox sh
+if [ -f /run/autorun_once ]
+then exec busybox sh
+else touch /run/autorun_once
+ cd /mnt/nfs && ./autorun.sh
+fi
+EOF
+chmod +x "$WORKDIR/initrd/bin/autorun_once.sh"
+
# XXX workaround, kernel makefile's cpio preseves everything and it is not so cool for us
$ROOTCMD chown -R root: "$WORKDIR/initrd"