From c8aeafe1a6d8b4b96cd0664034228a9b94410b00 Mon Sep 17 00:00:00 2001 From: Michael Housh Date: Mon, 21 Apr 2025 14:53:16 -0400 Subject: [PATCH] feat: Updates install script --- docker-restart.sh | 7 +++++++ install.sh | 30 +++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 docker-restart.sh diff --git a/docker-restart.sh b/docker-restart.sh new file mode 100644 index 0000000..ffed85b --- /dev/null +++ b/docker-restart.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Restart all stacks / services located in '/etc/komodo/stacks'. + +stackdir="/etc/komodo/stacks" +find "$stackdir" -maxdepth 1 -mindepth 1 -type d -print0 | + xargs -0 -I {} 'cd {} && docker compose up -d' diff --git a/install.sh b/install.sh index d79bfad..b25e8d0 100644 --- a/install.sh +++ b/install.sh @@ -4,6 +4,25 @@ baseurl="https://git.housh.dev/homelab/backup/raw/branch/main" systemdir="/etc/systemd/system" bindir="/usr/local/bin" +function downloadScripts() { + local scripts=( + "docker-backup" + "docker-restore" + "docker-restart" + ) + + for script in "${scripts[@]}"; do + # set the destination of the script. + local dest="$bindir/$script" + # Remove the file if it exists. + [ -f "$dest" ] && rm -f "$dest" + # download the script to the destination. + wget "$baseurl/$script.sh" -O "$dest" + # make the script executable. + chmod +x "$dest" + done +} + # Remove backup service file if it exists and install the service file. [ -f "$systemdir/backup.service" ] && systemctl stop backup.timer && @@ -15,17 +34,10 @@ wget "$baseurl/backup.service" -O "$systemdir/backup.service" [ ! -f "$systemdir/backup.timer" ] && wget "$baseurl/backup.timer" -O "$systemdir/backup.timer" -# Remove the backup script file if it exists and install the backup script. -[ -f "$bindir/docker-backup" ] && rm -f "$bindir/docker-backup" -wget "$baseurl/docker-backup.sh" -O "$bindir/docker-backup" && - chmod +x "$bindir/docker-backup" - -# Remove the restore script file if it exists and install the restore script. -[ -f "$bindir/docker-restore" ] && rm -f "$bindir/docker-restore" -wget "$baseurl/docker-restore.sh" -O "$bindir/docker-restore" && - chmod +x "$bindir/docker-restore" +downloadScripts # Start services systemctl daemon-reload systemctl start backup.timer systemctl start backup.service +systemctl status backup.service