From fe8e65809a7bc797dc8996a87a3b37a411ffeeda Mon Sep 17 00:00:00 2001 From: TolaMironcenko Date: Thu, 9 Jan 2025 10:17:56 +0700 Subject: [PATCH] updated init.in mkinitramfs.sh and added lsinitramfs --- src/init.in | 56 +++++++++++++++++++++++++++++++--------------- src/lsinitramfs | 16 +++++++++++++ src/mkinitramfs.sh | 4 ++-- 3 files changed, 56 insertions(+), 20 deletions(-) mode change 100644 => 100755 src/init.in create mode 100755 src/lsinitramfs mode change 100644 => 100755 src/mkinitramfs.sh diff --git a/src/init.in b/src/init.in old mode 100644 new mode 100755 index b85d7a5..7674b4d --- a/src/init.in +++ b/src/init.in @@ -1,11 +1,39 @@ #!/bin/sh -PATH=/usr/bin:/usr/sbin -export PATH +export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin +rootfspath=/.root +init=/sbin/init +root= +rootdelay= +rootfstype=auto +ro="ro" +rootflags= +device= +resume= +noresume=false + +#--- colors --- +RESET="\033[0m" +BRED="\033[1;31m" +#-------------- + +mount_setup() { + mount -t proc proc /proc -o nosuid,noexec,nodev + mount -t sysfs sys /sys -o nosuid,noexec,nodev + mount -t devtmpfs dev /dev -o mode=0755,nosuid + mount -t tmpfs run /run -o nosuid,nodev,mode=0755 +} + +move_mount_setup() { + mount --move /proc $rootfspath/proc + mount --move /sys $rootfspath/sys + mount --move /dev $rootfspath/dev + mount --move /run $rootfspath/run +} problem() { - printf "Encountered a problem!\n\nDropping you to a shell.\n\n" + printf "[$BRED ERROR $RESET] Encountered a problem!\n\nDropping you to a shell.\n\n" sh } @@ -67,20 +95,11 @@ do_try_resume() echo -n ${maj%,}:$min > /sys/power/resume ) } -init=/sbin/init -root= -rootdelay= -rootfstype=auto -ro="ro" -rootflags= -device= -resume= -noresume=false - -mount -n -t devtmpfs devtmpfs /dev -mount -n -t proc proc /proc -mount -n -t sysfs sysfs /sys -mount -n -t tmpfs tmpfs /run +mount_setup +# mount -n -t devtmpfs devtmpfs /dev +# mount -n -t proc proc /proc +# mount -n -t sysfs sysfs /sys +# mount -n -t tmpfs tmpfs /run read -r cmdline < /proc/cmdline @@ -123,4 +142,5 @@ do_mount_root killall -w ${UDEVD##*/} -exec switch_root /.root "$init" "$@" \ No newline at end of file +exec switch_root $rootfspath "$init" "$@" + diff --git a/src/lsinitramfs b/src/lsinitramfs new file mode 100755 index 0000000..e52ad89 --- /dev/null +++ b/src/lsinitramfs @@ -0,0 +1,16 @@ +#!/bin/sh -e + +[ -f /etc/mkinitramfs.conf ] && . /etc/mkinitramfs.conf + +[ "$1" ] || exit 1 + +case $INITFSCOMP in + gzip) compressor="gzip -dc" ;; + lz4) compressor="lz4 -d -c" ;; + cat) compressor="cat --" ;; + xz) compressor="xzcat --" ;; + zstd) compressor="zstd -d -c" ;; +esac + +$compressor "$1" | bsdcpio -it +exit 0 \ No newline at end of file diff --git a/src/mkinitramfs.sh b/src/mkinitramfs.sh old mode 100644 new mode 100755 index 2e68591..afd81b3 --- a/src/mkinitramfs.sh +++ b/src/mkinitramfs.sh @@ -1,6 +1,6 @@ #!/bin/bash -# This file based in part on the mkinitramfs script for the LFS LiveCD -# written by Alexander E. Patrakov and Jeremy Huntwork. + +export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin copy() {