summaryrefslogtreecommitdiff
path: root/lib/archroot.sh
blob: 7d7ab671bb6ffa17bda341ff3c2fc628ce2264c5 (plain)
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
}