mirror of
https://github.com/wickedyoda/public-setupfiles.git
synced 2026-11-16 13:31:56 -06:00
Update update-from_repo.sh
This commit is contained in:
1 parent
222775f820
commit
3910d808ca
1 file changed
+34
-15
+34
-15
@@ -1,28 +1,47 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# run apt update to make sure the system is got latest repo files
|
# Ensure script is run as root or with sudo
|
||||||
sudo apt update -y
|
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
|
||||||
|
|
||||||
# Check if git is installed
|
# Check if git is installed
|
||||||
if ! command -v git &> /dev/null; then
|
if ! command -v git &> /dev/null; then
|
||||||
# Install git
|
echo "Git is not installed. Installing Git..."
|
||||||
sudo apt-get install git -y
|
apt install -y git
|
||||||
|
else
|
||||||
|
echo "Git is already installed."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Specify the remote repository URL
|
# Specify the remote repository URL
|
||||||
remote_repo="https://github.com/wickedyoda/public-setupfiles.git"
|
REMOTE_REPO="https://github.com/wickedyoda/public-setupfiles.git"
|
||||||
|
|
||||||
# Specify the local file path
|
# Specify the local directory for the repository
|
||||||
local_file="./public-setupfiles"
|
LOCAL_DIR="./public-setupfiles"
|
||||||
|
|
||||||
# Check if the local file path exists and is not empty
|
# Check if the local directory exists and is not empty
|
||||||
if [ -d "$local_file" ] && [ -n "$(ls -A $local_file)" ]; then
|
if [ -d "$LOCAL_DIR" ] && [ -n "$(ls -A $LOCAL_DIR 2>/dev/null)" ]; then
|
||||||
# Delete the existing directory
|
echo "Existing directory detected. Deleting $LOCAL_DIR..."
|
||||||
sudo rm -rf "$local_file"
|
rm -rf "$LOCAL_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Clone the remote repository to the local file path
|
# Clone the remote repository to the local directory
|
||||||
git clone "$remote_repo" "$local_file"
|
echo "Cloning repository from $REMOTE_REPO to $LOCAL_DIR..."
|
||||||
|
git clone "$REMOTE_REPO" "$LOCAL_DIR"
|
||||||
|
|
||||||
# Make all files executable and public ownership
|
# Ensure all files have proper execution permissions
|
||||||
sudo chmod 777 -R $local_file
|
echo "Setting permissions for $LOCAL_DIR..."
|
||||||
|
chmod -R 777 "$LOCAL_DIR"
|
||||||
|
|
||||||
|
echo "Script execution completed successfully!"
|
||||||
Reference in new issue
Block a user