Skip to content

Instantly share code, notes, and snippets.

@jwatson3d
jwatson3d / docker-compose-update.sh
Created December 24, 2024 16:38 — forked from dgalli1/.sh
Simple update script for docker compose
#!/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"
# List of all folders that contain a docker compose
declare -a StringArray=("auth-stack" "bitwarden" "languagetool" "media-stack" "monitoring" "" "mosquitto" "portainer" "dnsmasq" "socks5" "nginx-proxy-manager" "filebrowser")
# Iterate the string array using for loop
aws ec2 describe-images --owners 136693071363 --filters 'Name=root-device-type,Values=ebs' 'Name=architecture,Values=x86_64' 'Name=name,Values=debian-11-amd64-20**' | jq -r '[ .Images[] | {ImageId,CreationDate} ] | sort_by(.CreationDate) | reverse | first | .ImageId'
vim /usr/bin/cloud-init
less /var/log/cloud-init.log
curl -s 169.254.169.254/1.0/meta-data/instance-id
curl -s 169.254.169.254/1.0/meta-data/public-ipv4
S3_USERID=$(aws s3api list-buckets --query Owner.ID --output text)
aws ce get-cost-and-usage --time-period Start=2022-12-01,End=2022-12-31 --granularity MONTHLY --metrics UsageQuantity --group-by Type=DIMENSION,Key=SERVICE | jq '.ResultsByTime[].Groups[] | select(.Metrics.UsageQuantity.Amount > 0) | .Keys[0]'
terraform show tfplan.out | jq >tfplan.json
jq '.terraform_version, .format_version' tfplan.json
find . -d -type d -name '.terraform' -exec rm -r {} \;
find . -d -type f -name '.terraform*' -exec rm -r {} \;
find . -d -type f -name '*tfstate*' -exec rm -r {} \;
find . -d -type f -name 'tfplan.out' -exec rm -r {} \;
# Verify distro
cat /etc/os-release
# Amazon Linux 2
sudo amazon-linux-extras install epel -y
# RHEL 8
sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y
# RHEL 7