WordPress Automatic Upgrade Bash / Shell Script

Keeping your Wordpress up to date is a good practice as it allows you to promptly fix any vulnerabilities and prevent malicious attacks. Upgrading Wordpress is not a complicated process either; a single script can take care of it.

Exploit-db contains information on various WordPress vulnerabilities, so staying up-to-date with the latest version is a good habit.

Upgrading WordPress is not so difficult, it can be done with just one script.
bash upgradewp.sh

wget -c https://wordpress.org/latest.tar.gz
echo "Unzip the file"
gunzip latest.tar.gz
tar xvf latest.tar
echo "Remove latest.tar"
rm latest.tar
echo "Remove wordpress/wp-content/"
rm -rf wordpress/wp-content/

echo "Remove /app1/wp-includes/"
rm -rf /app1/wp-includes/
echo "Remove /app1/wp-admin/"
rm -rf /app1/wp-admin/

echo "Remove /app2/wp-includes/"
rm -rf /app2/wp-includes/
echo "Remove /app2/wp-admin/"
rm -rf /app2/wp-admin/

echo "cp -rf wordpress/* /app1/"
cp -rf wordpress/* /app1/
echo "cp -rf wordpress/* /app2/"
cp -rf wordpress/* /app2/

echo "Remove wordpress/"
rm -rf wordpress/

echo "Visit http://app1.com/wp-admin/upgrade.php"
curl --silent http://app1.com/wp-admin/upgrade.php -o /dev/null
echo "Visit http://app2.com/wp-admin/upgrade.php"
curl --silent http://app2.com/wp-admin/upgrade.php -o /dev/null

Leave a Reply

Your email address will not be published. Required fields are marked *