Commit 238203043f7510f8f378846bca150c64ae1ecec1

Authored by Aurélio A. Heckert
1 parent 103b7ebe

Right database.yml update on quick-start script

Closes ActionItem2856
Showing 1 changed file with 19 additions and 4 deletions   Show diff stats
script/quick-start
... ... @@ -67,10 +67,25 @@ else
67 67 fi
68 68  
69 69 # create the database with sample data
70   -run cp config/database.yml.pgsql config/database.yml
71   -sudo -u postgres createuser $USER --no-superuser --createdb --no-createrole
72   -sed -ri "s/username: noosfero/username: $USER/"
73   -sudo -u postgres createdb noosfero_development -O $USER
  70 +if test -e config/database.yml; then
  71 + say 'Not updating existent database.yml.'
  72 + say 'If you wish to automatic reconfigure your database connection, you can delete config/database.yml and run this script again.'
  73 +else
  74 + say 'Configuring Noosfero to use PostgreSQL, with your user.'
  75 + run cp config/database.yml.pgsql config/database.yml
  76 + sed -ri "s/username: noosfero/username: $USER/" config/database.yml
  77 + sudo -u postgres createuser $USER --no-superuser --createdb --no-createrole
  78 +fi
  79 +DB_USER="$(
  80 + grep username: config/database.yml | head -n1 | sed -r 's/.*:\s*([^ ]+).*/\1/'
  81 +)"
  82 +if test -n "$DB_USER"; then
  83 + say "DB user: $DB_USER"
  84 +else
  85 + say 'It looks like your database.yml have no user defined'
  86 + DB_USER=$USER
  87 +fi
  88 +sudo -u postgres createdb noosfero_development -O $DB_USER
74 89 run rake db:schema:load
75 90 run rake db:data:minimal
76 91 run rake db:test:prepare
... ...