Check if running as root
- Added a check to see if the script is running as root to some of the scripts.
User will be prompted to confirm if they want to continue running as root.
Change-Id: If535945002f0e2fb58417388036373c0d5f69dfd
diff --git a/scripts/common/utils.sh b/scripts/common/utils.sh
index 0eaf0f8..7034685 100644
--- a/scripts/common/utils.sh
+++ b/scripts/common/utils.sh
@@ -77,3 +77,18 @@
mv ${temp} ${conf}
}
+
+# Confirm user whether to continue if running as root.
+function confirm-if-root {
+ if [ "`whoami`" == "root" ]; then
+ echo "This script should not be run as root. Are you sure you want to continue?[y/N]"
+ local key
+ read key
+ if [ "${key}" == "Y" -o "${key}" == "y" ]; then
+ echo "Continue running as root."
+ else
+ echo "Exiting script"
+ exit 1
+ fi
+ fi
+}