Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify sudo check require it always. #183

Merged
merged 1 commit into from
Oct 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 4 additions & 16 deletions bin/armbian-configng
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ json_file="$lib_dir/config.ng.jobs.json"
# Load The Bash procedure Objects
json_data=$(<"$json_file")

# Check if help or doc otherwise run sudo -E
[[ $EUID != 0 ]] && exec sudo "$0" "$@"
#
# 'whiptail' is a simple dialog box utility that works well with Bash. It doesn't have all the features of some other dialog box utilities, but it does everything we need for this script.
[[ -x "$(command -v whiptail)" ]] && DIALOG="whiptail"
Expand Down Expand Up @@ -76,21 +78,11 @@ case "$1" in
exit 0
;;
"--doc")
if [[ $EUID != 0 ]]; then
generate_readme
exit 0
else
echo "Error: You must run this command as a normal user"
exit 1
fi
generate_readme
exit 0
;;
"--cmd")
INPUTMODE="cmd"
if [[ $EUID != 0 ]]; then
echo "Error: Requires root privileges. Please run as root or use sudo."
exit 1
fi

shift
if [[ -z "$1" || "$1" == "help" ]]; then
see_cmd_list
Expand All @@ -102,10 +94,6 @@ case "$1" in
exit 0
;;
"--api")
if [[ $EUID != 0 ]]; then
echo "Error: The --api option requires root privileges. Please run as root or use sudo."
exit 1
fi
shift
if [[ -z "$1" || "$1" == "help" ]]; then
see_use
Expand Down