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

Improvement suggestion for iventoy.sh #80

Open
EvilSupahFly opened this issue Aug 23, 2024 · 0 comments
Open

Improvement suggestion for iventoy.sh #80

EvilSupahFly opened this issue Aug 23, 2024 · 0 comments

Comments

@EvilSupahFly
Copy link

The iventoy.sh script is pretty handy, but rather than have it terminate if not being run as root, like this:

uid=$(id -u)
if [ $uid -ne 0 ]; then
    echo "Please use sudo or run the script as root."
    exit 1
fi

I suggest doing this instead:

# Check if script is being run as root, and if not,
# Call script with sudo and pass original arguments
[[ $EUID -ne 0 ]] && exec sudo "$0" "$@"

This way, if you didn't run as root, the script call sudo to prompt you for the password and re-run itself with all your original arguments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant