Automating WordPress Upgrades with Shell Scripts

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 handle 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 *