summaryrefslogtreecommitdiff
path: root/fs-root
blob: a7b8eb41f28c135ed44c2659c1a69ad87ec3bc30 (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
52
53
54
55
56
57
58
59
60
61
#!/sbin/sh

set -e
set -u

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

export PATH=/sbin:/usr1/sbin:/usr1/bin
exec >/dev/msglog 2>&1

# First, remount / read-write to update /dev
mount -o remount /

# The sd nodes are not created till you try to access them.
echo "Probing for device nodes ..."
ls -lR /devices/* >/dev/null
devfsadm -C -c disk

echo "Mounting /usr image ..."
# Now, search removable media for $USR
found='no'
for dfile in /dev/removable-media/dsk/*s2; do
    if [ -e "$dfile" ]; then
        if mount -F hsfs -o ro "$dfile" "${MOUNTPOINT}"
        then
            if [ -f "${MOUNTPOINT}/${USR}" ]; then
                found='yes'
                break
            else
                umount "${MOUNTPOINT}"
            fi
        fi
    fi
done

if [ "$found" != 'yes' ]; then
    echo "FATAL: /usr image ($USR) not found"
    exit 1
fi

lofiadm -a "${MOUNTPOINT}/${USR}" >/dev/null &
for n in 1 2 3 4 5 6 7; do
    sleep 1
    devfsadm || true
    if [ -e /dev/lofi/1 ]; then
        break
    fi
done
if [ ! -e /dev/lofi/1 ]; then
    echo "FATAL: Loopback device not created"
    umount /cdrom
    exit 1
fi

mount -F hsfs -o ro /dev/lofi/1 /usr2
rm -f /usr
ln -sf /usr2 /usr

exit 0