#!/bin/bash # Copyright (c) 1999, William Stearns # It's this simple. # - Place randomsig in /usr/local/bin . # - mkdir ~/sigs # - edit ~/sigs/header and place the top lines of the sig there. # - edit ~/sigs/footer and place the bottom lines there. # - place any quotes you'd like in the rest of the files in ~/sigs. # - place the following line (without leading #) in /var/spool/cron/the_user_name and restart cron: # */10 * * * * /usr/local/bin/randomsig /the/users/home/directory >/dev/null # The optional command line parameter is the home directory to use. #DEBUG="YES" if [ -n "${1}" ]; then HOME="${1}" ; fi SIGDIR="${HOME}/sigs" if [ ! -d ${SIGDIR} ]; then mkdir ${SIGDIR} ; fi if [ ! -f ${SIGDIR}/header ]; then echo Please edit ${SIGDIR}/header to place a custom header here. >${SIGDIR}/header ; fi if [ ! -f ${SIGDIR}/footer ]; then echo Please edit ${SIGDIR}/footer to place a custom footer here. >${SIGDIR}/footer ; fi if [ ! -f ${HOME}/.signature.prerandomsig ]; then cp -p ${HOME}/.signature ${HOME}/.signature.prerandomsig ; fi QUOTEFILES="`ls -1F ${SIGDIR} 2>/dev/null | egrep -v '(header|footer)' | grep -v '^$' | grep -v '/$'`" if [ "${QUOTEFILES}" = "" ]; then cat ${SIGDIR}/header ${SIGDIR}/footer >${HOME}/.signature else NUMQUOTES=`echo "$QUOTEFILES" | wc -l` if [ -n "${DEBUG}" ]; then echo ${NUMQUOTES} quotes. ; fi QUOTENUM=$[ ${RANDOM} % ${NUMQUOTES} + 1 ] #Between 1 and the number of quotes if [ -n "${DEBUG}" ]; then echo Using quote ${QUOTENUM}. ; fi QUOTEFILE=`echo "${QUOTEFILES}" | head -${QUOTENUM} | tail -1` #Corresponding filename if [ -n "${DEBUG}" ]; then echo Using quotefile ${QUOTEFILE}. ; fi cat ${SIGDIR}/header ${SIGDIR}/${QUOTEFILE} ${SIGDIR}/footer >${HOME}/.signature fi