diff options
Diffstat (limited to 'make-boot-image.sh')
-rwxr-xr-x | make-boot-image.sh | 31 |
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 |