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": [
|
"bookmarks": []
|
||||||
{
|
|
||||||
"fsPath": "$ROOTPATH$/root/scripts/backup.sh",
|
|
||||||
"bookmarks": [
|
|
||||||
-1,
|
|
||||||
478,
|
|
||||||
225,
|
|
||||||
-1,
|
|
||||||
-1,
|
|
||||||
-1,
|
|
||||||
-1,
|
|
||||||
-1,
|
|
||||||
-1,
|
|
||||||
-1
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
@ -225,28 +225,24 @@ function cleanup {
|
|||||||
|
|
||||||
### operate docker containers
|
### operate docker containers
|
||||||
function operateDocker {
|
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)"
|
||||||
|
|
||||||
|
# determine action to take
|
||||||
|
if [ "$1" = "stop" ]; then
|
||||||
echo -e "${op}[$(stamp)] Stopping ${2}-mailcow container...${normal}" \
|
echo -e "${op}[$(stamp)] Stopping ${2}-mailcow container...${normal}" \
|
||||||
>> "$logFile"
|
>> "$logFile"
|
||||||
docker-compose stop --timeout ${dockerStopTimeout} ${2}-mailcow \
|
docker-compose stop --timeout ${dockerStopTimeout} ${2}-mailcow \
|
||||||
2>> "$logFile"
|
2>> "$logFile"
|
||||||
# verify container stopped (should return true)
|
# verify container stopped (should return true)
|
||||||
dockerResultState=$(docker inspect -f '{{ .State.Running }}' \
|
dockerResultState="$(docker inspect -f '{{ .State.Running }}' $containerName)"
|
||||||
$containerName)
|
|
||||||
# verify clean stop (exit code 0)
|
# verify clean stop (exit code 0)
|
||||||
dockerResultExit=$(docker inspect -f '{{ .State.ExitCode }}' \
|
dockerResultExit="$(docker inspect -f '{{ .State.ExitCode }}' $containerName)"
|
||||||
$containerName)
|
|
||||||
elif [ "$1" = "start" ]; then
|
elif [ "$1" = "start" ]; then
|
||||||
echo -e "${op}[$(stamp)] Starting ${2}-mailcow container...${normal}" \
|
echo -e "${op}[$(stamp)] Starting ${2}-mailcow container...${normal}" \
|
||||||
>> "$logFile"
|
>> "$logFile"
|
||||||
docker-compose start ${2}-mailcow 2>> "$logFile"
|
docker-compose start ${2}-mailcow 2>> "$logFile"
|
||||||
# verify
|
# verify
|
||||||
containerName="$(docker ps --format '{{.Names}}' --filter name=${COMPOSE_PROJECT_NAME}_${2}-mailcow_1)"
|
dockerResultState="$(docker inspect -f '{{ .State.Running }}' $containerName)"
|
||||||
dockerResultState=$(docker inspect -f '{{ .State.Running }}' \
|
|
||||||
$containerName)
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user