Last active
December 13, 2021 12:13
-
-
Save em-piguet/4ace59fdbcbc74cbcb14064dd90fadb4 to your computer and use it in GitHub Desktop.
Update Civi in Worpress
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
#!/bin/bash | |
################################################ | |
## | |
## Update CIVI plugin in Wordpress | |
## | |
## this script is called via | |
## $ ssh [email protected] 'bash -s -- sites/folder 5.41.0 SiteName' < civi-update.sh | |
## | |
################################################ | |
shopt -s expand_aliases | |
###################################################### | |
## security check | |
###################################################### | |
if [ ! -f ~/.bashrc ]; then | |
printf -- '\033[41m .bashrc must exist. abord. \033[0m\n' | |
exit 1 | |
fi | |
source ~/.bashrc | |
###################################################### | |
## VARS | |
###################################################### | |
civi_folder=$1 # "sites/stage/" | |
civi_version=$2 # "5.11.0" | |
civi_name=$3 # "YOUR NAME" | |
###################################################### | |
## UPDATE | |
###################################################### | |
civi_update (){ | |
# get the folder | |
cd $civi_folder/wp-content/plugins | |
# DL main plugin | |
wget https://download.civicrm.org/civicrm-$civi_version-wordpress.zip | |
# DL l10n | |
wget https://download.civicrm.org/civicrm-$civi_version-l10n.tar.gz | |
# clear cache civi | |
cv flush | |
# put the site into maintenance mode | |
wp maintenance-mode activate | |
# setup backup folder | |
mkdir -p civicrm-backup-tmp/$civi_version | |
cd civicrm-backup-tmp/$civi_version | |
# save db | |
wp db export | |
cd ../.. | |
# move actual plugin to the tmp folder | |
mv civicrm civicrm-backup-tmp/$civi_version | |
#rm -rf civicrm | |
# unzip the new version | |
unzip civicrm-$civi_version-wordpress.zip | |
# unzip the new l10n | |
tar -xzf civicrm-$civi_version-l10n.tar.gz | |
#copy sql & l10n content to the civicrm folder | |
cp -R civicrm/sql/* civicrm/civicrm/sql | |
cp -R civicrm/l10n civicrm/civicrm/l10n | |
#remove sql folder | |
rm -r civicrm/sql | |
# remove the downloaded files to save disk space | |
rm civicrm-$civi_version-wordpress.zip | |
rm civicrm-$civi_version-l10n.tar.gz | |
# remove maintenance | |
wp maintenance-mode deactivate | |
# upgrade db | |
cv upgrade:db | |
# upgrade bundled extension | |
cv ext:upgrade-db | |
# clear civi cache | |
cv flush | |
# check plugin status | |
wp plugin get civicrm | |
# clear wp cache | |
wp cache flush | |
echo -e '\e[93m=============================================\033[0m' | |
echo -e '\e[93m' $civi_name '\e[92m -> \033[32m UPGRADE END !\033[0m' | |
echo -e '\e[93m=============================================\033[0m' | |
exit | |
} | |
civi_update |
I would also add to line 78
cv ext:upgrade-db
to update bundled extensions.
Nice thank you, gist updated.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would also add to line 78
cv ext:upgrade-db
to update bundled extensions.