RASCSI/src/web/start.sh
Eric Helgeson 37f1166fd8
New Web Interface (#69)
* gitignore

* New Web Interface
Fixed spacing/tabs in easy install
Added migration check
Fix update web not actually updating

Migrating from https://github.com/erichelgeson/RaSCSI-web

* Allow user to select multiple types when creating images

* Show all devices even if nothing is attached.

* If attaching an iso to a cd device, dont detach, just insert

* UI feedback and restart rascsi service

* Check for any non-0 exit code for apache2 detection

* Pretty/informative 502

* Add confirms to some actions. Works in netscape 4.7

* Fix order of params for create_new_image

* Move non-route method to service

* Add method for getting logs

* Move settings to single file
add ability to mock commands for local dev
2020-12-30 19:39:32 -06:00

58 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
# set -x # Uncomment to Debug
cd $(dirname $0)
# verify packages installed
ERROR=0
if ! command -v genisoimage &> /dev/null ; then
echo "genisoimage could not be found"
echo "Run 'sudo apt install genisoimage' to fix."
ERROR=1
fi
if ! command -v python3 &> /dev/null ; then
echo "python3 could not be found"
echo "Run 'sudo apt install python3' to fix."
ERROR=1
fi
if ! python3 -m venv --help &> /dev/null ; then
echo "venv could not be found"
echo "Run 'sudo apt install python3-venv' to fix."
ERROR=1
fi
if ! command -v unzip &> /dev/null ; then
echo "unzip could not be found"
echo "Run 'sudo apt install unzip' to fix."
ERROR=1
fi
if [ $ERROR = 1 ] ; then
echo
echo "Fix errors and re-run ./start.sh"
exit 1
fi
if ! test -e venv; then
echo "Creating python venv for web server"
python3 -m venv venv
echo "Activating venv"
source venv/bin/activate
echo "Installing requirements.txt"
pip install -r requirements.txt
git rev-parse HEAD > current
fi
source venv/bin/activate
# Detect if someone updates - we need to re-run pip install.
if ! test -e current; then
git rev-parse > current
else
if [ "$(cat current)" != "$(git rev-parse HEAD)" ]; then
echo "New version detected, updating requirements.txt"
pip install -r requirements.txt
git rev-parse HEAD > current
fi
fi
echo "Starting web server..."
python3 web.py