diff --git a/Makefile b/Makefile index 11e0a43..a9e9189 100644 --- a/Makefile +++ b/Makefile @@ -2,11 +2,14 @@ PYTHON = python3 FLASK = flask SQLITE = sqlite3 -default: test +default: install test:: test/all.sh +install:: venv + . ./venv/bin/activate && pip3 install -r requirements.txt + venv: $(PYTHON) -m venv $@ diff --git a/README.md b/README.md new file mode 100644 index 0000000..c446530 --- /dev/null +++ b/README.md @@ -0,0 +1,26 @@ +# Agreper - minimal, no-JS forum software + +Agreper is a forum board with a focus on being easy to set up and manage. + +## Features + +## Install & running + +### Linux + +First clone or [download the latest release](todo). + +Then setup with: + +``` +make +./init_sqlite.sh forum.db +``` + +Lastly, run with: + +``` +./run_sqlite.sh forum.db forum.pid +``` + +You will need a proxy such as nginx to access the forum on the public internet. diff --git a/init_sqlite.sh b/init_sqlite.sh index 040659d..65a8733 100755 --- a/init_sqlite.sh +++ b/init_sqlite.sh @@ -5,9 +5,9 @@ PYTHON=python3 set -e -if [ $# != 1 ] +if [ $# -le 1 ] then - echo "Usage: $0 " >&2 + echo "Usage: $0 [--no-admin]" >&2 exit 1 fi @@ -17,8 +17,11 @@ then exit 1 fi -read -p 'Admin username: ' username -read -sp 'Admin password: ' password +if [ "$2" != --no-admin ] +then + read -p 'Admin username: ' username + read -sp 'Admin password: ' password +fi password=$($PYTHON tool.py password "$password") time=$($PYTHON -c 'import time; print(time.time_ns())') diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..ec6b9e6 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,14 @@ +argon2-cffi==21.3.0 +argon2-cffi-bindings==21.2.0 +cffi==1.15.1 +click==8.1.3 +Flask==2.2.2 +gunicorn==20.1.0 +importlib-metadata==5.0.0 +itsdangerous==2.1.2 +Jinja2==3.1.2 +MarkupSafe==2.1.1 +passlib==1.7.4 +pycparser==2.21 +Werkzeug==2.2.2 +zipp==3.8.1 diff --git a/restart.sh b/restart.sh index b6023e3..fb84270 100755 --- a/restart.sh +++ b/restart.sh @@ -1,4 +1,27 @@ #!/usr/bin/env bash -# This script is intended for dev environments only. -touch main.py +set -e + +if [ -z "$SERVER" ] +then + echo "SERVER is not set" >&2 + exit 1 +fi + +case "$SERVER" in + dev) + touch main.py + ;; + gunicorn) + if [ -z "$PID" ] + then + echo "PID is not set" >&2 + exit 1 + fi + kill -hup $(cat "$PID") + ;; + *) + echo "Unsupported $SERVER" >&2 + exit 1 + ;; +esac diff --git a/run_sqlite.sh b/run_sqlite.sh new file mode 100755 index 0000000..34cce80 --- /dev/null +++ b/run_sqlite.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +set -e + +if [ ! -e venv ] +then + echo "venv not found, did you run make?" >&2 + exit 1 +fi + +if [ $# != 2 ] +then + echo "Usage: $0 " >&2 + exit 1 +fi + +export DB="$1" +export SERVER=gunicorn +export PID="$2" +exec gunicorn -w 4 'main:app' --pid="$PID" -b 0.0.0.0:8000 diff --git a/test/all.sh b/test/all.sh index 2f38407..691bcb7 100755 --- a/test/all.sh +++ b/test/all.sh @@ -15,8 +15,10 @@ db=$tmp/forum.db . $base/../venv/bin/activate # initialize db -$base/../init_sqlite.sh $db +$base/../init_sqlite.sh $db --no-admin $SQLITE $db < $base/init_db.txt cd $base/.. -DB=$db $FLASK --app main --debug run +export DB=$db +export SERVER=dev +$FLASK --app main --debug run