Skip to content

Commit

Permalink
Add scripts for production, README
Browse files Browse the repository at this point in the history
  • Loading branch information
Demindiro committed Oct 9, 2022
1 parent 1c12ed4 commit 64972e6
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 9 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 $@

Expand Down
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
11 changes: 7 additions & 4 deletions init_sqlite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ PYTHON=python3

set -e

if [ $# != 1 ]
if [ $# -le 1 ]
then
echo "Usage: $0 <file>" >&2
echo "Usage: $0 <file> [--no-admin]" >&2
exit 1
fi

Expand All @@ -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())')
Expand Down
14 changes: 14 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
27 changes: 25 additions & 2 deletions restart.sh
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions run_sqlite.sh
Original file line number Diff line number Diff line change
@@ -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 <file.db> <pid file>" >&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
6 changes: 4 additions & 2 deletions test/all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 64972e6

Please sign in to comment.