From a6e057fb009d7ce600bffdc63e06b6718fde894f Mon Sep 17 00:00:00 2001 From: lolpro11 Date: Mon, 3 Jan 2022 20:35:22 -0800 Subject: [PATCH 1/2] version and root check --- install.sh | 65 +++++++++++++++++++++++++++++++++------------- install_full.sh | 68 ++++++++++++++++++++++++++++++++++++------------- 2 files changed, 98 insertions(+), 35 deletions(-) diff --git a/install.sh b/install.sh index 3d59bd1f..5520c7d8 100755 --- a/install.sh +++ b/install.sh @@ -1,27 +1,58 @@ #!/bin/bash +command -v jq >/dev/null 2>&1 || { JQ=0;} +command -v python3 >/dev/null 2>&1 || { PY=0;} +command -v python >/dev/null 2>&1 || { PY=0;} +if [ "${EUID}" -ne 0 ]; then + echo "You need to run this script as root." + exit 1 +fi #install python +if [[ $PY -ne 0 ]]; then + if [[ -e /etc/debian_version ]]; then + apt install python3 + elif [[ -e /etc/fedora-release ]]; then + dnf install python3 + elif [[ -e /etc/centos-release ]]; then + yum install -y python3 + elif [[ -e /etc/arch-release ]]; then + pacman -Sy python3 + else + echo "Looks like you aren't running this installer on a Debian, Ubuntu, Fedora, CentOS, or Arch Linux system." + exit 1 + fi +else + echo "Skipping installing python, as python is preinstalled" +fi #install tkinter, a dependency +#install jq, needed to get version number if [[ -e /etc/debian_version ]]; then - apt install python3 python3-tk + apt install python3-tk jq elif [[ -e /etc/fedora-release ]]; then - dnf install python3 - dnf install python3-tkinter + dnf install python3-tkinter jq elif [[ -e /etc/centos-release ]]; then - yum install -y python3 - yum install tkinter + yum install -y tkinter epel-release jq elif [[ -e /etc/arch-release ]]; then - pacman -Sy python3 tk + pacman -Sy tk jq +fi +command -v pip >/dev/null 2>&1 || { sudo -u $USER curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py; sudo -u $USER python3 get-pip.py --no-warn-script-location; rm get-pip.py; } +TAG=$(curl https://api.github.com/repos/ThioJoe/YT-Spammer-Purge/releases/latest -s | jq .name -r) +if [[ $JQ -ne 0 ]]; then + if [[ -e /etc/debian_version ]]; then + apt purge jq + elif [[ -e /etc/fedora-release ]]; then + dnf remove jq + elif [[ -e /etc/centos-release ]]; then + yum remove jq epel-release + elif [[ -e /etc/arch-release ]]; then + pacman -Rs jq + fi else - echo "Looks like you aren't running this installer on a Debian, Ubuntu, Fedora, CentOS, Arch Linux system." - exit 1 + echo "Did not unistall jq as it was preinstalled before running this script." fi -sudo -u $USER curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py -sudo -u $USER python3 get-pip.py --no-warn-script-location -# Uncomment if running this script alone, to also install the files for YT-Spammer-Purge -: 'sudo -u $USER curl https://codeload.github.com/ThioJoe/YT-Spammer-Purge/tar.gz/refs/tags/v2.6.1 -o yt-spammer.tar.gz +# Uncomment if running this script alone, to also install the files for Youtube-Spammer-Purge +: 'curl https://codeload.github.com/ThioJoe/YT-Spammer-Purge/tar.gz/refs/tags/v${TAG} -o yt-spammer.tar.gz sudo -u $USER tar -xzf yt-spammer.tar.gz -sudo -u $USER rm yt-spammer.tar.gz -sudo -u $USER cd YT-Spammer-Purge-2.6.1/' -sudo -u $USER rm get-pip.py -sudo -u $USER pip -q install -r requirements.txt -printf "Dependencies and Program installed!\nNow follow these instructions to get a client_secrets.json file!\nhttps://github.com/ThioJoe/YT-Spammer-Purge/wiki/Instructions:-Obtaining-an-API-Key\n" +rm yt-spammer.tar.gz +cd YouTube-Spammer-Purge-${TAG}/' +sudo -u $USER bash -c "pip install -r requirements.txt" +printf "Dependencies and Program installed!\nNow follow these instructions to get a client_secrets.json file!\nhttps://github.com/ThioJoe/YouTube-Spammer-Purge#instructions---obtaining-youtube-api-key\n" diff --git a/install_full.sh b/install_full.sh index d283e3ca..fb550536 100755 --- a/install_full.sh +++ b/install_full.sh @@ -1,26 +1,58 @@ #!/bin/bash -#install python and tkinter, a dependency +command -v jq >/dev/null 2>&1 || { JQ=0;} +command -v python3 >/dev/null 2>&1 || { PY=0;} +command -v python >/dev/null 2>&1 || { PY=0;} +if [ "${EUID}" -ne 0 ]; then + echo "You need to run this script as root." + exit 1 +fi +#install python +if [[ $PY -ne 0 ]]; then + if [[ -e /etc/debian_version ]]; then + apt install python3 + elif [[ -e /etc/fedora-release ]]; then + dnf install python3 + elif [[ -e /etc/centos-release ]]; then + yum install -y python3 + elif [[ -e /etc/arch-release ]]; then + pacman -Sy python3 + else + echo "Looks like you aren't running this installer on a Debian, Ubuntu, Fedora, CentOS, or Arch Linux system." + exit 1 + fi +else + echo "Skipping installing python, as python is preinstalled" +fi +#install tkinter, a dependency +#install jq, needed to get version number if [[ -e /etc/debian_version ]]; then - apt install python3 python3-tk + apt install python3-tk jq elif [[ -e /etc/fedora-release ]]; then - dnf install python3 - dnf install python3-tkinter + dnf install python3-tkinter jq elif [[ -e /etc/centos-release ]]; then - yum install -y python3 - yum install tkinter + yum install -y tkinter epel-release jq elif [[ -e /etc/arch-release ]]; then - pacman -Syu python3 tk + pacman -Sy tk jq +fi +command -v pip >/dev/null 2>&1 || { sudo -u $USER curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py; sudo -u $USER python3 get-pip.py --no-warn-script-location; rm get-pip.py; } +TAG=$(curl https://api.github.com/repos/ThioJoe/YT-Spammer-Purge/releases/latest -s | jq .name -r) +if [[ $JQ -ne 0 ]]; then + if [[ -e /etc/debian_version ]]; then + apt purge jq + elif [[ -e /etc/fedora-release ]]; then + dnf remove jq + elif [[ -e /etc/centos-release ]]; then + yum remove jq epel-release + elif [[ -e /etc/arch-release ]]; then + pacman -Rs jq + fi else - echo "Looks like you aren't running this installer on a Debian, Ubuntu, Fedora, CentOS, Arch Linux system." - exit 1 + echo "Did not unistall jq as it was preinstalled before running this script." fi -sudo -u $USER curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py -sudo -u $USER python3 get-pip.py -# Uncomment if running this script alone, to also install the files for YT-Spammer-Purge -sudo -u $USER curl https://codeload.github.com/ThioJoe/YT-Spammer-Purge/tar.gz/refs/tags/v2.6.1 -o yt-spammer.tar.gz +# Uncomment if running this script alone, to also install the files for Youtube-Spammer-Purge +curl https://codeload.github.com/ThioJoe/YT-Spammer-Purge/tar.gz/refs/tags/v${TAG} -o yt-spammer.tar.gz sudo -u $USER tar -xzf yt-spammer.tar.gz -sudo -u $USER rm yt-spammer.tar.gz -sudo -u $USER cd YT-Spammer-Purge-2.6.1/ -sudo -u $USER rm get-pip.py -sudo -u $USER pip install -r requirements.txt -printf "Dependencies and Program installed!\nNow follow these instructions to get a client_secrets.json file!\nhttps://github.com/ThioJoe/YT-Spammer-Purge/wiki/Instructions:-Obtaining-an-API-Key\n" +rm yt-spammer.tar.gz +cd YouTube-Spammer-Purge-${TAG}/ +sudo -u $USER bash -c "pip install -r requirements.txt" +printf "Dependencies and Program installed!\nNow follow these instructions to get a client_secrets.json file!\nhttps://github.com/ThioJoe/YouTube-Spammer-Purge#instructions---obtaining-youtube-api-key\n" From 9388e94e1918dad1dfaf347dc4fe066b102ccc35 Mon Sep 17 00:00:00 2001 From: lolpro11 Date: Thu, 6 Jan 2022 18:43:52 -0800 Subject: [PATCH 2/2] fixes --- install.sh | 32 +++++++++++++------------------- install_full.sh | 32 +++++++++++++------------------- 2 files changed, 26 insertions(+), 38 deletions(-) diff --git a/install.sh b/install.sh index 5520c7d8..d65a50a4 100755 --- a/install.sh +++ b/install.sh @@ -1,21 +1,15 @@ #!/bin/bash -command -v jq >/dev/null 2>&1 || { JQ=0;} -command -v python3 >/dev/null 2>&1 || { PY=0;} -command -v python >/dev/null 2>&1 || { PY=0;} -if [ "${EUID}" -ne 0 ]; then - echo "You need to run this script as root." - exit 1 -fi +command -v jq >/dev/null 2>&1 || { JQ=0; } #install python -if [[ $PY -ne 0 ]]; then +if ! command -v python3 &> /dev/null; then if [[ -e /etc/debian_version ]]; then - apt install python3 + sudo apt install python3 elif [[ -e /etc/fedora-release ]]; then - dnf install python3 + sudo dnf install python3 elif [[ -e /etc/centos-release ]]; then - yum install -y python3 + sudo yum install -y python3 elif [[ -e /etc/arch-release ]]; then - pacman -Sy python3 + sudo pacman -Sy python3 else echo "Looks like you aren't running this installer on a Debian, Ubuntu, Fedora, CentOS, or Arch Linux system." exit 1 @@ -26,15 +20,15 @@ fi #install tkinter, a dependency #install jq, needed to get version number if [[ -e /etc/debian_version ]]; then - apt install python3-tk jq + sudo apt install python3-tk jq elif [[ -e /etc/fedora-release ]]; then - dnf install python3-tkinter jq + sudo dnf install python3-tkinter jq elif [[ -e /etc/centos-release ]]; then - yum install -y tkinter epel-release jq + sudo yum install -y tkinter epel-release jq elif [[ -e /etc/arch-release ]]; then - pacman -Sy tk jq + sudo pacman -Sy tk jq fi -command -v pip >/dev/null 2>&1 || { sudo -u $USER curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py; sudo -u $USER python3 get-pip.py --no-warn-script-location; rm get-pip.py; } +command -v pip >/dev/null 2>&1 || { curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py; python3 get-pip.py --no-warn-script-location; rm get-pip.py; } TAG=$(curl https://api.github.com/repos/ThioJoe/YT-Spammer-Purge/releases/latest -s | jq .name -r) if [[ $JQ -ne 0 ]]; then if [[ -e /etc/debian_version ]]; then @@ -51,8 +45,8 @@ else fi # Uncomment if running this script alone, to also install the files for Youtube-Spammer-Purge : 'curl https://codeload.github.com/ThioJoe/YT-Spammer-Purge/tar.gz/refs/tags/v${TAG} -o yt-spammer.tar.gz -sudo -u $USER tar -xzf yt-spammer.tar.gz +tar -xzf yt-spammer.tar.gz rm yt-spammer.tar.gz cd YouTube-Spammer-Purge-${TAG}/' -sudo -u $USER bash -c "pip install -r requirements.txt" +bash -c "pip install -r requirements.txt" printf "Dependencies and Program installed!\nNow follow these instructions to get a client_secrets.json file!\nhttps://github.com/ThioJoe/YouTube-Spammer-Purge#instructions---obtaining-youtube-api-key\n" diff --git a/install_full.sh b/install_full.sh index fb550536..77498a24 100755 --- a/install_full.sh +++ b/install_full.sh @@ -1,21 +1,15 @@ #!/bin/bash -command -v jq >/dev/null 2>&1 || { JQ=0;} -command -v python3 >/dev/null 2>&1 || { PY=0;} -command -v python >/dev/null 2>&1 || { PY=0;} -if [ "${EUID}" -ne 0 ]; then - echo "You need to run this script as root." - exit 1 -fi +command -v jq >/dev/null 2>&1 || { JQ=0; } #install python -if [[ $PY -ne 0 ]]; then +if ! command -v python3 &> /dev/null; then if [[ -e /etc/debian_version ]]; then - apt install python3 + sudo apt install python3 elif [[ -e /etc/fedora-release ]]; then - dnf install python3 + sudo dnf install python3 elif [[ -e /etc/centos-release ]]; then - yum install -y python3 + sudo yum install -y python3 elif [[ -e /etc/arch-release ]]; then - pacman -Sy python3 + sudo pacman -Sy python3 else echo "Looks like you aren't running this installer on a Debian, Ubuntu, Fedora, CentOS, or Arch Linux system." exit 1 @@ -26,15 +20,15 @@ fi #install tkinter, a dependency #install jq, needed to get version number if [[ -e /etc/debian_version ]]; then - apt install python3-tk jq + sudo apt install python3-tk jq elif [[ -e /etc/fedora-release ]]; then - dnf install python3-tkinter jq + sudo dnf install python3-tkinter jq elif [[ -e /etc/centos-release ]]; then - yum install -y tkinter epel-release jq + sudo yum install -y tkinter epel-release jq elif [[ -e /etc/arch-release ]]; then - pacman -Sy tk jq + sudo pacman -Sy tk jq fi -command -v pip >/dev/null 2>&1 || { sudo -u $USER curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py; sudo -u $USER python3 get-pip.py --no-warn-script-location; rm get-pip.py; } +command -v pip >/dev/null 2>&1 || { curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py; python3 get-pip.py --no-warn-script-location; rm get-pip.py; } TAG=$(curl https://api.github.com/repos/ThioJoe/YT-Spammer-Purge/releases/latest -s | jq .name -r) if [[ $JQ -ne 0 ]]; then if [[ -e /etc/debian_version ]]; then @@ -51,8 +45,8 @@ else fi # Uncomment if running this script alone, to also install the files for Youtube-Spammer-Purge curl https://codeload.github.com/ThioJoe/YT-Spammer-Purge/tar.gz/refs/tags/v${TAG} -o yt-spammer.tar.gz -sudo -u $USER tar -xzf yt-spammer.tar.gz +tar -xzf yt-spammer.tar.gz rm yt-spammer.tar.gz cd YouTube-Spammer-Purge-${TAG}/ -sudo -u $USER bash -c "pip install -r requirements.txt" +bash -c "pip install -r requirements.txt" printf "Dependencies and Program installed!\nNow follow these instructions to get a client_secrets.json file!\nhttps://github.com/ThioJoe/YouTube-Spammer-Purge#instructions---obtaining-youtube-api-key\n"