#!/bin/sh #---------------------------------------------------------------------------------- # /var/install/bin/uucp-force-connect - force uucp mail exchange # # Copyright (c) 2001-2020 The Eisfair Team, team(at)eisfair(dot)org # # Creation: 2006-11-03 jed # Last Update: $Id$ # # Usage: uucp-force-connect --all - connect to all servers # uucp-force-connect --single - connect only to server # # 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. #---------------------------------------------------------------------------------- # read eislib . /var/install/include/eislib # exec 2>./uucp-trace-$$.log # set -x #---------------------------------------------------------------------------------- # show menu #---------------------------------------------------------------------------------- show_menu () { delete_tmp_file () { # delete old config file if [ -f ${generate_tmpconf} ] then rm -f ${generate_tmpconf} fi } ### get all external mail ### clrhome mecho --info "Selective UUCP Mail-Exchange" mecho mecho "For which one do you want to force a mail exchange?" mecho ### list uucp client accounts ### techo --begin 1 2 2 10 19 19 27 techo --row "" --info "Nr" "" --info "Status" --info "Server" --info "Account" --info "Comment" count=1 while [ ${count} -le ${UUCP_CLIENT_N} -a "${UUCP_CLIENT_ENABLED}" = "yes" ] do eval uu_active='$UUCP_CLIENT_'${count}'_ACTIVE' eval uu_comment='$UUCP_CLIENT_'${count}'_COMMENT' eval uu_host='$UUCP_CLIENT_'${count}'_HOST' eval uu_user='$UUCP_CLIENT_'${count}'_USER' if [ "${uu_active}" = "yes" ] then uu_active='Active' else uu_active='-warn Inactive' fi techo --row "" ${count} ":" ${uu_active} "${uu_host}" "${uu_user}" "${uu_comment}" count=`/usr/bin/expr ${count} + 1` done techo --end mecho endflag=0 count=`/usr/bin/expr ${count} - 1` if [ ${count} -gt 0 ] then until [ ${endflag} = 1 ] do /var/install/bin/ask "Please enter account number (1-${count}) or (q)uit:" '' '+' > /tmp/ask.$$ rc=$? nbr=`cat /tmp/ask.$$` rm -f /tmp/ask.$$ if [ $rc = 255 ] then exit 1 fi case "${nbr}" in [qQ] ) endflag=1 exit 1 ;; [0-9] | [1-9][0-9] ) ### number entered ### if [ ${nbr} -ge 1 -a ${nbr} -le ${count} ] then mecho --info "Forcing a mail exchange for uucp account: ${nbr} ..." if [ "${UUCP_DO_DEBUG}" != "yes" ] then # force 'normal' exchange /usr/sbin/uucico -S ${uu_host} else # force exchange in debug mode /usr/sbin/uucico -x 11 -S ${uu_host} fi endflag=1 else mecho --warn "Number not in range, try again!" fi ;; * ) ;; esac done else mecho --info "There are currently no uucp accounts defined!" fi mecho anykey } #---------------------------------------------------------------------------------- # force single connect #---------------------------------------------------------------------------------- force_connect_single () { nbr=$1 if [ -n "${nbr}" ] then eval uu_active='$UUCP_CLIENT_'${nbr}'_ACTIVE' if [ "${uu_active}" = "yes" ] then eval uu_host='$UUCP_CLIENT_'${nbr}'_HOST' if [ "${UUCP_DO_DEBUG}" != "yes" ] then # force 'normal' exchange /usr/sbin/uucico -S ${uu_host} else # force exchange in debug mode /usr/sbin/uucico -x 11 -S ${uu_host} fi ret=0 fi else # error echo "Missing entry number!" fi } #---------------------------------------------------------------------------------- # force all connects #---------------------------------------------------------------------------------- force_connect_all () { if [ "${UUCP_CLIENT_ENABLED}" = "yes" ] then count=1 while [ ${count} -le ${UUCP_CLIENT_N} ] do force_connect_single ${count} count=`/usr/bin/expr ${count} + 1` done fi } #================================================================================== # main #================================================================================== pgmname=$0 uucpfile=/etc/config.d/uucp confscript_file=/var/install/config.d/uucp.sh generate_tmpconf=/tmp/uucp-$$.tmp . ${uucpfile} cmd=$1 count=$2 case ${cmd} in -all|--all ) force_connect_all ;; -single|--single ) force_connect_single ${count} ;; * ) # show menu by default show_menu ;; esac #================================================================================== # end #==================================================================================