From a425b0fd9372a7d75ddd1bd34d9ab0c85a913744 Mon Sep 17 00:00:00 2001 From: Bernt Christian Egeland Date: Fri, 27 Oct 2023 21:05:01 +0200 Subject: [PATCH] add message if not executed with sudo --- install.ztnet/bash/ztnet.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/install.ztnet/bash/ztnet.sh b/install.ztnet/bash/ztnet.sh index 801a57b9..07c0e815 100755 --- a/install.ztnet/bash/ztnet.sh +++ b/install.ztnet/bash/ztnet.sh @@ -1,5 +1,11 @@ #!/bin/bash +# Check if the script is run as root (sudo) +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root (sudo). Exiting." + exit 1 +fi + # exit if any command fails set -e @@ -72,6 +78,7 @@ if ! command_exists openssl; then sudo apt install openssl -y fi + # Remove directories and then recreate the target directory rm -rf "$INSTALL_DIR" "$TARGET_DIR/.next" "$TARGET_DIR/prisma" "$TARGET_DIR/src" mkdir -p "$TARGET_DIR"