Files
public-setupfiles/update-from_repo.sh
T

35 lines
1.0 KiB
Bash
Raw Normal View History

2024-05-09 15:48:15 -05:00
#!/bin/bash
2025-01-30 12:11:57 -06:00
# Ensure script is run as root or with sudo
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root. Use sudo."
exit 1
fi
2025-02-25 13:49:24 -06:00
# Verify Git is installed
2024-05-09 16:22:56 -05:00
if ! command -v git &> /dev/null; then
2025-02-25 13:49:24 -06:00
echo "Error: Git is not installed. Please install Git manually and re-run the script."
exit 1
2024-05-09 16:22:56 -05:00
fi
2024-05-09 15:48:15 -05:00
# Specify the remote repository URL
2025-01-30 12:11:57 -06:00
REMOTE_REPO="https://github.com/wickedyoda/public-setupfiles.git"
2024-05-09 15:48:15 -05:00
2025-01-30 12:11:57 -06:00
# Specify the local directory for the repository
LOCAL_DIR="./public-setupfiles"
2024-05-09 15:48:15 -05:00
2025-01-30 12:11:57 -06:00
# Check if the local directory exists and is not empty
if [ -d "$LOCAL_DIR" ] && [ -n "$(ls -A $LOCAL_DIR 2>/dev/null)" ]; then
echo "Existing directory detected. Deleting $LOCAL_DIR..."
rm -rf "$LOCAL_DIR"
2024-05-09 15:59:36 -05:00
fi
2024-05-09 16:02:52 -05:00
2025-01-30 12:11:57 -06:00
# Clone the remote repository to the local directory
echo "Cloning repository from $REMOTE_REPO to $LOCAL_DIR..."
git clone "$REMOTE_REPO" "$LOCAL_DIR"
2024-05-09 16:09:58 -05:00
2025-01-30 12:11:57 -06:00
# Ensure all files have proper execution permissions
echo "Setting permissions for $LOCAL_DIR..."
2025-02-25 13:49:24 -06:00
chmod -R 755 "$LOCAL_DIR"
2025-01-30 12:11:57 -06:00
echo "Script execution completed successfully!"