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
710216a838
commit
4082128753
1 file changed
+28
-8
+28
-8
@@ -1,12 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
# run apt update to make sure the system is got latest repo files
|
||||
sudo apt update -y
|
||||
# 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
|
||||
|
||||
# Check if git is installed
|
||||
if ! command -v git &> /dev/null; then
|
||||
# Install git
|
||||
sudo apt-get install git -y
|
||||
echo "Git is not installed. Installing git using $PACKAGE_MANAGER..."
|
||||
$INSTALL_CMD git
|
||||
else
|
||||
echo "Git is already installed."
|
||||
fi
|
||||
|
||||
# Specify the remote repository URL
|
||||
@@ -16,14 +33,17 @@ 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)" ]; then
|
||||
# Delete the existing directory
|
||||
if [ -d "$local_file" ] && [ -n "$(ls -A $local_file 2>/dev/null)" ]; then
|
||||
echo "Existing directory detected. Deleting $local_file..."
|
||||
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 public ownership
|
||||
sudo chmod 777 -R $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!"
|
||||
Reference in new issue
Block a user