"Adam P. Harris" <[EMAIL PROTECTED]> writes: > > > Maybe I should submit this as a wishlist to the bug system, but I was > interested in getting some comments first. > > I think that /etc/ppp/ip-up and /etc/ppp/ip-down should use > 'run-parts' against, say, the directories /etc/ppp/ip-{up,down}.d/. > > This would allow, for instance, MTA packages to ship little scripts to > flush the mail queue when the link comes up, pop-deamons to start up, > bind to reload, clock sync daemons to re-sync, firewall and > masquerading rules to run, and dynamic PPP hosts to update some file > on some server indicating their current IP.
Well, the recent discussion of using run-parts in ip-up and ip-down finally convinced me to doing a little cleaning up of my hacked together system. I've basically implemented what Adam Harris was asking for, together with a HTML form, so that my wife can control our expensive (UK) modem link from her Windows 95 box. I'll launch straight into the scripts and describe as I go along. Here's my ip-up script... ======================== /etc/ppp/ip-up =========================== #!/bin/sh # # This script is run by the pppd after the link is established. # It should be used to add routes, set IP address, run the mailq # etc. # # This script is called with the following arguments: # Arg Name Example # $1 Interface name ppp0 # $2 The tty ttyS1 # $3 The link speed 38400 # $4 Local IP number 12.34.56.78 # $5 Peer IP number 12.34.56.99 # $6 Something passed with the 'ipparam' option for pppd # Save the options for possible later use INTERFACE=$1 TTY=$2 SPEED=$3 LOCAL_IP=$4 PEER_IP=$5 # Set up the runtime flag directory RUNDIR=/var/run/ppp # Set defaults FLASH=/bin/false # Parse the flags # Note that $6 is not protected in quotes here, so to break it up into # fields again. set $6 while [ "$1" != "" ] do case "$1" in flash) FLASH=/bin/true ;; "get-mail") touch $RUNDIR/get-mail ;; "send-mail") touch $RUNDIR/send-mail ;; "get-news") touch $RUNDIR/get-news ;; "get-www") touch $RUNDIR/get-www ;; esac shift done # Do all the things we want to when we're connected /bin/run-parts /etc/ppp/ip-up.d # If it's a flash session, wait until all done, then kill link. if $FLASH then while [ "`/bin/ls $RUNDIR`" != "" ] do sleep 5 done killall -TERM pppd fi exit 0 # End of file. ======================== EOF /etc/ppp/ip-up ======================== It is important that pppd is called in a statement in the form pppd ipparam "flash get-news get-mail" Notice the quoting around the argument. It is there since only one argument gets passed to the ip-up script, not the rest of the command line. Each of the lines in the case statement correspond to a script in the /etc/ppp/ip-up.d/ directory, apart from the FLASH check. I've borrowed the 'flash session' name from AOL (hope it's not trademarked!) The flags to `pppd ipparam [flags]` pass on the information as to which services to run in this ppp session. Each required service results in a flag file being touched in /var/run/ppp, and the scripts check for this flag. There are two types of script in ip-up.d. These which we always want to run (bind, masq, etc) and those we only want to run on choice. When a script is done, it removes the corresponding flag file. The ip-up script, if it's been called as a flash session loops until there are no flag files left, and then brings the ppp link down. Otherwise, it exits gracefully, and awaits the user/admin to close the link when they wish to. Here's my getnews script... ==================== /etc/ppp/ip-up.d/50getnews ==================== #!/bin/sh # This script will exchange news with the outside world FLAG=/var/run/ppp/get-news if [ -f $FLAG ] then if [ -x /usr/sbin/get-news ] ; then ( \ if [ -x /usr/bin/logger ] ; then \ /usr/bin/logger -t get-news -p news.info "Starting to get news..."; \ fi ; \ /usr/sbin/get-news ; \ /bin/rm -f $FLAG ; \ if [ -x /usr/bin/logger ] ; then \ /usr/bin/logger -t get-news -p news.info "Finished getting news."; \ fi ; \ ) & else /bin/rm -f $FLAG fi fi exit 0 =================== EOF /etc/ppp/ip-up.d/50getnews ================== So, it basically checks for the flag file set in ip-up script and runs only if it's there. There's a similar sequence of scripts in ip-down.d which clean up the flags if any are left (modem lines do die), and remove masquerading, reset bind for offline mode, etc. Here's the whole tree of scripts. Feel free to criticise, alter, and use freely. begin 644 etc.ppp.tar.gz M'XL(`.T)ES0``^U;6V_;[EMAIL PROTECTED])[EMAIL PROTECTED]:N8-/[EMAIL PROTECTED];!\<'+1% M2HE+B3!%,MQE%/_[SBPONE&B;4ARTW`,6!)W=W;(G6]F=G;(Q'AP<F`"2W-L M&TX`=,?6EC]+T@"&EF4/-</13&[EMAIL PROTECTED]@IP,DMBZ*['?V:VK]1 M8KC^29(<5`<>M/ZZC<U(3KO^QZ!R_8.DGR6J=Q`]H/77M.;U-TS'M'7\KANF M;;7K?PQ:7W]=F[G\<\92UV/[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