#!/bin/sh #---------------------------------------------------------------------------- # /var/install/bin/webmail-list-locale - list installed locale(s) # # Copyright (c) 2001-2011 The Eisfair Team, team(at)eisfair(dot)org # # Creation: 2005-06-26 jed # Last Update: $Id$ # # 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 etc. . /var/install/include/eislib . /var/install/include/check-eisfair-version #---------------------------------------------------------------------------- # create list of locales #---------------------------------------------------------------------------- create_locale_list () { for FNAME in $webmail_path/$locale_mask do disp_code=`basename "$FNAME"|cut -c1-5` inst=`basename "$FNAME"|sed -e 's/^.*filelist-//g' -e 's/.txt$//g'` code=`echo $disp_code|tr 'A-Z' 'a-z'` if [ $inst -le $WEBMAIL_N ] then echo "$inst:$code:$disp_code:$FNAME" fi done | sort > $tmpfile } #---------------------------------------------------------------------------- # print list of locales #---------------------------------------------------------------------------- print_locale_list () { # print header clrhome mecho -info "List installed locale(s)" mecho techo begin 2 35 10 techo row "" -info "Document Root" -info Code tty=`tty` idx=0 row=4 while read line do _ifs="$IFS" IFS=: set -- $line wm_inst=$1 disp_code="$3" IFS="$_ifs" if [ $idx -ne $wm_inst ] then # print document root eval wm_docroot='$WEBMAIL_'${wm_inst}'_DOCUMENT_ROOT' techo idx=`expr $idx + 1` row=`expr $row + 1` else wm_docroot='' fi # output data if [ "$disp_code" = "de_de" -o "$disp_code" = "en_us" ] then techo row "" "$wm_docroot" $disp_code "(part of webmail package)" else techo row "" "$wm_docroot" $disp_code fi row=`expr $row + 1` if [ "$act_pmode" = 'tty' ] then if [ $row -eq 21 ] then mecho mecho anykey <$tty # print header clrhome mecho -info "List locales" <$tty mecho techo row "" -info "Document Root" -info Code row=4 fi fi done < $tmpfile techo end mecho } #============================================================================ # main #============================================================================ #testroot=/tmp/wm # only for testing testroot="" act_pmode=`get_printmode` base=`basename $0` # set platform specific parameters case ${EISFAIR_SYSTEM} in eisfair-1) # eisfair-1 webmail_path=${testroot}/var/webmail ;; *) # default to eisfair-2/eisxen-1 webmail_path=${testroot}/data/packages/webmail ;; esac ### set file names #### webmailfile=/etc/config.d/webmail tmpfile="/tmp/$base-$$" tmpfile2="/tmp/$base-$$" locale_mask='??_??-filelist*.txt' # look for locale files # da_DK-1.4.5rc1-20050616.tar.gz ls $webmail_path/$locale_mask > /dev/null 2> /dev/null if [ $? -eq 0 ] then # extract document root grep -E "^START_WEBMAIL|^WEBMAIL_N|^WEBMAIL_._DOCUMENT_ROOT" ${webmailfile} > ${tmpfile2} . ${tmpfile2} if [ "$START_WEBMAIL" = "yes" -a $WEBMAIL_N -gt 0 ] then create_locale_list print_locale_list else # no webmail instance defined mecho -warn "The webmail package has not been activated or no webmail" mecho -warn "instance has been defined in the configuration file." mecho mecho -info "Please set START_WEBMAIL='yes' and WEBMAIL_N to a value greater than zero." fi rm -f ${tmpfile2} else # no files found mecho -warn "No locale file has been found in $webmail_path!" fi rm -f ${tmpfile} anykey #============================================================================ # end #============================================================================