diff options
author | Helmut Grohne <helmut@subdivi.de> | 2022-12-28 10:09:06 +0100 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2022-12-28 10:09:06 +0100 |
commit | 1f16c8718bebb1f4a3065599581dad392f6afc94 (patch) | |
tree | 9046fb0fe7ec5c2e84f1b7149fec9996e4d3db20 /9pmounthook | |
parent | 0c50e3b74ec8173d6b0b5f26250a8feee0ceda7b (diff) | |
parent | b666a2909890a7954b103388ec846cac8ce55722 (diff) | |
download | debvm-1f16c8718bebb1f4a3065599581dad392f6afc94.tar.gz |
Merge branch main into branch pod2man
This merge picks up long options and the -s to -z rename.
Diffstat (limited to '9pmounthook')
-rwxr-xr-x | 9pmounthook/customize.sh | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/9pmounthook/customize.sh b/9pmounthook/customize.sh new file mode 100755 index 0000000..67c4240 --- /dev/null +++ b/9pmounthook/customize.sh @@ -0,0 +1,42 @@ +#!/bin/sh +# Copyright 2022 Helmut Grohne <helmut@subdivi.de> +# SPDX-License-Identifier: MIT +# +# This is a mmdebstrap customize hook that adds a systemd-generator that causes +# 9p filesystems to be automatically mounted to /media/$SOMETAG during boot. +# You can enable it by passing the containing directory to --hook-dir. +# In order to add a 9p filesystem to your VM, pass +# -virtfs local,security_model=none,mount_tag=$SOMETAG,path=$SOMEDIR +# Note that the linux-image-cloud-* does not include a 9p driver. + +set -eu +GENERATOR_PATH="$1/etc/systemd/system-generators/9p-generator" +mkdir -p "${GENERATOR_PATH%/*}" +cat >"$GENERATOR_PATH" << 'ENDOFGENERATOR' +#!/bin/sh + +UNITDIR=$1 + +modprobe 9pnet_virtio || exit 0 + +for tagfile in /sys/bus/virtio/devices/*/mount_tag; do + tag=$(cat "$tagfile") || continue + test -z "$tag" && continue + mountpoint="/media/$tag" + mkdir -p "$mountpoint" + unitname="$(systemd-escape -p "$mountpoint").mount" + cat > "$UNITDIR/$unitname" <<ENDOFUNIT +[Unit] +Description=9p mount for tag $tag + +[Mount] +What=$tag +Where=$mountpoint +Type=9p +Options=trans=virtio +ENDOFUNIT + mkdir -p "$UNITDIR/remote-fs.target.wants" + ln -s "../$unitname" "$UNITDIR/remote-fs.target.wants/$unitname" +done +ENDOFGENERATOR +chmod 755 "$GENERATOR_PATH" |