diff options
author | Iru Cai <mytbk920423@gmail.com> | 2016-08-06 11:07:47 +0800 |
---|---|---|
committer | Iru Cai <mytbk920423@gmail.com> | 2016-08-06 11:07:47 +0800 |
commit | f56d7904f6fab99a0e2774828ba1858d77af042f (patch) | |
tree | 152c22511e12f0fac5620e43b5a7f36435600be5 /functions.sh | |
parent | 8d002632ac4d9bea79396651faf87d55432d3e02 (diff) | |
download | liveusb-builder-f56d7904f6fab99a0e2774828ba1858d77af042f.tar.xz |
functions.sh: add as-root function
Diffstat (limited to 'functions.sh')
-rw-r--r-- | functions.sh | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/functions.sh b/functions.sh index 3c05320..1ee9590 100644 --- a/functions.sh +++ b/functions.sh @@ -48,3 +48,13 @@ umount_iso() { getuuid() { lsblk -n -o UUID "$1" } + +as-root() { + if [ "$UID" == 0 ]; then + "$@" + elif type -p sudo > /dev/null; then + sudo "$@" + elif type -p su > /dev/null; then + su -c "$*" + fi +} |