aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCem Keylan <cem@ckyln.com>2020-01-10 10:06:23 +0300
committerCem Keylan <cem@ckyln.com>2020-01-10 10:06:23 +0300
commit950d0d97ba08584e89c276a8376eac20b4066099 (patch)
tree9fb8dfeb0aab91baa49ddd561001012825eb989e
parent6c0218395b01e77f247bfa9b9ae48d113a5aa627 (diff)
downloadmkrootfs-950d0d97ba08584e89c276a8376eac20b4066099.tar.gz
mkrootfs.sh: exit if the user doesn't have priviliges
-rwxr-xr-xmkrootfs.sh3
1 files changed, 3 insertions, 0 deletions
diff --git a/mkrootfs.sh b/mkrootfs.sh
index e7f8d95..7b91e61 100755
--- a/mkrootfs.sh
+++ b/mkrootfs.sh
@@ -11,6 +11,9 @@ die() { error "$1"; exit 1 ;}
ask() { printf "\033[1;33m== $1 ==\\n(y/N) "; read ans; case "$ans" in [Yy]*) return 0 ;; *) return 1 ;; esac ;}
+# Exit if the user is not root
+! [ "$(id -u)" -eq 0 ] && die "Please run as root"
+
# Let's get current working directory
BASEDIR="$PWD"