Skip to content

Instantly share code, notes, and snippets.

@zeisss
Created February 16, 2010 20:50
Show Gist options
  • Save zeisss/305908 to your computer and use it in GitHub Desktop.
Save zeisss/305908 to your computer and use it in GitHub Desktop.
#!/bin/sh
# This script performs an automated update of your wordpress blog.
# Please perform still some logical check (dbupdate, blog testing afterwards and so on)
# No error checking included!
WORKDIR=$HOME/public_html
BLOG_DIR=blog
WORDPRESS_URL=http://wordpress.org/latest.zip
OLD_BLOGDIR=blog-t`date +%Y%m%d`
echo This script tries to automatically update your wordpress software from bash
echo WORKDIR=$WORKDIR
echo BLOG_DIR=$BLOG_DIR
echo DOWNLOAD_URL=$WORDPRESS_URL
echo OLD_BLOGDIR=$OLD_BLOGDIR
echo
echo
cd $WORKDIR
wget $WORDPRESS_URL
unzip latest.zip
rm latest.zip
echo Wordpress should have been downloaded
echo and unpacked to $WORKDIR/wordpress
echo
echo Next: Moving $BLOG_DIR to $OLD_BLOGDIR and moving wordpress/ in place.
read
mv -v $BLOG_DIR $OLD_BLOGDIR
mv -v wordpress $BLOG_DIR
echo Done
echo
echo
echo Next: Symlinking the config, themes, plugins and uploads
# Install symlinks
cd $BLOG_DIR
ln -s $WORKDIR/blog-data/wp-config.php
cd wp-content
rm -rf plugins
ln -s ../../blog-data/wp-content/plugins
rm -rf themes
ln -s ../../blog-data/wp-content/themes
echo Done
echo Your blog should be updated now
echo Your themes, plugins and uploads stay at $WORKDDIR/blog-data
echo
#!/bin/sh
PLUGIN_DIR=$HOME/var/www/blog-data/wp-content/plugins
if [ ! -d $PLUGIN_DIR ]; then
echo Target folder $PLUGIN_DIR does not exist!
exit 1
fi
cd $PLUGIN_DIR
for name in *;
do
echo Checking "${name}"
if [ ! -d ${name} ]; then
echo Skipping, no folder.
continue
fi
# Download the plugin file
wget http://downloads.wordpress.org/plugin/${name}.zip || continue
# we found a file under the given url, so unzip it (yes, there is no checking if the files is really an update :()
if [ -f ${name}.zip ]; then
# move the plugin folder out of the way
mv $name $name-old
unzip ${name}.zip
rm -fv ${name}.zip
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment