From 7e64b143dbb9fbd2d441ea3fc9534107b844f87d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=83=E4=BD=8F=E6=9F=B1=E9=96=93?= Date: Sat, 6 Apr 2024 05:08:55 +0000 Subject: [PATCH] Upload files to "misc/scripts" --- misc/scripts/forgejo.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 misc/scripts/forgejo.sh diff --git a/misc/scripts/forgejo.sh b/misc/scripts/forgejo.sh new file mode 100644 index 0000000..6630dc3 --- /dev/null +++ b/misc/scripts/forgejo.sh @@ -0,0 +1,27 @@ +EXEC_SHELL_PATH=$(command -v bash) + +# Define the forgejo folder and log file path +FORGEJO_FOLDER="/mnt/Data/forgejo/" +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" > "$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