From 3390d07dbba383cbdb3f4b2c8b24117e6cde4ba1 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Wed, 27 Apr 2022 18:28:42 +0200 Subject: [PATCH] created check for root permissions --- configure.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/configure.sh b/configure.sh index bde154a..09349f3 100644 --- a/configure.sh +++ b/configure.sh @@ -3,14 +3,20 @@ # Get linux distro DISTRO=$(lsb_release -is) +if [[ $(id -u) != "0" ]] && [[ $1 != "force" ]]; then + echo "You must run this script as root! (To skip this, run with 'force' arg: \"./configure.sh force\")" + exit +fi + # Get COMMAND if [[ $DISTRO == "Arch" ]]; then - COMMAND="sudo pacman -S --needed json-c curl" + COMMAND="pacman -S --needed json-c curl" elif [[ $DISTRO == "Ubuntu" ]] || [[ $DISTRO == "Debian" ]]; then - COMMAND="sudo apt install libjson-c3 curl" + COMMAND="apt install libjson-c3 curl" else # 'Unsupported' distro echo "It seems you are using unsupported distribution... Don't worry, just install https://github.com/json-c/json-c (+ CURL if you haven't installed it already) and you'll be fine." + exit fi # Execute COMMAND