bluewind/scripts/install.sh

31 lines
805 B
Bash

#!/bin/bash
# Export the environment variables
if [ ! -f ".env" ]; then
echo "The .env file does not exist, please make a copy of default.env into .env and adjust its contents before proceeding."
exit 1
fi
export $(cat .env)
# Create new systemd file
touch /etc/systemd/system/bluewind.service
# Fill in the systemd file
echo -e """[Unit]
Description=Flask Application
After=multi-user.target
[Service]
Type=simple
ExecStart=$(pwd)/.venv/bin/python3 $(pwd)/main.py
Restart=always
Environment="FLASK_ADDRESS=$(echo $FLASK_ADDRESS)"
Environment="FLASK_URL=$(echo $FLASK_URL)"
[Install]
WantedBy=multi-user.target
""" > /etc/systemd/system/bluewind.service
# Reload systemd unit, start and enable the service
systemctl daemon-reload
systemctl enable bluewind.service
systemctl start bluewind.service