Added 'autorun' functionality loosely based on 'init.d'. Updated the software components with their latest versions (not tested yet).
This commit is contained in:
parent
37fdd26e82
commit
c915716a15
10
src/.config
10
src/.config
@ -11,7 +11,7 @@
|
||||
#
|
||||
# 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:
|
||||
#
|
||||
@ -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
|
||||
#
|
||||
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:
|
||||
#
|
||||
# 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
|
||||
# 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=/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:
|
||||
#
|
||||
|
@ -38,14 +38,14 @@ mkdir /mnt/var
|
||||
echo "Created folders for all critical file systems."
|
||||
|
||||
# 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
|
||||
|
||||
DEFAULT_OVERLAY_DIR="/tmp/minimal/overlay"
|
||||
DEFAULT_UPPER_DIR="/tmp/minimal/rootfs"
|
||||
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
|
||||
DEV=$(echo "${DEVICE##*/}")
|
||||
SYSDEV=$(echo "/sys/class/block/$DEV")
|
||||
@ -69,11 +69,11 @@ for DEVICE in /dev/* ; do
|
||||
mount $DEVICE $DEVICE_MNT 2>/dev/null
|
||||
if [ -d $DEVICE_MNT/minimal/rootfs -a -d $DEVICE_MNT/minimal/work ] ; then
|
||||
# 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
|
||||
if [ -f $DEVICE_MNT/minimal/rootfs/minimal.pid ] ; then
|
||||
# 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
|
||||
|
||||
@ -83,7 +83,7 @@ for DEVICE in /dev/* ; do
|
||||
WORK_DIR=$DEVICE_MNT/minimal/work
|
||||
else
|
||||
# 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_MNT=$DEVICE_MNT
|
||||
@ -92,7 +92,7 @@ for DEVICE in /dev/* ; do
|
||||
fi
|
||||
elif [ -f $DEVICE_MNT/minimal.img ] ; then
|
||||
#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
|
||||
IMAGE_MNT=/tmp/mnt/image
|
||||
@ -105,7 +105,7 @@ for DEVICE in /dev/* ; do
|
||||
touch $IMAGE_MNT/rootfs/minimal.pid 2>/dev/null
|
||||
if [ -f $IMAGE_MNT/rootfs/minimal.pid ] ; then
|
||||
# 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
|
||||
|
||||
@ -115,7 +115,7 @@ for DEVICE in /dev/* ; do
|
||||
WORK_DIR=$IMAGE_MNT/work
|
||||
else
|
||||
# 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_MNT=$IMAGE_MNT
|
||||
@ -137,21 +137,21 @@ for DEVICE in /dev/* ; do
|
||||
|
||||
OUT=$?
|
||||
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
|
||||
rmdir $OVERLAY_MNT 2>/dev/null
|
||||
|
||||
|
||||
rmdir $DEFAULT_OVERLAY_DIR 2>/dev/null
|
||||
rmdir $DEFAULT_UPPER_DIR 2>/dev/null
|
||||
rmdir $DEFAULT_WORK_DIR 2>/dev/null
|
||||
else
|
||||
# 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
|
||||
fi
|
||||
else
|
||||
echo " Device '$DEVICE' has no proper overlay structure."
|
||||
echo -e " Device \\e[31m$DEVICE\\e[0m has no proper overlay structure."
|
||||
fi
|
||||
|
||||
umount $DEVICE_MNT 2>/dev/null
|
||||
@ -163,10 +163,10 @@ mount --move /dev /mnt/dev
|
||||
mount --move /sys /mnt/sys
|
||||
mount --move /proc /mnt/proc
|
||||
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
|
||||
# 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.
|
||||
echo "Switching from initramfs root area to overlayfs root area."
|
||||
exec switch_root /mnt /etc/03_init.sh
|
||||
|
@ -45,7 +45,7 @@ read -t 5 -n1 -s key
|
||||
|
||||
if [ "$key" = "" ] ; then
|
||||
# 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
|
||||
else
|
||||
# Print second message on screen.
|
||||
|
@ -14,9 +14,7 @@
|
||||
# |
|
||||
# +--(1) /etc/04_bootscript.sh (this file)
|
||||
# | |
|
||||
# | +-- udhcpc
|
||||
# | |
|
||||
# | +-- /etc/05_rc.udhcp
|
||||
# | +-- /etc/autorun/* (all scripts)
|
||||
# |
|
||||
# +--(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)"
|
||||
|
||||
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
|
||||
# Autorun functionality
|
||||
for AUTOSCRIPT in /etc/autorun/*
|
||||
do
|
||||
echo -e "Executing \\e[32m$AUTOSCRIPT\\e[0m in subshell."
|
||||
sh $AUTOSCRIPT
|
||||
done
|
||||
|
||||
|
@ -33,9 +33,9 @@ if [ "$router" ]; then
|
||||
fi
|
||||
|
||||
if [ "$ip" ]; then
|
||||
echo "DHCP configuration for device $interface"
|
||||
echo "ip: $ip"
|
||||
echo "mask: $mask"
|
||||
echo "router: $router"
|
||||
echo -e "DHCP configuration for device $interface"
|
||||
echo -e "IP: \\e[1m$ip\\e[0m"
|
||||
echo -e "mask: \\e[1m$mask\\e[0m"
|
||||
echo -e "router: \\e[1m$router\\e[0m"
|
||||
fi
|
||||
|
||||
|
8
src/minimal_rootfs/etc/autorun/01_network.sh
Executable file
8
src/minimal_rootfs/etc/autorun/01_network.sh
Executable 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
|
Loading…
x
Reference in New Issue
Block a user