[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: ip-{up,down} scripts



On 02 Jun 1999 11:08:19 +0100, you wrote:
>Is it worth combining the up/down scripts, so we pass a parameter
>(``up'' or ``down'') and each script contains a case statement ?

I have been doing this for a couple of months with good results. The
ip.d scripts look something like

|mh@torres:/mnt/main6/home/mh > cat /etc/ppp/ip.d/fetchmail
|
|LOCKFILE="/var/lock/fetchmail"
|USER="fetchmail"
|OPTIONS="--daemon 160"
|ALLSETS="mh-large plannet-lists-large"
|
|if [ -z "$PPP_OPERATION" ]; then
|  PPP_OPERATION=$1
|  PPP_IFACE="ippp0"
|fi
|
|if [ "$PPP_IFACE" == "ippp1" ]; then
|  exit 1
|fi
|
|HOUR=`date +"%k"`
|if (( ($HOUR >= 21) || ($HOUR <= 4) )); then
|  OPTIONS="$OPTIONS $ALLSETS"
|fi
|
|case "$PPP_OPERATION" in
|  up)
|        if [ ! -e $LOCKFILE ]; then
|                touch $LOCKFILE
|                su - fetchmail -c "fetchmail $OPTIONS"
|        fi
|        ;;
|  down)
|        su - fetchmail -c "fetchmail --quit"
|        rm $LOCKFILE
|        ;;
|esac
|mh@torres:/mnt/main6/home/mh > ls -l /etc/ppp/ip-up.d/*fetch*
|lrwxrwxrwx   1 root     root           17 Mar 17 18:28 /etc/ppp/ip-up.d/80fetchmail -> ../ip.d/fetchmail*
|mh@torres:/mnt/main6/home/mh > ls -l /etc/ppp/ip-down.d/*fetch*
|lrwxrwxrwx   1 root     root           17 Mar 17 18:28 /etc/ppp/ip-down.d/80fetchmail -> ../ip.d/fetchmail*
|mh@torres:/mnt/main6/home/mh >

I have found it quite convenient to have everything that has to be
done for a service is in a single file.

Incidentally, this script also shows how I decide which service to
start for a given interface. This has proven to be quite practical.

Greetings
Marc

-- 
-------------------------------------- !! No courtesy copies, please !! -----
Marc Haber          |   " Questions are the         | Mailadresse im Header
Karlsruhe, Germany  |     Beginning of Wisdom "     | Fon: *49 721 966 32 15
Nordisch by Nature  | Lt. Worf, TNG "Rightful Heir" | Fax: *49 721 966 31 29


Reply to: