general improvements
This commit is contained in:
parent
9baf5880bd
commit
9670f5bf85
11
generate
11
generate
@ -22,6 +22,7 @@ msg() {
|
|||||||
|
|
||||||
# create tmpdir
|
# create tmpdir
|
||||||
create_tmpdir() {
|
create_tmpdir() {
|
||||||
|
msg info "creating working directory"
|
||||||
if [ -n "$XDG_CACHE_HOME" ]; then
|
if [ -n "$XDG_CACHE_HOME" ]; then
|
||||||
tmpdir="${XDG_CACHE_HOME}/initramfs.$$"
|
tmpdir="${XDG_CACHE_HOME}/initramfs.$$"
|
||||||
elif [ -n "$TMPDIR" ]; then
|
elif [ -n "$TMPDIR" ]; then
|
||||||
@ -35,7 +36,7 @@ create_tmpdir() {
|
|||||||
|
|
||||||
# remove tmpdir
|
# remove tmpdir
|
||||||
remove_tmpdir() {
|
remove_tmpdir() {
|
||||||
msg info "removing work dir"
|
msg info "removing working dir"
|
||||||
rm -rf "$tmpdir"
|
rm -rf "$tmpdir"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,12 +277,13 @@ install_all_drivers() {
|
|||||||
"${modker}/drivers/virtio" \
|
"${modker}/drivers/virtio" \
|
||||||
-type f 2> /dev/null)
|
-type f 2> /dev/null)
|
||||||
|
|
||||||
modker="${moddir}/${kernel}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# generate "modules" files
|
# generate "modules" files
|
||||||
generate_depmod() {
|
generate_depmod() {
|
||||||
msg info "generating dependendies list of drivers"
|
msg info "running depmod"
|
||||||
|
modker="${moddir}/${kernel}"
|
||||||
|
|
||||||
# install list of drivers
|
# install list of drivers
|
||||||
cp "${modker}/modules.softdep" "${modker}/modules.builtin" "${modker}/modules.order" "${tmpdir}/${modker}"
|
cp "${modker}/modules.softdep" "${modker}/modules.builtin" "${modker}/modules.order" "${tmpdir}/${modker}"
|
||||||
|
|
||||||
@ -312,7 +314,6 @@ install_binaries() {
|
|||||||
# handle libraries
|
# handle libraries
|
||||||
install_libraries() {
|
install_libraries() {
|
||||||
for library in $(ldd "$(command -v $1)" | sed -nre 's,.* (/.*lib.*/.*.so.*) .*,\1,p' -e 's,.*(/lib.*/ld.*.so.*) .*,\1,p'); do
|
for library in $(ldd "$(command -v $1)" | sed -nre 's,.* (/.*lib.*/.*.so.*) .*,\1,p' -e 's,.*(/lib.*/ld.*.so.*) .*,\1,p'); do
|
||||||
msg info "installing library $library"
|
|
||||||
# check symlink
|
# check symlink
|
||||||
if [ -h "$library" ]; then
|
if [ -h "$library" ]; then
|
||||||
# check lib already existence
|
# check lib already existence
|
||||||
@ -407,7 +408,7 @@ trap remove_tmpdir EXIT INT
|
|||||||
check_currentdir
|
check_currentdir
|
||||||
|
|
||||||
# source config
|
# source config
|
||||||
. ./config || msg panic "./config doesn't exists"
|
. ./config || msg panic "failed to source config"
|
||||||
|
|
||||||
# handle debug mode
|
# handle debug mode
|
||||||
[ "$debug" = 1 ] && {
|
[ "$debug" = 1 ] && {
|
||||||
|
42
init
42
init
@ -3,7 +3,8 @@
|
|||||||
# tiny init script
|
# tiny init script
|
||||||
|
|
||||||
panic() {
|
panic() {
|
||||||
printf "panic >> %s\n" "$1" && sh
|
printf "panic >> %s\n" "$1"
|
||||||
|
sh -l
|
||||||
}
|
}
|
||||||
|
|
||||||
# parse_cmdline() {
|
# parse_cmdline() {
|
||||||
@ -31,10 +32,10 @@ use_mdev() {
|
|||||||
mdev -s
|
mdev -s
|
||||||
|
|
||||||
# trigger uevent for usb devices
|
# trigger uevent for usb devices
|
||||||
for u in /sys/bus/usb/devices/*; do
|
for device in /sys/bus/usb/devices/*; do
|
||||||
case ${u##*/} in
|
case ${device##*/} in
|
||||||
[0-9]*-[0-9]*)
|
[0-9]*-[0-9]*)
|
||||||
printf add > "${u}/uevent"
|
printf add > "${device}/uevent"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@ -86,51 +87,32 @@ findfs_sh() {
|
|||||||
|
|
||||||
# unlock LUKS container
|
# unlock LUKS container
|
||||||
unlock_luks() {
|
unlock_luks() {
|
||||||
# find device of luks root
|
|
||||||
luks_root="$(findfs_sh $luks_root)"
|
|
||||||
|
|
||||||
# TODO investigate this
|
# TODO investigate this
|
||||||
# avoid race condition
|
# avoid race condition
|
||||||
[ "$devmgr" != "udev" ] && sleep 1.5
|
[ "$devmgr" != "udev" ] && sleep 1.5
|
||||||
|
|
||||||
# TODO improve mapper name ( crypttab or config option )
|
# TODO improve mapper name ( crypttab or config option )
|
||||||
# unlock luks container
|
# unlock luks container
|
||||||
cryptsetup $luks_args luksOpen "$luks_root" luks_root || panic "failed to unlock luks container"
|
cryptsetup $luks_args luksOpen $(findfs_sh "$luks_root") luks_root || panic "failed to unlock luks container"
|
||||||
}
|
}
|
||||||
|
|
||||||
# manually trigger LVM if udev disabled
|
# manually trigger LVM
|
||||||
trigger_lvm() {
|
trigger_lvm() {
|
||||||
lvm vgchange --quiet --sysinit -a y > /dev/null
|
lvm vgchange --quiet --sysinit -a y > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
# mount rootfs to /mnt/root
|
# mount rootfs to /mnt/root
|
||||||
mnt_rootfs() {
|
mnt_rootfs() {
|
||||||
# merge mount flags
|
|
||||||
[ -n "$root_args" ] && mount_args="$root_args"
|
|
||||||
[ -n "$root_type" ] && mount_args="$mount_args -t $root_type"
|
|
||||||
|
|
||||||
# find root
|
|
||||||
root="$(findfs_sh $root)"
|
|
||||||
|
|
||||||
# mount rootfs
|
# mount rootfs
|
||||||
mount $mount_args "$root" /mnt/root || panic "failed to mount rootfs"
|
mount $root_type $root_args $(findfs_sh "$root") /mnt/root || panic "failed to mount rootfs"
|
||||||
}
|
}
|
||||||
|
|
||||||
# kill and unmount
|
# kill and unmount
|
||||||
cleanup() {
|
cleanup() {
|
||||||
case "$devmgr" in
|
case "$devmgr" in
|
||||||
mdev)
|
mdev) { printf "" > /proc/sys/kernel/hotplug || killall uevent; } > /dev/null 2>&1 ;;
|
||||||
# stop mdev
|
mdevd) killall mdevd ;;
|
||||||
{ printf "" > /proc/sys/kernel/hotplug || killall uevent; } > /dev/null 2>&1
|
udev) udevadm control --exit ;;
|
||||||
;;
|
|
||||||
mdevd)
|
|
||||||
# stop mdevd
|
|
||||||
killall mdevd
|
|
||||||
;;
|
|
||||||
udev)
|
|
||||||
# stop udev
|
|
||||||
udevadm control --exit
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# TODO re-do
|
# TODO re-do
|
||||||
@ -150,7 +132,7 @@ boot_system() {
|
|||||||
/sbin/busybox --install -s
|
/sbin/busybox --install -s
|
||||||
|
|
||||||
# source config
|
# source config
|
||||||
. /config || panic "config doesn't exists"
|
. /config || panic "failed to source config"
|
||||||
|
|
||||||
# TODO re-do
|
# TODO re-do
|
||||||
if [ "$debug" = 1 ]; then
|
if [ "$debug" = 1 ]; then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user