PXE
PXE copied to clipboard
Improvement suggestion for iventoy.sh
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.