From 222775f8208607c28b6f5e6fd7bbb4a5379f437e Mon Sep 17 00:00:00 2001 From: WickedYoda <68271168+wickedyoda@users.noreply.github.com> Date: Thu, 30 Jan 2025 12:07:28 -0600 Subject: [PATCH] Update update-from_repo.sh --- update-from_repo.sh | 37 ++++++++----------------------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/update-from_repo.sh b/update-from_repo.sh index e5e15ed..d2508b3 100644 --- a/update-from_repo.sh +++ b/update-from_repo.sh @@ -1,29 +1,12 @@ #!/bin/bash -# Detect if the system is Debian/Ubuntu-based or OpenWRT -if command -v apt &> /dev/null; then - 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 +# run apt update to make sure the system is got latest repo files +sudo apt update -y # Check if git is installed if ! command -v git &> /dev/null; then - echo "Git is not installed. Installing git using $PACKAGE_MANAGER..." - $INSTALL_CMD git -else - echo "Git is already installed." + # Install git + sudo apt-get install git -y fi # Specify the remote repository URL @@ -33,17 +16,13 @@ remote_repo="https://github.com/wickedyoda/public-setupfiles.git" local_file="./public-setupfiles" # Check if the local file path exists and is not empty -if [ -d "$local_file" ] && [ -n "$(ls -A $local_file 2>/dev/null)" ]; then - echo "Existing directory detected. Deleting $local_file..." +if [ -d "$local_file" ] && [ -n "$(ls -A $local_file)" ]; then + # Delete the existing directory sudo rm -rf "$local_file" fi # Clone the remote repository to the local file path -echo "Cloning repository from $remote_repo to $local_file..." git clone "$remote_repo" "$local_file" -# Make all files executable and set public ownership -echo "Setting permissions for $local_file..." -sudo chmod -R 777 "$local_file" - -echo "Script execution completed successfully!" +# Make all files executable and public ownership +sudo chmod 777 -R $local_file \ No newline at end of file