Files
Varaverk/Rsync/git_pull_execute.sh
T
2026-03-21 21:34:42 +00:00

37 lines
1.1 KiB
Bash

#!/bin/bash
set -e
# -----------------------------
# Configurable variables
# -----------------------------
REPO_SSH="git@192.168.50.2:FailedProxy/Unraid_Scripts.git"
TARGET_DIR="/mnt/user/appdata/unraid_scripts"
SSH_KEY="/root/.ssh/id_gitea_rsync"
SSH_PORT=221
# -----------------------------
# Create target directory if it doesn't exist
# -----------------------------
mkdir -p "$TARGET_DIR"
cd "$TARGET_DIR"
# -----------------------------
# Clone or pull repo (discard local changes)
# -----------------------------
if [ -d ".git" ]; then
echo "Repository already exists. Resetting local changes and pulling latest..."
git reset --hard
git clean -fd
GIT_SSH_COMMAND="ssh -i $SSH_KEY -p $SSH_PORT" git pull
else
echo "Cloning $REPO_SSH into $TARGET_DIR..."
GIT_SSH_COMMAND="ssh -i $SSH_KEY -p $SSH_PORT" git clone "$REPO_SSH" .
fi
# -----------------------------
# Ensure scripts are executable
# -----------------------------
echo "Setting executable permissions on scripts..."
find "$TARGET_DIR" -type f -name "*.sh" -exec chmod +x {} \;
echo "Repository is up to date and scripts are executable."