On Wed, 8 Jun 2005, Khepri wrote:
> Eben King wrote:
> > On Wed, 8 Jun 2005, Khepri wrote:
>
> >>For the 9x's could probably use something such as Wingate's DHCP correct?
> >
> >
> > If one end runs pppd, then it should work if the other end pretends it's a
> > straight PPP connection (no modem) or dialup with the modem already
> > connected, or manual everything (for which the user does nothing).
>
> Hmmm, So I'd just set up the serial to PPP and the daemon will handle it
> on the Linux end then?....If so, cool!
I think PPP is symmetric. If not, then it's easy to make pppd act as the
"other" end.
> >>Well, there's always Samba...
> >
> > Easier to set up IMO and faster (usually).
>
> Dang...heh! I've already had one unsuccessful go around with Samba...:)
> And it's easy!?...ROFL
Well, I think it was easier to set up Samba over a LAN than to set up
routing + PPP/SLIP over a null modem. They were several years apart, so my
memory shouldn't necessarily be trusted. Samba over ethernet is definitely
faster, hundreds of KB/s over 100 Mb/s ethernet, vs 11 KB/s over 115.2 Kb/s
serial.
> Chris-in-SP
> p.s. Oh!...DO you still have that SIG script handy somewhere?...SO i
> don't have to keep writing CHris-in-SP pver and over to distinguish me
> from the much more knowledgeable Christopher here...He'd appreciate it!..LOL
/export/bin/sigmonster:
#!/bin/ksh
# eben wrote this
#
sigdir=/tmp/.sigmonster
signature=.signature
sigfile=.signatures
sigusers="$sigdir/users"
# must be a line with just this on it...
# a bunch of them on one line doesn't count.
# for some reason, if I make divider read-only,
# it changes from '-- ' to ' --'. A bug in pdksh?
divider='-- '
passwd=/etc/passwd
lsflags="-f -l --time=atime --full-time"
progname="sigmonster"
pidfile="/var/run/$progname.pid"
typeset -r signature sigfile sigdir passwd pidfile lsflags
typeset -i sig beginline endline numsigs counter=0 SLEEPTIME=10
[[ -d $sigdir ]] || mkdir "$sigdir" || {
print -u2 "Can't create '$sigdir'."
exit 1
}
# I know RANDOM isn't really random, but it's good enough.
RANDOM=$(( `date +%s` * $$ % 32767 ))
# hope that's a good enough seed...
# `date +%s` is num secs since 00:00:00 1/1/1970
set -o nohup
{
setup () {
logger -i -t "$progname" Initializing...
set -A user # empties out $user[*]
# scan over $passwd...
for thisuser in `cut -f 1 -d : < $passwd` ; do
# have to use \\ instead of \ cuz I have " instead of '
# have to use " so $thisuser gets interpreted
# get this user's home directory
homedir=$(sed -n -e "/^$thisuser:/!d" \
-e "s/^$thisuser:\\([^:]*:\\)\\{4\\}\\([^:]*\\):[^:]*$/\\2/" \
-e p < $passwd)
[[ ( -e "$homedir/.sigmonster.yes" ) && ( -w $homedir ) ]] && {
# this gets the number of elements in ${user[*]} and
# user[that]=$thisuser
# indexing starts from 0, and counting from 1, so... (cardinal
# vs. ordinal)
user[${#user[*]}]=$thisuser
# this does not allow for special chars in usernames, but
# neither does the "for name in ${user[*]} ; do" construct.
# not sure special chars are allowed in usernames, anyhow.
grep --line-number --line-regexp --fixed-strings --regexp="$divider" "$homedir/$sigfile" \
| cut -f 1 -d : \
| sed 's/^\(.*\)$/\1 1-pd/' \
| dc \
| tee "$sigdir/sigends-$thisuser" \
| wc -l > "$sigdir/numsigs-$thisuser"
/bin/ls $lsflags -- "$homedir/$signature" \
| colrm 1 42 \
| colrm 25 > "$sigdir/sigatime-$thisuser"
print -u1 "$homedir" > "$sigdir/homedir-$thisuser"
}
done # for
} # setup
# TERM is kill's default; ^C sends INT; EXIT happens when the shell exits
# not that the rm works... have to figure out why not.
setup
while true ; do
for thisuser in ${user[*]} ; do
homedir="$(<$sigdir/homedir-$thisuser)"
sigatime="$(<$sigdir/sigatime-$thisuser)"
# if ~/.signature has been read since last time...
[[ $sigatime = `ls $lsflags -- $homedir/$signature | colrm 1 42 | colrm 25` ]] || {
# pick random number [1..$numsigs]
# $((...)) rounds down, so without the '1 + ' it's
# '[0..$numsigs - 1]'.
sig=$(( 1 + ( RANDOM * $(<"$sigdir/numsigs-$thisuser") ) / 32767 ))
if [[ $sig -eq 1 ]] ; then
beginline=1
else
beginline=$(( `sed -n $((sig - 1))p < "$sigdir/sigends-$thisuser"` + 2 ))
fi
endline=`sed -n ${sig}p < "$sigdir/sigends-$thisuser"`
# write a new one
sed -n ${beginline},${endline}p < "$homedir/$sigfile" > "$homedir/$signature"
ls $lsflags -- "$homedir/$signature" \
| colrm 1 42 \
| colrm 25 80 > "$sigdir/sigatime-$thisuser"
}
done # for
counter=0
# I have to make each sleep short, because it responds to signals
# _after_ the current process exits, and the /etc/rc.d/init.d scripts
# won't wait for $sleeptime seconds.
while [[ $counter -lt $SLEEPTIME ]] ; do
sleep 1
counter=$((counter + 1))
done
done # while
} &
bgpid=$!
print $bgpid > "$pidfile" || {
print -u2 "Can't write to '$pidfile'."
kill $bgpid
exit 1
}
/etc/rc.d/init.d/sigmonster ("chkconfig --add sigmonster" makes the links):
#!/bin/sh
#
# chkconfig: 235 35 95
# description: starts sigmonster, which is a .signature-randomizing daemon. \
# If the .signature has been modified since the daemon last \
# looked at it, the .signature gets replaced by on randomly \
# chosen from .signatures. Currently the delay between looks \
# is 1s.
# processname: sigmonster
OPTIONS=""
#
# you shouldn't need to change anything below this line
#
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/export/bin:/export/bin/`arch`
# this chops off everything up to the last '/'... like 'basename'
PROGNAME="${0##*/}"
case $PROGNAME in
# this chops off leading S## or K##... see /etc/rc.d/rc?.d
S*|K*) PROGNAME=${PROGNAME#???}
;;
esac
LOCKFILE=/var/lock/subsys/$PROGNAME
BINARY="`which $PROGNAME 2>/dev/null`"
# Don't bother if $PROGNAME doesn't exist.
[ "a$BINARY" = a ] && exit 1
EXECUTABLE="$BINARY $OPTIONS"
# Source function library.
. /etc/rc.d/init.d/functions
RETVAL=0
# See how we were called.
case "$1" in
start)
echo -n "Starting $PROGNAME"
daemon "$EXECUTABLE"
RETVAL=$?
[ $RETVAL -eq 0 ] && touch $LOCKFILE
echo
;;
stop)
echo -n "Stopping $PROGNAME"
killproc $PROGNAME
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f $LOCKFILE 2> /dev/null
echo
;;
status)
status $BINARY
RETVAL=0
;;
restart|reload)
$0 stop
$0 start
# this only gets the return value of the start
RETVAL=$?
;;
*)
echo "Usage: $0 {start|stop|status|restart|reload}"
exit 1
esac
# put the PATH back the way we found it
exit $RETVAL
a file ~/.signatures:
--<space>
sig 1 line 1
sig 1 line 2
...
sig 1 line n1
--<space>
sig 2 line 1
sig 2 line 2
...
sig 2 line n2
--<space>
...
--<space>
sig m line 1
sig m line 2
...
sig m line nm
--<space>
All n* <= 4
any number of m, AFAIK
you'll need to global search&replace 'eben' with '<you>'
-- -eben ebQenW1@EtaRmpTabYayU.rIr.OcoPm home.tampabay.rr.com/hactar SAGITTARIUS: All your friends are laughing behind your back... kill them. Take down all those naked pictures of Ernest Borgnine you've got hanging in your den. -- Weird Al, _Your Horoscope for Today_
This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 20:38:07 EDT