2
0
Fork 0
rootfs/usr/local/bin/sh.zio.pod-systemd

23 lines
898 B
Plaintext
Raw Normal View History

2023-09-04 18:12:11 +02:00
#!/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/.config/systemd/user/container-$service_name.service"
2023-09-04 18:12:11 +02:00
systemctl --user daemon-reload
systemctl enable --user --now container-$service_name
say primary "User service file for $service_name created, enabled and started"
fi