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

36 lines
944 B
Bash
Executable file

#!/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
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
systemctl daemon-reload
systemctl start $service_name
say primary "System service file for $service_name created and started"
else
systemctl --user daemon-reload
systemctl --user start $service_name
say primary "User service file for $service_name created and started"
fi