Added 'autorun' functionality loosely based on 'init.d'. Updated the software components with their latest versions (not tested yet).

This commit is contained in:
Ivan Davidov 2017-06-17 14:48:38 +03:00
parent 37fdd26e82
commit c915716a15
6 changed files with 39 additions and 33 deletions

View File

@ -11,7 +11,7 @@
# #
# http://kernel.org # http://kernel.org
# #
KERNEL_SOURCE_URL=http://kernel.org/pub/linux/kernel/v4.x/linux-4.9.13.tar.xz KERNEL_SOURCE_URL=http://kernel.org/pub/linux/kernel/v4.x/linux-4.9.33.tar.xz
# You can find the latest GNU libc source bundles here: # You can find the latest GNU libc source bundles here:
# #
@ -51,21 +51,21 @@ LINKS_SOURCE_URL=http://links.twibright.com/download/links-2.14.tar.bz2
# #
# http://matt.ucc.asn.au/dropbear/dropbear.html # http://matt.ucc.asn.au/dropbear/dropbear.html
# #
DROPBEAR_SOURCE_URL=http://matt.ucc.asn.au/dropbear/releases/dropbear-2016.74.tar.bz2 DROPBEAR_SOURCE_URL=http://matt.ucc.asn.au/dropbear/releases/dropbear-2017.75.tar.bz2
# You can find the latest Apache Felix source bundles here: # You can find the latest Apache Felix source bundles here:
# #
# http://felix.apache.org # http://felix.apache.org
# #
FELIX_SOURCE_URL=http://www-us.apache.org/dist/felix/org.apache.felix.main.distribution-5.6.1.tar.gz FELIX_SOURCE_URL=http://archive.apache.org/dist/felix/org.apache.felix.main.distribution-5.6.4.tar.gz
# You need to manually download Oracle's JRE or JDK and set the property with # You need to manually download Oracle's JRE or JDK and set the property with
# the absolute path to the downloaded archive. Example: # the absolute path to the downloaded archive. Example:
# #
# JAVA_ARCHIVE=/home/ivan/Downloads/jdk-8u102-linux-x64.tar.gz # JAVA_ARCHIVE=/home/ivan/Downloads/jdk-8u131-linux-x64.tar.gz
# #
#JAVA_ARCHIVE=/absolute/path/to/java.archive.tar.gz #JAVA_ARCHIVE=/absolute/path/to/java.archive.tar.gz
#JAVA_ARCHIVE=/home/ivan/Downloads/jdk-8u111-linux-x64.tar.gz #JAVA_ARCHIVE=/home/ivan/Downloads/jdk-8u131-linux-x64.tar.gz
# You can find the latest Lua source bundes here: # You can find the latest Lua source bundes here:
# #

View File

@ -38,14 +38,14 @@ mkdir /mnt/var
echo "Created folders for all critical file systems." echo "Created folders for all critical file systems."
# Copy root folders in the new mountpoint. # Copy root folders in the new mountpoint.
echo "Copying the root file system to /mnt..." echo -e "Copying the root file system to \\e[94m/mnt\\e[0m."
cp -a bin etc lib lib64 root sbin src usr var /mnt 2>/dev/null cp -a bin etc lib lib64 root sbin src usr var /mnt 2>/dev/null
DEFAULT_OVERLAY_DIR="/tmp/minimal/overlay" DEFAULT_OVERLAY_DIR="/tmp/minimal/overlay"
DEFAULT_UPPER_DIR="/tmp/minimal/rootfs" DEFAULT_UPPER_DIR="/tmp/minimal/rootfs"
DEFAULT_WORK_DIR="/tmp/minimal/work" DEFAULT_WORK_DIR="/tmp/minimal/work"
echo "Searching available devices for overlay content..." echo "Searching available devices for overlay content."
for DEVICE in /dev/* ; do for DEVICE in /dev/* ; do
DEV=$(echo "${DEVICE##*/}") DEV=$(echo "${DEVICE##*/}")
SYSDEV=$(echo "/sys/class/block/$DEV") SYSDEV=$(echo "/sys/class/block/$DEV")
@ -69,11 +69,11 @@ for DEVICE in /dev/* ; do
mount $DEVICE $DEVICE_MNT 2>/dev/null mount $DEVICE $DEVICE_MNT 2>/dev/null
if [ -d $DEVICE_MNT/minimal/rootfs -a -d $DEVICE_MNT/minimal/work ] ; then if [ -d $DEVICE_MNT/minimal/rootfs -a -d $DEVICE_MNT/minimal/work ] ; then
# folder # folder
echo " Found '/minimal' folder on device '$DEVICE'." echo -e " Found \\e[94m/minimal\\e[0m folder on device \\e[31m$DEVICE\\e[0m."
touch $DEVICE_MNT/minimal/rootfs/minimal.pid 2>/dev/null touch $DEVICE_MNT/minimal/rootfs/minimal.pid 2>/dev/null
if [ -f $DEVICE_MNT/minimal/rootfs/minimal.pid ] ; then if [ -f $DEVICE_MNT/minimal/rootfs/minimal.pid ] ; then
# read/write mode # read/write mode
echo " Device '$DEVICE' is mounted in read/write mode." echo -e " Device \\e[31m$DEVICE\\e[0m is mounted in read/write mode."
rm -f $DEVICE_MNT/minimal/rootfs/minimal.pid rm -f $DEVICE_MNT/minimal/rootfs/minimal.pid
@ -83,7 +83,7 @@ for DEVICE in /dev/* ; do
WORK_DIR=$DEVICE_MNT/minimal/work WORK_DIR=$DEVICE_MNT/minimal/work
else else
# read only mode # read only mode
echo " Device '$DEVICE' is mounted in read only mode." echo -e " Device \\e[31m$DEVICE\\e[0m is mounted in read only mode."
OVERLAY_DIR=$DEVICE_MNT/minimal/rootfs OVERLAY_DIR=$DEVICE_MNT/minimal/rootfs
OVERLAY_MNT=$DEVICE_MNT OVERLAY_MNT=$DEVICE_MNT
@ -92,7 +92,7 @@ for DEVICE in /dev/* ; do
fi fi
elif [ -f $DEVICE_MNT/minimal.img ] ; then elif [ -f $DEVICE_MNT/minimal.img ] ; then
#image #image
echo " Found '/minimal.img' image on device '$DEVICE'." echo -e " Found \\e[94m/minimal.img\\e[0m image on device \\e[31m$DEVICE\\e[0m."
mkdir -p /tmp/mnt/image mkdir -p /tmp/mnt/image
IMAGE_MNT=/tmp/mnt/image IMAGE_MNT=/tmp/mnt/image
@ -105,7 +105,7 @@ for DEVICE in /dev/* ; do
touch $IMAGE_MNT/rootfs/minimal.pid 2>/dev/null touch $IMAGE_MNT/rootfs/minimal.pid 2>/dev/null
if [ -f $IMAGE_MNT/rootfs/minimal.pid ] ; then if [ -f $IMAGE_MNT/rootfs/minimal.pid ] ; then
# read/write mode # read/write mode
echo " Image '$DEVICE/minimal.img' is mounted in read/write mode." echo -e " Image \\e[94m$DEVICE/minimal.img\\e[0m is mounted in read/write mode."
rm -f $IMAGE_MNT/rootfs/minimal.pid rm -f $IMAGE_MNT/rootfs/minimal.pid
@ -115,7 +115,7 @@ for DEVICE in /dev/* ; do
WORK_DIR=$IMAGE_MNT/work WORK_DIR=$IMAGE_MNT/work
else else
# read only mode # read only mode
echo " Image '$DEVICE/minimal.img' is mounted in read only mode." echo -e " Image \\e[94m$DEVICE/minimal.img\\e[0m is mounted in read only mode."
OVERLAY_DIR=$IMAGE_MNT/rootfs OVERLAY_DIR=$IMAGE_MNT/rootfs
OVERLAY_MNT=$IMAGE_MNT OVERLAY_MNT=$IMAGE_MNT
@ -137,21 +137,21 @@ for DEVICE in /dev/* ; do
OUT=$? OUT=$?
if [ ! "$OUT" = "0" ] ; then if [ ! "$OUT" = "0" ] ; then
echo " Mount failed (probably on vfat)." echo -e " \\e[31mMount failed (probably on vfat).\\e[0m"
umount $OVERLAY_MNT 2>/dev/null umount $OVERLAY_MNT 2>/dev/null
rmdir $OVERLAY_MNT 2>/dev/null rmdir $OVERLAY_MNT 2>/dev/null
rmdir $DEFAULT_OVERLAY_DIR 2>/dev/null rmdir $DEFAULT_OVERLAY_DIR 2>/dev/null
rmdir $DEFAULT_UPPER_DIR 2>/dev/null rmdir $DEFAULT_UPPER_DIR 2>/dev/null
rmdir $DEFAULT_WORK_DIR 2>/dev/null rmdir $DEFAULT_WORK_DIR 2>/dev/null
else else
# All done, time to go. # All done, time to go.
echo " Overlay data from device '$DEVICE' has been merged." echo -e " Overlay data from device \\e[31m$DEVICE\\e[0m has been merged."
break break
fi fi
else else
echo " Device '$DEVICE' has no proper overlay structure." echo -e " Device \\e[31m$DEVICE\\e[0m has no proper overlay structure."
fi fi
umount $DEVICE_MNT 2>/dev/null umount $DEVICE_MNT 2>/dev/null
@ -163,10 +163,10 @@ mount --move /dev /mnt/dev
mount --move /sys /mnt/sys mount --move /sys /mnt/sys
mount --move /proc /mnt/proc mount --move /proc /mnt/proc
mount --move /tmp /mnt/tmp mount --move /tmp /mnt/tmp
echo "Mount locations /dev, /sys, /tmp and /proc have been moved to /mnt." echo -e "Mount locations \\e[94m/dev\\e[0m, \\e[94m/sys\\e[0m, \\e[94m/tmp\\e[0m and \\e[94m/proc\\e[0m have been moved to \\e[94m/mnt\\e[0m."
# The new mountpoint becomes file system root. All original root folders are # The new mountpoint becomes file system root. All original root folders are
# deleted automatically as part of the command execution. The '/sbin/init' # deleted automatically as part of the command execution. The '/sbin/init'
# process is invoked and it becomes the new PID 1 parent process. # process is invoked and it becomes the new PID 1 parent process.
echo "Switching from initramfs root area to overlayfs root area." echo "Switching from initramfs root area to overlayfs root area."
exec switch_root /mnt /etc/03_init.sh exec switch_root /mnt /etc/03_init.sh

View File

@ -45,7 +45,7 @@ read -t 5 -n1 -s key
if [ "$key" = "" ] ; then if [ "$key" = "" ] ; then
# Use default initialization logic based on configuration in '/etc/inittab'. # Use default initialization logic based on configuration in '/etc/inittab'.
echo "Executing /sbin/init as PID 1." echo -e "Executing \\e[32m/sbin/init\\e[0m as PID 1."
exec /sbin/init exec /sbin/init
else else
# Print second message on screen. # Print second message on screen.

View File

@ -14,9 +14,7 @@
# | # |
# +--(1) /etc/04_bootscript.sh (this file) # +--(1) /etc/04_bootscript.sh (this file)
# | | # | |
# | +-- udhcpc # | +-- /etc/autorun/* (all scripts)
# | |
# | +-- /etc/05_rc.udhcp
# | # |
# +--(2) /bin/sh (Alt + F1, main console) # +--(2) /bin/sh (Alt + F1, main console)
# | # |
@ -28,9 +26,9 @@
echo -e "Welcome to \\e[1mMinimal \\e[32mLinux \\e[31mLive\\e[0m (/sbin/init)" echo -e "Welcome to \\e[1mMinimal \\e[32mLinux \\e[31mLive\\e[0m (/sbin/init)"
for DEVICE in /sys/class/net/* ; do # Autorun functionality
echo "Found network device ${DEVICE##*/}" for AUTOSCRIPT in /etc/autorun/*
ip link set ${DEVICE##*/} up do
[ ${DEVICE##*/} != lo ] && udhcpc -b -i ${DEVICE##*/} -s /etc/05_rc.dhcp echo -e "Executing \\e[32m$AUTOSCRIPT\\e[0m in subshell."
sh $AUTOSCRIPT
done done

View File

@ -33,9 +33,9 @@ if [ "$router" ]; then
fi fi
if [ "$ip" ]; then if [ "$ip" ]; then
echo "DHCP configuration for device $interface" echo -e "DHCP configuration for device $interface"
echo "ip: $ip" echo -e "IP: \\e[1m$ip\\e[0m"
echo "mask: $mask" echo -e "mask: \\e[1m$mask\\e[0m"
echo "router: $router" echo -e "router: \\e[1m$router\\e[0m"
fi fi

View File

@ -0,0 +1,8 @@
#!/bin/sh
# DHCP network
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