From 379e29c5b7fb38f403116bb196fd1c77f19c0511 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Thu, 17 Oct 2019 16:15:47 +0200 Subject: [PATCH] WIP: Determine the service name to use --- docker/container.backup | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/docker/container.backup b/docker/container.backup index 8ec63cd..a7935b2 100755 --- a/docker/container.backup +++ b/docker/container.backup @@ -19,7 +19,7 @@ DEBUG=0 # Tests {{{ -# Expect at least 1 argument and 3 maximum {{{ +## Expect at least 1 argument and 3 maximum {{{ case $# in 1 ) ct_name="${1}" @@ -81,4 +81,16 @@ fi # }}} +# Get container service name {{{ +ct_service_name=$(find /etc/systemd -type f -iname "*${ct_name}*.service" -printf "%f\n") + +## If no specific systemd service exists, the docker.service will be used +if [ "${ct_service_name}" = "" ]; then + ct_service_name="docker.service" + [ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Service name — No specific service found for ${ct_name} container, the ${ct_service_name} will be stopped." +else + [ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Service name — Service name of the container to backup : ${ct_service_name} ." +fi +# }}} + exit 0