Skip to content

Commit 64972e6

Browse files
committed
Add scripts for production, README
1 parent 1c12ed4 commit 64972e6

File tree

7 files changed

+100
-9
lines changed

7 files changed

+100
-9
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ PYTHON = python3
22
FLASK = flask
33
SQLITE = sqlite3
44

5-
default: test
5+
default: install
66

77
test::
88
test/all.sh
99

10+
install:: venv
11+
. ./venv/bin/activate && pip3 install -r requirements.txt
12+
1013
venv:
1114
$(PYTHON) -m venv $@
1215

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Agreper - minimal, no-JS forum software
2+
3+
Agreper is a forum board with a focus on being easy to set up and manage.
4+
5+
## Features
6+
7+
## Install & running
8+
9+
### Linux
10+
11+
First clone or [download the latest release](todo).
12+
13+
Then setup with:
14+
15+
```
16+
make
17+
./init_sqlite.sh forum.db
18+
```
19+
20+
Lastly, run with:
21+
22+
```
23+
./run_sqlite.sh forum.db forum.pid
24+
```
25+
26+
You will need a proxy such as nginx to access the forum on the public internet.

init_sqlite.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ PYTHON=python3
55

66
set -e
77

8-
if [ $# != 1 ]
8+
if [ $# -le 1 ]
99
then
10-
echo "Usage: $0 <file>" >&2
10+
echo "Usage: $0 <file> [--no-admin]" >&2
1111
exit 1
1212
fi
1313

@@ -17,8 +17,11 @@ then
1717
exit 1
1818
fi
1919

20-
read -p 'Admin username: ' username
21-
read -sp 'Admin password: ' password
20+
if [ "$2" != --no-admin ]
21+
then
22+
read -p 'Admin username: ' username
23+
read -sp 'Admin password: ' password
24+
fi
2225

2326
password=$($PYTHON tool.py password "$password")
2427
time=$($PYTHON -c 'import time; print(time.time_ns())')

requirements.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
argon2-cffi==21.3.0
2+
argon2-cffi-bindings==21.2.0
3+
cffi==1.15.1
4+
click==8.1.3
5+
Flask==2.2.2
6+
gunicorn==20.1.0
7+
importlib-metadata==5.0.0
8+
itsdangerous==2.1.2
9+
Jinja2==3.1.2
10+
MarkupSafe==2.1.1
11+
passlib==1.7.4
12+
pycparser==2.21
13+
Werkzeug==2.2.2
14+
zipp==3.8.1

restart.sh

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
11
#!/usr/bin/env bash
22

3-
# This script is intended for dev environments only.
4-
touch main.py
3+
set -e
4+
5+
if [ -z "$SERVER" ]
6+
then
7+
echo "SERVER is not set" >&2
8+
exit 1
9+
fi
10+
11+
case "$SERVER" in
12+
dev)
13+
touch main.py
14+
;;
15+
gunicorn)
16+
if [ -z "$PID" ]
17+
then
18+
echo "PID is not set" >&2
19+
exit 1
20+
fi
21+
kill -hup $(cat "$PID")
22+
;;
23+
*)
24+
echo "Unsupported $SERVER" >&2
25+
exit 1
26+
;;
27+
esac

run_sqlite.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
if [ ! -e venv ]
6+
then
7+
echo "venv not found, did you run make?" >&2
8+
exit 1
9+
fi
10+
11+
if [ $# != 2 ]
12+
then
13+
echo "Usage: $0 <file.db> <pid file>" >&2
14+
exit 1
15+
fi
16+
17+
export DB="$1"
18+
export SERVER=gunicorn
19+
export PID="$2"
20+
exec gunicorn -w 4 'main:app' --pid="$PID" -b 0.0.0.0:8000

test/all.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ db=$tmp/forum.db
1515
. $base/../venv/bin/activate
1616

1717
# initialize db
18-
$base/../init_sqlite.sh $db
18+
$base/../init_sqlite.sh $db --no-admin
1919
$SQLITE $db < $base/init_db.txt
2020
cd $base/..
2121

22-
DB=$db $FLASK --app main --debug run
22+
export DB=$db
23+
export SERVER=dev
24+
$FLASK --app main --debug run

0 commit comments

Comments
 (0)