From cbb890865a17b272f688c94282d6fd26677411d3 Mon Sep 17 00:00:00 2001 From: Ivan Davidov Date: Sat, 23 Apr 2016 04:41:57 +0300 Subject: [PATCH] Yet another rootfs reorganization related to the rootfs initialization scripts. --- src/08_generate_rootfs/etc/01_prepare.sh | 26 +++++++++++++ src/08_generate_rootfs/etc/02_overlay.sh | 26 +++++++++++++ src/08_generate_rootfs/etc/03_init.sh | 27 ++++++++++++++ src/08_generate_rootfs/etc/04_bootscript.sh | 36 ++++++++++++++++++ src/08_generate_rootfs/etc/05_rc.dhcp | 41 +++++++++++++++++++++ src/08_generate_rootfs/etc/bootscript.sh | 10 ----- src/08_generate_rootfs/etc/inittab | 2 +- src/08_generate_rootfs/etc/rc.dhcp | 15 -------- src/08_generate_rootfs/init | 28 +++++++++++++- 9 files changed, 184 insertions(+), 27 deletions(-) create mode 100755 src/08_generate_rootfs/etc/04_bootscript.sh create mode 100755 src/08_generate_rootfs/etc/05_rc.dhcp delete mode 100755 src/08_generate_rootfs/etc/bootscript.sh delete mode 100755 src/08_generate_rootfs/etc/rc.dhcp diff --git a/src/08_generate_rootfs/etc/01_prepare.sh b/src/08_generate_rootfs/etc/01_prepare.sh index e1b9aa552..8514294e0 100755 --- a/src/08_generate_rootfs/etc/01_prepare.sh +++ b/src/08_generate_rootfs/etc/01_prepare.sh @@ -1,5 +1,31 @@ #!/bin/sh +# System initialization sequence: +# +# /init +# | +# +--(1) /etc/01_prepare.sh (this file) +# | +# +--(2) /etc/02_overlay.sh +# | +# +-- /etc/03_init.sh +# | +# +-- /sbin/init +# | +# +--(1) /etc/04_bootscript.sh +# | | +# | +-- udhcpc +# | | +# | +-- /etc/05_rc.udhcp +# | +# +--(2) /bin/sh (Alt + F1, main console) +# | +# +--(2) /bin/sh (Alt + F2) +# | +# +--(2) /bin/sh (Alt + F3) +# | +# +--(2) /bin/sh (Alt + F4) + echo "Suppress most kernel messages." dmesg -n 1 diff --git a/src/08_generate_rootfs/etc/02_overlay.sh b/src/08_generate_rootfs/etc/02_overlay.sh index 2deaee910..57e9c098e 100755 --- a/src/08_generate_rootfs/etc/02_overlay.sh +++ b/src/08_generate_rootfs/etc/02_overlay.sh @@ -1,5 +1,31 @@ #!/bin/sh +# System initialization sequence: +# +# /init +# | +# +--(1) /etc/01_prepare.sh +# | +# +--(2) /etc/02_overlay.sh (this file) +# | +# +-- /etc/03_init.sh +# | +# +-- /sbin/init +# | +# +--(1) /etc/04_bootscript.sh +# | | +# | +-- udhcpc +# | | +# | +-- /etc/05_rc.udhcp +# | +# +--(2) /bin/sh (Alt + F1, main console) +# | +# +--(2) /bin/sh (Alt + F2) +# | +# +--(2) /bin/sh (Alt + F3) +# | +# +--(2) /bin/sh (Alt + F4) + # Create the new mountpoint in RAM. mount -t tmpfs none /mnt diff --git a/src/08_generate_rootfs/etc/03_init.sh b/src/08_generate_rootfs/etc/03_init.sh index f1d53f3c4..852317407 100755 --- a/src/08_generate_rootfs/etc/03_init.sh +++ b/src/08_generate_rootfs/etc/03_init.sh @@ -1,5 +1,31 @@ #!/bin/sh +# System initialization sequence: +# +# /init +# | +# +--(1) /etc/01_prepare.sh +# | +# +--(2) /etc/02_overlay.sh +# | +# +-- /etc/03_init.sh (this file) +# | +# +-- /sbin/init +# | +# +--(1) /etc/04_bootscript.sh +# | | +# | +-- udhcpc +# | | +# | +-- /etc/05_rc.udhcp +# | +# +--(2) /bin/sh (Alt + F1, main console) +# | +# +--(2) /bin/sh (Alt + F2) +# | +# +--(2) /bin/sh (Alt + F3) +# | +# +--(2) /bin/sh (Alt + F4) + # If you have persistent overlay support then you can edit this file and replace # the default initialization of the system. For example, you could use this: # @@ -36,6 +62,7 @@ cat << CEOF CEOF + # Interactive shell with controlling tty as PID 1. exec setsid cttyhack sh fi diff --git a/src/08_generate_rootfs/etc/04_bootscript.sh b/src/08_generate_rootfs/etc/04_bootscript.sh new file mode 100755 index 000000000..73ba48ceb --- /dev/null +++ b/src/08_generate_rootfs/etc/04_bootscript.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +# System initialization sequence: +# +# /init +# | +# +--(1) /etc/01_prepare.sh +# | +# +--(2) /etc/02_overlay.sh +# | +# +-- /etc/03_init.sh +# | +# +-- /sbin/init +# | +# +--(1) /etc/04_bootscript.sh (this file) +# | | +# | +-- udhcpc +# | | +# | +-- /etc/05_rc.udhcp +# | +# +--(2) /bin/sh (Alt + F1, main console) +# | +# +--(2) /bin/sh (Alt + F2) +# | +# +--(2) /bin/sh (Alt + F3) +# | +# +--(2) /bin/sh (Alt + F4) + +echo "Welcome to \"Minimal Linux Live\" (/sbin/init)" + +for DEVICE in /sys/class/net/* ; do + echo "Found network device ${DEVICE##*/}" + ip link set ${DEVICE##*/} up + [ ${DEVICE##*/} != lo ] && udhcpc -b -i ${DEVICE##*/} -s /etc/05_rc.dhcp +done + diff --git a/src/08_generate_rootfs/etc/05_rc.dhcp b/src/08_generate_rootfs/etc/05_rc.dhcp new file mode 100755 index 000000000..355646eba --- /dev/null +++ b/src/08_generate_rootfs/etc/05_rc.dhcp @@ -0,0 +1,41 @@ +#!/bin/sh + +# System initialization sequence: +# +# /init +# | +# +--(1) /etc/01_prepare.sh +# | +# +--(2) /etc/02_overlay.sh +# | +# +-- /etc/03_init.sh +# | +# +-- /sbin/init +# | +# +--(1) /etc/04_bootscript.sh +# | | +# | +-- udhcpc +# | | +# | +-- /etc/05_rc.udhcp (this file) +# | +# +--(2) /bin/sh (Alt + F1, main console) +# | +# +--(2) /bin/sh (Alt + F2) +# | +# +--(2) /bin/sh (Alt + F3) +# | +# +--(2) /bin/sh (Alt + F4) + +ip addr add $ip/$mask dev $interface + +if [ "$router" ]; then + ip route add default via $router dev $interface +fi + +if [ "$ip" ]; then + echo "DHCP configuration for device $interface" + echo "ip: $ip" + echo "mask: $mask" + echo "router: $router" +fi + diff --git a/src/08_generate_rootfs/etc/bootscript.sh b/src/08_generate_rootfs/etc/bootscript.sh deleted file mode 100755 index cfca84333..000000000 --- a/src/08_generate_rootfs/etc/bootscript.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -echo "Welcome to \"Minimal Linux Live\" (/sbin/init)" - -for DEVICE in /sys/class/net/* ; do - echo "Found network device ${DEVICE##*/}" - ip link set ${DEVICE##*/} up - [ ${DEVICE##*/} != lo ] && udhcpc -b -i ${DEVICE##*/} -s /etc/rc.dhcp -done - diff --git a/src/08_generate_rootfs/etc/inittab b/src/08_generate_rootfs/etc/inittab index 463866def..60d007217 100644 --- a/src/08_generate_rootfs/etc/inittab +++ b/src/08_generate_rootfs/etc/inittab @@ -1,4 +1,4 @@ -::sysinit:/etc/bootscript.sh +::sysinit:/etc/04_bootscript.sh ::restart:/sbin/init ::shutdown:echo "Sync file buffers..." ::shutdown:sync diff --git a/src/08_generate_rootfs/etc/rc.dhcp b/src/08_generate_rootfs/etc/rc.dhcp deleted file mode 100755 index c2406d45b..000000000 --- a/src/08_generate_rootfs/etc/rc.dhcp +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -ip addr add $ip/$mask dev $interface - -if [ "$router" ]; then - ip route add default via $router dev $interface -fi - -if [ "$ip" ]; then - echo "DHCP configuration for device $interface" - echo "ip: $ip" - echo "mask: $mask" - echo "router: $router" -fi - diff --git a/src/08_generate_rootfs/init b/src/08_generate_rootfs/init index 4e8ca293e..4f1113068 100755 --- a/src/08_generate_rootfs/init +++ b/src/08_generate_rootfs/init @@ -1,5 +1,31 @@ #!/bin/sh +# System initialization sequence: +# +# /init (this file) +# | +# +--(1) /etc/01_prepare.sh +# | +# +--(2) /etc/02_overlay.sh +# | +# +-- /etc/03_init.sh +# | +# +-- /sbin/init +# | +# +--(1) /etc/04_bootscript.sh +# | | +# | +-- udhcpc +# | | +# | +-- /etc/05_rc.udhcp +# | +# +--(2) /bin/sh (Alt + F1, main console) +# | +# +--(2) /bin/sh (Alt + F2) +# | +# +--(2) /bin/sh (Alt + F3) +# | +# +--(2) /bin/sh (Alt + F4) + echo "Welcome to \"Minimal Linux Live\" (/init)" # Let's mount all core file systems. @@ -7,7 +33,7 @@ echo "Welcome to \"Minimal Linux Live\" (/init)" # Create new mountpoint in RAM, make it our new root location and overlay it # with our storage area (if overlay area exists at all). This operation invokes -# the script '/etc/03_switch.sh' as the new init process. +# the script '/etc/03_init.sh' as the new init process. exec /etc/02_overlay.sh echo "(/init) - you can never see this unless there is a serious bug..."