#!/bin/sh #---------------------------------------------------------------------------- # eisfax-update - update or generate new eisfax configuration # # Copyright (c) 2002-2004 Stefan Krister # Copyright (c) 2005 Frank Meyer # # Last Update: $Id$ # # if password is empty, user will be prompted # if uid or gid is empty, values will be evaluated # # 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 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- #testroot=/tmp testroot='' eisfaxfile=$testroot/etc/config.d/eisfax #------------------------------------------------------------------------------ # return string of spaces # $1 - name of variable # $2 - length of string - length of variable ($1) # ret - string of spaces #------------------------------------------------------------------------------ spaces () { varname=$1 varlen=${#varname} explen=$2 if [ "$explen" = "" ] then # empty string explen=$varname varlen=0 fi if [ $explen -gt $varlen ] then # string should be extended strlen=`expr $explen - $varlen` # fixed spaces string - 60 character long (fast method) spacestr=" " echo "${spacestr:0:$strlen}" # variable spaces string loop (slow method) # idx=1 # while [ $idx -le $strlen ] # do # echo -e " \c" # idx=`expr $idx + 1` # done # echo fi } #------------------------------------------------------------------------------ # rename variables #------------------------------------------------------------------------------ rename_variables () { renamed=0 colecho "renaming parameter(s) ..." br x br # v1.0.5 if [ ! -z "`grep ^EISFAX_SEND_DELETE_SENT $source_conf`" ] then echo "- EISFAX_SEND_DELETE_SENT -> EISFAX_SEND_ACTION" if [ "$EISFAX_SEND_DELETE_SENT" = "yes" ] then EISFAX_SEND_ACTION="delete" else EISFAX_SEND_ACTION="nothing" fi renamed=1 fi if [ $renamed = 1 ] then colecho "... read documentation for renamed parameter(s)!" br x br /var/install/bin/anykey else colecho "... nothing to do." br x br fi } #------------------------------------------------------------------------------ # modify variables #------------------------------------------------------------------------------ modify_variables () { modified=0 colecho "modifying parameter(s) ..." br x br # if [ "$FETCHMAIL_LIMIT" = "" ] # then # echo "- FETCHMAIL_LIMIT, '' -> will now be interpreted as 4096000 bytes!" # modified=1 # fi if [ $modified = 1 ] then colecho "... read documentation for modified parameter(s)!" br x br /var/install/bin/anykey else colecho "... nothing to do." br x br fi } #------------------------------------------------------------------------------ # add variables #------------------------------------------------------------------------------ add_variables () { added=0 colecho "adding new parameter(s) ..." br x br # v1.0.5 if [ -z "`grep ^EISFAX_TYPE $source_conf`" ] then echo "- EISFAX_TYPE='analog'" EISFAX_TYPE='analog' added=1 fi if [ -z "`grep ^EISFAX_RECEIVE_MSN $source_conf`" ] then echo "- EISFAX_RECEIVE_MSN=''" EISFAX_RECEIVE_MSN='' added=1 fi if [ -z "`grep ^EISFAX_SEND_MSN $source_conf`" ] then echo "- EISFAX_SEND_MSN=''" EISFAX_SEND_MSN='' added=1 fi if [ -z "`grep ^EISFAX_SEND_SUPPRESS_MSN $source_conf`" ] then echo "- EISFAX_SEND_SUPPRESS_MSN='no'" EISFAX_SEND_SUPPRESS_MSN='no' added=1 fi if [ -z "`grep ^EISFAX_SEND_USE_ISDN_FAXSERVICE $source_conf`" ] then echo "- EISFAX_SEND_USE_ISDN_FAXSERVICE='no'" EISFAX_SEND_USE_ISDN_FAXSERVICE='no' added=1 fi if [ -z "`grep ^EISFAX_LOG_COUNT $source_conf`" ] then echo "- EISFAX_LOG_COUNT='10'" EISFAX_LOG_COUNT='10' added=1 fi if [ -z "`grep ^EISFAX_LOG_INTERVAL $source_conf`" ] then echo "- EISFAX_LOG_INTERVAL='monthly'" EISFAX_LOG_INTERVAL='monthly' added=1 fi if [ -z "`grep ^EISFAX_SEND_ARCHIVE_PREFACE $source_conf`" ] then echo "- EISFAX_SEND_ARCHIVE_PREFACE='yes'" EISFAX_SEND_ARCHIVE_PREFACE='yes' added=1 fi if [ -z "`grep ^EISFAX_HEADER_PERUSER $source_conf`" ] then echo "- EISFAX_HEADER_PERUSER='yes'" EISFAX_HEADER_PERUSER='yes' added=1 fi if [ -z "`grep ^EISFAX_SEND_DEFAULTDELAY $source_conf`" ] then echo "- EISFAX_SEND_DEFAULTDELAY='18:00'" EISFAX_SEND_DEFAULTDELAY='18:00' added=1 fi # 1.0.7 if [ -z "`grep ^EISFAX_RECEIVE_AUTOPRINT $source_conf`" ] then echo "- EISFAX_RECEIVE_AUTOPRINT='no'" EISFAX_RECEIVE_AUTOPRINT='no' added=1 fi if [ -z "`grep ^EISFAX_RECEIVE_PRINTERQUEUE $source_conf`" ] then echo "- EISFAX_RECEIVE_PRINTERQUEUE='pr1'" EISFAX_RECEIVE_PRINTERQUEUE='pr1' added=1 fi if [ -z "`grep ^EISFAX_RECEIVE_PRINTERDRIVER $source_conf`" ] then echo "- EISFAX_RECEIVE_PRINTERDRIVER='pcl3'" EISFAX_RECEIVE_PRINTERDRIVER='pcl3' added=1 fi if [ -z "`grep ^EISFAX_SEND_MAIL_WITH_PDF $source_conf`" ] then echo "- EISFAX_SEND_MAIL_WITH_PDF='no'" EISFAX_SEND_MAIL_WITH_PDF='no' added=1 fi # 1.0.8 if [ -z "`grep ^EISFAX_REFRESH $source_conf`" ] then echo "- EISFAX_REFRESH='60'" EISFAX_REFRESH='60' added=1 fi if [ $added -eq 1 ] then colecho "... read documentation for new parameter(s)!" br x br /var/install/bin/anykey else colecho "... nothing to do." br x br fi } #------------------------------------------------------------------------------ # delete variables #------------------------------------------------------------------------------ delete_variables () { deleted=0 colecho "deleting old parameters ..." br x br # v1.0.5 for varname in "EISFAX_ADMINISTRATOR" do if [ ! -z "`grep \"^$varname\" $source_conf`" ] then echo "- $varname" echo " all messages will now be send to user 'faxadm' by default!" deleted=1 fi done if [ $deleted -eq 1 ] then /var/install/bin/anykey else colecho "... nothing to do." br x br fi } #------------------------------------------------------------------------------ # create new configuration #------------------------------------------------------------------------------ create_config () { colecho "updating/creating configuration ..." br x br ( echo '#------------------------------------------------------------------------------' echo '# /etc/config.d/eisfax - configuration for eisfax services on EIS/FAIR' echo '#' echo '# Copyright (c) 2002 Frank Meyer ' echo '#' echo '# Creation: 30.03.2003 sk' echo '# Last Update: 30.03.2003 sk' echo '#' echo '# This program is free software; you can redistribute it and/or modify' echo '# it under the terms of the GNU General Public License as published by' echo '# the Free Software Foundation; either version 2 of the License, or' echo '# (at your option) any later version.' echo '#------------------------------------------------------------------------------' echo echo "START_EISFAX='$START_EISFAX'`spaces \"$START_EISFAX\" 21` # start eisfax server: yes or no" echo echo '#------------------------------------------------------------------------------' echo '# global section' echo '#------------------------------------------------------------------------------' echo echo "EISFAX_TYPE='$EISFAX_TYPE'`spaces \"$EISFAX_TYPE\" 22` # fax type: 'analog' or 'isdn'" echo echo "EISFAX_ID='$EISFAX_ID'`spaces \"$EISFAX_ID\" 24` # Your Fax-ID (MSN)" echo "EISFAX_NAME='$EISFAX_NAME'`spaces \"$EISFAX_NAME\" 22` # fax station name (fax header, journals)" echo "EISFAX_PORTSPEED='$EISFAX_PORTSPEED'`spaces \"$EISFAX_PORTSPEED\" 17` # 19200, 38400" echo "EISFAX_INITSTRING='$EISFAX_INITSTRING'`spaces \"$EISFAX_INITSTRING\" 16` # modem initialisationstring" echo "EISFAX_REFRESH='60'`spaces \"$EISFAX_REFRESH\" 19` # Seconds to refresh in webfrontend. 0=never" echo echo '#------------------------------------------------------------------------------' echo '# receive configuration' echo '#------------------------------------------------------------------------------' echo echo "EISFAX_RECEIVE='$EISFAX_RECEIVE'`spaces \"$EISFAX_RECEIVE\" 19` # start fax receive daemon: yes or no" echo "EISFAX_RECEIVE_DEVICE='$EISFAX_RECEIVE_DEVICE'`spaces \"$EISFAX_RECEIVE_DEVICE\" 12` # device (1st comport=ttyS0, 2nd=ttyS1 ...)" echo "EISFAX_RECEIVE_MSN='$EISFAX_RECEIVE_MSN'`spaces \"$EISFAX_RECEIVE_MSN\" 15` # MSN to listen on for EISFAX_TYPE='isdn'" echo "EISFAX_RECEIVE_LOGLEVEL='$EISFAX_RECEIVE_LOGLEVEL'`spaces \"$EISFAX_RECEIVE_LOGLEVEL\" 10` # debug level: 0-9" echo "EISFAX_RECEIVE_AUTOMAIL='$EISFAX_RECEIVE_AUTOMAIL'`spaces \"$EISFAX_RECEIVE_AUTOMAIL\" 10` # mail received faxes?" echo "EISFAX_RECEIVE_AUTOMAIL_MAILADDR='$EISFAX_RECEIVE_AUTOMAIL_MAILADDR'`spaces \"$EISFAX_RECEIVE_AUTOMAIL_MAILADDR\" 1` # Mailaddress to send received faxdocuments." echo "EISFAX_RECEIVE_AUTOPRINT='$EISFAX_RECEIVE_AUTOPRINT' `spaces \"$EISFAX_RECEIVE_AUTOPRINT\" 8` # print received faxes: yes or no" echo "EISFAX_RECEIVE_PRINTERQUEUE='$EISFAX_RECEIVE_PRINTERQUEUE' `spaces \"$EISFAX_RECEIVE_PRINTERQUEUE\" 5` # printerqueue to print the faxes" echo "EISFAX_RECEIVE_PRINTERDRIVER='$EISFAX_RECEIVE_PRINTERDRIVER' `spaces \"$EISFAX_RECEIVE_PRINTERDRIVER\" 1` # printerdriver for your printer - see doc" echo echo '#------------------------------------------------------------------------------' echo '# send configuration' echo '#------------------------------------------------------------------------------' echo echo "EISFAX_SEND='$EISFAX_SEND'`spaces \"$EISFAX_SEND\" 22` # start fax send daemon: yes or no" echo "EISFAX_SEND_DEVICE='$EISFAX_SEND_DEVICE'`spaces \"$EISFAX_SEND_DEVICE\" 15` # Device, if more than one use this:" echo " # 'ttyS0:ttyS1:ttyS2'" echo "EISFAX_SEND_MSN='$EISFAX_SEND_MSN'`spaces \"$EISFAX_SEND_MSN\" 18` # sender MSN for EISFAX_TYPE='isdn'" echo "EISFAX_SEND_SUPPRESS_MSN='$EISFAX_SEND_SUPPRESS_MSN'`spaces \"$EISFAX_SEND_SUPPRESS_MSN\" 9` # suppress MSN when sending: yes or no" echo "EISFAX_SEND_USE_ISDN_FAXSERVICE='$EISFAX_SEND_USE_ISDN_FAXSERVICE'`spaces \"$EISFAX_SEND_USE_ISDN_FAXSERVICE\" 2` # use isdn fax service indicator: yes or no" echo "EISFAX_SEND_DIALPREFIX='$EISFAX_SEND_DIALPREFIX'`spaces \"$EISFAX_SEND_DIALPREFIX\" 11` # dial prefix e.g. ATDT" echo "EISFAX_SEND_DENY='$EISFAX_SEND_DENY'`spaces \"$EISFAX_SEND_DENY\" 17` # list of usernames not allowed to fax" echo " # FUNCTION NOT YET IMPLEMENTED" echo "EISFAX_SEND_DEFAULTDELAY='$EISFAX_SEND_DEFAULTDELAY'`spaces \"$EISFAX_SEND_DEFAULTDELAY\" 9` # Time to send delayed faxes" echo "EISFAX_SEND_MAIL_ON_SUCCESS='$EISFAX_SEND_MAIL_ON_SUCCESS'`spaces \"$EISFAX_SEND_MAIL_ON_SUCCESS\" 6` # controls whether a mail will be sent after" echo ' # successful completion of the fax job' echo "EISFAX_SEND_MAIL_ON_FAILURE='$EISFAX_SEND_MAIL_ON_FAILURE'`spaces \"$EISFAX_SEND_MAIL_ON_FAILURE\" 6` # controls whether a mail will be sent after" echo ' # the fax job has failed more than the maximum' echo ' # number of times' echo "EISFAX_SEND_MAIL_WITH_PDF='$EISFAX_SEND_MAIL_WITH_PDF' `spaces \"$EISFAX_SEND_MAIL_WITH_PDF\" 7` # attach faxed document as pdf to the mail" echo "EISFAX_SEND_MAXFAIL_COSTLY='$EISFAX_SEND_MAXFAIL_COSTLY'`spaces \"$EISFAX_SEND_MAXFAIL_COSTLY\" 7` # This specifies the number of times that a fax" echo ' # may fail "fatally", that is, causing telephone' echo ' # costs' echo "EISFAX_SEND_MAXFAIL_TOTAL='$EISFAX_SEND_MAXFAIL_TOTAL'`spaces \"$EISFAX_SEND_MAXFAIL_TOTAL\" 8` # This is the absolute maximum number of times" echo " # that eisfax will try to send any given fax." echo "EISFAX_SEND_ACTION='$EISFAX_SEND_ACTION'`spaces \"$EISFAX_SEND_ACTION\" 15` # action after fax has been sent:" echo " # nothing, delete, archive" echo "EISFAX_SEND_ARCHIVE_PREFACE='$EISFAX_SEND_ARCHIVE_PREFACE'`spaces \"$EISFAX_SEND_ARCHIVE_PREFACE\" 6` # Put a status preface on 1st page of archived PDF" echo echo "EISFAX_HEADER='$EISFAX_HEADER'" echo " # fax header line" echo " # see documentation for meaning of tokens @X@" echo "EISFAX_HEADER_DATE='$EISFAX_HEADER_DATE'`spaces \"$EISFAX_HEADER_DATE\" 15` # date format for fax header line" echo " # e.g. EISFAX_HEADER_DATE='+%d.%m.%Y %H:%M Uhr'" echo " # gives '23.01.2003 22:10 Uhr'" echo "EISFAX_HEADER_PERUSER='$EISFAX_HEADER_PERUSER'`spaces \"$EISFAX_HEADER_PERUSER\" 12` # individual header line permitted?" echo echo "#------------------------------------------------------------------------------" echo "# log handling" echo "#" echo "# Here you can specify how many logs should be saved and in what interval." echo "#" echo "# Example:" echo "# EISFAX_LOG_COUNT='10' - save the last 10 log files" echo "# EISFAX_LOG_INTERVAL='daily' - save one log file per day" echo "#------------------------------------------------------------------------------" echo echo "EISFAX_LOG_COUNT='$EISFAX_LOG_COUNT'`spaces \"$EISFAX_LOG_COUNT\" 17` # number of log files to save" echo "EISFAX_LOG_INTERVAL='$EISFAX_LOG_INTERVAL'`spaces \"$EISFAX_LOG_INTERVAL\" 14` # interval: daily, weekly, monthly" echo echo "#------------------------------------------------------------------------------" echo "# End" echo "#------------------------------------------------------------------------------" ) > $generate_conf colecho "... finished." br x br /var/install/bin/anykey } #============================================================================== # main #============================================================================== # setting defaults source_conf=$eisfaxfile.install generate_conf=$eisfaxfile goflag=0 case "$1" in update) goflag=1 ;; test) # source_conf=$eisfaxfile source_conf=$eisfaxfile.sample # source_conf=$eisfaxfile.sample.v1.0.4 # source_conf=$eisfaxfile.sample.v1.0.5 generate_conf=$testroot/etc/config.d/mk_eisfax.test goflag=1 ;; *) echo echo "Use one of the following options:" echo echo " eisfax-update [test] - the file $eisfaxfile.sample will be read and a test configuration" echo " will be written to the file $testroot/etc/config.d/mk_eisfax.test." echo echo " eisfax-update [update] - the file $eisfaxfile.import will be read, the configuration will" echo " be checked and an updated mail configuration file will be written." echo goflag=0 esac if [ $goflag -eq 1 ] then if [ -f $source_conf ] then # previous configuration file exists colecho "previous configuration found ..." br x br . $source_conf rename_variables modify_variables add_variables delete_variables create_config #backup is done in eisfax-edit script #mv $source_conf $eisfaxfile.backup else colecho "no configuration $source_conf found - exiting." rd fi fi #============================================================================== # end #==============================================================================