Files
web2.0-backend/setup.sh
2017-09-20 23:19:50 +03:00

76 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
echo "SIK WEB 2.0"
echo "This script will set up the environment for this project."
echo "========================================================="
echo "Dependencies: postgresql>9.5, python>3.5"
INTERACTIVE="true"
USE_NPM="true"
if [[ $* == *--no-input* ]]
then
INTERACTIVE="false"
fi
if [[ $* == *--no-npm* ]]
then
USE_NPM="false"
fi
$INTERACTIVE || (echo "Running in non-interactive mode." && env)
$INTERACTIVE && read -p "Are these programs installed? [y/n]" -n 1 -r || REPLY="y"
echo ""
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo "Please install the dependencies. Exiting."
exit 0
fi
$INTERACTIVE && read -p "Create user 'sik' in postgres (needs sudo) [y/n]?" -n 1 -r || REPLY="n"
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]
then
sudo -u postgres psql < "$PWD/scripts/db/init.sql"
fi
$INTERACTIVE && read -p "Is virtualenv activated? [y/n]" -n 1 -r || REPLY="y"
echo ""
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo "Please activate virtualenv first. Exiting."
exit 0
fi
$INTERACTIVE && read -p "Copy settings from template? [y/n]" -n 1 -r || REPLY="y"
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]
then
cp "$PWD/sikweb/settings-sample.py" "$PWD/sikweb/settings.py"
fi
$INTERACTIVE && read -p "Start setup? [y/n]" -n 1 -r || REPLY="y"
echo ""
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo "Exiting."
exit 0
fi
set -e
set -x
pip install -r requirements.txt
$USE_NPM && npm install
python manage.py migrate
python manage.py createdefaultadmin
set +e
set +x
echo "Done."
echo "Run 'python manage.py runserver 0.0.0.0:8000' to start the development server!"