rclone
This commit is contained in:
parent
ab0e0a31e8
commit
a04065a56c
2
Makefile
2
Makefile
@ -12,7 +12,7 @@ setup:
|
|||||||
|
|
||||||
# Just stow the dotfiles
|
# Just stow the dotfiles
|
||||||
stow:
|
stow:
|
||||||
stow . --target=$$HOME --ignore="setup.sh" --ignore=".git" --ignore=".gitignore" --ignore="README.md" --ignore=".zsh_secrets" --ignore=".zsh_secrets.example" --ignore="LICENSE" --ignore="Makefile"
|
stow . --target=$$HOME --ignore="setup.sh" --ignore=".git" --ignore=".gitignore" --ignore="README.md" --ignore=".zsh_secrets" --ignore=".zsh_secrets.example" --ignore="LICENSE" --ignore="Makefile" --ignore="provision.sh" --ignore="rclone.sh"
|
||||||
@echo "Dotfiles linked."
|
@echo "Dotfiles linked."
|
||||||
|
|
||||||
# Clean old files and links
|
# Clean old files and links
|
||||||
|
|||||||
114
rclone.sh
Normal file
114
rclone.sh
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Colors
|
||||||
|
BLUE='\033[1;34m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
GREEN='\033[1;32m'
|
||||||
|
RED='\033[1;31m'
|
||||||
|
NC='\033[0m'
|
||||||
|
|
||||||
|
SECRETS_FILE="$HOME/.zsh_secrets"
|
||||||
|
REMOTE_NAME="hetzner-box"
|
||||||
|
|
||||||
|
# 1. Dependency Check
|
||||||
|
if ! command -v rclone &> /dev/null; then
|
||||||
|
echo -e "${RED}Error: rclone is not installed.${NC}"
|
||||||
|
echo "Run: sudo pacman -S rclone (Arch) or sudo apt install rclone (Ubuntu)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 2. Load Secrets
|
||||||
|
if [ -f "$SECRETS_FILE" ]; then
|
||||||
|
source "$SECRETS_FILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 3. Configure Remote (If missing)
|
||||||
|
if ! rclone listremotes | grep -q "^${REMOTE_NAME}:$"; then
|
||||||
|
echo -e "${BLUE}Configuration missing. Starting setup...${NC}"
|
||||||
|
|
||||||
|
# Prompt if variables are missing
|
||||||
|
if [ -z "$HETZNER_USER" ]; then
|
||||||
|
HETZNER_USER="u513875"
|
||||||
|
read -p "Enter Storage Box Username (u123456): " HETZNER_USER
|
||||||
|
fi
|
||||||
|
if [ -z "$HETZNER_HOST" ]; then
|
||||||
|
HETZNER_HOST="u513875.your-storagebox.de"
|
||||||
|
read -p "Enter Storage Box Host (u513875.your-storagebox.de): " HETZNER_HOST
|
||||||
|
fi
|
||||||
|
if [ -z "$HETZNER_PASS" ]; then
|
||||||
|
HETZNER_PASS=""
|
||||||
|
echo -e "${YELLOW}Note: Passwords are obscured in config, but saving to secrets file uses plain text.${NC}"
|
||||||
|
read -s -p "Enter Storage Box Password: " HETZNER_PASS
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Save to secrets for future use
|
||||||
|
if ! grep -q "HETZNER_USER" "$SECRETS_FILE" 2>/dev/null; then
|
||||||
|
echo -e "${BLUE}Saving credentials to $SECRETS_FILE...${NC}"
|
||||||
|
{
|
||||||
|
echo ""
|
||||||
|
echo "# Hetzner Storage Box"
|
||||||
|
echo "export HETZNER_USER=\"$HETZNER_USER\""
|
||||||
|
echo "export HETZNER_HOST=\"$HETZNER_HOST\""
|
||||||
|
echo "export HETZNER_PASS=\"$HETZNER_PASS\""
|
||||||
|
} >> "$SECRETS_FILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create Rclone Config (Obscure password first)
|
||||||
|
OBSCURED_PASS=$(rclone obscure "$HETZNER_PASS")
|
||||||
|
rclone config create "$REMOTE_NAME" sftp \
|
||||||
|
host "$HETZNER_HOST" \
|
||||||
|
user "$HETZNER_USER" \
|
||||||
|
pass "$OBSCURED_PASS" \
|
||||||
|
port 23 \
|
||||||
|
--non-interactive
|
||||||
|
|
||||||
|
echo -e "${GREEN}Configuration created!${NC}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 4. Interactive Menu
|
||||||
|
echo -e "${BLUE}--- Hetzner Storage Box Manager ---${NC}"
|
||||||
|
echo "1) List files (ls)"
|
||||||
|
echo "2) Upload (Copy LOCAL -> REMOTE)"
|
||||||
|
echo "3) Download (Copy REMOTE -> LOCAL)"
|
||||||
|
echo "4) Mount (Browse files)"
|
||||||
|
echo "q) Quit"
|
||||||
|
|
||||||
|
read -p "Select option: " OPTION
|
||||||
|
|
||||||
|
case $OPTION in
|
||||||
|
1)
|
||||||
|
rclone ls "${REMOTE_NAME}:" --max-depth 1
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
read -p "Enter local folder to upload from (e.g., $HOME/Documents): " LOCAL_FOLDER
|
||||||
|
LOCAL_FOLDER=${LOCAL_FOLDER%/}
|
||||||
|
|
||||||
|
read -p "Enter remote folder name on Hetzner (e.g. Backup): " REMOTE_FOLDER
|
||||||
|
|
||||||
|
echo -e "${YELLOW}Uploading (Copying)...${NC}"
|
||||||
|
|
||||||
|
rclone copy "$LOCAL_FOLDER" "${REMOTE_NAME}:/${REMOTE_FOLDER}" -P
|
||||||
|
;;
|
||||||
|
3)
|
||||||
|
read -p "Enter remote folder on Hetzner to download (e.g. Backup): " REMOTE_FOLDER
|
||||||
|
read -p "Enter local destination folder: " LOCAL_FOLDER
|
||||||
|
|
||||||
|
echo -e "${YELLOW}Downloading (Copying)...${NC}"
|
||||||
|
rclone copy "${REMOTE_NAME}:/${REMOTE_FOLDER}" "$LOCAL_FOLDER" -P
|
||||||
|
;;
|
||||||
|
4)
|
||||||
|
MOUNT_POINT="/mnt/resources/storagebox"
|
||||||
|
|
||||||
|
mkdir -p "$MOUNT_POINT"
|
||||||
|
echo -e "${YELLOW}Mounting to $MOUNT_POINT... (Ctrl+C to stop)${NC}"
|
||||||
|
rclone mount "${REMOTE_NAME}:" "$MOUNT_POINT" --vfs-cache-mode writes
|
||||||
|
;;
|
||||||
|
q)
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Invalid option"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
2
setup.sh
2
setup.sh
@ -220,7 +220,7 @@ touch "$HOME/.zsh_secrets"
|
|||||||
# Stow Dotfiles
|
# Stow Dotfiles
|
||||||
echo -e "${BLUE} LOG:${YELLOW} Stowing dotfiles...${NC}"
|
echo -e "${BLUE} LOG:${YELLOW} Stowing dotfiles...${NC}"
|
||||||
cd "$DOTFILES_DIR"
|
cd "$DOTFILES_DIR"
|
||||||
stow . --target="$HOME" --ignore="setup.sh" --ignore=".git" --ignore=".gitignore" --ignore="README.md" --ignore=".zsh_secrets" --ignore=".zsh_secrets.example" --ignore="LICENSE" --ignore="Makefile" --ignore="provision.sh"
|
stow . --target="$HOME" --ignore="setup.sh" --ignore=".git" --ignore=".gitignore" --ignore="README.md" --ignore=".zsh_secrets" --ignore=".zsh_secrets.example" --ignore="LICENSE" --ignore="Makefile" --ignore="provision.sh" --ignore="rclone.sh"
|
||||||
|
|
||||||
# Language Setup
|
# Language Setup
|
||||||
echo -e "${BLUE} LOG:${YELLOW} Finalizing Language Setup...${NC}"
|
echo -e "${BLUE} LOG:${YELLOW} Finalizing Language Setup...${NC}"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user