sh.zio.pod-systemd: add script
parent
286322b3e6
commit
966d996fb3
|
@ -46,6 +46,7 @@
|
|||
!/usr/local/bin/sh.zio.backup
|
||||
!/usr/local/bin/sh.zio.install-package
|
||||
!/usr/local/bin/sh.zio.pod-exec
|
||||
!/usr/local/bin/sh.zio.pod-systemd
|
||||
!/usr/local/bin/sh.zio.update-rootfs
|
||||
!/usr/local/bin/zio-backup
|
||||
!/usr/local/bin/zio-libvirt-port-forward
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if [[ "$(realpath "$(dirname "$(realpath -s "$0")")/../../../")" == "/" ]]; then
|
||||
. /usr/local/libexec/zio/helpers/bash.sh
|
||||
else
|
||||
. "$(dirname "$(realpath -s "$0")")/../libexec/zio/helpers/bash.sh"
|
||||
fi
|
||||
|
||||
service_name="$1"
|
||||
|
||||
say info "Creating systemd service for $service_name"
|
||||
if [[ $(id -u) = 0 ]]; then
|
||||
podman generate systemd -n --new $service_name > "/etc/systemd/system/container-$service_name.service"
|
||||
systemctl daemon-reload
|
||||
systemctl enable --now container-$service_name
|
||||
say primary "System service file for $service_name created, enabled and started"
|
||||
else
|
||||
podman generate systemd -n --new $service_name > "$HOME/.local/share/systemd/container-$service_name.service"
|
||||
systemctl --user daemon-reload
|
||||
systemctl enable --user --now container-$service_name
|
||||
say primary "User service file for $service_name created, enabled and started"
|
||||
fi
|
Loading…
Reference in New Issue