From f0738fd218786187375e1efa4215f881dfbb08d6 Mon Sep 17 00:00:00 2001 From: Mo8it Date: Tue, 19 Jul 2022 23:14:13 +0200 Subject: [PATCH] stop container if exists --- .config/fish/config.fish | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.config/fish/config.fish b/.config/fish/config.fish index 9d1d5e8..57d6f1c 100644 --- a/.config/fish/config.fish +++ b/.config/fish/config.fish @@ -3,19 +3,24 @@ set -p PATH "$HOME/.cargo/bin" # Non interactive functions function podman-default-create -w podman + set -l container_name $argv[1] + + if podman container exists $container_name + podman stop $container_name + end + podman create \ - --name $argv[1] \ - --detach \ + --name $container_name \ --pull always \ --label "io.containers.autoupdate=registry" \ $argv[2..] set -l old_pwd (pwd) cd ~/.config/systemd/user - podman generate systemd --new --files --name $argv[1] + podman generate systemd --new --files --name $container_name cd $old_pwd - systemctl --user enable --now container-$argv[1] + systemctl --user enable --now container-$container_name end if status is-interactive