Skip to content

irssi + bitlbee + xmpp conference auto join

28-Jan-10

Since moving Instant Messaging platforms from Pidgin to irssi I have been having problems automatically logging into a XMPP chatroom automatically.

Got it sorted today.

in the ~/.irssi/config file , under the chatnet section for the bitlbee server I added :-

autosendcmd = "wait 2000;  /msg &bitlbee join_chat 0 ROOM@CONFERENCE.SERVER.TLD &CHATROOM NICK ROOMPASSWORD"

Windows script to keep Dropbox tidy

06-Jan-10

Thought I’d write a little script for Dad to keep his Dropbox folder tidy due to my uploading nightly backup archive files.

I don’t use Windows so its a tricky for me to test but it should work , anyone want to test and comment ?

FORFILES -pC:\Documents and Settings\mark\My Documents\My Dropbox\CloudBackup\ -d-4 -c"CMD /C MOVE @FILE C:\Documents and Settings\mark\Desktop\"

It uses the forfiles command to move all but the 4 newest files from the Dropbox directory structure to a folder on the Desktop , this way the files can be burnt to a DVD-R and don’t clutter up Dad’s Dropbox capacity.

Was hoping Dad would test the script but he has deleted it twice now so I give up , anyone else tried it ?

Apache Proxy for the Gallery

01-Jan-10

For a while I have been running our Gallery on a seperate webserver to the rest of our sites because of disk capacity constraints.
Today I moved the Gallery to my PC as its the fastest machine we have which will make the image resizing smoother.

On the front-facing webserver I have setup Apache to proxy to the backend server with this VirtualHost configuration :-

NameVirtualHost *:80
ServerAdmin mark@weloveit.info
ServerName gallery.weloveit.info
ProxyRequests Off
ProxyPreserveHost On
Order deny,allow
Allow from all
ProxyPass / http://gallery.core6.collective-b.dyndns.org/
ProxyPassReverse / http://gallery.core6.collective-b.dyndns.org/
ErrorLog /var/log/apache2/proxy.gallery.weloveit.info.error.log
CustomLog /var/log/apache2/proxy.gallery.weloveit.info.access.log combined env=!dontlog

With

ProxyPreserveHost Off

the backend server hostname was showing through.

On the backend server I am using this VirtualHost configuration :-

NameVirtualHost *:80
ServerAdmin mark@weloveit.info
ServerName gallery.weloveit.info
DocumentRoot /var/www/zenphoto-1.2.8_RC1/

Exporting just the Draft Wordpress posts

30-Dec-09

I wanted to export just the draft posts from one of our Wordpress-MU sites.

Fired up the text editor and opened the

wp-admin/includes/export.php

file.

Located :-

$post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts $where ORDER BY post_date_gmt ASC");

added in this :-

AND post_type = 'post' AND post_status = 'draft'

to change it to this :-

$post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts $where AND post_type = 'post' AND post_status = 'draft' ORDER BY post_date_gmt ASC");

Now an export only exports the the draft posts , easy.

Bulk Traffic Management Script

28-Dec-09

Now we are using the free.fr freebox as our router it lacks any ability to shape our traffic.

This script runs every hour via cron , the Asterisk server also calls the script at the start and end of any external call.
Here is the script :-

#!/bin/sh
# script to manage the bulk traffic server rates

HOUR=`date "+%H"`
APP="/usr/local/bin/nzbget"
PAUSED="$APP --pause"
RUNNING="$APP --unpause"
SLOW="$APP --rate 150"
FAST="$APP --rate 175"
VOIPACTIVELOCK=/tmp/voipactive.lock

if [ -f $VOIPACTIVELOCK ]; then
        $PAUSED
        else
        case $HOUR in
        01|02|03|04|05|06|07)
            $RUNNING
            $FAST
            ;;
        08|09|10|11|12|13|14|15|16|17)
            $RUNNING
            $SLOW
            ;;
        18|19|20|21)
            $PAUSED
            ;;
        22|23|00)
            $RUNNING
            $FAST
            ;;
        esac
fi

I am using an if statement to check for a current VOIP call (the Asterisk server sets the lockfile during an external call).
Also using the case conditional to check for the various times of day and adjust the rate or pause entirely.

Cleaning out old Linux kernels

21-Dec-09

After a while and many Ubuntu updates your PC starts acumulating old kernels , not really a problem but you only need the last couple really and might as well delete the old ones.

Get a list of all the installed kernels with :-

dpkg --get-selections | grep linux-image

I got this :-

linux-image-2.6.24-23-generic                   install
linux-image-2.6.24-24-generic                   install
linux-image-2.6.27-14-generic                   install
linux-image-2.6.28-12-generic                   install
linux-image-2.6.28-13-generic                   install
linux-image-2.6.28-14-generic                   install
linux-image-2.6.28-15-generic                   install
linux-image-2.6.28-16-generic                   install
linux-image-2.6.28-17-generic                   install
linux-image-generic                             install

The oldest ones are at the top , so I deleted them with :-

apt-get purge linux-image-2.6.24-23-generic

Each removed Kernel saved over 100Mb of disk space.
Keep your Ubuntu recovery CD handy just-in-case.

MySQL Backup Script

14-Nov-09

I wanted a way to backup all our MySQL databases to a central server.

First each server dumps , compresses and uploads its MySQL databases to a central server with this simple script :-

#!/bin/sh
#
# script to dump the mysql databases daily and send to backup on separate server.
#
DESTINATION=/var/tmp/mysql_database_dumps
DBUSER=XXXXXX
DBPASSWORD=YYYYYY
SLAVEUSER=MMMMMM
SLAVESERVER=NNNNNN
SLAVEDESTINATION=/srv/datadrive/data_share/data_library/backups/mysql_database_dumps
for DATABASELIST in AAAAAA BBBBBB CCCCCC DDDDDD EEEEEE FFFFFF
do
nice mysqldump --user=$DBUSER --password=$DBPASSWORD $DATABASELIST > $DESTINATION/$DATABASELIST.sql
nice gzip -f $DESTINATION/$DATABASELIST.sql
nice scp -q $DESTINATION/$DATABASELIST.sql.gz $SLAVEUSER@$SLAVESERVER:$SLAVEDESTINATION/
done

You will need to change :-

  • AAAAAA – FFFFFF to the names of your databases on this server
  • MMMMMM = username of an account on central server
  • NNNNNN = hostname of central server
  • XXXXXX = your MySQL root username (root)
  • YYYYYY = your MySQL root user password

Dropbox Cloud Backup Script

13-Nov-09

After getting the MySQL databases backed up I now wanted a way to safely upload them to ‘the cloud’ , so I wrote this quick script.

#!/bin/sh
#
# script to backup to the dropbox cloud
# 1. zip the database dumps into a single file
# 2. encrypt the single file with gpg
# 3. move file from /tmp to ~/Dropbox/CloudBackups
DATABASEDUMPSDIR=/srv/datadrive/data_share/data_library/backups/mysql_database_dumps
ZIPFILENAME=/tmp/mysql_database_dumps_`date +%Y%m%d`
DROPBOXDIR=/home/mark/Dropbox/CloudBackup
# zip
zip $ZIPFILENAME $DATABASEDUMPSDIR/*
# encrypt
gpg -e -r mark@weloveit.info $ZIPFILENAME.zip
# move
mv $ZIPFILENAME.zip.gpg $DROPBOXDIR
# delete temp files
rm $ZIPFILENAME.zip
  1. dumps the databases to a local directory with the mysqldump command
  2. compresses it with gzip
  3. send it to the central backup server using scp (this needs to be setup beforehand)

Once all the servers have done their backups a script on this central server then :-

  1. collects all the files together using zip
  2. encrypts the zip file with gpg (this needs to be setup beforehand)
  3. moves it to my Dropbox directory where it is uploaded automatically

Audiobook Grabber

24-Oct-09

I wanted a little script to grab all the mp3 files from a specific page , it makes life a little easier when you want to listen to one of Scott Sigler’s masterpieces , like Contagious.

Here I am using curl piped into grep which is piped into wget

I call it web-mp3-grabber

#!/bin/sh
# script to grab all the mp3 files from a specific web page
# useful for getting a complete collection of files for an audiobook
# like the amazing Scott Sigler's Contagious at
# http://www.podiobooks.com/title/contagious
# Mark Waters 20091024
# setup variables
$url=$1
curl --silent $url | grep -o http://[^[:space:]]*.mp3 | xargs wget

Run it like this :-

web-mp3-grabber http://www.podiobooks.com/title/contagious

How Freedom Hating am I ?

12-Sep-09

First install the ‘virtual RMS’ application :-

sudo apt-get install vrms

then run it in a shell :-

mark@core6:~$ vrms
               Non-free packages installed on core6

fglrx-modaliases          Identifiers supported by the ATI graphics driver
libmyth-0.21-0            Common library code for MythTV and add-on modules (run
libmyth-perl              A PERL library to access some MythTV features
linux-generic             Complete Generic Linux kernel
linux-restricted-modules- Non-free Linux 2.6.24 modules on x86/x86_64
linux-restricted-modules- Non-free Linux 2.6.24 modules on x86/x86_64
linux-restricted-modules- Non-free Linux 2.6.28 modules helper script
linux-restricted-modules- Restricted Linux modules for generic kernels
mythtv                    A personal video recorder application (client and serv
mythtv-backend            A personal video recorder application (server)
mythtv-common             A personal video recorder application (common data)
mythtv-database           A personal video recorder application (database)
mythtv-frontend           A personal video recorder application (client)
mythtv-transcode-utils    Utilities used for transcoding MythTV tasks
mythweb                   Web interface add-on module for MythTV
nvidia-173-modaliases     Modaliases for the NVIDIA binary X.Org driver
nvidia-180-kernel-source  NVIDIA binary kernel module source
nvidia-180-libvdpau       Video Decode and Presentation API for Unix
nvidia-180-libvdpau-dev   Video Decode and Presentation API for Unix development
nvidia-180-modaliases     Modaliases for the NVIDIA binary X.Org driver
nvidia-71-modaliases      Modaliases for the NVIDIA binary X.Org driver
nvidia-96-modaliases      Modaliases for the NVIDIA binary X.Org driver
nvidia-glx-180            NVIDIA binary Xorg driver
nvidia-glx-180-dev        NVIDIA binary Xorg driver development files
opera                     The Opera Web Browser
sun-java6-bin             Sun Java(TM) Runtime Environment (JRE) 6 (architecture
sun-java6-jdk             Sun Java(TM) Development Kit (JDK) 6
sun-java6-jre             Sun Java(TM) Runtime Environment (JRE) 6 (architecture
tangerine-icon-theme      Tangerine Icon theme

    Non-free packages with status other than installed on core6

nvidia-glx-177            ( dei)  NVIDIA binary Xorg driver
nvidia-glx-new            ( dei)  NVIDIA binary XFree86 4.x/X.Org 'new' driver
xorg-driver-fglrx         ( dei)  Video driver for ATI graphics accelerators

                Contrib packages installed on core6

em8300-headers            Kernel headers to access DXR3/Hollywood+ decoder cards
msttcorefonts             transitional dummy package
nvidia-common             Find obsolete NVIDIA drivers
nvidia-kernel-common      NVIDIA binary kernel module common files
nvidia-settings           Tool of configuring the NVIDIA graphics driver
ttf-mscorefonts-installer Installer for Microsoft TrueType core fonts

  32 non-free packages, 1.7% of 1935 installed packages.
  6 contrib packages, 0.3% of 1935 installed packages.

Bad Behavior has blocked 192 access attempts in the last 7 days.