install script and nginx example

This commit is contained in:
2024-11-22 19:04:42 -08:00
parent 8385487b82
commit fe908bfc43
2 changed files with 66 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
#!/bin/bash
# Check for root privileges
if [[ $EUID -ne 0 ]]; then
echo "This install script requires root privileges. Please run with sudo."
exit 1
fi
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
echo "Attempting to install dependancies"
apt install python3-flask sqlite3 libhunspell-dev python3-hunspell uwsgi-core uwsgi-plugin-python3 python3-requests curl
echo "Creating new user kjv with no login shell"
useradd -r -s /bin/false kjv
echo "Copying server files to /opt/kjv-api"
mkdir /opt/kjv-api
cp -r "${script_dir}"/. /opt/kjv-api
echo "Setting ownership to kjv user"
chmod -R kjv:kjv /opt/kjv-api
echo "Installing systemd service task"
cp /opt/kjv-api/install/kjv-api.service /etc/systemd/system/kjv-api.service
echo "Enabling auto-start and starting kjv-api"
systemctl enable kjv-api.service
systemctl start kjv-api.service
echo "If you see a random Bible verse below in json format, your installation was successful:"
curl -XGET 127.0.0.1:1611/random
echo "You must now set your webserver as a reverse proxy for your domain and point it to 127.0.0.1:1611"
echo "See the `install` folder for example configuration files."
echo
echo "Notes:"
echo " - Thank you for running this software to bring the Bible to people."
echo " - You can change the pages (it's not fancy) in html/. There's no fancy libraries."
echo
+24
View File
@@ -0,0 +1,24 @@
server {
listen 80;
server_name domain.tld;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name domain.tld;
ssl_certificate /etc/letsencrypt/live/domain.tld/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/domain.tld/privkey.pem;  
location / {
proxy_pass http://127.0.0.1:1611;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;  
}
}