#! /bin/sh #---------------------------------------------------------------------------- # /var/install/deinstall/webmail - webmail deinstallation # # Copyright (c) 2001-2014 The Eisfair Team, team(at)eisfair(dot)org # # Creation: 2002-12-01 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 #testroot=/soft/jedwebmail # only for testing testroot="" # 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 ### wm_configfile=$testroot/etc/config.d/webmail wm_package_filelist=$testroot/etc/filelist.d/webmail-files.txt wm_docroot_filelist=${webmail_path}/wm-filelist.txt wm_tmpfile=/tmp/webmail-deinstall-$$ update=0 case $1 in (*update) update=1 ;; esac ### ------------------------------------------------------------------------- ### stop service ### ------------------------------------------------------------------------- $testroot/var/install/config.d/webmail.sh removecron ### ------------------------------------------------------------------------- ### remove mail/vmail from menue system ### ------------------------------------------------------------------------- mecho "removing menue entry ..." if [ ${update} -eq 0 ] then # no update, remove menu if [ -f ${testroot}/var/install/packages/mail ] then # mail package /var/install/bin/del-menu "setup.services.mail.modules.menu" "setup.services.mail.modules.webmail.menu" elif [ -f ${testroot}/var/install/packages/vmail ] then # vmail package /var/install/bin/del-menu "setup.services.vmail.modules.menu" "setup.services.mail.modules.webmail.menu" fi fi # standalone installation /var/install/bin/del-menu "setup.services.menu" "setup.services.mail.modules.webmail.menu" ### ------------------------------------------------------------------------- ### remove installed locale(s) ### ------------------------------------------------------------------------- # extract document root grep -E "^START_WEBMAIL|^WEBMAIL_N|^WEBMAIL_._DOCUMENT_ROOT" ${wm_configfile} > ${wm_tmpfile} . ${wm_tmpfile} rm -f ${wm_tmpfile} if [ $WEBMAIL_N -ne 0 ] then mecho "removing locale files ..." idx=1 while [ $idx -le $WEBMAIL_N ] do wm_nbr=$idx locale_mask="??_??-filelist-${wm_nbr}.txt" # get document root eval wm_doc_root=${testroot}'$WEBMAIL_'${wm_nbr}'_DOCUMENT_ROOT' if [ -d "${wm_doc_root}" ] then for FLIST in ${webmail_path}/${locale_mask} do # example: de_DE-filelist-1.txt disp_code=`basename "${FLIST}"|cut -c1-5` ccode=`echo "${disp_code}" | tr 'A-Z' 'a-z'` # check if included locale should be removed if [ "$ccode" != "de_de" -a "$ccode" != "en_us" ] then # locale not included - go on ... mecho "- ${disp_code} ..." # remove files for FDNAME in `cat "${FLIST}"` do # check for comment echo "${wm_doc_root}/${FDNAME}" | grep -q "^#" if [ $? -ne 0 ] then # no comment - go on... if [ -f "${wm_doc_root}/${FDNAME}" ] then # remove file rm -f "${wm_doc_root}/${FDNAME}" fi fi done fi # remove directories if [ -d "${wm_doc_root}/locale/${disp_code}/LC_MESSAGES" ] then rmdir --ignore-fail-on-non-empty "${wm_doc_root}/locale/${disp_code}/LC_MESSAGES" fi if [ -d "${wm_doc_root}/locale/${disp_code}" ] then rmdir --ignore-fail-on-non-empty "${wm_doc_root}/locale/${disp_code}" fi if [ -d "${wm_doc_root}/help/${disp_code}" ] then rmdir --ignore-fail-on-non-empty "${wm_doc_root}/help/${disp_code}" fi # remove list file if [ -f "${FLIST}" ] then rm -f "${FLIST}" fi done # remove document root directory if [ -d "${wm_doc_root}" ] then rmdir --ignore-fail-on-non-empty "${wm_doc_root}" fi fi idx=`expr $idx + 1` done fi ### ------------------------------------------------------------------------- ### remove webmail document roots ### ------------------------------------------------------------------------- if [ -f "${wm_docroot_filelist}" ] then if [ $WEBMAIL_N -ne 0 ] then idx=1 while [ ${idx} -le ${WEBMAIL_N} ] do eval wm_doc_root='$WEBMAIL_'${idx}'_DOCUMENT_ROOT' if [ -d "${wm_doc_root}" ] then mecho "removing program files ..." while read line do # check for comment echo "${wm_doc_root}/${FDNAME}" | grep -q "^#" if [ $? -ne 0 ] then # no comment - go on ... FDNAME="${testroot}${wm_doc_root}/${line}" if [ -d "${FDNAME}" ] then # remove directory rmdir --ignore-fail-on-non-empty "${FDNAME}" elif [ -f "${FDNAME}" ] then # remove file rm -f "${FDNAME}" fi fi done < "${wm_docroot_filelist}" fi # remove document root directory if [ -d "${wm_doc_root}" ] then rmdir --ignore-fail-on-non-empty "${wm_doc_root}" fi idx=`expr $idx + 1` done # remove file list rm -f "${wm_docroot_filelist}" fi else mecho -error "missing ${wm_docroot_filelist} file, error removing package files!" fi ### ------------------------------------------------------------------------- ### remove program files ### ------------------------------------------------------------------------- if [ -f "${wm_package_filelist}" ] then while read line do #check if comment echo "${line}" | grep -q "^#" if [ $? -ne 0 ] then # no comment - go on ... delflag=1 ftype=`echo "${line}" | cut -d' ' -f1` fname=`echo "${line}" | cut -d' ' -f6` case $ftype in b|u) # remove program files if [ "${fname}" = "tmp/install.sh" -o "${fname}" = "tmp/preinstall.sh"\ -o "${fname}" = "var/install/deinstall/webmail" ] then delflag=0 else if [ $update -eq 1 ] then # update! - check for /var/webmail / /data/packages/webmail directory wm_path="`echo "${webmail_path}" | sed 's/^\///'`" echo "${fname}" | grep -q "^${wm_path}" if [ $? -eq 0 ] then delflag=0 fi fi fi if [ $delflag -eq 1 ] then rm -f ${testroot}/${fname} fi ;; f) # remove directories if [ -d "${testroot}/${fname}" ] then rmdir --ignore-fail-on-non-empty "${testroot}/${fname}" fi ;; esac fi done < ${wm_package_filelist} fi # remove filelist itself rm -f "${wm_package_filelist}" ### ------------------------------------------------------------------------- ### remove config files ### ------------------------------------------------------------------------- rm -f $testroot/etc/config.d/webmail rm -f $testroot/etc/config.d/webmail.backup if [ $update -ne 1 ] then # no update - deinstall rm -f $testroot/etc/backup.d/webmail* rm -f $testroot/etc/config.d/webmail.backup rm -f $testroot/etc/logrotate.d/webmail rm -r -f ${webmail_path} else mecho -info "directory structure ${webmail_path} will be preserved!" fi ### ------------------------------------------------------------------------- ### remove deinstall script ### ------------------------------------------------------------------------- rm -f ${wm_tmpfile} rm -f $testroot/var/install/deinstall/webmail mecho "done." ### ------------------------------------------------------------------------- ### end ### -------------------------------------------------------------------------