-
-
Notifications
You must be signed in to change notification settings - Fork 729
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix script/setup by making it less clever
Now we ask the dev to create the "ofn" user as precondition. This is way easier than developing a script that fits all possible setups. It also stops requiring a particlar Postgres version. Although in production we use 9.5 it is very unlikely we will use any version-specific feature in the near future. This should make it a bit easier for new devs to set up their environment.
- Loading branch information
1 parent
23964b2
commit 14480b9
Showing
2 changed files
with
18 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
#!/usr/bin/env sh | ||
|
||
# Set up Rails app. Run this script immediately after cloning the codebase. | ||
# | ||
# First, you need to create the database user the app will use by manually | ||
# typing the following in your terminal: | ||
# | ||
# $ sudo -u postgres psql -c "CREATE USER ofn WITH SUPERUSER CREATEDB PASSWORD 'f00d'" | ||
# | ||
# This will create the "ofn" user as superuser and allowing it to create | ||
# databases. | ||
|
||
# Exit if any command fails | ||
set -e | ||
|
@@ -11,10 +19,6 @@ NO_COLOR='\033[0m' | |
|
||
RUBY_VERSION=$(cat .ruby-version) | ||
NODE_VERSION=$(cat .node-version) | ||
POSTGRESQL_VERSION='9.5' | ||
|
||
DB_USER='ofn' | ||
DB_PASSWORD='f00d' | ||
|
||
# Check ruby version | ||
if ! ruby --version | grep $RUBY_VERSION > /dev/null; then | ||
|
@@ -27,12 +31,6 @@ if ! node --version | grep $NODE_VERSION > /dev/null; then | |
printf "${RED}Open Food Network requires node ${NODE_VERSION}${NO_COLOR}. Have a look at: https://github.com/nodenv/nodenv\n" | ||
fi | ||
|
||
# Check postgresql version | ||
if ! psql -V | grep $POSTGRESQL_VERSION > /dev/null; then | ||
printf "${RED}Open Food Network requires postgresql ${POSTGRESQL_VERSION}${NO_COLOR}\n" | ||
exit 1 | ||
fi | ||
|
||
# Set up Ruby dependencies via Bundler | ||
if ! command -v bundle > /dev/null; then | ||
gem install bundler | ||
|
@@ -48,11 +46,6 @@ if [ ! -f config/application.yml ]; then | |
printf "${YELLOW}Copied config/application.yml Make sure to fill it with the appropriate configuration values.\n\n${NO_COLOR}" | ||
fi | ||
|
||
# Create the development database user | ||
if ! psql -c '\du' -t | grep $DB_USER > /dev/null; then | ||
psql -c "CREATE USER ${DB_USER} WITH SUPERUSER PASSWORD '${DB_PASSWORD}';" | ||
fi | ||
|
||
# Set up the database for both development and test | ||
# Confirming the default user and password Spree prompts | ||
printf '\n\n' | bundle exec rake db:setup db:test:prepare | ||
|
@@ -65,7 +58,7 @@ printf '\n' | |
printf "${YELLOW}WELCOME TO OPEN FOOD NETWORK!\n" | ||
printf '\n' | ||
|
||
printf "To login as Spree default user, use:" | ||
printf "To login as the Spree default user, use:" | ||
printf '\n' | ||
printf '\n' | ||
printf ' email: [email protected]\n' | ||
|