#! /bin/sh #------------------------------------------------------------------------------ # part of the sn-package for eisfair # update the old configuration to the new version # last update: 2003/09/11 # (c) 2003 by Christian Würdig (eisfair@chriswue.de) #------------------------------------------------------------------------------ #test_root="$HOME/EIS/SN/testroot" # testing only test_root="" old_conf="$test_root/etc/config.d/sn.backup" def_conf="$test_root/etc/config.d/sn.default" new_conf="$test_root/etc/config.d/sn" # # gen_v1 # ------ # # generate variables with one number marked as # # parameters: # $1 start index (1 or 2) # $2 maximum number of elements to generate # if examples are generated this value is greater # than the number contained in the master variable # $3 name of master variable # $4.. names of dependent variables # # stolen from Ansgar :) # gen_v1() { do_echo=$1 shift start=$1 shift lto=$1 shift iname=$1 shift names=$* if [ "$do_echo" = "yes" ]; then echo; fi # check highest index eval [ "\$${iname}" -gt $lto ] && eval lto=\$${iname} eval [ "\$OLD_${iname}" -gt $lto ] && eval lto=\$OLD_${iname} idx=$start while [ $idx -le $lto ]; do for name in $names; do vname=`echo $name | sed "s|#|$idx|"` eval val=\${OLD_$vname:=\$$vname} echo "$vname='$val'" done idx=`expr $idx + 1` if [ "$do_echo" = "yes" ]; then echo; fi done if [ "$do_echo" = "no" ]; then echo; fi } update_config() { # prepare old configuration -> mark all variables with OLD_ # stolen from Ansgar :) sed -e "s|^[A-Z].*|OLD_&|" $old_conf > ${old_conf}.old # source old config . ${old_conf}.old rm -f ${old_conf}.old # source default config . $def_conf creation_time=`date` ( echo "#------------------------------------------------------------------------------" echo "# part of the sn-package for EIS/FAIR" echo "# configfile" echo "# last update: 2003/09/10" echo "# (c) 2001-2003 by Christian Würdig (eisfair@chriswue.de)" echo "#------------------------------------------------------------------------------" echo "# created by sn-update-config, $creation_time" echo "#------------------------------------------------------------------------------" echo "" echo "# complete doku: /usr/share/doc/news/sn.txt" echo "" echo "#------------------------------------------------------------------------------" echo "# misc" echo "#------------------------------------------------------------------------------" echo "" start=${OLD_START_SN:=$OLD_SN_START} printf "%-34s %s\n" "START_SN='${start:=$START_SN}'" "# Activate the Newsserver in xinetd?" echo "" printf "%-34s %s\n" "SN_FQDN='${OLD_SN_FQDN:=$SN_FQDN}'" "# FQDN-part of MessageID" echo "" printf "%-34s %s\n" "SN_CLEAR_LOGS='${OLD_SN_CLEAR_LOGS:=$SN_CLEAR_LOGS}'" "# Clear log's at boot-time?" echo "" printf "%-34s %s\n" "SN_REQ_NEW_GROUPS='${OLD_SN_REQ_NEW_GROUPS:=$SN_REQ_NEW_GROUPS}'" "# Scan for new groups on external server(s)?" echo "" echo "#------------------------------------------------------------------------------" echo "# access" echo "#------------------------------------------------------------------------------" echo "" printf "%-34s %s\n" "SN_ALLOW_HOSTS_N='${OLD_SN_ALLOW_HOSTS_N:=$SN_ALLOW_HOSTS_N}'" "# number of allowed hosts" echo "SN_ALLOW_HOST_1='${OLD_SN_ALLOW_HOST_1:=$SN_ALLOW_HOST_1}'" gen_v1 "no" 2 3 SN_ALLOW_HOSTS_N SN_ALLOW_HOST_# printf "%-34s %s\n" "SN_USER_N='${OLD_SN_USER_N:=$SN_USER_N}'" "# number of allowed users" echo "SN_USER_1='${OLD_SN_USER_1:=$SN_USER_1}'" gen_v1 "no" 2 2 SN_USER_N SN_USER_# echo "#------------------------------------------------------------------------------" echo "# logs" echo "#------------------------------------------------------------------------------" echo "" printf "%-34s %s\n" "SN_LOG_DIR='${OLD_SN_LOG_DIR:=$SN_LOG_DIR}'" "# directory for the logfiles" echo "" printf "%-34s %s\n" "SN_FETCH_LOG='${OLD_SN_FETCH_LOG:=$SN_FETCH_LOG}'" "# log for snfetch" printf "%-34s %s\n" "SN_NNTPD_LOG='${OLD_SN_NNTPD_LOG:=$SN_NNTPD_LOG}'" "# log for postings" printf "%-34s %s\n" "SN_DB_LOG='${OLD_SN_DB_LOG:=$SN_DB_LOG}'" "# log for database actions" printf "%-34s %s\n" "SN_CONF_LOG='${OLD_SN_CONF_LOG:=$SN_CONF_LOG}'" "# log for configuration actions" echo "" printf "%-34s %s\n" "SN_ADMIN='${OLD_SN_ADMIN:=$SN_ADMIN}'" "# destination for administrative messages" printf "%-34s %s\n" " " "# read the doku for whole syntax" echo "" echo "#------------------------------------------------------------------------------" echo "# contact behavior" echo "#------------------------------------------------------------------------------" echo "" printf "%-34s %s\n" "SN_FETCH_MODE='${OLD_SN_FETCH_MODE:=$SN_FETCH_MODE}'" "# how to get the news" printf "%-34s %s\n" " " "# read the doku for whole syntax" echo "" fetcht=${OLD_SN_FETCH_TIMES_1:=$OLD_SN_FETCH_TIMES} printf "%-34s %s\n" "SN_FETCH_TIMES_N='${OLD_SN_FETCH_TIMES_N:=$SN_FETCH_TIMES_N}'" "# number of cronjobs" echo "SN_FETCH_TIMES_1='${fetcht:=$SN_FETCH_TIMES_1}'" gen_v1 "no" 2 0 SN_FETCH_TIMES_N SN_FETCH_TIMES_# printf "%-34s %s\n" "SN_FETCH_CONNECTS='${OLD_SN_FETCH_CONNECTS:=$SN_FETCH_CONNECTS}'" "# number of simultaneous connects to external" printf "%-34s %s\n" " " "# newsserver" echo "" printf "%-34s %s\n" "SN_WAIT_PORT='${OLD_SN_WAIT_PORT:=$SN_WAIT_PORT}'" "# wait on port 20000 for message 'ONLINE'" printf "%-34s %s\n" " " "# only used if SN_FETCH_MODE='${OLD_SN_FETCH_MODE:=$SN_FETCH_MODE}'" printf "%-34s %s\n" " " "# read the doku for more information" echo "" printf "%-34s %s\n" "SN_WAIT_ALLOW='${OLD_SN_WAIT_ALLOW:=$SN_WAIT_ALLOW}'" "# accept connect on port SN_WAIT_PORT only" printf "%-34s %s\n" " " "# from this host" printf "%-34s %s\n" " " "# only used if SN_FETCH_MODE='${OLD_SN_FETCH_MODE:=$SN_FETCH_MODE}'" printf "%-34s %s\n" " " "# read the doku for more information" echo "" echo "#------------------------------------------------------------------------------" echo "# general settings for newsgroups" echo "#------------------------------------------------------------------------------" echo "" printf "%-34s %s\n" "SN_GENERAL_N='${OLD_SN_GENERAL_N:=$SN_GENERAL_N}'" "# how many different settings for subscribed" printf "%-34s %s\n" " " "# groups; they will be applied in the given" printf "%-34s %s\n" " " "# order" echo "" printf "%-34s %s\n" "SN_GENERAL_GROUP_1='${OLD_SN_GENERAL_GROUP_1:=$SN_GENERAL_GROUP_1}'" "# select all groups matching this regex" printf "%-34s %s\n" "SN_GENERAL_EXPIRETIME_1='${OLD_SN_GENERAL_EXPIRETIME_1:=$SN_GENERAL_EXPIRETIME_1}'" "# kill all older articles" printf "%-34s %s\n" "SN_GENERAL_MAXARTICLES_1='${OLD_SN_GENERAL_MAXARTICLES_1:=$SN_GENERAL_MAXARTICLES_1}'" "# fetch not more than xxx articles per group" printf "%-34s %s\n" "SN_GENERAL_STATUS_1='${OLD_SN_GENERAL_STATUS_1:=$SN_GENERAL_STATUS_1}'" "# rw - read-write, ro - read-only" gen_v1 "yes" 2 0 SN_GENERAL_N SN_GENERAL_GROUP_# SN_GENERAL_EXPIRETIME_# SN_GENERAL_MAXARTICLES_# SN_GENERAL_STATUS_# echo "#------------------------------------------------------------------------------" echo "# settings for moderated newsgroups" echo "#------------------------------------------------------------------------------" echo "" printf "%-34s %s\n" "SN_MODERATED_N='${OLD_SN_MODERATED_N:=$SN_MODERATED_N}'" "# how many moderated groups" echo "" printf "%-34s %s\n" "SN_MODERATED_GROUP_1='${OLD_SN_MODERATED_GROUP_1:=$SN_MODERATED_GROUP_1}'" "# first moderated group" printf "%-34s %s\n" "SN_MODERATED_MOD_1='${OLD_SN_MODERATED_MOD_1:=$SN_MODERATED_MOD_1}'" "# moderator" gen_v1 "yes" 2 0 SN_MODERATED_N SN_MODERATED_GROUP_# SN_MODERATED_MOD_# echo "#------------------------------------------------------------------------------" echo "# mail-to-news settings" echo "#------------------------------------------------------------------------------" echo "" printf "%-34s %s\n" "SN_LIST_N='${OLD_SN_LIST_N:=$SN_LIST_N}'" "# number of mailinglists piped to newsgroups" echo "" printf "%-34s %s\n" "SN_LIST_USER_1='${OLD_SN_LIST_USER_1:=$SN_LIST_USER_1}'" "# id of user who subscribed the mailinglist" printf "%-34s %s\n" "SN_LIST_NAME_1='${OLD_SN_LIST_NAME_1:=$SN_LIST_NAME_1}'" "# name of mailinglist" printf "%-34s %s\n" "SN_LIST_TO_1='${OLD_SN_LIST_TO_1:=$SN_LIST_TO_1}'" "# reply-to adress for list, only fill out if" printf "%-34s %s\n" " " "# different from SN_LIST_NAME_1" printf "%-34s %s\n" "SN_LIST_NEWSGROUP_1='${OLD_SN_LIST_NEWSGROUP_1:=$SN_LIST_NEWSGROUP_1}'" "# newsgroup where the mails will be send to" printf "%-34s %s\n" "SN_LIST_SENDER_1='${OLD_SN_LIST_SENDER_1:=$SN_LIST_SENDER_1}'" "# envelope sender of the mail" printf "%-34s %s\n" " " "# use 'ro' for read-only newsgroup" gen_v1 "yes" 2 0 SN_LIST_N SN_LIST_USER_# SN_LIST_NAME_# SN_LIST_TO_# SN_LIST_NEWSGROUP_# SN_LIST_SENDER_# ) > $new_conf } if [ ! -f $def_conf ]; then colecho "Default config not found, aborting!" br x br echo "Old config still available at $old_conf" exit 1 fi if [ ! -f $old_conf ]; then echo "No previous config found. Default config will be used." mv $def_conf $new_conf else echo "Updating old config ..." update_config rm -f $def_conf echo "Old config still available at $old_conf" fi if [ ! -s $new_conf ]; then colecho "Creation of config failed, aborting!" br x br echo "Old config still available at $old_conf" exit 1 fi chown root $new_conf chgrp root $new_conf chmod 600 $new_conf exit 0