-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbefore_install.sh
39 lines (34 loc) · 1.12 KB
/
before_install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
#
# Inspired by ownCloud´s before_install.sh script <3
#
WORKDIR=$PWD
DB=$1
echo "Work directory: $WORKDIR"
echo "Database: $DB"
#
# set up mysql
#
if [ "$DB" == "mysql" ] ; then
echo "Setting up mysql ..."
mysql -u root -e "CREATE DATABASE userfrosting;"
mysql -u root -e "GRANT ALL ON userfrosting.* TO 'travis'@'localhost';"
printf "UF_MODE=\"testing\"\nDB_DRIVER=\"mysql\"\nDB_HOST=\"localhost\"\nDB_PORT=\"3306\"\nDB_NAME=\"userfrosting\"\nDB_USER=\"travis\"\nDB_PASSWORD=\"\"\n" > app/.env
fi
#
# set up pgsql
#
if [ "$DB" == "pgsql" ] ; then
echo "Setting up pgsql ..."
psql -c "CREATE DATABASE userfrosting;" -U postgres
psql -c "GRANT ALL PRIVILEGES ON DATABASE userfrosting TO postgres;" -U postgres
printf "UF_MODE=\"testing\"\nDB_DRIVER=\"pgsql\"\nDB_HOST=\"localhost\"\nDB_PORT=\"5432\"\nDB_NAME=\"userfrosting\"\nDB_USER=\"postgres\"\nDB_PASSWORD=\"\"\n" > app/.env
fi
#
# set up sqlite
#
if [ "$DB" == "sqlite" ] ; then
echo "Setting up sqlite ..."
touch userfrosting.db
printf "UF_MODE=\"testing\"\nDB_DRIVER=\"sqlite\"\nDB_NAME=\"userfrosting.db\"\n" > app/.env
fi