1 2 3 4 5 6 7 8 9 10 11 12 13 14
CHROOT_VERSION='v4' ## # usage : check_root ## orig_argv=("$0" "$@") check_root() { (( EUID == 0 )) && return if type -P sudo >/dev/null; then exec sudo -- "${orig_argv[@]}" else exec su root -c "$(printf ' %q' "${orig_argv[@]}")" fi }