summaryrefslogtreecommitdiff
path: root/fs-root
blob: a59cb1f318b35ebd83bac2469009955b7e061b4d (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
#!/sbin/sh

set -e
set -u

MOUNTPOINT="/cdrom"
USR='##USR_IMG##'

export PATH=/sbin:/usr/sbin:/usr/bin

# First, remount / read-write to update /dev
mount -o remount / >/dev/msglog 2>&1

# Second, update /dev
devfsadm -C -c disk

# Now, search removable media for $USR
found='no'
for dfile in /dev/removable-media/dsk/*s2; do
    if [ -e "$dfile" ]; then
        echo "Probing \`$dfile' ..." >/dev/msglog
        if mount -F hsfs -o ro "$dfile" "${MOUNTPOINT}" >/dev/msglog 2>&1
        then
            if [ -f "${MOUNTPOINT}/${USR}" ]; then
                found='yes'
                echo "Found ${USR}" >/dev/msglog
                break
            else
                echo "${USR} not found" >/dev/msglog
                umount "${MOUNTPOINT}"
            fi
        else
            echo "Failed to mount \`$dfile'" >/dev/msglog
        fi
    fi
done

if [ "$found" != 'yes' ]; then
    echo "$USR not found" >/dev/msglog
    exit 1
fi


echo "Mounting \`${MOUNTPOINT}/${USR}' on /usr2 ..." >/dev/msglog
mount -F hsfs -o ro -O "${MOUNTPOINT}/${USR}" /usr2 >/dev/msglog 2>&1
echo "Switching /usr to /usr2 ..." >/dev/msglog
rm -f /usr
ln -sf /usr2 /usr

exit 0