Jose Henrique
e4108b8305
All checks were successful
Check scripts syntax / check-scripts-syntax (push) Successful in 3s
63 lines
1.4 KiB
Bash
63 lines
1.4 KiB
Bash
#!/bin/bash
|
|
|
|
NC='\033[0m'
|
|
LIGHT_BLUE='\033[1;34m'
|
|
LIGHT_GREEN='\033[1;32m'
|
|
LIGHT_GREY='\033[0;37m'
|
|
|
|
### AUTO-UPDATER ###
|
|
export FILE_NAME="docker-updater.sh"
|
|
SERVER_AU="https://git.ivanch.me/ivanch/server-scripts/raw/branch/main/auto-updater.sh"
|
|
|
|
# Run auto-updater script
|
|
UPDATER=$(curl -sSL $SERVER_AU | bash)
|
|
|
|
if [ $? -eq 2 ]; then
|
|
exit 0
|
|
fi
|
|
|
|
####################
|
|
|
|
# Navigate to docker folder
|
|
DOCKER_FOLDER=/root/docker
|
|
|
|
if [ -d "$DOCKER_FOLDER" ]; then
|
|
cd $DOCKER_FOLDER
|
|
else
|
|
echo -e "${LIGHT_GREY}[i] Docker folder not found.${NC}"
|
|
exit 1
|
|
fi
|
|
|
|
# Navigate on each folder and run docker-compose stop, pull and up -d
|
|
|
|
for folder in */; do
|
|
cd $folder
|
|
|
|
DOCKER_RUNNING=$(docker-compose ps -q)
|
|
|
|
if [ -n "$DOCKER_RUNNING" ]; then
|
|
echo -e "${LIGHT_BLUE}[$folder] Stopping Docker containers"
|
|
docker-compose down > /dev/null
|
|
else
|
|
echo -e "${LIGHT_BLUE}[$folder] No Docker containers running"
|
|
fi
|
|
|
|
echo -e "${LIGHT_BLUE}[$folder] Updating images"
|
|
docker-compose pull > /dev/null
|
|
|
|
if [ -n "$DOCKER_RUNNING" ]; then
|
|
echo -e "${LIGHT_BLUE}[$folder] Starting Docker containers"
|
|
docker-compose up -d > /dev/null
|
|
fi
|
|
|
|
echo -e "${LIGHT_GREEN}[$folder] Updated!"
|
|
|
|
cd ..
|
|
done
|
|
|
|
# Run Docker image prune
|
|
|
|
echo -e "${LIGHT_BLUE}Running Docker image prune..."
|
|
docker image prune -af
|
|
|
|
echo -e "${LIGHT_GREEN} All done!" |