-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating setup for db and web and added necessary magento (de)crypt i…
…mplemenation for writing encrypted config values
- Loading branch information
Showing
4 changed files
with
79 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
require_once '/path/to/running/mageinstall/app/Mage.php'; | ||
umask(0); | ||
$app = Mage::app('default'); | ||
$data = $_SERVER['argv'][1]; | ||
$obj = Mage::getModel('core/encryption'); | ||
$helper = Mage::helper('core'); | ||
$obj->setHelper($helper); | ||
echo $obj->encrypt($data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
require_once '/path/to/running/mageinstall/app/Mage.php'; | ||
umask(0); | ||
$app = Mage::app('default'); | ||
$data = $_SERVER['argv'][1]; | ||
$obj = Mage::getModel('core/encryption'); | ||
$helper = Mage::helper('core'); | ||
$obj->setHelper($helper); | ||
echo $obj->decrypt($data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,54 @@ | ||
#!/bin/bash | ||
|
||
BASEDIR=`dirname $0` | ||
MYSQLADMIN="/opt/local/bin/mysqladmin5" | ||
MYSQL="/usr/bin/mysql" | ||
MYSQLADMIN="/usr/bin/mysqladmin" | ||
CRYPT="php -f $BASEDIR/magento_crypt.php" | ||
MYSQL="/opt/local/bin/mysql5" | ||
USER="" | ||
PASS="" | ||
DBNAME="" | ||
DEVDBNAME="" | ||
BASEURL="" | ||
DEVBASEURL="" | ||
FEDEXKEY="" | ||
FEDEXPASSWORD="" | ||
FEDEXMETER="" | ||
FEDEXACCOUNT="" | ||
AUTHNETLOGIN="" | ||
AUTHNETTRANSKEY="" | ||
AUTHNETURL="" | ||
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 [dev]" | ||
echo "Usage: setupdb.sh gzipdbsnapshot.gz" | ||
exit 1 | ||
fi; | ||
|
||
if [ $# -eq 2 ]; then | ||
if [ $2 = "dev" ]; then | ||
DBNAME=$DEVDBNAME | ||
BASEURL=$DEVBASEURL | ||
fi; | ||
fi; | ||
|
||
echo "Dropping database $DBNAME in 5s, hit control-c NOW to abort!" | ||
sleep 5; | ||
|
||
echo "Importing DB from: $1" | ||
$MYSQLADMIN -u$USER -p$PASS -f drop $DBNAME | ||
$MYSQLADMIN -u$USER -p$PASS -f create $DBNAME | ||
gzcat $1 | $MYSQL -u$USER -p$PASS $DBNAME | ||
|
||
QUERY1="UPDATE core_config_data SET value = 'http://$BASEURL/store/' WHERE path = 'web/unsecure/base_url'" | ||
QUERY2="UPDATE core_config_data SET value = 'https://$BASEURL/store/' WHERE path = 'web/secure/base_url'" | ||
# use test fedex account details | ||
QUERY3="UPDATE core_config_data SET value='1' WHERE path='carriers/fedex/test_mode'" | ||
QUERY4="UPDATE core_config_data SET value='`$CRYPT $FEDEXKEY`' WHERE path='carriers/fedex/key'" | ||
QUERY5="UPDATE core_config_data SET value='`$CRYPT $FEDEXPASSWORD`' WHERE path='carriers/fedex/password'" | ||
QUERY6="UPDATE core_config_data SET value='`$CRYPT $FEDEXMETER`' WHERE path='carriers/fedex/meter'" | ||
QUERY7="UPDATE core_config_data SET value='`$CRYPT $FEDEXACCOUNT`' WHERE path='carriers/fedex/account'" | ||
# use test auth.net account details | ||
QUERY8="UPDATE core_config_data SET value='`$CRYPT $AUTHNETLOGIN`' WHERE path='payment/authorizenet/login'" | ||
QUERY9="UPDATE core_config_data SET value='`$CRYPT $AUTHNETTRANSKEY`' WHERE path='payment/authorizenet/trans_key'" | ||
QUERY10="UPDATE core_config_data SET value='$AUTHNETURL' WHERE path='payment/authorizenet/cgi_url'" | ||
$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 i in `seq 1 10`; do | ||
eval QUERY="\${QUERY${i}}" | ||
echo $QUERY | $MYSQL -u$USER -p$PASS $DBNAME | ||
for QUERY in "${QUERIES[@]}"; do | ||
echo $QUERY | $MYSQL -u$DBUSER -p$DBPASS $DBNAME | ||
done | ||
echo "Done" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,34 @@ | ||
#!/bin/bash | ||
|
||
USER="" | ||
PASS="" | ||
HOST="" | ||
DBNAME="" | ||
SNAPDBUSER="myremoteuser" | ||
SNAPDBPASS="myremotepass" | ||
SNAPDBHOST="myremotehost" | ||
SNAPDBNAME="myremotedbname" | ||
LOCALDBUSER="myuser" | ||
LOCALDBPASS="mypass" | ||
LOCALDBHOST="127.0.0.1" | ||
LCOCALDBNAME="magento" | ||
SED="/bin/sed" | ||
|
||
if [ $# -lt 2 ]; then | ||
echo "Usage: setupweb.sh bzip2websnapshot.tar.bz2 destination-dir" | ||
exit 1 | ||
fi; | ||
|
||
STORE="$2/store" | ||
STORE="$2" | ||
if [ ! -d $STORE ]; then | ||
echo "Destination directory does not exist, creating it..." | ||
mkdir $STORE | ||
fi | ||
|
||
rm -rf $STORE | ||
tar -C $2 -jxvf $1 | ||
rm -rf $STORE/var/* | ||
sed -i '' "s/$LIVEDBUSER/$USER/" $STORE/app/etc/local.xml | ||
sed -i '' "s/$LIVEDBPASS/$PASS/" $STORE/app/etc/local.xml | ||
sed -i '' "s/$LIVEDBHOST/$HOST/" $STORE/app/etc/local.xml | ||
sed -i '' "s/$LIVEDBNAME/$DBNAME/" $STORE/app/etc/local.xml | ||
sed -i '' "s/i:1/i:0/g" $STORE/app/etc/use_cache.ser | ||
# disable caching | ||
$SED -i'' "s/\(<dbname>.*\)$SNAPDBNAME/\\1$LOCALDBNAME/" $STORE/app/etc/local.xml | ||
$SED -i'' "s/\(<username>.*\)$SNAPDBUSER/\\1$LOCALDBUSER/" $STORE/app/etc/local.xml | ||
$SED -i'' "s/$SNAPDBPASS/$LOCALDBPASS/" $STORE/app/etc/local.xml | ||
chmod -R 777 $STORE/var/ $STORE/media/ $STORE/app/etc/ $STORE/media/downloadable/ | ||
# remove caching configuration | ||
perl -e 'while (<>) { $content .= $_; } $content =~ s#\s{8}<cache.*</cache>\n##s; print $content;' < $STORE/app/etc/local.xml > $STORE/app/etc/local.xml.tmp | ||
mv $STORE/app/etc/local.xml.tmp $STORE/app/etc/local.xml | ||
|
||
chmod -R 777 $STORE/app $STORE/var/ $STORE/media/ $STORE/app/etc/ $STORE/media/downloadable/ $STORE/media/import/ $STORE/app/etc/use_cache.ser | ||
# nuke var cache files which can cause issues | ||
rm -rf $STORE/var/cache |