better
This commit is contained in:
parent
a899c50a84
commit
61f74510aa
42
files/init
42
files/init
@ -10,8 +10,11 @@ panic() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parse_cmdline() {
|
parse_cmdline() {
|
||||||
|
# store output in variable
|
||||||
|
read -r cmdline < /proc/cmdline
|
||||||
|
|
||||||
# turn output into list
|
# turn output into list
|
||||||
set -- $(cat /proc/cmdline)
|
set -f && set +f -- $cmdline
|
||||||
|
|
||||||
for line in "$@"; do
|
for line in "$@"; do
|
||||||
value="${line##*=}"
|
value="${line##*=}"
|
||||||
@ -93,18 +96,19 @@ findfs_sh() {
|
|||||||
sleep 0.5
|
sleep 0.5
|
||||||
[ "$increment" ] || increment=0
|
[ "$increment" ] || increment=0
|
||||||
increment=$(( increment + 1 ))
|
increment=$(( increment + 1 ))
|
||||||
[ "$increment" = 10 ] &&
|
[ "$increment" = 10 ] && panic "failed to lookup partition"
|
||||||
panic "failed to lookup partition"
|
|
||||||
done
|
done
|
||||||
|
|
||||||
printf "%s\n" "$device"
|
printf "%s\n" "$device"
|
||||||
}
|
}
|
||||||
|
|
||||||
unlock_luks() {
|
unlock_luks() {
|
||||||
[ "$luks_discard" = 1 ] &&
|
[ "$luks_discard" = 1 ] && luks_args="--allow-discards $luks_args"
|
||||||
luks_args="--allow-discards $luks_args"
|
|
||||||
|
|
||||||
cryptsetup $luks_args luksOpen $(findfs_sh "$luks_root") ${luks_name:-luks_root} ||
|
cryptsetup $luks_args \
|
||||||
|
luksOpen \
|
||||||
|
$(findfs_sh "$luks_root") \
|
||||||
|
${luks_name:-luks_root} ||
|
||||||
panic "failed to unlock luks container"
|
panic "failed to unlock luks container"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +123,10 @@ trigger_lvm() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mount_rootfs() {
|
mount_rootfs() {
|
||||||
mount ${root_type:+-t $root_type} ${root_opts:+-o $root_opts} $(findfs_sh "$root") /mnt/root ||
|
mount ${root_type:+-t $root_type} \
|
||||||
|
${root_opts:+-o $root_opts} \
|
||||||
|
$(findfs_sh "$root") \
|
||||||
|
/mnt/root ||
|
||||||
panic "failed to mount rootfs"
|
panic "failed to mount rootfs"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,33 +142,28 @@ cleanup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boot_system() {
|
boot_system() {
|
||||||
exec switch_root /mnt/root ${init:-/sbin/init} ||
|
exec switch_root /mnt/root \
|
||||||
|
${init:-/sbin/init} ||
|
||||||
panic "failed to boot system"
|
panic "failed to boot system"
|
||||||
}
|
}
|
||||||
|
|
||||||
/sbin/busybox --install -s
|
/sbin/busybox --install -s
|
||||||
|
|
||||||
. /config ||
|
. /config || panic "failed to source config"
|
||||||
panic "failed to source config"
|
|
||||||
|
|
||||||
mount_pseudofs
|
mount_pseudofs
|
||||||
parse_cmdline
|
parse_cmdline
|
||||||
|
|
||||||
[ "$debug" = 1 ] && set -x
|
[ "$debug" = 1 ] && set -x
|
||||||
|
|
||||||
setup_devmgr
|
setup_devmgr
|
||||||
|
|
||||||
# TODO handle situations when LUKS on LVM
|
# TODO handle situations when LUKS on LVM
|
||||||
[ "$luks" = 1 ] && command -v cryptsetup > /dev/null 2>&1 &&
|
[ "$luks" = 1 ] &&
|
||||||
unlock_luks
|
command -v cryptsetup > /dev/null 2>&1 && unlock_luks
|
||||||
|
|
||||||
[ "$lvm" = 1 ] && command -v lvm > /dev/null 2>&1 &&
|
[ "$lvm" = 1 ] &&
|
||||||
trigger_lvm
|
command -v lvm > /dev/null 2>&1 && trigger_lvm
|
||||||
|
|
||||||
mount_rootfs
|
mount_rootfs
|
||||||
|
[ "$debug" = 1 ] && panic "dropping to shell"
|
||||||
[ "$debug" = 1 ] &&
|
|
||||||
panic "dropping to shell"
|
|
||||||
|
|
||||||
cleanup
|
cleanup
|
||||||
boot_system
|
boot_system
|
||||||
|
Loading…
Reference in New Issue
Block a user