Re: Recipes for automatically starting deschall (different OSes)

Dan Calle (dcalle@lucifer.bevc.blacksburg.va.us)
Sun, 20 Apr 1997 23:33:38 -0400 (EDT)


On Sun, 20 Apr 1997, Nelson Minar wrote:

> Here's my script:
>
[snip]

I took your script and fleshed it out a bit
only thing I changed that might break anything was to use "nice -n 10"
instead of "nice -10" since the latter is apparently obsolescent syntax.

Here are some instructions and notes, the script follows.
Don't forget to delete my sig.

1) Edit the script and modify the variables at the top as needed.
2) su to root
3) rename the script to /sbin/init.d/deschall
4) chown bin.bin /sbin/init.d/deschall
5) chmod 750 /sbin/init.d/deschall
6) cd /sbin/rc3.d/
7) ln -s ../init.d/deschall Sxxdeschall
8) reboot to test OR just type /sbin/init.d/deschall start

Notes:

- If you're only going to run the script manually, you only need to do step
1.
- In step 7, replace "xx" by some number from 00..99. The rc scripts
execute every script in that directory in ascending order so you probably
want to name it something like S95deschall.init so that it runs after all
the important stuff. Just make sure the number isn't taken.

- To kill it, just type /sbin/init.d/deschall stop

Here's the script:

--------cut here--------cut here--------cut here--------cut here--------
#! /bin/sh
#
# <nelson@media.mit.edu> quick hack up to start deschall nicely as user
# nobody, nice 19, and do logging.
#
# <dan@vt.edu> - modified to handle some errors, make it easier to change
# some parameters, fix it so it works with some other Unixen, implement
# the "stop" argument, and allow it to be run by normal users.
#
# more info on deschall is at http://www.frii.com/~rcv/deschall.htm

# Edit these to reflect your setup.
#
LOGDIR=/var/log/
LOGNAME=deschall
DESCHALL=/usr/local/bin/deschall
KEYSERVER=keymaster.verser.frii.com

# You'll need to change this if user nobody has an invalid shell
# (often the case for security reasons) or if you're not going to be running th# is as root.
#
DESUSER=nobody

# This is an offset so, for example, since deschall runs niced to 10 by
# default, setting NICEOFFSET to 5 will result in deschall running niced
# to 15. The higher the nice level, the lower the priority.
#
NICEOFFSET=0

# You probably don't need to modify anything beyond this point
#
LOGPATH=$LOGDIR/$LOGNAME

case "$1" in
start)
if [ ! -x $DESCHALL ]; then
echo "$0: ERROR: could not execute $DESCHALL"
exit 1
elif [ ! -d $LOGDIR ]; then
echo "$0: ERROR: $LOGDIR does not exist, unable to write log"
echo "$0: exiting"
exit 1
else
echo "Starting deschall to crack DES"

# create the logfile if it doesn't already exist
#
if [ ! -f $LOGPATH ]; then
touch $LOGPATH
chown $DESUSER $LOGPATH
fi
echo "" >> $LOGPATH
echo "Starting deschall at `date`" >> $LOGPATH

# start the cracker as user DESUSER, niced to NICEOFFSET + 10
#
su $DESUSER -c "exec nice -n $NICEOFFSET $DESCHALL \
$KEYSERVER >> $LOGPATH 2>&1 &"
fi
;;
stop)
pid=`/bin/ps -e | grep $DESCHALL | grep -v grep | \
sed -e 's/^ *//' -e 's/ .*//' | head -1`
if [ "X$pid" != "X" ]; then
kill $pid
fi
echo "" >> $LOGPATH
echo -n "Stopping deschall at `date`" >> $LOGPATH
echo "" >> $LOGPATH
;;
*)
echo "Usage: deschall {start|stop}"
exit 1
esac

exit 0
--------cut here--------cut here--------cut here--------cut here--------

--
Dan Calle                        Senior, Computer Science, Virginia Tech
Email: dan@vt.edu                    Assistant Administrator: acm.vt.edu
http://acm.vt.edu/~dcalle/          dcalle@lucifer.bevc.blacksburg.va.us