From 22530be0f5ca516f95746c3be6b4d12aea4f06e2 Mon Sep 17 00:00:00 2001 From: astravexton Date: Mon, 7 Jul 2025 18:02:18 +0100 Subject: [PATCH] sh.zio.pod-systemd: update to use podlet --- usr/local/bin/sh.zio.pod-systemd | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/usr/local/bin/sh.zio.pod-systemd b/usr/local/bin/sh.zio.pod-systemd index 49fb03a..8d55465 100755 --- a/usr/local/bin/sh.zio.pod-systemd +++ b/usr/local/bin/sh.zio.pod-systemd @@ -6,17 +6,31 @@ else . "$(dirname "$(realpath -s "$0")")/../libexec/zio/helpers/bash.sh" fi +test_prog "podlet" +test_prog "podman" + service_name="$1" +command_args="${@:2}" + +if [[ -z $service_name ]]; then + say warning "No service name given, exiting" + exit +fi + +if [[ -z $command_args ]]; then + say warning "No command args given, exiting" + exit +fi say info "Creating systemd service for $service_name" + +podlet -u -i -d \"$service_name container\" podman run $command_args 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" + systemctl start $service_name + say primary "System service file for $service_name created and started" else - podman generate systemd -n --new $service_name > "$HOME/.config/systemd/user/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" + systemctl --user start $service_name + say primary "User service file for $service_name created and started" fi