diff --git a/crontab b/crontab new file mode 100644 index 0000000..b6b775b --- /dev/null +++ b/crontab @@ -0,0 +1,6 @@ +# SnapRAID +30 4 * * 0 python3 /opt/snapraid-runner/snapraid-runner.py --conf /etc/snapraid-runner.conf --ignore-deletethreshold +# LG TV renew dev mode (https://github.com/webosbrew/dev-manager-desktop) +0 * * * * /etc/tv-renew-devmode.sh >> /var/log/tv-renew-devmode.log 2>&1 +# DNS issues fix with Torguard +0 5 * * * /apps/homeserver/docker/torguard-fix.sh diff --git a/docker/mgmt.sh b/docker/mgmt.sh index a800544..5841599 100755 --- a/docker/mgmt.sh +++ b/docker/mgmt.sh @@ -1,27 +1,50 @@ #!/bin/bash -if [ $# -ne 1 ]; then - echo "Please provide command to execute: 'up', 'stop' or 'restart'" +BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +if [ $# -lt 1 ]; then + echo "Please provide command to execute: 'up', 'stop', 'restart', or 'recreate'" exit 1 fi command="$1" -for stack in stacks/*/* -do - case "$command" in - "up") - docker-compose -f "${stack}" --env-file .env up -d - ;; - "stop") - docker-compose -f "${stack}" --env-file .env stop - ;; - "restart") - docker-compose -f "${stack}" --env-file .env restart - ;; - *) - echo "Wrong command. Please use 'up', 'stop' or 'restart'" +case "$command" in + "up") + for stack in "$BASE_DIR"/stacks/*/* + do + docker-compose -f "${stack}" --env-file "$BASE_DIR/.env" up -d + done + ;; + "stop" | "restart") + for stack in "$BASE_DIR"/stacks/*/* + do + docker-compose -f "${stack}" --env-file "$BASE_DIR/.env" $command + done + ;; + "recreate") + if [ $# -lt 3 ]; then + echo "Please provide both the stack name and the service to recreate" + echo "Usage: $0 recreate " exit 1 - ;; - esac -done + fi + + stack_name="$2" + service="$3" + stack_file="$BASE_DIR/stacks/${stack_name}/${stack_name}.yml" + + if [ ! -f "$stack_file" ]; then + echo "Stack file '$stack_file' does not exist" + exit 1 + fi + + docker-compose -f "${stack_file}" --env-file "$BASE_DIR/.env" stop "$service" + docker-compose -f "${stack_file}" --env-file "$BASE_DIR/.env" rm -f "$service" + docker-compose -f "${stack_file}" --env-file "$BASE_DIR/.env" up -d "$service" + ;; + *) + echo "Wrong command. Please use 'up', 'stop', 'restart', or 'recreate'" + exit 1 + ;; +esac + diff --git a/docker/torguard-fix.sh b/docker/torguard-fix.sh new file mode 100755 index 0000000..eda0520 --- /dev/null +++ b/docker/torguard-fix.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +dir="/apps/homeserver/docker/appdata/gluetun/wireguard" +file="$dir/wg0.conf" +file_old="$dir/wg0.conf.old" +file_tmp="$dir/wg0.conf.tmp" + +mv $file $file_tmp +mv $file_old $file +mv $file_tmp $file_old + +bash /apps/homeserver/docker/mgmt.sh recreate media qbittorrentvpn