Just a sample of the Echomail archive
[ << oldest | < older | list | newer > | newest >> ]
|  Message 334  |
|  Tony Langdon to Wilfred van Velzen  |
|  Re: Favs  |
|  24 May 16 09:20:00  |
 
-=> Wilfred van Velzen wrote to Ben Ritchey <=-
WvV> This is a usefull script.
WvV> You should have asked for usefull scripts instead of the one and only
WvV> most favorite script. ;)
I have a number of useful little scripts. Some actually look at the current
working directory, look for specific configuration files, parse them and
configure themselves accordingly (by setting key environment variables), before
doing their thing. These are used for things like managing the multichannel
IRLP reflector that I have, where paths and ports vary, depending on what
channel I'm working with (which can be derived from the current working
directory).
Here's an example of one of those utility scripts.
-------------------------------------------------------------------
#!/bin/bash
CONFIG=`cat echo_config`
CONF=$CONFIG.conf
CMD="$CONFIG"cmd
if [ -f ./$CONF ]; then
CMDPORT=`cat $CONF | grep ^CmdPort | cut -d ' ' -f3`
echo "running $CMD on port $CMDPORT"
$CMD -p$CMDPORT "$@"
else
echo "tbd or tlb config file not found. Channel not running tlb or tbd, or
no
t in a channel directory."
fi
-------------------------------------------------------------------
Now the key to this is the contents of the file echo_config, which can contain
either
tbd
or
tlb
This tells the system what software is running on a particular channel (and
will allow you to fill in the variables for different cases). :) This script
is not a key system script, it's only used for my convenience, so its error
checking is not as strict as I would normally use. The scripts in the system
check the contents of echo_config for valid values, etc.
And here's one that auto configures the environment that each channel runs
under. This one does have a lot more error checking.
[reflect@dedicated06 ~]$ cat $SCRIPT/echo_env
#!/bin/bash
if [ `/usr/bin/whoami` != "reflect" ] ; then
echo This program must be run as user REFLECT!
exit 1
fi
. /home/reflect/custom/environment
if [ "$PWD" = "$SCRIPT" ] ; then
echo This script is meant to be run from the "channel" directories
echo Running it here will cause problems. Exiting.
exit 1
fi
# Initialise configuration check
CONF_VALID=NO
# Move up one level to channel directory
#cd ..
# Determines which channel we are talking about here by cutting the PWD
CURRENT_CHANNEL=`echo $PWD | cut -d"/" -f5`
if [ -z $CURRENT_CHANNEL ] ; then
echo Current channel could not be determined. Exiting....
exit 2
fi
# Location of dropecho script
export CH_SCRIPT=$CHANNELDIR/$CURRENT_CHANNEL/scripts
# Location of exception list
export CH_CUSTOM=$CHANNELDIR/$CURRENT_CHANNEL
# Location of enable/disable flag file.
export FLAGPATH=$CHANNELDIR/$CURRENT_CHANNEL
# Determine whether using tbd or tlb
export PROG=`cat $CHANNELDIR/$CURRENT_CHANNEL/echo_config`
# location of tbdcmd and tbd.conf
if [ "$PROG" = "tbd" ]; then
export TBDCMD=/usr/local/bin/tbdcmd
CONF_VALID=YES
elif [ "$PROG" = "tlb" ]; then
export TBDCMD=/usr/local/bin/tlbcmd
CONF_VALID=YES
else
# echo "Unable to identify software in use, forcing use of sfreflect"
export PROG=""
CONF_VALID=NO
fi
# Binary in use
# Check to see if relevant config file actually exists!
if [ "$CONF_VALID" = "YES" ]; then
export TBDCONF="$CHANNELDIR/$CURRENT_CHANNEL/$PROG".conf
# Port to send commands to - Obtain correct port from config file.
if [ -f "$TBDCONF" ]; then
CONF_VALID=YES
export PORT=`cat $TBDCONF | grep ^CmdPort | cut -d' ' -f3`
# Now check that the port is a valid numeric (in decimal) value.
PORTCHECK=`echo $PORT | grep [[:alpha:]]`
if [ $PORT = "" ]; then
echo Invalid port value
CONF_VALID=NO
elif ! [ "$PORTCHECK" = "" ]; then
CONF_VALID=NO
fi
fi
fi
if [ "$CONF_VALID" = "YES" ]; then
CHATPORT=$PORT
let "CHATPORT += 1"
export CHATPORT
export CHANNEL_ENV=YES
export APPNAME=`cat $TBDCONF | grep ^AppName | cut -d' ' -f3`
if [ "$APPNAME" = "" ]; then APPNAME=$PROG ; fi
else
export PROG=""
fi
-----------------------------------------------------------------------
And this one does use some bash extensions. :)
... If little else, the brain is an educational toy.
--- MultiMail/Win32 v0.49
* Origin: Freeway BBS - freeway.apana.org.au (3:633/410)
|
[ << oldest | < older | list | newer > | newest >> ]