improving
All checks were successful
Check scripts syntax / check-scripts-syntax (push) Successful in 28s
All checks were successful
Check scripts syntax / check-scripts-syntax (push) Successful in 28s
This commit is contained in:
parent
86bd2f0793
commit
72272cacac
@ -18,3 +18,7 @@ This script is used to backup a directory to a remote server using `rsync`. It i
|
|||||||
### `clean.sh`
|
### `clean.sh`
|
||||||
|
|
||||||
This script is used to clean some of the files, docker dangling images, and docker stopped/unused containers.
|
This script is used to clean some of the files, docker dangling images, and docker stopped/unused containers.
|
||||||
|
|
||||||
|
### `docker-updater.sh`
|
||||||
|
|
||||||
|
This script is used to update all the docker containers on the server.
|
@ -53,12 +53,25 @@ fi
|
|||||||
|
|
||||||
for folder in */; do
|
for folder in */; do
|
||||||
cd $folder
|
cd $folder
|
||||||
echo "Updating $folder..."
|
|
||||||
docker-compose down
|
|
||||||
docker-compose pull
|
|
||||||
docker-compose up -d
|
|
||||||
|
|
||||||
echo "Updated $folder!"
|
DOCKER_RUNNING = $(docker-compose ps -q)
|
||||||
|
|
||||||
|
if [ -n "$DOCKER_RUNNING" ]; then
|
||||||
|
echo "[$folder] Stopping Docker containers"
|
||||||
|
docker-compose down
|
||||||
|
else
|
||||||
|
echo "[$folder] No Docker containers running"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[$folder] Updating images"
|
||||||
|
docker-compose pull
|
||||||
|
|
||||||
|
if [ -n "$DOCKER_RUNNING" ]; then
|
||||||
|
echo "[$folder] Starting Docker containers"
|
||||||
|
docker-compose up -d
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[$folder] Updated!"
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
done
|
done
|
||||||
@ -68,4 +81,4 @@ done
|
|||||||
echo "Running Docker image prune..."
|
echo "Running Docker image prune..."
|
||||||
docker image prune -af
|
docker image prune -af
|
||||||
|
|
||||||
echo "Done."
|
echo "Done!"
|
@ -149,7 +149,17 @@ for FILE in "${FILES[@]}"; do
|
|||||||
echo -e "${LIGHT_BLUE}[i] [$FILE] Crontab already exists. Skipping.${NC}"
|
echo -e "${LIGHT_BLUE}[i] [$FILE] Crontab already exists. Skipping.${NC}"
|
||||||
else
|
else
|
||||||
echo -e "${LIGHT_BLUE}[i] [$FILE] Adding crontab...${NC}"
|
echo -e "${LIGHT_BLUE}[i] [$FILE] Adding crontab...${NC}"
|
||||||
|
|
||||||
|
if [ "$FILE" == "clean.sh" ]; then
|
||||||
(crontab -l 2>/dev/null; echo "0 0 * * * ${CURRENT_WORKDIR}/$FILE") | crontab -
|
(crontab -l 2>/dev/null; echo "0 0 * * * ${CURRENT_WORKDIR}/$FILE") | crontab -
|
||||||
|
elif [ "$FILE" == "backup.sh" ]; then
|
||||||
|
(crontab -l 2>/dev/null; echo "0 0 * * * ${CURRENT_WORKDIR}/$FILE") | crontab -
|
||||||
|
elif [ "$FILE" == "docker-updater.sh" ]; then
|
||||||
|
(crontab -l 2>/dev/null; echo "0 3 */4 * * ${CURRENT_WORKDIR}/$FILE") | crontab -
|
||||||
|
else
|
||||||
|
echo -e "${YELLOW}[w] [$FILE] Warning: Crontab specific schedule not setup.${NC}" >&2
|
||||||
|
(crontab -l 2>/dev/null; echo "0 0 * * * ${CURRENT_WORKDIR}/$FILE") | crontab -
|
||||||
|
fi
|
||||||
|
|
||||||
echo -e "${GREEN}[✓] [$FILE] Crontab added, double-checking set up...${NC}"
|
echo -e "${GREEN}[✓] [$FILE] Crontab added, double-checking set up...${NC}"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user