Yum: Checking for updates.

Friday, September 23rd, 2005

Here’s a quick script you can put in your cron rotation to check and see if there are any updates available and what they are:


#!/bin/bash

yum_output=/tmp/yum-check-update-output.txt
python=/usr/bin/python1.5
yum=/usr/bin/yum

$python $yum check-update > $yum_output

yum_return_code="$?"

case $yum_return_code in
100)
# Packages available for update.
echo '********************************************************'
echo "The following packages need to be udpated on $HOSTNAME"
echo '********************************************************'
echo ''
cat $yum_output
;;
0)
# No packages available for update.
;;
*)
echo "YUM: Undefined return code: $yum_return_code ."
exit 1
esac

exit 0

Init script for rsyncd.

Saturday, September 3rd, 2005

Ed: another one that was sitting in “drafts” for months.

#!/bin/bash
#
# Startup script for rsyncd.
#
# chkconfig: 345 86 16
# description: rsync rocks.
#

case “$1″ in
start)
echo “Starting rsyncd…”
/opt/rsync/bin/rsync –daemon –ipv4
;;
stop)
echo “Stopping rsyncd…”
killall /opt/rsync/bin/rsync
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo “Usage: $0 {start|stop|restart}”
exit 1
;;
esac

exit 0

Supybot init script for Debian.

Sunday, April 17th, 2005

Supybot is a neat little IRC bot written in Python. I had been looking for a bot to do some logging of my favorite IRC channel (#nblug on irc.nblug.org). The setup was pretty easy and the documentation is nice, but the one thing I didn’t find was an init script, so I modified one from an existing blootbot init script.


#! /bin/sh
#
# supybot init script
#
#
# Cobbled together from the blootbot init script.
#

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/supybot
NAME=supybot
DESC=supybot

test -f $DAEMON || exit 0

set -e

case "$1" in
start)
echo -n "Starting $DESC: "
start-stop-daemon --start --quiet --pidfile /var/run/supybot/$NAME.pid \
--chuid supybot --exec $DAEMON -- --daemon /etc/supybot/nibler.conf
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon --stop --quiet --pidfile /var/run/supybot/$NAME.pid \
--oknodo --exec /usr/bin/python
echo "$NAME."
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}" >&2
exit 1
;;
esac

exit 0

Note: I am still a big Mandriva weenie, but the server this bot runs on is a Debian box.