Files
kjv_api/install.sh
T
2024-11-22 20:06:33 -08:00

57 lines
1.9 KiB
Bash
Executable File

#!/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 python3-dotenv curl
echo "Creating new user kjv with no login shell"
useradd -r -s /bin/false kjv
echo "Creating destination directory: /opt/kjv-api"
mkdir /opt/kjv-api
echo "Copying server files to /opt/kjv-api"
cp -r "${script_dir}"/. /opt/kjv-api
echo "Setting ownership to kjv user"
chown -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 "Waiting for the service to initialize"
sleep 3
echo "If you see a random Bible verse below in json format, your installation was successful:"
echo
echo
curl -XGET 127.0.0.1:1611/random
echo
echo
YEL='\033[0;33m'
NC='\033[0m' # No Color
echo -e "${YEL}You must now set your webserver as a reverse proxy for your domain and point it to 127.0.0.1:1611 ${NC}"
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 /opt/kjv-api/html/. There's no fancy libraries."
echo " - Logs are located in two places (application logs and uwsgi logs)."
echo " - /opt/kjv-api/logs/"
echo " - journalctl -e -u kjv-api.service"
echo " - If this install failed (you didn't get a Bible verse above) - try running /opt/kjv-api/kjv-api-test.sh"
echo " after stopping the kjv-api.service with systemctl, it should give you a traceback in your console."