Update update-from_repo.sh

This commit is contained in:
WickedYoda committed 2025-01-30 12:07:28 -06:00
1 parent 4082128753
commit 222775f820
1 file changed
+8 -29
+8 -29
View File
@@ -1,29 +1,12 @@
#!/bin/bash #!/bin/bash
# Detect if the system is Debian/Ubuntu-based or OpenWRT # run apt update to make sure the system is got latest repo files
if command -v apt &> /dev/null; then sudo apt update -y
PACKAGE_MANAGER="apt"
UPDATE_CMD="sudo apt update -y"
INSTALL_CMD="sudo apt install -y"
elif command -v opkg &> /dev/null; then
PACKAGE_MANAGER="opkg"
UPDATE_CMD="opkg update"
INSTALL_CMD="opkg install"
else
echo "Unsupported system. This script supports Debian/Ubuntu (apt) and OpenWRT (opkg)."
exit 1
fi
# Update package lists
echo "Updating package lists using $PACKAGE_MANAGER..."
$UPDATE_CMD
# Check if git is installed # Check if git is installed
if ! command -v git &> /dev/null; then if ! command -v git &> /dev/null; then
echo "Git is not installed. Installing git using $PACKAGE_MANAGER..." # Install git
$INSTALL_CMD git sudo apt-get install git -y
else
echo "Git is already installed."
fi fi
# Specify the remote repository URL # Specify the remote repository URL
@@ -33,17 +16,13 @@ remote_repo="https://github.com/wickedyoda/public-setupfiles.git"
local_file="./public-setupfiles" local_file="./public-setupfiles"
# Check if the local file path exists and is not empty # Check if the local file path exists and is not empty
if [ -d "$local_file" ] && [ -n "$(ls -A $local_file 2>/dev/null)" ]; then if [ -d "$local_file" ] && [ -n "$(ls -A $local_file)" ]; then
echo "Existing directory detected. Deleting $local_file..." # Delete the existing directory
sudo rm -rf "$local_file" sudo rm -rf "$local_file"
fi fi
# Clone the remote repository to the local file path # Clone the remote repository to the local file path
echo "Cloning repository from $remote_repo to $local_file..."
git clone "$remote_repo" "$local_file" git clone "$remote_repo" "$local_file"
# Make all files executable and set public ownership # Make all files executable and public ownership
echo "Setting permissions for $local_file..." sudo chmod 777 -R $local_file
sudo chmod -R 777 "$local_file"
echo "Script execution completed successfully!"