#!/bin/bash ### Test for root if [ "$EUID" -ne 0 ]; then echo "Must run this script as root." exit 1 fi ### Test for rclone executable and install if not found RCLONE_BIN="/usr/bin/rclone" if [ -f "$RCLONE_BIN" ]; then echo "rclone installed already" else echo "rclone not installed, installing" curl https://rclone.org/install.sh | bash fi ### Grab the files from repo and distribute them to the filesystem mkdir -p /tmp/rclone && cd /tmp/rclone git clone https://git.codetical.com/Codetical/rclone-config.git mv -f /tmp/rclone/rclone-config/etc/rclone.conf /etc/ rm /etc/systemd/system/rclone@.conf mv /tmp/rclone/rclone-config/etc/systemd/system/rclone@.conf /etc/systemd/system/ rm -Rf /etc/rclone mv /tmp/rclone/rclone-config/etc/rclone /etc/ chown root:root /etc/rclone.conf chown root:root -R /etc/rclone chown root:root /etc/systemd/system/rclone@.conf rm -Rf /tmp/rclone systemctl daemon-reload ### Check for services SERVICES=( "rclone@gdBackups.service" "rclone@gdBooks.service" "rclone@gdExternal.service" "rclone@gdInternal.service" "rclone@gdMedia.service" "rclone@gdMediaExtra.service" "rclone@gdProjects.service" "rclone@gdVault.service" ) # Loop through each service in the list for SERVICE in "${SERVICES[@]}"; do # Check if the service exists if systemctl list-unit-files "$SERVICE" &>/dev/null; then echo "Found: '$SERVICE'. Stopping and disabling..." systemctl disable --now "$SERVICE" echo "Found: '$SERVICE'. re-creating and starting..." systemctl enable --now "$SERVICE" else echo "Skipped: '$SERVICE' does not exist on this system." fi done