-
Notifications
You must be signed in to change notification settings - Fork 1
/
setupdb.sh
executable file
·54 lines (49 loc) · 2.3 KB
/
setupdb.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
BASEDIR=`dirname $0`
MYSQL="/usr/bin/mysql"
MYSQLADMIN="/usr/bin/mysqladmin"
CRYPT="php -f $BASEDIR/magento_crypt.php"
DBUSER="myuser"
DBPASS="mypass"
DBNAME="magento"
UNSECUREURL="http://magento.host.com/"
SECUREURL="https://magento.host.com/"
if [ $# -lt 1 ]; then
echo "Usage: setupdb.sh gzipdbsnapshot.gz"
exit 1
fi;
echo "Dropping database $DBNAME in 5s, hit control-c NOW to abort!"
sleep 5;
echo "Importing DB from: $1"
$MYSQLADMIN -u$DBUSER -p$DBPASS -f drop $DBNAME
$MYSQLADMIN -u$DBUSER -p$DBPASS -f create $DBNAME
gunzip -c $1 | $MYSQL -u$DBUSER -p$DBPASS $DBNAME
QUERIES=(
"UPDATE core_config_data SET value = '$UNSECUREURL' WHERE path = 'web/unsecure/base_url'"
"UPDATE core_config_data SET value = '$SECUREURL' WHERE path = 'web/secure/base_url'"
# use test fedex account details
"UPDATE core_config_data SET value='1' WHERE path='carriers/fedex/test_mode'"
"UPDATE core_config_data SET value='`$CRYPT mykey`' WHERE path='carriers/fedex/key'"
"UPDATE core_config_data SET value='`$CRYPT mypass`' WHERE path='carriers/fedex/password'"
"UPDATE core_config_data SET value='`$CRYPT mymeterno`' WHERE path='carriers/fedex/meter'"
"UPDATE core_config_data SET value='`$CRYPT myacctno`' WHERE path='carriers/fedex/account'"
"UPDATE core_config_data SET value = 1 WHERE path = 'carriers/fedex/debug'"
# use test auth.net account details
"UPDATE core_config_data SET value='`$CRYPT mylogin`' WHERE path='payment/authorizenet/login'"
"UPDATE core_config_data SET value='`$CRYPT mypass`' WHERE path='payment/authorizenet/trans_key'"
"UPDATE core_config_data SET value='https://test.authorize.net/gateway/transact.dll' WHERE path='payment/authorizenet/cgi_url'"
# use test usaepay account details
"UPDATE core_config_data SET value='mysrckey' WHERE path='payment/usaepay/sourcekey'"
"UPDATE core_config_data SET value='mypin' WHERE path='payment/usaepay/sourcepin'"
"UPDATE core_config_data SET value = 1 WHERE path='payment/usaepay/sandbox'"
# disable caching
"UPDATE core_cache_option SET value = 0"
"TRUNCATE core_cache"
# enable logging
"UPDATE core_config_data SET value = 1 WHERE path = 'dev/log/active'"
)
echo "Setting DB test defaults"
for QUERY in "${QUERIES[@]}"; do
echo $QUERY | $MYSQL -u$DBUSER -p$DBPASS $DBNAME
done
echo "Done"