dserodio
6/1/2017 - 7:39 PM

Ensure that a script is executed as root

Ensure that a script is executed as root

#!/bin/bash

if [[ "$(id -u)" -ne 0 ]]; then
    sudo "$0" "$@"
    exit $?
fi