Require install script to run as root
@@ -19,6 +19,18 @@ CLI_ZIP="aws-greengrass-cli.zip"
CLI_DIR="cli-1.0-SNAPSHOT"
HTTP_JAR="aws-greengrass-http.jar"
+if [ "$(whoami)" != "root" ]; then
+ echo "You must run the installer as root"
+ echo "Suggestion: sudo $0 $@"
+ echo "Want us to run this for you? (y/n)"
+ read -r choice
+ case "$choice" in
+ y|Y) exec sudo "$0" "$@";;
+ *) echo "Quitting.";;
+ esac
+ exit 1
+fi
+
# make sure required file/directory exist
for i in $NUCLEUS_ZIP $CLI_ZIP $HTTP_JAR ; do
if [ ! -e $i ] ; then
@@ -57,9 +69,8 @@ if "$FRESH_INSTALL" && [ -d "$GG_ROOT_DIR" ]; then
esac
fi
-# Make the directory, if it fails, create it as root and then give us permissions
GG_INSTALL_DIR="$GG_ROOT_DIR"/first-install
-mkdir -p "$GG_INSTALL_DIR" 2>/dev/null || (sudo mkdir -p "$GG_INSTALL_DIR" && sudo chmod -R 777 "$GG_ROOT_DIR")
+mkdir -p "$GG_INSTALL_DIR"
# unzip
(unzip $CLI_ZIP && unzip $NUCLEUS_ZIP -d "$GG_INSTALL_DIR") || { echo "Install failed. Cannot unzip"; exit 1; }
