-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbia_replace_script.sh
executable file
·29 lines (26 loc) · 1.79 KB
/
bia_replace_script.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
#!/usr/bin/env bash
BIA_HOSTNAME=$1
BIA_SITENAME=$2
#pushd /var/aegir/platforms/obiaa-staging/sites/bia1.mainstreetrm.com/
#wp db export obiaa_backup.sql
#nano obiaa_backup.sql
#popd
pushd /var/aegir/platforms/obiaa/sites/$1
CIVICRM_CREDS=`wp civicrm db connect`
cat /var/aegir/platforms/obiaa-staging/sites/bia1.mainstreetrm.com/biastarterdb.sql | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' | $CIVICRM_CREDS
echo "UPDATE civicrm_setting SET value = 's:38:\"/var/aegir/platforms/obiaa/wp-load.php\";' WHERE name='wpLoadPhp'" | $CIVICRM_CREDS
# Replace URLs with the new domain
wp search-replace --all-tables-with-prefix 'bia1.mainstreetrm.com' $BIA_HOSTNAME
wp civicrm api system.flush
# Remove all contacts that aren't for user accounts or the domain contact
echo "DELETE FROM civicrm_contact WHERE id NOT IN (SELECT contact_id FROM civicrm_uf_match) AND id NOT IN (SELECT contact_id FROM civicrm_domain)" | $CIVICRM_CREDS
echo "DELETE FROM civicrm_unit" | $CIVICRM_CREDS
echo "DELETE FROM civicrm_property" | $CIVICRM_CREDS
# Update Domain Contact with correct information.
wp civicrm api contact.create organization_name="My Bia $2" id=1 contact_type='Organization' contact_sub_type='BIA'
echo "UPDATE civicrm_option_value ov INNER JOIN civicrm_option_group og ON og.id = ov.option_group_id SET ov.label = '\"$2\" <info@$1>', ov.name = '\"$2\" <info@$1>' WHERE ov.is_default= 1 AND og.name = 'from_email_address'" | $CIVICRM_CREDS
echo "DELETE ov.* FROM civicrm_option_value ov INNER JOIN civicrm_option_group og ON og.id = ov.option_group_id WHERE ov.value IN ('Bakeries', 'Dine', 'Miscellaneous', 'Shoppe', 'Sip', 1) AND og.name = 'Business_Category_Child_Class_Unique'" | $CIVICRM_CREDS
# update site title
wp option update blogname $2
popd
#rm /var/aegir/platforms/obiaa-staging/sites/bia1.mainstreetrm.com/obiaa_backup.sql