summaryrefslogtreecommitdiff
path: root/init
diff options
context:
space:
mode:
Diffstat (limited to 'init')
-rw-r--r--init51
1 files changed, 51 insertions, 0 deletions
diff --git a/init b/init
new file mode 100644
index 0000000..ee906d1
--- /dev/null
+++ b/init
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+trap 'kill $dropbear_pid; exec sh' EXIT
+
+case "$PATH" in
+ */*) ;;
+ *) export PATH="/usr/sbin:/usr/bin:/sbin:/bin" ;;
+esac
+
+mount -t proc proc /proc
+mount -t devtmpfs devtmpfs /dev
+mkdir -p /dev/pts
+mount -t devpts devpts /dev/pts
+mount -t sysfs sysfs /sys
+
+(
+ip link set eth0 up
+ip addr add 192.168.0.7/24 dev eth0
+exec dropbear -F -s -p 2222 -K 30
+) &
+dropbear_pid=$!
+
+enc_root=$(findfs UUID=26748575-d7a7-418b-8f68-21be7c937500) || exit
+(
+amixer sset Master on
+amixer sset Master 30%
+aplay -Dhw:0,0 /usr/share/sounds/ding.wav
+) >/dev/null 2>&1 &
+cryptsetup open --tries 65535 --allow-discards "$enc_root" root || [ -e /dev/mapper/root ] || exit
+
+kill $dropbear_pid
+dropbear_pid=
+
+e2fsck -C 0 -E inode_count_fullmap -p /dev/mapper/root
+e2fsck_r=$?
+if [ $(( e2fsck_r & 2 )) = 2 ]; then
+ reboot -f
+fi
+case "$e2fsck_r" in
+ 0|1) ;;
+ *) exit
+esac
+
+mount -o nodev,commit=30 /dev/mapper/root /mnt || exit
+cd /mnt
+umount /dev/pts
+mount --move /dev dev
+mount --move /proc proc
+mount --move /sys sys
+
+exec switch_root /mnt /usr/lib/systemd/systemd