2021-08-26 10:47:07 +00:00
|
|
|
#!/bin/sh
|
|
|
|
CONTAINER=rclone
|
2023-02-22 16:49:54 +00:00
|
|
|
# Get DataDir location
|
|
|
|
DATA_DIR="/data"
|
|
|
|
case "$(ubnt-device-info firmware || true)" in
|
|
|
|
1*)
|
|
|
|
DATA_DIR="/mnt/data"
|
|
|
|
;;
|
|
|
|
2*)
|
|
|
|
DATA_DIR="/data"
|
|
|
|
;;
|
|
|
|
3*)
|
|
|
|
DATA_DIR="/data"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "ERROR: No persistent storage found." 1>&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Check if the directory exists
|
|
|
|
if [ ! -d "${DATA_DIR}/backups" ]; then
|
|
|
|
# If it does not exist, create the directory
|
|
|
|
mkdir -p "${DATA_DIR}/backups"
|
|
|
|
echo "Directory '${DATA_DIR}/backups' created."
|
|
|
|
else
|
|
|
|
# If it already exists, print a message
|
|
|
|
echo "Directory '${DATA_DIR}/backups' already exists. Moving on."
|
|
|
|
fi
|
2021-08-26 10:47:07 +00:00
|
|
|
|
|
|
|
if podman container exists "$CONTAINER"; then
|
|
|
|
podman start "$CONTAINER"
|
|
|
|
else
|
|
|
|
podman run -i -d --rm \
|
|
|
|
--net=host \
|
2023-02-22 16:49:54 +00:00
|
|
|
-v ${DATA_DIR}/rclone:${DATA_DIR}/backups/rclone \
|
|
|
|
-v ${DATA_DIR}/pihole:${DATA_DIR}/backups/pihole \
|
|
|
|
-v ${DATA_DIR}/on_boot.d:${DATA_DIR}/backups/on_boot.d \
|
|
|
|
-v ${DATA_DIR}/unifi/data/backup/autobackup:${DATA_DIR}/backup/unifi/autobackup \
|
|
|
|
-v ${DATA_DIR}/podman/cni:${DATA_DIR}/backups/podman/cni \
|
|
|
|
-v ${DATA_DIR}/rclone:/config/rclone \
|
|
|
|
-v ${DATA_DIR}/rclone/sync.sh:${DATA_DIR}/sync.sh \
|
2021-08-26 10:47:07 +00:00
|
|
|
--name "$CONTAINER" \
|
|
|
|
--security-opt=no-new-privileges \
|
|
|
|
rclone/rclone:latest \
|
|
|
|
rcd --rc-web-gui --rc-addr :5572 \
|
|
|
|
--rc-user rclone --rc-pass randompassword12345
|
2023-02-22 16:49:54 +00:00
|
|
|
fi
|