diff --git a/.gitignore b/.gitignore index 379c68f..0516714 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ __pycache__/ messages.txt .env .venv/ +*.log diff --git a/scripts/message-board b/scripts/message-board new file mode 100644 index 0000000..6b2bc43 --- /dev/null +++ b/scripts/message-board @@ -0,0 +1,49 @@ +#!/data/data/com.termux/files/usr/bin/bash + +APP_DIR="$HOME/storage/shared/Documents/repos/phone-message-board" +APP_FILE="$APP_DIR/app.py" +LOG_FILE="$APP_DIR/message-board.log" + +case "$1" in + start) + if pgrep -f "$APP_FILE" >/dev/null; then + echo "Message board already running." + exit 0 + fi + + cd "$APP_DIR" || exit 1 + nohup python app.py > "$LOG_FILE" 2>&1 & + echo "Message board started." + echo "Open: http://192.168.44.1:8080" + ;; + + stop) + pkill -f "$APP_FILE" && echo "Message board stopped." || echo "Message board was not running." + ;; + + restart) + pkill -f "$APP_FILE" 2>/dev/null + cd "$APP_DIR" || exit 1 + nohup python app.py > "$LOG_FILE" 2>&1 & + echo "Message board restarted." + echo "Open: http://192.168.44.1:8080" + ;; + + status) + if pgrep -f "$APP_FILE" >/dev/null; then + echo "Message board is running." + echo "Open: http://192.168.44.1:8080" + else + echo "Message board is stopped." + fi + ;; + + logs) + tail -n 50 "$LOG_FILE" + ;; + + *) + echo "Usage: message-board {start|stop|restart|status|logs}" + exit 1 + ;; +esac