summaryrefslogtreecommitdiff
path: root/init
blob: ee906d1f2e6f6fb59f19815cef910af3f203e592 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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