Generating /etc/motd from ‘fortune’ at boot

2008.04.14 05:46

I created a script fortune2motd:

file=/etc/motd

# the wrapping echos are for spacing
echo > $file
/usr/games/fortune -a >> $file
echo >> $file

Then I created/etc/init.d/fortune2motd:

#! /bin/sh

N=/etc/init.d/fortune2motd

case "$1" in
  start)
        /home/system/private/bin/fortune2motd
        ;;
  stop|reload|restart|force-reload)
        echo "got 'em"
        ;;
  *)
        echo "Usage: $N {start|stop|restart|force-reload}" >&2
        exit 1
        ;;
esac

Then I configured it to run at boot using Debian’s update-rc.d command. I don’t remember the exact syntax, but I think it’s something like:

update-rc.d fortune2motd defaults 99

And now I get cute messages whenever I login to my box remotely.

Comments? (moderated as hell)

allowed HTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>