blob: cb45f7b5ffc98ae354a19dfd6f35d594c60efacb [file] [log] [blame]
Jan Kundrát567058d2018-11-08 19:15:56 +01001#!/bin/sh
2
3echo "Preparing /etc overlay"
4/bin/mount -t tmpfs tmpfs /.ov -o mode=0700
5/bin/mkdir /.ov/etc-u
6/bin/mkdir /.ov/etc-w
7/bin/mount overlay -t overlay /etc -olowerdir=/etc,upperdir=/.ov/etc-u,workdir=/.ov/etc-w
8
9/bin/mount -t proc proc /proc -o rw,nosuid,nodev,noexec,relatime
10if grep -q rauc.slot=A /proc/cmdline; then
11 RAUC_SLOT_NO=0
12 RAUC_SLOT_NAME=A
13elif grep -q rauc.slot=B /proc/cmdline; then
14 RAUC_SLOT_NO=1
15 RAUC_SLOT_NAME=B
16else
17 echo "Cannot determine active RAUC rootfs slot"
18 #exit 1
19fi
20/bin/umount /proc
21echo "RAUC: active slot ${RAUC_SLOT_NAME}"
22
23# sed magic:
24# 1) use `sed -n` so that we only print what's explicitly printed
25# 2) anchor the search between the "[slot.cfg.$RAUC_SLOT_NO]" and any other section
26# 3) look for a line beginning with "device="
27# 4) take stuff which is behind the "="
28# 5) print it
29DEVICE=$(sed -n "/\[slot\.cfg\.${RAUC_SLOT_NO}\]/,/\[.*\]/{/^device=/s/\(.*\)=\(.*\)/\\2/p}" /etc/rauc/system.conf)
30
31if [ x$DEVICE = x ]; then
32 echo "Cannot determine device for /cfg from RAUC"
33 #exit 1
34fi
35
36if [ ! -b $DEVICE ]; then
37 echo "Device ${DEVICE} is not a block device"
38 #exit 1
39fi
40
41echo "Mounting /cfg"
42/bin/mount ${DEVICE} /cfg -t auto -o relatime,nosuid,nodev
43
44if [ -d /cfg/etc ]; then
45 echo "Restoring /etc from /cfg"
46 /bin/cp -a /cfg/etc/* /etc/
47fi
48
Jan Kundrát6b05a1d2019-03-06 17:01:28 +010049if [ -f /cfg/random-seed/random-seed ]; then
50 cat /cfg/random-seed/random-seed | /sbin/czechlight-random-seed
51fi
52
Jan Kundrát567058d2018-11-08 19:15:56 +010053exec /sbin/init