| 1 |
#!/bin/bash -x |
| 2 |
|
| 3 |
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh |
| 4 |
type getOverlayBaseDirectory >/dev/null 2>&1 || . /lib/kiwi-live-lib.sh |
| 5 |
|
| 6 |
[ -z "${root}" ] && root=$(getarg root=) |
| 7 |
|
| 8 |
if [ "${root%%:*}" = "live" ] ; then |
| 9 |
liveroot="${root}" |
| 10 |
fi |
| 11 |
|
| 12 |
[ "${liveroot%%:*}" = "live" ] || exit 0 |
| 13 |
|
| 14 |
case "${liveroot}" in |
| 15 |
live:CDLABEL=*|CDLABEL=*) \ |
| 16 |
root="${root#live:}" |
| 17 |
root="${root//\//\\x2f}" |
| 18 |
root="live:/dev/disk/by-label/${root#CDLABEL=}" |
| 19 |
rootok=1 ;; |
| 20 |
live:AOEINTERFACE=*|AOEINTERFACE=*) \ |
| 21 |
root="${root#live:}" |
| 22 |
root="${root//\//\\x2f}" |
| 23 |
root="live:aoe:/dev/etherd/${root#AOEINTERFACE=}" |
| 24 |
rootok=1 ;; |
| 25 |
live:ftp:*|live:http:*|live:https:*|live:dolly:*) \ |
| 26 |
root="${root#live:}" |
| 27 |
root="live:net:${root}" |
| 28 |
rootok=1 ;; |
| 29 |
esac |
| 30 |
|
| 31 |
[ "${rootok}" != "1" ] && exit 0 |
| 32 |
|
| 33 |
GENERATOR_DIR="$2" |
| 34 |
[ -z "$GENERATOR_DIR" ] && exit 1 |
| 35 |
[ -d "$GENERATOR_DIR" ] || mkdir "$GENERATOR_DIR" |
| 36 |
|
| 37 |
OVERLAY_BASE="$(getOverlayBaseDirectory)" |
| 38 |
ROOTFLAGS="$(getarg rootflags)" |
| 39 |
{ |
| 40 |
echo "[Unit]" |
| 41 |
echo "Before=initrd-root-fs.target" |
| 42 |
echo "DefaultDependencies=no" |
| 43 |
echo "[Mount]" |
| 44 |
echo "Where=/sysroot" |
| 45 |
echo "What=LiveOS_rootfs" |
| 46 |
echo "Options=${ROOTFLAGS},lowerdir=${OVERLAY_BASE}/rootfsbase,upperdir=${OVERLAY_BASE}/overlayfs/rw,workdir=${OVERLAY_BASE}/overlayfs/work" |
| 47 |
echo "Type=overlay" |
| 48 |
_dev=LiveOS_rootfs |
| 49 |
} > "$GENERATOR_DIR"/sysroot.mount |
| 50 |
|
| 51 |
if [ ! -e "$GENERATOR_DIR/initrd-root-fs.target.requires/sysroot.mount" ]; then |
| 52 |
mkdir -p "$GENERATOR_DIR"/initrd-root-fs.target.requires |
| 53 |
ln -s "$GENERATOR_DIR"/sysroot.mount \ |
| 54 |
"$GENERATOR_DIR"/initrd-root-fs.target.requires/sysroot.mount |
| 55 |
fi |
| 56 |
|
| 57 |
mkdir -p "$GENERATOR_DIR/$_dev.device.d" |
| 58 |
{ |
| 59 |
echo "[Unit]" |
| 60 |
echo "JobTimeoutSec=3000" |
| 61 |
} > "$GENERATOR_DIR/$_dev.device.d/timeout.conf" |