#!/bin/sh #------------------------------------------------------------------------------ # /var/install/bin/-iupdate - update or generate new configuration # # Copyright (c) 2004 # # Creation: # Last Update: # # 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. #------------------------------------------------------------------------------ package='' service='' configfile=/etc/config.d/$package #------------------------------------------------------------------------------ # 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}" fi } #------------------------------------------------------------------------------ # rename variables #------------------------------------------------------------------------------ rename_variables () { renamed=0 colecho "renaming parameter(s) ..." br x br # v1.1.2 # if [ ! -z "`grep ^SMTP_SMART_HOST $source_conf`" ] # then # echo "- SMTP_SMART_HOST -> SMTP_SMARTHOST_1_HOST" # SMTP_SMARTHOST_1_HOST="$SMTP_SMART_HOST" # 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 [ "$EXISCAN_CRYPT_SALT" = "" ] # then # randsalt="`random_char``random_char`" # echo "-EXISCAN_CRYPT_SALT, '' -> '$randsalt'" # EXISCAN_CRYPT_SALT="$randsalt" # 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 if [ -z "`grep ^TWADMIN_TUNE $source_conf`" ] then echo "- TWADMIN_TUNE='no'" TWADMIN_TUNE='no' added=1 fi if [ -z "`grep ^TWADMIN_TUNE_MIN_READAHEAD $source_conf`" ] then echo "- TWADMIN_TUNE_MIN_READAHEAD='512'" TWADMIN_TUNE_MIN_READAHEAD='512' added=1 fi if [ -z "`grep ^TWADMIN_TUNE_MAX_READAHEAD $source_conf`" ] then echo "- TWADMIN_TUNE_MAX_READAHEAD='512'" TWADMIN_TUNE_MAX_READAHEAD='512' 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 # for varname in "EXISCAN_AV_CLAMAV_HOST EXISCAN_AV_CLAMAV_PORT" # do # if [ ! -z "`grep \"^$varname\" $source_conf`" ] # then # echo "- $varname" # 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/twadmin - configuration for 3ware Escalade IDE RAID' echo '# services on EIS/FAIR' echo '#' echo '# Copyright (c) 2002 Maximilian Pasternak' echo '# ' echo '#' echo '# Creation: 19.07.2003 mp' echo '# Last Update: 09.08.2003 mp' 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 '#------------------------------------------------------------------------------' echo '# Settings' echo '#------------------------------------------------------------------------------' echo echo "START_TWADMIN='$START_TWADMIN'`spaces \"$START_TWADMIN\" 23` # use 3ware services: yes or no" echo echo echo '#------------------------------------------------------------------------------' echo echo "TWADMIN_TUNE='$TWADMIN_TUNE'`spaces \"$TWADMIN_TUNE\" 24` # use performance settings" echo echo "TWADMIN_TUNE_MIN_READAHEAD='$TWADMIN_TUNE_MIN_READAHEAD'`spaces \"$TWADMIN_TUNE_MIN_READAHEAD\" 10` # /proc/sys/vm/min-readahead" echo "TWADMIN_TUNE_MAX_READAHEAD='$TWADMIN_TUNE_MAX_READAHEAD'`spaces \"$TWADMIN_TUNE_MAX_READAHEAD\" 10` # /proc/sys/vm/max-readahead" echo echo echo '#------------------------------------------------------------------------------' echo echo "TWADMIN_CRON='$TWADMIN_CRON'`spaces \"$TWADMIN_CRON\" 24` # use cron to check array" echo " # status: yes or no" echo echo "TWADMIN_CRON_SCHEDULE='$TWADMIN_CRON_SCHEDULE'`spaces \"$TWADMIN_CRON_SCHEDULE\" 15` # cron configuration string" echo echo "TWADMIN_SYSLOGD='$TWADMIN_SYSLOGD'`spaces \"$TWADMIN_SYSLOGD\" 21` # log output to syslogd: yes or no" echo echo "TWADMIN_FULLLOG='$TWADMIN_FULLLOG'`spaces \"$TWADMIN_FULLLOG\" 21` # activate full logging" echo " # in /var/log/log.twadmin" echo "TWADMIN_FULLLOG_LOGROTATION='$TWADMIN_FULLLOG_LOGROTATION'`spaces \"$TWADMIN_FULLLOG_LOGROTATION\" 9` # for logrotation" echo echo '#------------------------------------------------------------------------------' echo '# End' echo '#------------------------------------------------------------------------------' ) > $generate_conf colecho "... finished." br x br /var/install/bin/anykey } #============================================================================== # main #============================================================================== # setting defaults source_conf=$configfile generate_conf=$configfile.new goflag=0 case "$1" in update) goflag=1 ;; test) source_conf=$configfile generate_conf=$configfile.test goflag=1 ;; *) echo echo "Use one of the following options:" echo echo " twadmin-update [update] - the file $configfile will be read, this configuration will" echo " be checked and an updated twadmin 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 # take over of the new config is done in install.sh # backup is done in twadmin-edit script else colecho "no configuration $source_conf found - exiting." rd /var/install/bin/anykey fi fi