From 039015bafb72d2263e486549c9c1908cdb3b255c Mon Sep 17 00:00:00 2001 From: HelloDarkness <111370255+hellodarkness@users.noreply.github.com> Date: Fri, 7 Apr 2023 20:23:49 +0100 Subject: [PATCH] Added directory check to start scripts (#252) Fixes #218 --- scripts/start | 9 +++++++++ scripts/start_local | 8 ++++++++ scripts/start_with_tor | 8 ++++++++ 3 files changed, 25 insertions(+) diff --git a/scripts/start b/scripts/start index 10eee12..7d1d192 100755 --- a/scripts/start +++ b/scripts/start @@ -4,6 +4,15 @@ DOCKER_COMPOSE_FILE="${PROJECT_ROOT}/docker-compose.yml" NOSTR_CONFIG_DIR="${PROJECT_ROOT}/.nostr" SETTINGS_FILE="${NOSTR_CONFIG_DIR}/settings.yaml" DEFAULT_SETTINGS_FILE="${PROJECT_ROOT}/resources/default-settings.yaml" +CURRENT_DIR=$(pwd) + +if [[ ${CURRENT_DIR} =~ /scripts$ ]]; then + echo "Please run this script from the Nostream root folder, not the scripts directory." + echo "To do this, change up one directory, and then run the following command:" + echo "./scripts/start" + exit 1 +fi + if [ "$EUID" -eq 0 ] then echo "Error: Nostream should not be run as root." diff --git a/scripts/start_local b/scripts/start_local index 25b31a9..9322231 100755 --- a/scripts/start_local +++ b/scripts/start_local @@ -4,6 +4,14 @@ set -e PROJECT_ROOT="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))/.." DOCKER_COMPOSE_FILE="${PROJECT_ROOT}/docker-compose.yml" DOCKER_COMPOSE_LOCAL_FILE="${PROJECT_ROOT}/docker-compose.local.yml" +CURRENT_DIR=$(pwd) + +if [[ ${CURRENT_DIR} =~ /scripts$ ]]; then + echo "Please run this script from the Nostream root folder, not the scripts directory." + echo "To do this, change up one directory, and then run the following command:" + echo "./scripts/start" + exit 1 +fi if [ "$EUID" -eq 0 ] then echo "Error: Nostream should not be run as root." diff --git a/scripts/start_with_tor b/scripts/start_with_tor index 581734a..cb7f52b 100755 --- a/scripts/start_with_tor +++ b/scripts/start_with_tor @@ -6,6 +6,14 @@ TOR_DATA_DIR="$PROJECT_ROOT/.nostr/tor/data" NOSTR_CONFIG_DIR="${PROJECT_ROOT}/.nostr" SETTINGS_FILE="${NOSTR_CONFIG_DIR}/settings.yaml" DEFAULT_SETTINGS_FILE="${PROJECT_ROOT}/resources/default-settings.yaml" +CURRENT_DIR=$(pwd) + +if [[ ${CURRENT_DIR} =~ /scripts$ ]]; then + echo "Please run this script from the Nostream root folder, not the scripts directory." + echo "To do this, change up one directory, and then run the following command:" + echo "./scripts/start" + exit 1 +fi if [ "$EUID" -eq 0 ] then echo "Error: Nostream should not be run as root."