From: Frank Brehm Date: Wed, 22 Apr 2020 06:05:42 +0000 (+0200) Subject: Adding function check_for_root() X-Git-Tag: 0.1.2~5^2~6 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=54c91f756ca084b873ed985a029eb301cea814db;p=pixelpark%2Fadmin-tools.git Adding function check_for_root() --- diff --git a/lib/functions.rc b/lib/functions.rc index ae808a0..767201a 100644 --- a/lib/functions.rc +++ b/lib/functions.rc @@ -10,7 +10,7 @@ BLUE="" CYAN="" NORMAL="" -VERSION="0.2.0" +VERSION="0.3.0" STD_SHORT_OPTIONS="sdvhV" STD_LONG_OPTIONS="simulate,debug,verbose,nocolor,help,version" @@ -338,4 +338,14 @@ set_locale() { } +#------------------------------------------------------------------------------ +check_for_root() { + local my_id=$( id -u ) + if [[ "${my_id}" != "0" ]] ; then + error "You must be ${RED}root${NORMAL} to execute this script." + echo >&2 + exit 1 + fi +} + # vim: filetype=sh ts=4 et list