File to generate the config file `isdn.conf'

This commit is contained in:
luethje 1997-04-08 21:18:50 +00:00
parent d5215e576a
commit 03df7c7544
1 changed files with 85 additions and 0 deletions

85
isdnlog/install/genconf Executable file
View File

@ -0,0 +1,85 @@
#!/bin/sh
## $Id: genconf,v 1.1 1997/04/08 21:18:50 luethje Exp $
##
## ISDN accounting for isdn4linux.
##
## Copyright 1995, 1997 by Andreas Kool (akool@Kool.f.EUnet.de)
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2, or (at your option)
## any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##
## $Log: genconf,v $
## Revision 1.1 1997/04/08 21:18:50 luethje
## File to generate the config file `isdn.conf'
##
CONFFILE=$1
setentry() {
SECTION=$1
ENTRY=$2
VALUE=$3
RESFILE=/tmp/`basename $0`.res.$$
AWKFILE=/tmp/`basename $0`.$$
grep $ENTRY $CONFFILE >/dev/null 2>&1
if [ $? -eq 1 ]
then
cat >$AWKFILE << EOF
{
if (\$0 == "$SECTION")
printf ( "%s\n%s\t= %s\n", \$0, "$ENTRY", "$VALUE" )
else
print
}
EOF
awk -f $AWKFILE $CONFFILE >$RESFILE
cp $RESFILE $CONFFILE
fi
rm -f $AWKFILE $RESFILE
}
if [ ! -f $CONFFILE ]
then
echo -n "Creating config file \"$CONFFILE\"..."
cat >$CONFFILE << EOF
############################################################################
#
# File $CONFFILE generated by `basename $0` on `date`
#
############################################################################
[GLOBAL]
[VARIABLES]
[ISDNLOG]
EOF
else
echo -n "Adding some entries to the config file \"$CONFFILE\"..."
fi
setentry "[GLOBAL]" "AREACODE" "$AREACODE"
setentry "[GLOBAL]" "AREAPREFIX" "$AREAPREFIX"
setentry "[GLOBAL]" "COUNTRYCODE" "$COUNTRYCODE"
setentry "[GLOBAL]" "COUNTRYPREFIX" "$COUNTRYPREFIX"
setentry "[ISDNLOG]" "CHARGEMAX" "$CHARGEMAX"
setentry "[ISDNLOG]" "OLABEL" "$OLABEL"
setentry "[ISDNLOG]" "ILABEL" "$ILABEL"
setentry "[ISDNLOG]" "LOGFILE" "$LOGFILE"
echo " Ready."