Blame view

database/update/old/db-update-2017-05-23.sh 1.08 KB
2389dbd8   Thibaud Ajas   bugfixes lies au ...
1
2
3
#!/bin/bash

# Pour Mac OS recent (10.10, Yosemite), la syntaxe du SED est differente
4056b809   Etienne Pallier   petites modifs su...
4
5
# Il faut donc executer ce script comme ceci :
# ./macos-db-update.sh ce_script.sh
2389dbd8   Thibaud Ajas   bugfixes lies au ...
6
7
8
9
10
11
12
13
14
15
16
17
18
19

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)


4ba8486d   Etienne Pallier   regroupement de t...
20
cp -p ./script_sql/db-update-2017-05-23.sql ./script_sql/db-update-2017-05-23-build.sql
2389dbd8   Thibaud Ajas   bugfixes lies au ...
21
22

# Execute sql update script
4ba8486d   Etienne Pallier   regroupement de t...
23
24
sed -e "s/database/$database/" -i ./script_sql/db-update-2017-05-23-build.sql
mysql --user=$username --password=$password -h $host < ./script_sql/db-update-2017-05-23-build.sql
2389dbd8   Thibaud Ajas   bugfixes lies au ...
25
26
27
28
29
30
31
32

# 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