finally
This commit is contained in:
parent
574e206ef0
commit
ead666ef0d
2
config
2
config
@ -18,7 +18,7 @@ root="UUID=07729c48-25d8-4096-acaf-ce5322915680"
|
|||||||
#root_args=""
|
#root_args=""
|
||||||
|
|
||||||
# device manager ( mdev,mdevd,udev )
|
# device manager ( mdev,mdevd,udev )
|
||||||
devmgr="mdev"
|
devmgr="udev"
|
||||||
|
|
||||||
# drivers
|
# drivers
|
||||||
#drivers=""
|
#drivers=""
|
||||||
|
17
generate
17
generate
@ -184,6 +184,7 @@ install_libraries() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
install_files() {
|
install_files() {
|
||||||
|
# FIXME eof broken
|
||||||
# initialize config
|
# initialize config
|
||||||
cat <<EOF > "${tmpdir}/config"
|
cat <<EOF > "${tmpdir}/config"
|
||||||
debug="$debug"
|
debug="$debug"
|
||||||
@ -191,7 +192,6 @@ root="$root"
|
|||||||
root_type="$root_type"
|
root_type="$root_type"
|
||||||
root_args="$root_args"
|
root_args="$root_args"
|
||||||
devmgr="$devmgr"
|
devmgr="$devmgr"
|
||||||
use_mdev="1"
|
|
||||||
#drivers="$drivers"
|
#drivers="$drivers"
|
||||||
use_lvm="$use_lvm"
|
use_lvm="$use_lvm"
|
||||||
use_luks="$use_luks"
|
use_luks="$use_luks"
|
||||||
@ -241,25 +241,26 @@ create_initramfs() {
|
|||||||
[ "$?" = 0 ] || panic "failed to generate initramfs image"
|
[ "$?" = 0 ] || panic "failed to generate initramfs image"
|
||||||
}
|
}
|
||||||
|
|
||||||
# main function :)
|
# TODO cd to script directory
|
||||||
|
|
||||||
[ "$(id -u)" = 0 ] || panic "must be run as root"
|
[ "$(id -u)" = 0 ] || panic "must be run as root"
|
||||||
|
|
||||||
# remove tmpdir on exit or unexpected error
|
# remove tmpdir on exit or unexpected error
|
||||||
trap remove_tmpdir EXIT INT
|
trap remove_tmpdir EXIT INT
|
||||||
|
|
||||||
# handle debug mode
|
|
||||||
[ "$debug" = 1 ] && {
|
|
||||||
set -x
|
|
||||||
trap : EXIT INT
|
|
||||||
}
|
|
||||||
|
|
||||||
# variables
|
# variables
|
||||||
tmpdir="$(mktemp -d /tmp/initramfs.XXXXXXXX)" || panic "failed to create working directory"
|
tmpdir="$(mktemp -d /tmp/initramfs.XXXXXXXX)" || panic "failed to create working directory"
|
||||||
kernel="$(uname -r)"
|
kernel="$(uname -r)"
|
||||||
moddir="/lib/modules/"
|
moddir="/lib/modules/"
|
||||||
|
|
||||||
check_requirements
|
check_requirements
|
||||||
|
|
||||||
|
# handle debug mode
|
||||||
|
[ "$debug" = 1 ] && {
|
||||||
|
set -x
|
||||||
|
trap : EXIT INT
|
||||||
|
}
|
||||||
|
|
||||||
create_structure
|
create_structure
|
||||||
create_symlinks
|
create_symlinks
|
||||||
#parse_fstab
|
#parse_fstab
|
||||||
|
37
init
37
init
@ -3,12 +3,7 @@
|
|||||||
# tiny init script
|
# tiny init script
|
||||||
|
|
||||||
panic() {
|
panic() {
|
||||||
printf "panic >> %s\n" "$@"
|
printf "panic >> %s\n" "$@" && sh
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
info() {
|
|
||||||
printf "info >> %s\n" "$@"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# parse_cmdline() {
|
# parse_cmdline() {
|
||||||
@ -43,7 +38,7 @@ use_mdev() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
# load drivers
|
# load drivers
|
||||||
find /sys -name 'modalias' -type f -exec cat '{}' + | sort -u | xargs modprobe -ba
|
find /sys -name "modalias" -type f -exec cat "{}" + | sort -u | xargs modprobe -ba
|
||||||
}
|
}
|
||||||
|
|
||||||
use_mdevd() {
|
use_mdevd() {
|
||||||
@ -90,26 +85,17 @@ mnt_rootfs() {
|
|||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
# clean up
|
# clean up
|
||||||
[ "$use_mdev" = 1 ] && { printf "" >/proc/sys/kernel/hotplug || killall uevent; } >/dev/null 2>&1
|
[ "$devmgr" = "mdev" ] && { printf "" >/proc/sys/kernel/hotplug || killall uevent; } >/dev/null 2>&1
|
||||||
[ "$use_mdevd" = 1 ] && killall mdevd
|
[ "$devmgr" = "mdevd" ] && killall mdevd
|
||||||
[ "$use_udev" = 1 ] && udevadm control --exit
|
[ "$devmgr" = "udev" ] && udevadm control --exit
|
||||||
umount /dev /sys /proc
|
umount /dev /sys /proc
|
||||||
}
|
}
|
||||||
|
|
||||||
boot_system() {
|
boot_system() {
|
||||||
# boot system
|
# boot system
|
||||||
[ "$debug" = 1 ] && info SUCCESS
|
|
||||||
exec switch_root /mnt/root /sbin/init || panic "failed to boot system"
|
exec switch_root /mnt/root /sbin/init || panic "failed to boot system"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ "$debug" = 1 ]; then
|
|
||||||
# debug shell commands
|
|
||||||
set -x
|
|
||||||
else
|
|
||||||
# silence is golden
|
|
||||||
printf 0 >/proc/sys/kernel/printk
|
|
||||||
fi
|
|
||||||
|
|
||||||
# install busybox
|
# install busybox
|
||||||
/sbin/busybox --install -s
|
/sbin/busybox --install -s
|
||||||
|
|
||||||
@ -120,16 +106,27 @@ else
|
|||||||
panic "config doesn't exists"
|
panic "config doesn't exists"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$debug" = 1 ]; then
|
||||||
|
# debug shell commands
|
||||||
|
set -x
|
||||||
|
else
|
||||||
|
# silence is golden
|
||||||
|
printf 0 >/proc/sys/kernel/printk
|
||||||
|
fi
|
||||||
|
|
||||||
#parse_cmdline
|
#parse_cmdline
|
||||||
mnt_pseudofs
|
mnt_pseudofs
|
||||||
|
|
||||||
case "$devmgr" in
|
case "$devmgr" in
|
||||||
mdev) use_mdev ;;
|
mdev) use_mdev ;;
|
||||||
mdevd) use_mdevd ;;
|
mdevd) use_mdevd ;;
|
||||||
udev) use_udev ;;
|
udev) use_udev ;;
|
||||||
|
*) panic "devmgr option broken" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# TODO handle situations when LUKS on LVM
|
# TODO handle situations when LUKS on LVM
|
||||||
[ "$use_luks" = 1 ] && unlock_luks
|
[ "$use_luks" = 1 ] && unlock_luks
|
||||||
[ "$use_lvm" = 1 ] && [ "$use_udev" = 0 ] && trigger_lvm
|
[ "$use_lvm" = 1 ] && [ "$devmgr" != "udev" ] && trigger_lvm
|
||||||
mnt_rootfs
|
mnt_rootfs
|
||||||
cleanup
|
cleanup
|
||||||
boot_system
|
boot_system
|
||||||
|
Loading…
x
Reference in New Issue
Block a user