From 445fa9118ec507c20a0bc2e04e6c9018ba0c8dad Mon Sep 17 00:00:00 2001 From: minoplhy Date: Wed, 4 Dec 2024 15:54:09 +0700 Subject: [PATCH] alpine-initramfs-dropbear: update to 3.11.0_rc5 --- alpine-initramfs-dropbear/README.md | 57 +++++----- alpine-initramfs-dropbear/initramfs-dropbear | 106 ++++++++++++++----- 2 files changed, 101 insertions(+), 62 deletions(-) diff --git a/alpine-initramfs-dropbear/README.md b/alpine-initramfs-dropbear/README.md index c45ac19..b452fda 100644 --- a/alpine-initramfs-dropbear/README.md +++ b/alpine-initramfs-dropbear/README.md @@ -55,51 +55,42 @@ mkinitfs -i path/to/initramfs-dropbear setup_dropbear() { -> local port="${KOPT_dropbear}" -> local keys="" +> local port="${KOPT_dropbear}" +> local keys="" > -> # set the unlock_disc script as shell for root -> sed -i 's|\(root:x:0:0:root:/root:\).*$|\1/etc/dropbear/unlock_disk|' /etc/passwd -> echo '/etc/dropbear/unlock_disk' > /etc/shells +> # set the unlock_disc script as shell for root +> sed -i 's|\(root:x:0:0:root:/root:\).*$|\1/etc/dropbear/unlock_disk|' /etc/passwd +> echo '/etc/dropbear/unlock_disk' > /etc/shells > -> # transfer authorized_keys -> mkdir /root/.ssh -> cp /etc/dropbear/authorized_keys /root/.ssh/authorized_keys +> # transfer authorized_keys +> mkdir /root/.ssh +> cp /etc/dropbear/authorized_keys /root/.ssh/authorized_keys > -> dropbear -R -E -s -j -k -p $port +> dropbear -R -E -s -j -k -p $port > } > -453c468 -< s390x_net dasd ssh_key BOOTIF zfcp uevent_buf_size aoe aoe_iflist aoe_mtu wireguard" ---- -> s390x_net dasd ssh_key BOOTIF zfcp uevent_buf_size aoe aoe_iflist aoe_mtu wireguard dropbear" -581c596,604 +512a528 +> dropbear +641c657,665 < if [ -n "$KOPT_cryptroot" ]; then --- > if [ -n "$KOPT_dropbear" ]; then -> if [ -n "$KOPT_cryptroot" ]; then -> configure_ip -> setup_dropbear -> fi +> if [ -n "$KOPT_cryptroot" ]; then +> configure_ip +> setup_dropbear +> fi > fi > > # Add Workaround for dropbear > if [ -n "$KOPT_cryptroot" ] && [ ! -b /dev/mapper/"${KOPT_cryptdm}" ]; then -645a669,672 -> # Kill all struck nlplug-findfs jobs and dropbear -> killall -9 nlplug-findfs -> killall -9 dropbear +705a730,733 +> # Kill all struck nlplug-findfs jobs and dropbear +> killall -9 nlplug-findfs +> killall -9 dropbear > -715a743 +781a810,813 > -733a762,765 -> -> # Kill all struck nlplug-findfs jobs and dropbear -> killall -9 nlplug-findfs -> killall -9 dropbear -1003c1035 -< reboot ---- -> reboot -\ No newline at end of file +> # Kill all struck nlplug-findfs jobs and dropbear +> killall -9 nlplug-findfs +> killall -9 dropbear ``` \ No newline at end of file diff --git a/alpine-initramfs-dropbear/initramfs-dropbear b/alpine-initramfs-dropbear/initramfs-dropbear index a3d8751..d0f58da 100644 --- a/alpine-initramfs-dropbear/initramfs-dropbear +++ b/alpine-initramfs-dropbear/initramfs-dropbear @@ -303,7 +303,7 @@ find_boot_repositories() { if [ -n "$ALPINE_REPO" ]; then echo "$ALPINE_REPO" | tr ',' '\n' else - find /media/* -maxdepth 3 -name .boot_repository -type f \ + find "$ROOT"/media/* -maxdepth 3 -name .boot_repository -type f \ | sed 's:/.boot_repository$::' fi } @@ -406,16 +406,38 @@ want_tiny_cloud() { if [ -f "$sysroot/etc/tiny-cloud.disabled" ]; then return 1 fi - case "$KOPT_ds" in - nocloud*) return 0;; - esac - if grep -q "^ds=nocloud" "$ROOT"/sys/class/dmi/id/product_serial 2>/dev/null; then + if [ -n "$KOPT_ds" ] || [ "$KOPT_tinycloud" ]; then + return 0 + fi + if grep -q "^ds=" "$ROOT"/sys/class/dmi/id/product_serial 2>/dev/null; then return 0 fi findfs LABEL=cidata >/dev/null 2>&1 || findfs LABEL=CIDATA >/dev/null 2>&1 } -/bin/busybox mkdir -p "$ROOT"/usr/bin \ +resume_from_disk () { + if [ -z "$KOPT_resume" ]; then + return + fi + if [ ! -e "$ROOT"/sys/power/resume ]; then + echo "resume: no hibernation support found" + return + fi + echo "Resume from disk" + case "$KOPT_resume" in + UUID*|LABEL*) resume_dev=$(findfs "$KOPT_resume");; + *) resume_dev="$KOPT_resume";; + esac + printf "%d:%d" $(stat -Lc "0x%t 0x%T" "$resume_dev") > "$ROOT"/sys/power/resume + if [ -n "$KOPT_resume_offset" ]; then + echo "$KOPT_resume_offset" > "$ROOT"/sys/power/resume_offset + fi +} + +/bin/busybox mkdir -p \ + "$ROOT"/bin \ + "$ROOT"/sbin \ + "$ROOT"/usr/bin \ "$ROOT"/usr/sbin \ "$ROOT"/proc \ "$ROOT"/sys \ @@ -461,11 +483,50 @@ $MOCK mount -t tmpfs -o nodev,nosuid,noexec shm /dev/shm # acpi_osi="!Windows 2006" xen-pciback.hide=(01:00.0) set -- $(cat "$ROOT"/proc/cmdline) -myopts="autodetect_serial chart cryptroot cryptdm cryptheader cryptoffset - cryptdiscards cryptkey debug_init ds init init_args keep_apk_new modules - pkgs quiet root_size root usbdelay ip alpine_repo apkovl splash - blacklist overlaytmpfs overlaytmpfsflags rootfstype rootflags nbd resume resume_offset - s390x_net dasd ssh_key BOOTIF zfcp uevent_buf_size aoe aoe_iflist aoe_mtu wireguard dropbear" +myopts="BOOTIF + alpine_repo + aoe + aoe_iflist + aoe_mtu + apkovl + autodetect_serial + blacklist + chart + cryptdiscards + cryptdm + cryptheader + cryptkey + cryptoffset + cryptroot + dasd + debug_init + ds + init + init_args + ip + keep_apk_new + modules + nbd + overlaytmpfs + overlaytmpfsflags + pkgs + quiet + resume + resume_offset + root + root_size + rootflags + rootfstype + s390x_net + splash + ssh_key + tinycloud + uevent_buf_size + usbdelay + wireguard + zfcp + dropbear +" for opt; do case "$opt" in @@ -680,21 +741,7 @@ if [ -n "$KOPT_root" ]; then echo "Failed to scan devices for btrfs filesystem." fi - if [ -n "$KOPT_resume" ]; then - echo "Resume from disk" - if [ -e $ROOT/sys/power/resume ]; then - case "$KOPT_resume" in - UUID*|LABEL*) resume_dev=$(findfs "$KOPT_resume");; - *) resume_dev="$KOPT_resume";; - esac - printf "%d:%d" $(stat -Lc "0x%t 0x%T" "$resume_dev") > $ROOT/sys/power/resume - if [ -n "$KOPT_resume_offset" ]; then - echo "$KOPT_resume_offset" > $ROOT/sys/power/resume_offset - fi - else - echo "resume: no hibernation support found" - fi - fi + resume_from_disk if [ "$KOPT_overlaytmpfs" = "yes" ]; then # Create mountpoints @@ -740,13 +787,14 @@ if [ -n "$KOPT_root" ]; then $MOCK mount -o move $DIR $sysroot/$DIR fi done - $MOCK sync exec switch_root $switch_root_opts $sysroot $chart_init "$KOPT_init" $KOPT_init_args echo "initramfs emergency recovery shell launched" exec /bin/busybox sh fi +resume_from_disk + if $do_networking; then repoopts="-n" else @@ -849,7 +897,7 @@ if [ -f "$sysroot/etc/.default_boot_services" -o ! -f "$ovl" ]; then fi if want_tiny_cloud; then - pkgs="$pkgs tiny-cloud-alpine ifupdown-ng doas" + pkgs="$pkgs tiny-cloud ifupdown-ng doas" rc_add tiny-cloud-boot boot rc_add tiny-cloud-early default rc_add tiny-cloud-main default @@ -1032,4 +1080,4 @@ exec switch_root $switch_root_opts $sysroot $chart_init "$KOPT_init" $KOPT_init_ [ "$KOPT_splash" != "no" ] && echo exit > $sysroot/$splashfile echo "initramfs emergency recovery shell launched" exec /bin/busybox sh -reboot \ No newline at end of file +reboot