head 1.46; access; symbols; locks; strict; comment @# @; 1.46 date 99.05.07.14.28.17; author alexis; state Exp; branches; next 1.45; 1.45 date 99.04.28.09.44.33; author alexis; state Exp; branches; next 1.44; 1.44 date 99.04.26.16.13.46; author alexis; state Exp; branches; next 1.43; 1.43 date 99.02.20.18.06.40; author alexis; state Exp; branches; next 1.42; 1.42 date 99.01.07.13.05.31; author alexis; state Exp; branches; next 1.41; 1.41 date 98.10.07.16.29.00; author alexis; state Exp; branches; next 1.40; 1.40 date 98.09.06.16.11.16; author alexis; state Exp; branches; next 1.39; 1.39 date 98.08.30.21.09.06; author alexis; state Exp; branches; next 1.38; 1.38 date 98.08.29.16.43.54; author alexis; state Exp; branches; next 1.37; 1.37 date 98.08.28.17.39.26; author alexis; state Exp; branches; next 1.36; 1.36 date 98.08.28.13.09.55; author alexis; state Exp; branches; next ; desc @shpp port of ppplcc.in version 1.35 @ 1.46 log @command line 'id' command now displays the variable meanings. @ text @#!MARKER_SHELL_CMD ############################################################################### # # # PPP LINK CONTROL CLIENT # # # ############################################################################### ############################################################################### # # Things you should know about this script: # # It is stored under RCS! Keep it that way! If you want a history of # changes made to this script then refer to rlog(1) - don't look here! # ############################################################################### ############################################################################### # # USER CONFIGURABLE STUFF STARTS HERE # ############################################################################### ############################################################################### # # USER CONFIGURABLE STUFF ENDS HERE # ############################################################################### ############################################################################### # # PACKAGE INDEPENDENT VARIABLE SETTINGS # ############################################################################### PATH=/bin:/usr/bin PROGNAME=`basename $0` VERSION="MARKER_PATCHLEVEL" #UMASK=022 #LOCK_DIR=MARKER_LOCK_DIR #ERRORS_CAUSE_EXITS=true # $Header: /diskb/home/alexis/dev/supported/ppplc/bin/RCS/ppplcc.shpp,v 1.45 1999/04/28 09:44:33 alexis Exp alexis $ #shpp include sm_msgids.shpp #shpp include ppplc_msgids.shpp ############################################################################### # # PACKAGE SPECIFIC VARIABLE SETTINGS # ############################################################################### PPPLCD=MARKER_LCLSBINDIR/ppplcd SNDMSG=MARKER_LCLBINDIR/sndmsg GETMSG=MARKER_LCLBINDIR/getmsg DHUY=MARKER_LCLBINDIR/dhuy XPPPLCC=MARKER_LCLXBINDIR/xppplcc PPPLCC=MARKER_LCLBINDIR/ppplcc CONF_FILE=MARKER_PRGCFGDIR/ppplcd.conf BROWN="" WHITE="" INVBROWN="" ############################################################################### # # MAIN FUNCTION (called from very bottom of script) # ############################################################################### main() { ########################################################################### # # PROCESS OPTIONS # ########################################################################### # default values for things changable by command line options PAUSE=0 DOIT=true while [ "X$1" != X ]; do case "$1" in -V) echo "$PROGNAME version $VERSION" exit 0 ;; -d) [ "X$2" = X ] && usage VERBOSE_LEVEL=$2 shift ;; -v) VERBOSE_LEVEL=3 ;; -q) [ "X$2" = X ] && usage SNDMSG="$SNDMSG -q $2" shift ;; -n) DOIT=false ;; -c) [ "X$2" = X ] && usage CONF_FILE=$2 shift ;; -p) [ "X$2" = X ] && usage PAUSE=$2 shift ;; -*) usage ;; *) break ;; esac shift done [ $DOIT = false ] && SNDMSG="echo $SNDMSG" # Are locks required? Nah. # Are you going to register temporary files? No. #trap sighandler 1 2 15 ########################################################################## # # SCRIPT GUTS STARTS HERE # ########################################################################## if [ "X$1" = X ]; then ppplcc_interactive else ppplcc_commandline "$@@" fi #exitdel } usage() { { echo "Usage: $PROGNAME [ -d | -v ] [ -p ] [ -q ] [ -n ] [ ... ]" echo " $PROGNAME -V" } >&2 exit 2 } ppplcc_commandline() { debug 5 "ppplcc_commandline: SOF" while [ "X$1" != X ]; do debug 5 "args is $1" case "$1" in c) $SNDMSG MARKER_MSGID_EXEC_PPPD ;; d) $SNDMSG MARKER_MSGID_HANGUP ;; m) $SNDMSG MARKER_MSGID_EXEC_MAIL ;; n) $SNDMSG MARKER_MSGID_EXEC_NEWS ;; dn) $SNDMSG MARKER_MSGID_UNSET_DONEWS ;; en) $SNDMSG MARKER_MSGID_SET_DONEWS ;; da) $SNDMSG MARKER_MSGID_UNSET_AUTORECONNECT ;; ea) $SNDMSG MARKER_MSGID_SET_AUTORECONNECT ;; q) clear exit ;; es) $DHUY ;; ds) $DHUY -c ;; S) [ ! -f $CONF_FILE ] && error "can't read $CONF_FILE" $PPPLCD $CONF_FILE ;; K) $SNDMSG MARKER_MSGID_SET_QUIT ;; ii) ipcs -qc pause ;; id) $SNDMSG MARKER_MSGID_INFO_REQ 2 $GETMSG | while read X00 X01 X02 X03 X04 X05 X06 X07 X08 X09 \ X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 \ X20 X21 X22 X23 X24 X25 X26 X27 X28 X29 \ X30 X31 X32 X33 X34 X35 X36 X37 X38 X39; do X25=`printf "%o" $X25` cat <<- EOF Read/Write 1 flag_wannabe_up: $X00 2 smf_setquit: $X01 3 do_xfer_news_flag: $X02 4 flag_autoreconnect: $X03 5 debug_level: $X04 6 idle_timeout: $X05 7 quality_minlevel: $X06 8 quality_interval: $X07 Readonly 21 flag_officially_up: $X20 22 state_cfgok: $X21 23 state_donemx: $X22 24 state_donenx: $X23 25 state_inipup: $X24 26 ipc_mode: $X25 27 ipc_owner: $X26 28 ipc_group: $X27 EOF done ;; id*) $SNDMSG MARKER_MSGID_INFO_REQ 2 $GETMSG | cut -d' ' -f`expr "$1" : 'id\(.*\)'` ;; ir) report_versions -r ;; iv) report_versions ;; sq) [ "X$3" = X ] && usage $SNDMSG MARKER_MSGID_SET_QUALITY $2 $3 shift; shift ;; si) [ "X$2" = X ] && usage $SNDMSG MARKER_MSGID_SET_IDLEPARS $2 shift ;; sd) [ "X$2" = X ] && usage $SNDMSG MARKER_MSGID_SET_DEBUG $2 shift ;; ct) [ "X$2" = X ] && usage echo $SNDMSG MARKER_MSGID_EXEC_PPPD | at $2 shift ;; dt) [ "X$2" = X ] && usage echo $SNDMSG MARKER_MSGID_HANGUP | at $2 shift ;; e) $SNDMSG MARKER_MSGID_NOACTION ;; *) debug 5 "error on $1" usage ;; esac shift done } ppplcc_interactive() { if [ "X$TERM" = Xxterm ]; then echo -n "]0;$PROGNAME" fi while :; do menu echo question "select, or press ENTER to redraw the screen" read RESPONSE case "$RESPONSE" in c) $SNDMSG MARKER_MSGID_EXEC_PPPD ;; d) $SNDMSG MARKER_MSGID_HANGUP ;; m) $SNDMSG MARKER_MSGID_EXEC_MAIL ;; n) $SNDMSG MARKER_MSGID_EXEC_NEWS ;; dn) $SNDMSG MARKER_MSGID_UNSET_DONEWS ;; en) $SNDMSG MARKER_MSGID_SET_DONEWS ;; da) $SNDMSG MARKER_MSGID_UNSET_AUTORECONNECT ;; ea) $SNDMSG MARKER_MSGID_SET_AUTORECONNECT ;; q) clear exit ;; es) $DHUY ;; ds) $DHUY -c ;; S) [ ! -f $CONF_FILE ] && error -ne "can't read $CONF_FILE" $PPPLCD $CONF_FILE ;; K) $SNDMSG MARKER_MSGID_SET_QUIT ;; ii) ipcs -qc pause ;; id) $SNDMSG MARKER_MSGID_INFO_REQ 2 $GETMSG ;; id*) $SNDMSG MARKER_MSGID_INFO_REQ 2 $GETMSG | cut -d' ' -f`expr "$1" : 'id\(.*\)'` ;; ir) report_versions -r 2>&1 | ${PAGER:-more} pause ;; iv) report_versions 2>&1 | ${PAGER:-more} pause ;; sq) question "minimum quality" read QC_MINLEVEL question "quality check interval (secs)" read QC_INTERVAL $SNDMSG MARKER_MSGID_SET_QUALITY $QC_MINLEVEL $QC_INTERVAL ;; si) question "idle timeout" read IDLE_TIMEOUT $SNDMSG MARKER_MSGID_SET_IDLEPARS $IDLE_TIMEOUT ;; sd) question "debug level" read DEBUG_LEVEL $SNDMSG MARKER_MSGID_SET_DEBUG $DEBUG_LEVEL ;; ct) info time now: `date '+%H%M'` question "connect time" read CONNECT_TIME echo $SNDMSG MARKER_MSGID_EXEC_PPPD | at $CONNECT_TIME ;; dt) info time now: `date '+%H%M'` question "disconnect time" read DISCONNECT_TIME echo $SNDMSG MARKER_MSGID_HANGUP | at $DISCONNECT_TIME ;; e) $SNDMSG MARKER_MSGID_NOACTION ;; h) ppplcchelp | ${PAGER:-more } ;; !*) CMD=`echo "$RESPONSE" | sed 's/!//'` do_a_shell -p "$PROGNAME> " $CMD pause ;; "") ;; *) warning "unrecognised, choose again ... " ;; esac [ $PAUSE != 0 ] && sleep $PAUSE done } menu() { clear printf "$INVBROWN PPP LINK CONTROL CLIENT %28s $WHITE\\n" "Ver. $VERSION" cat < /dev/null; } && LOCK_DIR= L_LOCK_DIR=${LOCK_DIR:-/var/run} # For instance if you're just preventing concurrent executions of this # program then this should be sufficient: #echo $L_LOCK_DIR/$PROGNAME.pid # On th other hand, database programs *without* a centralised db spooldir, # will want lock files in the same directory as the table file, like this: #echo .$L_LOCK_WHAT.lock @ 1.41 log @added '-n' option to only simulate sending messages @ text @d1 1 a1 1 #!SCRIPTSHELLCMD_MARKER d38 1 a38 1 VERSION="PATCHLEVEL_MARKER" d40 1 a40 1 #LOCK_DIR=LOCK_DIR_MARKER d42 1 a42 1 # $Id: ppplcc.shpp,v 1.40 1998/09/06 16:11:16 alexis Exp alexis $ d50 7 a56 7 PPPLCD=LCLSBINDIR_MARKER/ppplcd SNDMSG=LCLBINDIR_MARKER/sndmsg GETMSG=LCLBINDIR_MARKER/getmsg DHUY=LCLBINDIR_MARKER/dhuy XPPPLCC=LCLXBINDIR_MARKER/xppplcc PPPLCC=LCLBINDIR_MARKER/ppplcc CONF_FILE=PRGCFGDIR_MARKER/ppplcd.conf d108 1 a108 1 #lock d180 2 d199 1 d240 2 d265 1 d297 1 d350 2 a351 2 [ ! -d PRGLIBDIR_MARKER/$DIR ] && { warning "PRGLIBDIR_MARKER/$DIR does not exist!"; continue; } for FILE in PRGLIBDIR_MARKER/$DIR/*; do d368 1 a368 1 #shpp include utils.sh @ 1.40 log @changed error -f for error -e or error -ne @ text @d42 1 a42 1 # $Id: ppplcc.shpp,v 1.39 1998/08/30 21:09:06 alexis Exp alexis $ d79 1 d92 1 d105 2 d148 1 a148 1 echo "Usage: $PROGNAME [ -d | -v ] [ -p ] [ -q ] [ ... ]" d259 1 a259 1 echo $SNDMSG 5 | at $CONNECT_TIME ;; @ 1.39 log @corrected missing double shift on commands requiring 2 parameters @ text @d42 1 a42 1 # $Id: ppplcc.shpp,v 1.38 1998/08/29 16:43:54 alexis Exp alexis $ d169 1 a169 1 S) [ ! -f $CONF_FILE ] && error -f "can't read $CONF_FILE" d226 1 a226 1 S) [ ! -f $CONF_FILE ] && error -f "can't read $CONF_FILE" @ 1.38 log @missed off test for arguments on commandline version - so it did what it was supposed to but then produced an error message when it ran out of arguments @ text @d42 1 a42 1 # $Id: ppplcc.shpp,v 1.37 1998/08/28 17:39:26 alexis Exp alexis $ d180 1 a180 1 shift ;; @ 1.37 log @removed the test on version names, because it fails when stderr is redirected. @ text @d42 1 a42 1 # $Id: ppplcc.shpp,v 1.36 1998/08/28 13:09:55 alexis Exp alexis $ d154 1 a154 1 while :; do @ 1.36 log @shpp port of ppplcc.in version 1.35 @ text @d42 1 a42 1 # $Id: mondsk.shpp,v 1.13 1998/08/23 14:38:06 alexis Exp $ d54 3 a56 7 QTEST=PRGLIBDIR_MARKER/qtest USECNT=PRGLIBDIR_MARKER/usecnt ANNOUNCE=PRGLIBDIR_MARKER/announce XPPPLCC=LCLBINDIR_MARKER/xppplcc IPUP=/etc/ppp/ip-up IPDOWN=/etc/ppp/ip-down CFGFILE=PRGCFGDIR_MARKER/ppplc.conf d82 2 a83 7 -V) if expr "$VERSION" : 'PATCHLEVEL_MA.KER$' > /dev/null; then warning "this is a development version; use 'ident' for version information" exit 1 else echo "$PROGNAME version $VERSION" exit 0 fi ;; d92 1 a92 1 CFGFILE=$2 a158 4 ns) $SNDMSG 11 ;; ng) $SNDMSG 17 ;; ms) $SNDMSG 8 ;; mg) $SNDMSG 14 ;; a162 2 qd) $SNDMSG 32 ;; id) $SNDMSG 31 ;; d165 10 a174 3 lc) $SNDMSG 34 ;; gc) $SNDMSG 36 ;; i0) $SNDMSG 29 2 d176 2 a177 61 es) # clear pending announcements and hangups $SNDMSG 31 26 24 31 5 24 # queue a 'going down in 5 minutes' announcement $SNDMSG -q 900 26 7 # queue a hangup for 20 minutes $SNDMSG -q 1200 5 # queue an immediate announcement $SNDMSG 26 8 ;; ds) # clear pending announcements and hangups $SNDMSG 31 26 24 31 5 24 ;; h) ppplcchelp ;; S) [ ! -f $CFGFILE ] && error -f "can't read $CFGFILE" $PPPLCD $CFGFILE ;; K) $SNDMSG 3 ;; i3) ipcs -qc ;; i4) echo if expr "$VERSION" : 'P.*R$' > /dev/null; then echo "$PROGNAME: WARNING: not a bonafide release; no version information available" else echo "$PROGNAME version \ $VERSION" $SNDMSG -V $PPPLCD -V $XPPPLCC -V $QTEST -V $USECNT -V $ANNOUNCE -V $DHUY -V $IPUP -V $IPDOWN -V PRGLIBDIR_MARKER/getmail-sendmail -V PRGLIBDIR_MARKER/sndmail-sendmail -V PRGLIBDIR_MARKER/getmail-fetchmail -V PRGLIBDIR_MARKER/getnews-suck -V PRGLIBDIR_MARKER/sndnews-suck -V PRGLIBDIR_MARKER/getnews-slurp -V PRGLIBDIR_MARKER/sndnews-nntpxmit -V fi ;; i5) echo ident `which $PROGNAME` ident `which $SNDMSG` ident `which $PPPLCD` ident `which $XPPPLCC` ident $QTEST ident $USECNT ident $ANNOUNCE ident $DHUY ident $IPUP ident $IPDOWN ident PRGLIBDIR_MARKER/getmail-sendmail ident PRGLIBDIR_MARKER/sndmail-sendmail ident PRGLIBDIR_MARKER/getmail-fetchmail ident PRGLIBDIR_MARKER/getnews-suck ident PRGLIBDIR_MARKER/sndnews-suck ident PRGLIBDIR_MARKER/getnews-slurp ident PRGLIBDIR_MARKER/sndnews-nntpxmit ;; a179 1 shift a186 1 a192 3 mm) $SNDMSG $* break ;; "") break ;; a214 4 ns) $SNDMSG 11 ;; ng) $SNDMSG 17 ;; ms) $SNDMSG 8 ;; mg) $SNDMSG 14 ;; a218 2 qd) $SNDMSG 32 ;; id) $SNDMSG 31 ;; a220 4 lc) $SNDMSG 34 ;; gc) $SNDMSG 36 ;; i0) $SNDMSG 29 2 $GETMSG ;; d224 4 a227 17 es) # clear pending announcements and hangups $SNDMSG 31 26 24 31 5 24 # queue a 'going down in 5 minutes' announcement $SNDMSG -q 900 26 7 # queue a hangup for 20 minutes $SNDMSG -q 1200 5 # queue an immediate announcement $SNDMSG 26 8 ;; ds) # clear pending announcements and hangups $SNDMSG 31 26 24 31 5 24 ;; qe) warning "qe: not coded yet" ;; ie) warning "ie: not coded yet" ;; sm) warning "sm: not coded yet" ;; S) [ ! -f $CFGFILE ] && error -f "can't read $CFGFILE" $PPPLCD $CFGFILE ;; d229 1 a229 1 i3) ipcs -qc d231 3 a233 24 i4) echo if expr "$VERSION" : 'P.*R$' > /dev/null; then echo "$PROGNAME: WARNING: not a bonafide release; no version information available" else echo "$PROGNAME version \ $VERSION" $SNDMSG -V $PPPLCD -V $XPPPLCC -V $QTEST -V $USECNT -V $ANNOUNCE -V $DHUY -V $IPUP -V $IPDOWN -V PRGLIBDIR_MARKER/getmail-sendmail -V PRGLIBDIR_MARKER/sndmail-sendmail -V PRGLIBDIR_MARKER/getmail-fetchmail -V PRGLIBDIR_MARKER/getnews-suck -V PRGLIBDIR_MARKER/sndnews-suck -V PRGLIBDIR_MARKER/getnews-slurp -V PRGLIBDIR_MARKER/sndnews-nntpxmit -V echo fi d235 1 a235 19 i5) ( echo ident `which $PROGNAME` ident `which $SNDMSG` ident `which $PPPLCD` ident `which $XPPPLCC` ident $QTEST ident $USECNT ident $ANNOUNCE ident $DHUY ident $IPUP ident $IPDOWN ident PRGLIBDIR_MARKER/getmail-sendmail ident PRGLIBDIR_MARKER/sndmail-sendmail ident PRGLIBDIR_MARKER/getmail-fetchmail ident PRGLIBDIR_MARKER/getnews-suck ident PRGLIBDIR_MARKER/sndnews-suck ident PRGLIBDIR_MARKER/getnews-slurp ident PRGLIBDIR_MARKER/sndnews-nntpxmit echo ) | ${PAGER:-more} a236 1 a255 3 mm) question "message number (and parameters)" read MESSAGE_LIST $SNDMSG $MESSAGE_LIST ;; d275 2 a276 1 n) news now! m) mail now! a278 1 ${BROWN}SETTINGS${WHITE} d281 1 d284 2 a285 8 S) start control daemon K) kill control daemon ct) connect at time dt) disconnect at time i0) info (ver/active) i1) info (stt,flg,msgq) i2) info (msgs) i3) info (ipc) i4) info (ver/ask) i5) info (ver/force) i6) info (commands) ${BROWN}ADVANCED SETTINGS${WHITE} ea) enable autoreconnect da) disable autoreconnect d295 2 a296 1 (c) Connect connects to the internet now d298 2 a299 1 (d) Disconnect disconnect from the internet now d301 2 a302 3 (n) News attempt to transfer news now (this is normally done as immediately after a connection is established) d304 2 a305 3 (m) Mail attempt to transfer mail now (this is normally done as immediately after a connection is established) d307 1 a307 1 (h) Help display this help screen d309 1 a309 1 (q) Quit quit $PROGNAME (note that depending on the d311 1 a311 1 quit out of this help screen) d313 15 a327 1 SETTINGS d329 1 a329 21 (en) Enable News if you have disabled the transfer of news then this command re-enables it. note that this only applies when news is transferred immediately after a connection is established. it does not affect use of the (n) command (dn) Disable News this command disables transfer of news. note that this only applies when news is transferred immediately after a connection is established. it does not affect use of the (n) command (es) Enable Safety Hangup this is a neat little piece of insurance you can use when accessing your machine remotely via telnet. run this command and your connection will be hung up in 20 minutes, but 5 minutes before that you will be warned about it. run it again and it will cancel any pending disconnection and schedule hangup in 20 minutes as before. a330 2 (ds) Disable Safety Hangup cancels safety hangup. your connection may still time out as normal though. d332 23 @