created check for root permissions

This commit is contained in:
Václav Šmejkal 2022-04-27 18:28:42 +02:00
parent 4772e7ae6f
commit 3390d07dbb

View File

@ -3,14 +3,20 @@
# Get linux distro # Get linux distro
DISTRO=$(lsb_release -is) 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 # Get COMMAND
if [[ $DISTRO == "Arch" ]]; then 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 elif [[ $DISTRO == "Ubuntu" ]] || [[ $DISTRO == "Debian" ]]; then
COMMAND="sudo apt install libjson-c3 curl" COMMAND="apt install libjson-c3 curl"
else else
# 'Unsupported' distro # '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." 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 fi
# Execute COMMAND # Execute COMMAND