Last active
April 19, 2022 04:10
-
-
Save MattLoyeD/f910bf052f7371eb35810f9aac0e0d55 to your computer and use it in GitHub Desktop.
Update & Deploy tool for wordpress installations
This file contains hidden or 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/sh | |
# Use it as sudoer for better results, not optimal I know | |
# Usage : cd /path && sudo sh wp-tools.sh deploy|update|push | |
# Deploy will go to dir and make databases updates along with chmod after git pull | |
# Update will update all components inside the wp install | |
# Push will create a commit and push it to origin/master | |
# Verify if wp cli is installed, installing if not | |
WP_FILE=/usr/local/bin/wp | |
if [ -f "$WP_FILE" ]; then | |
echo "$WP_FILE exists."; | |
echo "trying update the tool"; | |
sudo wp cli update --allow-root; | |
else | |
echo "trying to install WP tool as it's not on the system already"; | |
sudo curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar; | |
sudo chmod +x wp-cli.phar; | |
sudo mv wp-cli.phar /usr/local/bin/wp; | |
fi | |
# Check if worked and then use methods | |
if [ -f "$WP_FILE" ]; then | |
if [ $1 = "deploy" ]; then | |
sudo git pull origin master && sudo chmod 777 -R wp-content; | |
sudo wp core update-db --allow-root && sudo wp wc update --allow-root; | |
fi | |
if [ $1 = "update" ]; then | |
sudo wp plugin update --all --allow-root; | |
sudo wp core update --allow-root; | |
sudo wp core update-db --allow-root; | |
sudo wp theme update --all --allow-root; | |
sudo wp core language update --allow-root; | |
sudo wp language theme update --all --allow-root; | |
sudo wp language plugin update --all --allow-root; | |
fi | |
if [ $1 = "push" ]; then | |
sudo chmod 777 -R wp-content; | |
sudo git add -A; | |
sudo git commit; | |
sudo git push origin master; | |
fi | |
else | |
# WP tool not here, thats a bit sad | |
echo "No WP Cli installed, could not install it as well it seems"; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Update 19/04/22 :