blob: 38603bf8189260680befea3095b2f65fcdf133ed (
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
62
63
64
|
#!/bin/sh
type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
[ -z "$root" ] && root=$(getarg root=)
[ "${root%%:*}" = "nbd" ] || exit 0
GENERATOR_DIR="$2"
[ -z "$GENERATOR_DIR" ] && exit 1
[ -d "$GENERATOR_DIR" ] || mkdir -p "$GENERATOR_DIR"
ROOTFLAGS="$(getarg rootflags)"
nroot=${root#nbd:}
nbdserver=${nroot%%:*}
if [ "${nbdserver%"${nbdserver#?}"}" = "[" ]; then
nbdserver=${nroot#[}
nbdserver=${nbdserver%%]:*}\]
nroot=${nroot#*]:}
else
nroot=${nroot#*:}
fi
nbdport=${nroot%%:*}
nroot=${nroot#*:}
nbdfstype=${nroot%%:*}
nroot=${nroot#*:}
nbdflags=${nroot%%:*}
if [ "$nbdflags" = "$nbdfstype" ]; then
unset nbdflags
fi
if [ "$nbdfstype" = "$nbdport" ]; then
unset nbdfstype
fi
[ -n "$nbdflags" ] && ROOTFLAGS="$nbdflags"
if getarg "ro"; then
if [ -n "$ROOTFLAGS" ]; then
ROOTFLAGS="$ROOTFLAGS,ro"
else
ROOTFLAGS="ro"
fi
fi
if [ -n "$nbdfstype" ]; then
ROOTFSTYPE="$nbdfstype"
else
ROOTFSTYPE=$(getarg rootfstype=) || unset ROOTFSTYPE
fi
{
echo "[Unit]"
echo "Before=initrd-root-fs.target"
echo "[Mount]"
echo "Where=/sysroot"
echo "What=/dev/root"
[ -n "$ROOTFSTYPE" ] && echo "Type=${ROOTFSTYPE}"
[ -n "$ROOTFLAGS" ] && echo "Options=${ROOTFLAGS}"
} > "$GENERATOR_DIR"/sysroot.mount
exit 0
|