Last active
July 8, 2023 13:09
-
-
Save dgalli1/8039d91c80493b139ca07015dce1af92 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "Now Updating all Docker Containers" | |
export TZ=UTC # force all timestamps to be in UTC (+00:00 / Z) | |
printf -v start_date_epoch '%(%s)T' | |
printf -v start_date_iso8601 '%(%Y-%m-%dT%H:%M:%S+00:00)T' "$start_date_epoch" | |
# Declare an array of string with type | |
declare -a StringArray=("auth-stack" "bitwarden" "filerun" "languagetool" "media-stack" "monitoring" ) | |
# Iterate the string array using for loop | |
for val in ${StringArray[@]}; do | |
cd /data | |
echo Now Updating $val | |
cd $val | |
docker-compose pull | |
docker-compose up -d | |
done | |
while IFS= read -r -d '' name; do | |
names+=( "$name" ) | |
done < <( | |
docker container ls --format="{{.Names}}" | xargs -n1 docker container inspect | jq -j --arg start_date "$start_date_iso8601" '.[] | select(.State.StartedAt > $start_date) | (.Name, "\u0000")' | |
) | |
echo "now Updating the system" | |
apt update | |
apt upgrade | |
echo "Updated those containers:" | |
for containername in ${names[@]}; do | |
#if string does not contain matrix | |
if [[ $containername != *"matrix"* ]]; then | |
echo $containername | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment