mirror of https://github.com/samply/bridgehead.git
Don't delete docker images if BK is not running
This commit is contained in:
parent
0ff153ef22
commit
380511d3bb
|
@ -73,7 +73,8 @@ case "$ACTION" in
|
||||||
exec $COMPOSE -p bridgehead-$PROJECT -f ./$PROJECT/docker-compose.yml $OVERRIDE down
|
exec $COMPOSE -p bridgehead-$PROJECT -f ./$PROJECT/docker-compose.yml $OVERRIDE down
|
||||||
;;
|
;;
|
||||||
is-running)
|
is-running)
|
||||||
exit bk_is_running
|
bk_is_running
|
||||||
|
exit $?
|
||||||
;;
|
;;
|
||||||
update)
|
update)
|
||||||
loadVars
|
loadVars
|
||||||
|
|
|
@ -170,9 +170,10 @@ function retry {
|
||||||
}
|
}
|
||||||
|
|
||||||
function bk_is_running {
|
function bk_is_running {
|
||||||
|
detectCompose
|
||||||
RUNNING="$($COMPOSE -p bridgehead-$PROJECT -f ./$PROJECT/docker-compose.yml $OVERRIDE ps -q)"
|
RUNNING="$($COMPOSE -p bridgehead-$PROJECT -f ./$PROJECT/docker-compose.yml $OVERRIDE ps -q)"
|
||||||
NUMBEROFRUNNING=$(echo "$RUNNING" | wc -l)
|
NUMBEROFRUNNING=$(echo "$RUNNING" | wc -l)
|
||||||
if [ $NUMBEROFRUNNING -gt 0 ]; then
|
if [ $NUMBEROFRUNNING -ge 2 ]; then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
return 1
|
return 1
|
||||||
|
|
|
@ -4,10 +4,15 @@ source lib/functions.sh
|
||||||
AUTO_HOUSEKEEPING=${AUTO_HOUSEKEEPING:-true}
|
AUTO_HOUSEKEEPING=${AUTO_HOUSEKEEPING:-true}
|
||||||
|
|
||||||
if [ "$AUTO_HOUSEKEEPING" == "true" ]; then
|
if [ "$AUTO_HOUSEKEEPING" == "true" ]; then
|
||||||
A="Performing automatic maintenance: Cleaning docker images."
|
A="Performing automatic maintenance: "
|
||||||
|
if bk_is_running; then
|
||||||
|
A="$A Cleaning docker images."
|
||||||
|
docker system prune -a -f
|
||||||
|
else
|
||||||
|
A="$A Not cleaning docker images since BK is not running."
|
||||||
|
fi
|
||||||
hc_send log "$A"
|
hc_send log "$A"
|
||||||
log INFO "$A"
|
log INFO "$A"
|
||||||
docker system prune -a -f
|
|
||||||
else
|
else
|
||||||
log WARN "Automatic housekeeping disabled (variable AUTO_HOUSEKEEPING != \"true\")"
|
log WARN "Automatic housekeeping disabled (variable AUTO_HOUSEKEEPING != \"true\")"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue