From 9e0ac55028076cd4ea752d2dc89eac803a1c2274 Mon Sep 17 00:00:00 2001 From: WickedYoda <68271168+wickedyoda@users.noreply.github.com> Date: Thu, 9 May 2024 17:41:33 -0500 Subject: [PATCH] s sws --- update-from_repo.py | 8 +++-- updates/dist-upgrade.sh | 11 ------ updates/update-public-setupfiles.sh | 46 ------------------------- updates_scripts/dist-upgrade.sh | 43 +++++++++++++++++++++++ {updates => updates_scripts}/updates.py | 0 {updates => updates_scripts}/updates.sh | 0 6 files changed, 48 insertions(+), 60 deletions(-) delete mode 100644 updates/dist-upgrade.sh delete mode 100644 updates/update-public-setupfiles.sh create mode 100644 updates_scripts/dist-upgrade.sh rename {updates => updates_scripts}/updates.py (100%) rename {updates => updates_scripts}/updates.sh (100%) diff --git a/update-from_repo.py b/update-from_repo.py index 601e20d..ec6da2d 100644 --- a/update-from_repo.py +++ b/update-from_repo.py @@ -1,16 +1,18 @@ #!/bin/bash -# run apt update to make sure the system has the latest repo files import subprocess -subprocess.run(["sudo", "apt", "update", "-y"]) +subprocess.run(["apt", "install", "python", "python3", "-y"]) + +# run apt update to make sure the system has the latest repo files +subprocess.run(["apt", "update", "-y"]) # Check if git is installed try: subprocess.run(["git", "--version"], check=True) except subprocess.CalledProcessError: # Install git - subprocess.run(["sudo", "apt-get", "install", "git", "-y"]) + subprocess.run(["apt-get", "install", "git", "-y"]) # Specify the remote repository URL remote_repo = "https://github.com/wickedyoda/public-setupfiles.git" diff --git a/updates/dist-upgrade.sh b/updates/dist-upgrade.sh deleted file mode 100644 index 3e03a80..0000000 --- a/updates/dist-upgrade.sh +++ /dev/null @@ -1,11 +0,0 @@ -# /bin/bash - -sudo apt update -sudo apt upgrade -y -sudo apt full-upgrade -y -sudo apt dist-upgrade -y -sudo apt autoremove -y -sudo apt clean -y -sudo apt purge -y - -echo "System update and cleanup complete!" \ No newline at end of file diff --git a/updates/update-public-setupfiles.sh b/updates/update-public-setupfiles.sh deleted file mode 100644 index 8ccb50b..0000000 --- a/updates/update-public-setupfiles.sh +++ /dev/null @@ -1,46 +0,0 @@ - -# Change to /home/traver -cd /home/traver - -# Check distro and download updated public-setupfiles -if [ -x "$(command -v os-release)" ]; then - $ID=$(os-release -si) -else - $ID=$(cat /etc/os-release | grep -oP '(?<=^ID=).+' | tr -d '"') -fi - -if [ "$ID" = "Ubuntu" ]; then - # Pull file A - wget https://raw.githubusercontent.com/wickedyoda/public-setupfiles/main/server_config/ubuntu/ubuntu-setup.sh && chmod +x ./ubuntu-setup.sh -elif [ "$ID" = "Debian" ]; then - # Pull file B - wget https://raw.githubusercontent.com/wickedyoda/public-setupfiles/main/server_config/debian/debian-setup.sh && chmod +x ./debian-setup.sh -elif [ "$ID" = "raspbian" ]; then - # Pull file B - wget https://raw.githubusercontent.com/wickedyoda/public-setupfiles/main/server_config/debian/debian-setup.sh && chmod +x ./debian-setup.sh -fi - -# make updated files executable -cd /home/traver - -# Check if /home/traver/public-setupfiles exists -if [ -d "/home/traver/public-setupfiles" ]; then - # Change directory to /home/traver/public-setupfiles - cd /home/traver/public-setupfiles - - # Stash any local changes - git stash - - # Pull the latest changes from the remote repository - git pull -else - # mkdir for git repo - sudo mkdir -p /home/traver/public-setupfiles - cd /home/traver/public-setupfiles - git init - git remote add origin https://github.com/wickedyoda/public-setupfiles - git pull origin main - git checkout main - -# make directory executable -chmod +x -R /home/traver/public-setupfiles \ No newline at end of file diff --git a/updates_scripts/dist-upgrade.sh b/updates_scripts/dist-upgrade.sh new file mode 100644 index 0000000..4064274 --- /dev/null +++ b/updates_scripts/dist-upgrade.sh @@ -0,0 +1,43 @@ +# /bin/bash + +# Backup of existing sources.list file +sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup + +# Create variable from /etc/os-release file to get ID +ID=$(grep -oP '(?<=^ID=).+' /etc/os-release) + +if [ "$ID" == "debian" ]; then + echo "ID_LIKE is debian" + echo "Updating sources.list file" + echo "deb http://deb.debian.org/debian/ bookworm main contrib non-free" | sudo tee /etc/apt/sources.list + echo "deb-src http://deb.debian.org/debian/ bookworm main contrib non-free" | sudo tee -a /etc/apt/sources.list + echo "deb http://deb.debian.org/debian/ bookworm-updates main contrib non-free" | sudo tee -a /etc/apt/sources.list + echo "deb-src http://deb.debian.org/debian/ bookworm-updates main contrib non-free" | sudo tee -a /etc/apt/sources.list + echo "deb http://deb.debian.org/debian/ bookworm-backports main contrib non-free" | sudo tee -a /etc/apt/sources.list + echo "deb-src http://deb.debian.org/debian/ bookworm-backports main contrib non-free" | sudo tee -a /etc/apt/sources.list + echo "deb http://security.debian.org/debian-security/ bookworm-security main contrib non-free" | sudo tee -a /etc/apt/sources.list + echo "deb-src http://security.debian.org/debian-security/ bookworm-security main contrib non-free" | sudo tee -a /etc/apt/sources.list +fi + +if [ "$ID" == "ubuntu" ]; then + echo "ID_LIKE is ubuntu" + echo "Updating sources.list file" + echo "deb http://archive.ubuntu.com/ubuntu/ Minotaur restricted universe multiverse" | sudo tee /etc/apt/sources.list + echo "deb http://archive.ubuntu.com/ubuntu/ Minotaur main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list + echo "deb http://archive.ubuntu.com/ubuntu/ Minotaur main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list + echo "deb http://security.ubuntu.com/ubuntu Minotaur main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list +fi + +# update repositories +sudo apt update + +# Full upgrade of system +sudo apt full-upgrade -y && sudo apt dist-upgrade -y + +# Clean up system +sudo apt autoremove -y +sudo apt clean -y +sudo apt autopurge -y + +echo "System update and cleanup complete!" + diff --git a/updates/updates.py b/updates_scripts/updates.py similarity index 100% rename from updates/updates.py rename to updates_scripts/updates.py diff --git a/updates/updates.sh b/updates_scripts/updates.sh similarity index 100% rename from updates/updates.sh rename to updates_scripts/updates.sh