Blame view

database/update/db-update-2017-08-23.sh 1.34 KB
42c8c622   Etienne Pallier   update database f...
1
2
#!/bin/bash

20f1aa98   Etienne Pallier   bugfix script db ...
3
4
5
6
#myname=`basename $0 .sh`
myname=`basename $0`
myname=${myname%%.*}

42c8c622   Etienne Pallier   update database f...
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Pour Mac OS recent (10.10, Yosemite), la syntaxe du SED est differente
# Il faut donc faire une copie de ce fichier et transformer les instructions sed a l'interieur
# Pour cela, il suffit d'executer ces 2 lignes :
# cp ce_script.sh ce_script_macosx.sh
# sed -e "s/ -i / -i '' /" -i '' ce_script_macosx.sh

if [ ! -f ../../config/app.php ] ; then
echo "Vous devez executer ce script depuis le dossier database/update/"
exit 1
fi


# Get login, pass, dbname, and hostname
username=$(grep "/\*d\*/'username'" ../../config/app.php | cut -d"'" -f4)
password=$(grep "/\*d\*/'password'" ../../config/app.php | cut -d"'" -f4)
database=$(grep "/\*d\*/'database'" ../../config/app.php | cut -d"'" -f4)
host=$(grep "/\*d\*/'host'" ../../config/app.php | cut -d"'" -f4)


20f1aa98   Etienne Pallier   bugfix script db ...
26
27
#cp -p ./script_sql/db-update-2016-07-01-irap.sql ./script_sql/db-update-2016-07-01-irap-build.sql
cp -p ./script_sql/$myname.sql ./script_sql/$myname-build.sql
42c8c622   Etienne Pallier   update database f...
28
29

# Execute sql update script
20f1aa98   Etienne Pallier   bugfix script db ...
30
31
sed -e "s/database/$database/" -i ./script_sql/$myname-build.sql
mysql --user=$username --password=$password -h $host < ./script_sql/$myname-build.sql
42c8c622   Etienne Pallier   update database f...
32
33
34
35
36
37
38
39

# Delete cakephp cache
sudo rm ../../tmp/cache/models/*
sudo rm ../../tmp/cache/persistent/*

sudo chmod -R 777 ../../tmp
sudo chmod -R 777 ../../vendor
sudo chmod -R 777 ../../webroot