#!/usr/bin/env sh set -e if [ -n "$RCLONE_CONFIG_CONTENT" ]; then echo "$RCLONE_CONFIG_CONTENT" > "${RCLONE_CONFIG:=/config/rclone.conf}" elif [ ! -e "${RCLONE_CONFIG:=/config/rclone.conf}" ]; then echo "No rclone config found" rclone --config "${RCLONE_CONFIG:=/config/rclone.conf}" config fi RCLONE_REMOTE="$(rclone listremotes | head -1)" echo "Using remote: $RCLONE_REMOTE" RESTIC_REPOSITORY="rclone:$RCLONE_REMOTE" echo "Using repository: $RESTIC_REPOSITORY" # if RESTIC_PASSWORD is empty if [ -z "$RESTIC_PASSWORD" ] && [ -z "$RESTIC_PASSWORD_FILE" ]; then echo "Set \$RESTIC_PASSWORD or \$RESTIC_PASSWORD_FILE" exit 1 fi export RCLONE_REMOTE export RESTIC_REPOSITORY restic init echo "Display rclone config [y/N]?" read -r answer # check if answer is yes if [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then rclone --config "${RCLONE_CONFIG:=/config/rclone.conf}" config show echo "" fi echo "Environemnt variables:" echo "RCLONE_REMOTE=$RCLONE_REMOTE" echo "RESTIC_PASSWORD=*********" echo "RESTIC_REPOSITORY=$RESTIC_REPOSITORY" echo ""