define containerName once
This commit is contained in:
parent
bbbdf38dcc
commit
a26bb36f17
18
.vscode/numbered-bookmarks.json
vendored
18
.vscode/numbered-bookmarks.json
vendored
@ -1,19 +1,3 @@
|
||||
{
|
||||
"bookmarks": [
|
||||
{
|
||||
"fsPath": "$ROOTPATH$/root/scripts/backup.sh",
|
||||
"bookmarks": [
|
||||
-1,
|
||||
478,
|
||||
225,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1
|
||||
]
|
||||
}
|
||||
]
|
||||
"bookmarks": []
|
||||
}
|
@ -225,29 +225,25 @@ function cleanup {
|
||||
|
||||
### operate docker containers
|
||||
function operateDocker {
|
||||
# determine action to take
|
||||
if [ "$1" = "stop" ]; then
|
||||
containerName="$(docker ps --format '{{.Names}}' --filter name=${COMPOSE_PROJECT_NAME}_${2}-mailcow_1)"
|
||||
containerName="$(docker ps --format '{{ .Names }}' --filter name=${COMPOSE_PROJECT_NAME}_${2}-mailcow_1)"
|
||||
|
||||
echo -e "${op}[$(stamp)] Stopping ${2}-mailcow container...${normal}" \
|
||||
>> "$logFile"
|
||||
docker-compose stop --timeout ${dockerStopTimeout} ${2}-mailcow \
|
||||
2>> "$logFile"
|
||||
# verify container stopped (should return true)
|
||||
dockerResultState=$(docker inspect -f '{{ .State.Running }}' \
|
||||
$containerName)
|
||||
# verify clean stop (exit code 0)
|
||||
dockerResultExit=$(docker inspect -f '{{ .State.ExitCode }}' \
|
||||
$containerName)
|
||||
elif [ "$1" = "start" ]; then
|
||||
echo -e "${op}[$(stamp)] Starting ${2}-mailcow container...${normal}" \
|
||||
>> "$logFile"
|
||||
docker-compose start ${2}-mailcow 2>> "$logFile"
|
||||
# verify
|
||||
containerName="$(docker ps --format '{{.Names}}' --filter name=${COMPOSE_PROJECT_NAME}_${2}-mailcow_1)"
|
||||
dockerResultState=$(docker inspect -f '{{ .State.Running }}' \
|
||||
$containerName)
|
||||
fi
|
||||
# determine action to take
|
||||
if [ "$1" = "stop" ]; then
|
||||
echo -e "${op}[$(stamp)] Stopping ${2}-mailcow container...${normal}" \
|
||||
>> "$logFile"
|
||||
docker-compose stop --timeout ${dockerStopTimeout} ${2}-mailcow \
|
||||
2>> "$logFile"
|
||||
# verify container stopped (should return true)
|
||||
dockerResultState="$(docker inspect -f '{{ .State.Running }}' $containerName)"
|
||||
# verify clean stop (exit code 0)
|
||||
dockerResultExit="$(docker inspect -f '{{ .State.ExitCode }}' $containerName)"
|
||||
elif [ "$1" = "start" ]; then
|
||||
echo -e "${op}[$(stamp)] Starting ${2}-mailcow container...${normal}" \
|
||||
>> "$logFile"
|
||||
docker-compose start ${2}-mailcow 2>> "$logFile"
|
||||
# verify
|
||||
dockerResultState="$(docker inspect -f '{{ .State.Running }}' $containerName)"
|
||||
fi
|
||||
}
|
||||
|
||||
### End of Functions ###
|
||||
|
Loading…
Reference in New Issue
Block a user