EXEC_SHELL_PATH=$(command -v bash) # Define the forgejo folder and log file path FORGEJO_FOLDER="/mnt/Data/forgejo/" FORGEJO_CONFIG="/mnt/Data/forgejo/custom/conf/app.ini" LOG_SERVICE="/tmp/tunneling_service.log" LOG_FILE="/tmp/forgejo.log" # Create the log directory if it doesn't exist mkdir -p "$(dirname "$LOG_FILE")" mkdir -p "$(dirname "$LOG_SERVICE")" # Check if the hdd is mounted if [ ! -d "$FORGEJO_FOLDER" ]; then echo -e "\e[91mMount the hard drive first!\e[0m" exit 1 fi # Check if Forgejo is already running if pgrep -x "forgejo" > /dev/null; then echo "Forgejo is already running. Exiting." else # Run forgejo command, redirecting output to the log file and detaching it from the terminal setsid nohup forgejo -w "$FORGEJO_FOLDER" -c "$FORGEJO_CONFIG" > "$LOG_FILE" 2>&1 & setsid nohup ~/.local/bin/loophole http 3000 --hostname ajattix > "$LOG_SERVICE" 2>&1 & echo "Forgejo started and detached from the terminal." fi