diff --git a/libexec/handles-setup b/libexec/handles-setup index 7e18030..d3af4d1 100755 --- a/libexec/handles-setup +++ b/libexec/handles-setup @@ -15,15 +15,20 @@ elif [ -f "Rakefile" ] && bundle exec rake -T setup &>/dev/null; then exec bundle exec rake setup fi -PROJECT_NAME="${PWD/#${PROJECT_HOME:?}\//}" +PROJECT_NAME="${PWD#${PROJECT_HOME:?}\/}" if [ -f ".env.example" ]; then echo "==> Copying environment file…" cp .env.example .env fi +if [ -f "nginx.conf.erb" ]; then + echo "==> Generating nginx server configuration file…" + handles-setup-nginx-conf "${PROJECT_NAME//\//-}" +fi + if [ -f "manage.py" ]; then - echo "==> Preparing database…" + echo "==> Setting up database…" handles-setup-postgres-db "${PROJECT_NAME%/*}" pipenv run python manage.py migrate fi diff --git a/libexec/handles-setup-nginx-conf b/libexec/handles-setup-nginx-conf index 6c8b357..887ae5a 100755 --- a/libexec/handles-setup-nginx-conf +++ b/libexec/handles-setup-nginx-conf @@ -1,5 +1,5 @@ #!/bin/bash -# Usage: handles setup-nginx-conf [] +# Usage: handles setup-nginx-conf [] # Summary: Generate an nginx server configuration file # Hidden: true @@ -9,9 +9,9 @@ cd "$(git rev-parse --show-toplevel 2>/dev/null)" INPUT_FILE="${2-"nginx.conf.erb"}" OUTPUT_FILE="${PWD}/${INPUT_FILE//.erb}" -SERVER_NAME="$1" +PROJECT_NAME="$1" -if [ -z "$SERVER_NAME" ] || [ -z "$INPUT_FILE" ]; then +if [ -z "$PROJECT_NAME" ] || [ -z "$INPUT_FILE" ]; then handles help setup-nginx-conf >&2 exit 1 elif [ ! -f "$INPUT_FILE" ] || [[ "$INPUT_FILE" != *.erb ]]; then @@ -36,8 +36,8 @@ fi if [ "$(uname -s)" = "Darwin" ]; then BREWFILE=( - "brew 'launch_socket_server'" - "brew 'launchdns', restart_service: true" + 'brew "launch_socket_server"' + 'brew "launchdns", restart_service: true' ) PREFIX="$(brew --prefix)" @@ -62,7 +62,7 @@ if [ "$(uname -s)" = "Darwin" ]; then fi fi - SERVER_FILE="${PREFIX}/etc/nginx/servers/${SERVER_NAME}.conf" + SERVER_FILE="${PREFIX}/etc/nginx/servers/${PROJECT_NAME}.conf" if ! ln -sf "$OUTPUT_FILE" "$SERVER_FILE" &>/dev/null; then echo "!!! Error: failed to symlink ${OUTPUT_FILE} to ${SERVER_FILE}" >&2 exit 1