Forever Updating

I find little time these days and I noticed with some annoyance that I was behind with my Wordpress updates. I run a number of sites (13 Wordpress sites alone) and updating from 2.5 -> 2.5.1 is sort of painful and tedious.

So I made a script (most of the domain names are removed but you could add to the list):

sites=(illusoryfollies.com
       flanaganclan.com
       sarahflanagan.com)
 
base_path="/var/www/vhosts"
wordpress_download_url="http://wordpress.org/latest.tar.gz"
wordpress_download_file="latest.tar.gz"
wordpress_download_directory="wordpress"
wordpress_database_update_url="wp-admin/upgrade.php?step=1&backto=%2Fwp-admin%2F"
jailed_directory="httpdocs"
temp_directory="wp-temp"
 
number_of_sites=${#sites[@]}
 
 
echo "Updating $number_of_sites websites with the latest version of Wordpress."
 
for current_site in ${sites[@]}
do
  echo "Now processing $current_site..."
  echo "  Setting up directories..."
  if [ -e $base_path/$current_site/$jailed_directory ]
  then
    echo "  !!Detected a jail'ed website..."
    mkdir -p $base_path/$current_site/$jailed_directory/$temp_directory
    cd $base_path/$current_site/$jailed_directory/$temp_directory
  else
    mkdir -p $base_path/$current_site/$temp_directory
    cd $base_path/$current_site/$temp_directory
  fi
 
  echo "  Downloading latest version of Wordpress..."
  wget -q $wordpress_download_url
  echo "  Uncompressing..."
  tar zxfv $wordpress_download_file > /dev/null
  cd $wordpress_download_directory
  echo "  Copying into existing directory..."
  cp -r * ../..
  cd ../..
  echo "  Updating database..."
  wget -q "http://$current_site/$wordpress_database_update_url" -O /dev/null
  echo "  Cleaning up..."
  rm -rf $temp_directory
  echo "Done processing $current_site."
  echo ""
 
done

Now it takes about 15 seconds to update everyone’s site and it even performs the “Database Upgrade” step (at least for now).

Automation is a good thing. Speaking of which, I’m interested in Capistrano but I still haven’t really done anything with it. It looks like fun… I’ll have to add a post if I have any luck experimenting with it.

No Comments »

Andrew Flanagan on May 10th 2008 in Actual Events, Geekiness

Making Cygwin more handy

I enjoy having Cygwin installed on Windows and often like to use the shell commands (grep, find, etc.). However, it’s inconvenient to spawn a new terminal window and slog through the often-complex Windows directory structure. Based off of some websites I found, I now have a way to make this work…

Create a batch script file in your Cygwin /bin folder (for me, this is C:\Cygwin\bin) with the following:

@cd /d %1
 
@bash --rcfile BASCHRC -i

Create a file called “bashcontext.reg” and save the following text into it:

[HKEY_CLASSES_ROOT\Directory\shell\bash]
@="Open Bash shell here"
 
[HKEY_CLASSES_ROOT\Directory\shell\bash\command]
@="C:\\Cygwin\\bin\\runBash.bat \"%1\""
 
[HKEY_CLASSES_ROOT\Drive\shell\bash]
@="Open Bash shell here"
 
[HKEY_CLASSES_ROOT\Drive\shell\bash\command]
@="C:\\Cygwin\\bin\\runBash.bat \"%1\""
 
[HKEY_CLASSES_ROOT\*\shell\bash]
@="Open Bash shell here"
 
[HKEY_CLASSES_ROOT\*\shell\bash\command]
@="C:\\Cygwin\\bin\\runBash.bat \"%1\""

You can add the registry information by double-clicking the file to run it.

Now on every directory you have a “Open Bash shell here” option that will take you there immediately. Handy!

Here’s a screenshot showing my cluttered context menu:

clutteredcontext.png

1 Comment »

Andrew Flanagan on November 28th 2007 in Actual Events

WordPress Tagging

I just upgraded to WordPress 2.3 which supports tagging natively. There’s a new spot under the Edit window where you can enter tags. I’m lazy though so I’d like it if it could present me with a list of my tags so I could click and add them automatically… I just modified the code a little bit for one file in Wordpress and it appears to work… here’s what I did.

In the file wp-admin/edit-form-advanced.php, insert the following:

162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
        <script type="text/javascript">
        function setTag(text)
        {
                var curvalue = document.getElementById('tags-input').value;
 
                if (curvalue == "")
                {
                        document.getElementById('tags-input').value = text;
                }
                else
                {
                        document.getElementById('tags-input').value = curvalue + ", " + text;
                }
        }
        </script>
        <?php
        $output = "<legend>";
        $tags = (array) get_terms('post_tag', $args);
        foreach ($tags as $tag)
        {
                $output .= "<a href=\"#\" onClick=\"setTag('".$tag->name."')\">".$tag->name."</a>,";
        }
        $output = substr($output, 0, strlen($output) - 1);
        $output .= "</legend>";
        echo $output;
        ?>

No Comments »

Andrew Flanagan on October 5th 2007 in Actual Events, Geekiness, MetaData

More Bash Scripts

I need to copy all of my FLAC files out of my directory tree but preserve the folder structure that they were in… Here’s my script.

Unfortunately, it’s not a “perfect” solution as there are issues when handling special characters in files (especially newline characters). However, since my file really just have spaces in them, that’s all this was designed to beat.

SOURCEDIR="/var/mirror/Data/Audio/My CD Archive"
TARGETDIR="/var/mirror/FLAC"
 
mkdir "$TARGETDIR"
 
find "$SOURCEDIR" -type d | while read DIR; do
  if [[ "$DIR" != "$SOURCEDIR" ]]; then
    SHORTDIR=`echo $DIR | sed 's/.*///g'`
    mkdir "$TARGETDIR/$SHORTDIR"
    echo "Now in $DIR"
    find "$DIR" -name "*.flac" | while read FILE; do
      SHORTFILE=`echo $FILE | sed 's/.*///g'`
      echo "Now moving $SHORTFILE"
      mv "$FILE" "$TARGETDIR/$SHORTDIR"
    done
    echo "--------------------"
    sleep 1
  fi
done

1 Comment »

Andrew Flanagan on September 25th 2007 in Actual Events, Geekiness

Fun with Javascript

1. Browse to a site like Amazon.

2. Enter the following into your browser address window

javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.images; DIL=DI.length; function A(){for(i=0; i-DIL; i++){DIS=DI[ i ].style; DIS.position='absolute'; DIS.left=Math.sin (R*x1+i*x2+x3)*x4+x5; DIS.top=Math.cos(R*y1+i*y2+y3)*y4+y5}R++}setInterval('A()',5); void(0);

3. Hit Enter and watch the weirdness.

4 Comments »

Andrew Flanagan on September 13th 2007 in Geekiness