#!/bin/bash ################################################################################ # # auto rebuild 'playdough' app # # This script can be used to automatically re-create from scratch, a new # app named 'playdough' - for sake of testing the cookiecutter template. # # IMPORTANT: To use this script, place a copy in the root of the # cookiecutter template source folder (~/src/cookiecutter-wuttaweb) # alongside the cookiecutter.json file. Name it `newapp.sh` and then # modify your copy of the script as needed. (See TODO comments below.) # # The script does the following: # - remove existing virtualenv and source code # - drop and recreate database # - make new virtualenv # - install cookiecutter # - make new source code via cookiecutter # - install new app # - run web app # ################################################################################ set -e # TODO: adjust paths as needed # nb. thanks to https://stackoverflow.com/a/246128 SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) SRC_DIR=$( dirname -- "${SCRIPT_DIR}" ) WORKON_HOME=/srv/envs # teardown rm -rf $WORKON_HOME/playdough rm -rf $SRC_DIR/playdough # database sudo -u postgres dropdb --if-exists playdough # TODO: adjust db owner as needed sudo -u postgres createdb -O playdough playdough # virtualenv python3 -m venv $WORKON_HOME/playdough cd $WORKON_HOME/playdough bin/pip install -U pip bin/pip install -U setuptools wheel bin/pip install -U cookiecutter # source bin/cookiecutter --no-input -o $SRC_DIR $SCRIPT_DIR \ full_name="Your Name" \ email="you@example.com" \ project_name="Playdough" \ project_short_description="My web app" \ open_source_license="Not open source" # install app bin/pip install -e $SRC_DIR/playdough bin/playdough install # serve web app bin/pserve --reload file+ini:app/web.conf