summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2016-12-24 15:35:54 +0100
committerLudovic Pouzenc <ludovic@pouzenc.fr>2016-12-24 15:35:54 +0100
commit5024b3634f45ee9e65e0593dee27842f2bb9f880 (patch)
tree0df4f52caea814f5a31dc31927b885a23e8d4535
parentf02721cfe244b98aa44176d196f2fdbeb311c5ae (diff)
downloadeficast-5024b3634f45ee9e65e0593dee27842f2bb9f880.tar.gz
eficast-5024b3634f45ee9e65e0593dee27842f2bb9f880.tar.bz2
eficast-5024b3634f45ee9e65e0593dee27842f2bb9f880.zip
busybox is now PID 1 and starts /etc/init.d/rcS (was /init script)
-rwxr-xr-xmake-boot-image.sh31
1 files changed, 24 insertions, 7 deletions
diff --git a/make-boot-image.sh b/make-boot-image.sh
index c7e1384..f1a8e5c 100755
--- a/make-boot-image.sh
+++ b/make-boot-image.sh
@@ -227,7 +227,7 @@ fi
# Initial Ram Disk building (embed in kernel) #
###############################################
if [ ! -d "$WORKDIR/initrd" ]
-then mkdir -p "$WORKDIR/initrd/"{bin,dev,etc,mnt,root,proc,root,sbin,sys,run/lock,run/uftpd,tmp,var/log}
+then mkdir -p "$WORKDIR/initrd/"{bin,dev,etc/init.d,mnt,root,proc,root,sbin,sys,run/lock,run/uftpd,tmp,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"
@@ -239,6 +239,7 @@ if [ ! -f "$WORKDIR/initrd/bin/busybox" ]
then [ -f "$DLDIR/busybox" ] || $WGET -O "$DLDIR/busybox" "$BUSYBOX_BIN_URL"
cp "$DLDIR/busybox" "$WORKDIR/initrd/bin/busybox"
chmod +x "$WORKDIR/initrd/bin/busybox"
+ ln -s /bin/busybox "$WORKDIR/initrd/init"
fi
if [ ! -f "$WORKDIR/initrd/etc/keys.bmap" ]
@@ -317,12 +318,13 @@ then [ -f "$DLDIR/nic-firmware.deb" ] || $WGET -O "$DLDIR/nic-firmware.deb" "$NI
find "$WORKDIR/initrd/lib/firmware/" \( -name 'ipw*' -o -name 'brcmfmac*' -o -name '*wifi*' \) -print0 | xargs -r0 rm -v
fi
-cat > "$WORKDIR/initrd/funcs" <<"EOF"
+cat > "$WORKDIR/initrd/etc/init.d/funcs" <<"EOF"
rescue_shell() {
echo "Something went wrong. Dropping to a shell."
- setsid cttyhack sh
+ setsid cttyhack /bin/busybox sh
sync
umount /dev /sys /proc
+ #umount /dev/pts /dev /sys /proc
poweroff -d1 -f
}
@@ -369,11 +371,26 @@ start_uftpd() {
}
EOF
-cat > "$WORKDIR/initrd/init" <<"EOF"
+cat > "$WORKDIR/initrd/etc/inittab" <<"EOF"
+# Custom init scripts
+::sysinit:/etc/init.d/rcS
+# Executes as root what is received via uftpd (no security at all)
+::respawn:/bin/sinkdo /run/uftpd /run/sink
+# Standard things follow
+::ctrlaltdel:/sbin/reboot
+::shutdown:/sbin/swapoff -a
+::shutdown:/bin/umount -a -r
+::restart:/sbin/init
+tty2::askfirst:/bin/sh
+tty3::askfirst:/bin/sh
+tty4::askfirst:/bin/sh
+EOF
+
+cat > "$WORKDIR/initrd/etc/init.d/rcS" <<"EOF"
#!/bin/busybox sh
-echo "Initrd started"
+echo "rcS script started"
# Load helper functions
-. /funcs
+. /etc/init.d/funcs
# Trace execution
set -v
@@ -405,7 +422,7 @@ start_uftpd
# Remote control on telnet port (23). You could press Alt+F3 to have a shell.
nc -ll -p 23 -e /bin/sh -i
EOF
-chmod +x "$WORKDIR/initrd/init"
+chmod +x "$WORKDIR/initrd/etc/init.d/rcS"
cat > "$WORKDIR/initrd/bin/sinkcat" <<"EOF"
#!/bin/busybox sh