Files
public-setupfiles/update-from_repo.sh
T

47 lines
1.3 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
# Detect if the system is Debian/Ubuntu-based
if ! command -v apt &> /dev/null; then
echo "This script only supports Debian-based systems (Ubuntu, Debian, etc.)."
exit 1
fi
# Update package lists
echo "Updating package lists..."
apt update -y
2024-05-09 16:22:56 -05:00
# Check if git is installed
if ! command -v git &> /dev/null; then
2025-01-30 12:11:57 -06:00
echo "Git is not installed. Installing Git..."
apt install -y git
else
echo "Git is already installed."
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..."
chmod -R 777 "$LOCAL_DIR"
echo "Script execution completed successfully!"