mirror of
https://github.com/kairos-io/kcrypt.git
synced 2025-08-10 20:01:37 +00:00
Conditionals bring still deps in systemd
Generate instead of enabling both services
This commit is contained in:
parent
d496900927
commit
c9680590bf
40
dracut/29kcrypt/generator.sh
Executable file
40
dracut/29kcrypt/generator.sh
Executable file
@ -0,0 +1,40 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||||
|
|
||||||
|
GENERATOR_DIR="$2"
|
||||||
|
|
||||||
|
[ -z "$GENERATOR_DIR" ] && exit 1
|
||||||
|
[ -d "$GENERATOR_DIR" ] || mkdir "$GENERATOR_DIR"
|
||||||
|
|
||||||
|
if getargbool 0 rd.neednet; then
|
||||||
|
{
|
||||||
|
echo "[Unit]"
|
||||||
|
echo "DefaultDependencies=no"
|
||||||
|
echo "Description=kcrypt online mount"
|
||||||
|
echo "Before=cos-immutable-rootfs.service"
|
||||||
|
echo "After=network-online.target"
|
||||||
|
echo "Wants=network-online.target"
|
||||||
|
echo "[Service]"
|
||||||
|
echo "Type=oneshot"
|
||||||
|
echo "RemainAfterExit=no"
|
||||||
|
echo "ExecStart=/sbin/kcrypt-mount-local"
|
||||||
|
} > "$GENERATOR_DIR"/kcrypt.service
|
||||||
|
else
|
||||||
|
{
|
||||||
|
echo "[Unit]"
|
||||||
|
echo "DefaultDependencies=no"
|
||||||
|
echo "Description=kcrypt mount"
|
||||||
|
echo "Before=cos-immutable-rootfs.service"
|
||||||
|
echo "[Service]"
|
||||||
|
echo "Type=oneshot"
|
||||||
|
echo "RemainAfterExit=no"
|
||||||
|
echo "ExecStart=/sbin/kcrypt-mount-local"
|
||||||
|
} > "$GENERATOR_DIR"/kcrypt.service
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -e "$GENERATOR_DIR/initrd-fs.target.requires/kcrypt.service" ]; then
|
||||||
|
mkdir -p "$GENERATOR_DIR"/initrd-fs.target.requires
|
||||||
|
ln -s "$GENERATOR_DIR"/kcrypt.service \
|
||||||
|
"$GENERATOR_DIR"/initrd-fs.target.requires/kcrypt.service
|
||||||
|
fi
|
@ -1,12 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=kcrypt online mount
|
|
||||||
DefaultDependencies=no
|
|
||||||
Before=cos-immutable-rootfs.service
|
|
||||||
After=network-online.target
|
|
||||||
Wants=network-online.target
|
|
||||||
ConditionKernelCommandLine=rd.neednet=1
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=oneshot
|
|
||||||
RemainAfterExit=no
|
|
||||||
ExecStart=/sbin/kcrypt-mount-local
|
|
@ -1,10 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=kcrypt mount
|
|
||||||
DefaultDependencies=no
|
|
||||||
Before=cos-immutable-rootfs.service
|
|
||||||
ConditionKernelCommandLine=!rd.neednet=1
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=oneshot
|
|
||||||
RemainAfterExit=no
|
|
||||||
ExecStart=/sbin/kcrypt-mount-local
|
|
@ -29,16 +29,8 @@ install() {
|
|||||||
kcrypt
|
kcrypt
|
||||||
inst_script "${moddir}/mount-local.sh" "/sbin/kcrypt-mount-local"
|
inst_script "${moddir}/mount-local.sh" "/sbin/kcrypt-mount-local"
|
||||||
#inst_hook pre-trigger 10 "$moddir/mount-local.sh"
|
#inst_hook pre-trigger 10 "$moddir/mount-local.sh"
|
||||||
inst_simple "${moddir}/kcrypt.service" \
|
inst_script "${moddir}/generator.sh" \
|
||||||
"${systemdsystemunitdir}/kcrypt.service"
|
"${systemdutildir}/system-generators/dracut-kcrypt-generator"
|
||||||
|
|
||||||
inst_simple "${moddir}/kcrypt-online.service" \
|
|
||||||
"${systemdsystemunitdir}/kcrypt-online.service"
|
|
||||||
|
|
||||||
mkdir -p "${initdir}/${systemdsystemunitdir}/initrd-fs.target.requires"
|
|
||||||
ln_r "../kcrypt.service" \
|
|
||||||
"${systemdsystemunitdir}/initrd-fs.target.requires/kcrypt.service"
|
|
||||||
ln_r "../kcrypt-online.service" \
|
|
||||||
"${systemdsystemunitdir}/initrd-fs.target.requires/kcrypt-online.service"
|
|
||||||
dracut_need_initqueue
|
dracut_need_initqueue
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user