From 2f5c6b7e82eaf889ba9e3b8e06511a8d6de57cf7 Mon Sep 17 00:00:00 2001 From: bol-van Date: Thu, 23 Dec 2021 21:03:52 +0300 Subject: [PATCH] more compatible require_root --- blockcheck.sh | 6 ++++-- install_easy.sh | 6 ++++-- uninstall_easy.sh | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/blockcheck.sh b/blockcheck.sh index 7e969c6..a4b4940 100755 --- a/blockcheck.sh +++ b/blockcheck.sh @@ -87,11 +87,13 @@ ask_yes_no_var() require_root() { + local exe echo \* checking privileges [ $(id -u) -ne "0" ] && { echo root is required - exists sudo && exec sudo "$0" - exists su && exec su -c "$0" + exe="$EXEDIR/$(basename "$0")" + exists sudo && exec sudo "$exe" + exists su && exec su root -c "$exe" echo su or sudo not found exitp 2 } diff --git a/install_easy.sh b/install_easy.sh index 0ba092f..58083f9 100755 --- a/install_easy.sh +++ b/install_easy.sh @@ -55,11 +55,13 @@ exitp() require_root() { + local exe echo \* checking privileges [ $(id -u) -ne "0" ] && { echo root is required - exists sudo && exec sudo "$0" - exists su && exec su -c "$0" + exe="$EXEDIR/$(basename "$0")" + exists sudo && exec sudo "$exe" + exists su && exec su root -c "$exe" echo su or sudo not found exitp 2 } diff --git a/uninstall_easy.sh b/uninstall_easy.sh index 018e262..22815c0 100755 --- a/uninstall_easy.sh +++ b/uninstall_easy.sh @@ -33,11 +33,13 @@ exitp() require_root() { + local exe echo \* checking privileges [ $(id -u) -ne "0" ] && { echo root is required - exists sudo && exec sudo "$0" - exists su && exec su -c "$0" + exe="$EXEDIR/$(basename "$0")" + exists sudo && exec sudo "$exe" + exists su && exec su root -c "$exe" echo su or sudo not found exitp 2 }