Add down, up, start, stop

This commit is contained in:
Alex Hyett 2024-09-13 14:30:24 +01:00
parent a563249f10
commit 11e5b41784
5 changed files with 77 additions and 1 deletions

View file

@ -12,3 +12,7 @@ A collection of useful scripts that I use everyday.
- `copyfiles.sh` - Same as the above but it copies instead of moves the files. [Notes](https://www.alexhyett.com/notes/moving-files-with-rsync/)
- `slackit.sh` - I use this to easily send slack notifications to myself from inside other scripts. [Notes](https://www.alexhyett.com/notes/send-slack-messages-with-a-command/)
- `sort_photos.py` - This file moves photos in my camera uploads folder into my main photos folder based on the date the photo was taken. [Notes](https://www.alexhyett.com/notes/sorting-photos-into-folders/)
- `down.sh` - Runs `docker-compose down` on in all the nested folders under `directory` [Notes](https://www.alexhyett.com/notes/docker-scripts-for-nested-folders/)
- `up.sh` - Runs `docker-compose up -d` on in all the nested folders under `directory` [Notes](https://www.alexhyett.com/notes/docker-scripts-for-nested-folders/)
- `stop.sh` - Runs `docker-compose stop` on in all the nested folders under `directory` [Notes](https://www.alexhyett.com/notes/docker-scripts-for-nested-folders/)
- `start.sh` - Runs `docker-compose start` on in all the nested folders under `directory` [Notes](https://www.alexhyett.com/notes/docker-scripts-for-nested-folders/)

18
down.sh Executable file
View file

@ -0,0 +1,18 @@
#!/bin/bash
# Directory containing docker-compose files
directory="/media/data/jarvis/docker"
# Loop through each subfolder
for subfolder in "$directory"/*; do
if [ -d "$subfolder" ]; then
cd "$subfolder" || exit
# Check if docker-compose.yml or docker-compose.yaml file exists
if [ -e "docker-compose.yml" ] || [ -e "docker-compose.yaml" ]; then
echo "Downing containers in $subfolder"
docker-compose down
else
echo "No docker-compose file found in $subfolder"
fi
fi
done

18
start.sh Executable file
View file

@ -0,0 +1,18 @@
#!/bin/bash
# Directory containing docker-compose files
directory="/media/data/jarvis/docker"
# Loop through each subfolder
for subfolder in "$directory"/*; do
if [ -d "$subfolder" ]; then
cd "$subfolder" || exit
# Check if docker-compose.yml or docker-compose.yaml file exists
if [ -e "docker-compose.yml" ] || [ -e "docker-compose.yaml" ]; then
echo "Starting containers in $subfolder"
docker-compose start
else
echo "No docker-compose file found in $subfolder"
fi
fi
done

18
stop.sh Executable file
View file

@ -0,0 +1,18 @@
#!/bin/bash
# Directory containing docker-compose files
directory="/media/data/jarvis/docker"
# Loop through each subfolder
for subfolder in "$directory"/*; do
if [ -d "$subfolder" ]; then
cd "$subfolder" || exit
# Check if docker-compose.yml or docker-compose.yaml file exists
if [ -e "docker-compose.yml" ] || [ -e "docker-compose.yaml" ]; then
echo "Stopping containers in $subfolder"
docker-compose stop
else
echo "No docker-compose file found in $subfolder"
fi
fi
done

18
up.sh Executable file
View file

@ -0,0 +1,18 @@
#!/bin/bash
# Directory containing docker-compose files
directory="/media/data/jarvis/docker"
# Loop through each subfolder
for subfolder in "$directory"/*; do
if [ -d "$subfolder" ]; then
cd "$subfolder" || exit
# Check if docker-compose.yml or docker-compose.yaml file exists
if [ -e "docker-compose.yml" ] || [ -e "docker-compose.yaml" ]; then
echo "Upping containers in $subfolder"
docker-compose up -d
else
echo "No docker-compose file found in $subfolder"
fi
fi
done