summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIru Cai <mytbk920423@gmail.com>2016-08-06 11:07:47 +0800
committerIru Cai <mytbk920423@gmail.com>2016-08-06 11:07:47 +0800
commitf56d7904f6fab99a0e2774828ba1858d77af042f (patch)
tree152c22511e12f0fac5620e43b5a7f36435600be5
parent8d002632ac4d9bea79396651faf87d55432d3e02 (diff)
downloadliveusb-builder-f56d7904f6fab99a0e2774828ba1858d77af042f.tar.xz
functions.sh: add as-root function
-rw-r--r--functions.sh10
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
+}