#!/bin/sh #---------------------------------------------------------------------------- # /var/install/deinstall/eisportal - deinstall script # # Creation: 13.05.2006 ys # Last Update: $Id$ # # Copyright (c) 2005-2006 Yves Schumann # # 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. #---------------------------------------------------------------------------- # include eislib . /var/install/include/eislib package_name='eisportal' . /etc/config.d/${package_name} # read the configuration mysql_data_dir=/var/lib/mysql mysql_base_dir=/usr/local/mysql packageFolder=${EISPORTAL_INSTALL_PATH}/${EISPORTAL_INSTALL_FOLDER} if [ "$1" = "update" ] then mecho -info "Updating EisPortal (removing previous version)" update=1 else mecho -info "Removing Eisportal" update=0 fi ### ------------------------------------------------------------------------- ### check if there are some files of installed modules ### ------------------------------------------------------------------------- removeModulesDir="yes" #stillModulesInstalled=`dir /var/www/htdocs/${package_name}/modules` stillModulesInstalled=`dir ${packageFolder}/modules` if [ -z "${stillModulesInstalled}" ] then mecho "No files of installed EisPortal modules found" else if [ "$update" = "1" ] then mecho "" mecho -warn "Found files of following modules:" mecho -warn "${stillModulesInstalled}" mecho "" mecho "They where not modified so these modules should work after the update." mecho "Just take a look for updates for the modules too!" mecho "" anykey fi # removeModulesDir=`/var/install/bin/ask "Remove files of these packages anyway?" "n"` fi ### ------------------------------------------------------------------------- ### remove config and check file ### ------------------------------------------------------------------------- rm -f /etc/default.d/${package_name} rm -f /etc/check.d/${package_name}* ### ------------------------------------------------------------------------- ### remove program files ### ------------------------------------------------------------------------- #rm -rf /usr/local/${package_name} ### ------------------------------------------------------------------------- ### remove doc files ### ------------------------------------------------------------------------- rm -rf /usr/share/doc/${package_name} ### ------------------------------------------------------------------------- ### remove all menu and config files ### ------------------------------------------------------------------------- rm -f /var/install/menu/setup.services.${package_name}* #rm -f /var/install/bin/${package_name}-* # scripte werden noch benötigt! rm -f /var/install/config.d/${package_name}.sh rm -f /var/install/config.d/${package_name}-update.sh rm -f /var/install/help/${package_name} rm -f /var/install/packages/${package_name} ### ------------------------------------------------------------------------- ### stop remove for update only ### ------------------------------------------------------------------------- if [ "$update" = "1" ] then exit 0 fi ### ------------------------------------------------------------------------- ### remove webpage files ### ------------------------------------------------------------------------- removeWholeDirectory="yes" if [ -z "${stillModulesInstalled}" ] then mecho "No modul files in webpage folder found" else for modul in ${stillModulesInstalled} do if [ -h "${modul}" ] # is this modul a symlink? then # yes, its a symlink mecho "" mecho "Modul ${modul} is only a symlink. Removing this" mecho "symlink will not remove the EisPortal modul ${modul}." removeSymLink=`/var/install/bin/ask "Remove symlink?" "y"` if [ "${removeSymLink}" = "yes" ] then unlink ${modul} else removeWholeDirectory="no" fi else # no, its not a symlink mecho "" mecho -n "Deinstall modul " mecho -n -info "${modul} " mecho "with deinstall" mecho "script of this modul? If you answer with 'no' you have to " removeModule=`/var/install/bin/ask "cleanup your system by hand:" "y"` if [ "${removeModule}" = "yes" ] then mecho "" mecho "Starting deinstallation of ${modul}..." mecho "" /var/install/deinstall/${modul} mecho "" mecho "Deinstallation of ${modul} finished" else removeWholeDirectory="no" fi fi done fi if [ "${removeWholeDirectory}" = "yes" ] then mecho -n "Removing EisPortal webpage files... " # rm -rf /var/www/htdocs/${package_name} rm -rf ${packageFolder} mecho "Done" mecho "" else mecho -n "Removing EisPortal webpage files except of the modules directory... " callDir=`pwd` # cd /var/www/htdocs/eisportal/ cd ${packageFolder} # ------------------------------------------------------------------------- # Find and delete all files and directories without modules directory: # 1. find # - don`t go into the subdirs (-maxdepth 1) # - search for everything except "modules" (-not -name 'modules') # - search for everything except "." (-not -name '.') # 2. xargs # - give every line once to the next command (-n1) # 3. rm # - remove the given directory recursively # ------------------------------------------------------------------------- find -maxdepth 1 -not -name 'modules' -not -name '.' | xargs -n1 rm -rf cd ${callDir} mecho "Done" mecho "" fi ### ------------------------------------------------------------------------- ### remove database and db admin user ### ------------------------------------------------------------------------- # read settings . /etc/config.d/${package_name} ### ------------------------------------------------------------------------- ### check for mysql if [ ! -f /var/run/mysql.pid ] then mecho -error "Error! Cannot connect to MySQL server." else if [ "${EISPORTAL_DB_LOCATION_LOCAL}" = "yes" ] then ### ------------------------------------------------------------------------- ### get backup password ### ------------------------------------------------------------------------- mysql_pass=`grep passwd= ${mysql_data_dir}/backup.pwd | sed "s/passwd=//g"` user="backup" ### ------------------------------------------------------------------------- ### Remove Remote Hosts ### ------------------------------------------------------------------------- yesRemoveRemoteHosts=`/var/install/bin/ask "Remove remote hosts?" "y"` if [ "${yesRemoveRemoteHosts}" = "yes" ] then # begin idx -le ${EISPORTAL_REMOTEHOST_N} idx=1 # count for active remote hosts idx1=1 while [ "${idx}" -le "${EISPORTAL_REMOTEHOST_N}" ] do # eval active='${EISPORTAL_REMOTEHOST_'${idx}'_ACTIVE}' # # # begin $active # if [ "${active}" = "yes" ] # then # eval remotehost='${EISPORTAL_REMOTEHOST_'${idx}'_HOST}' # # # create admin user for eisportal # show_eisportal_user=`${mysql_base_dir}/bin/mysql -D mysql -u backup -p${mysql_pass} -e "SELECT user FROM user WHERE user='${EISPORTAL_DB_ADMIN_USER}' AND host='${remotehost}';"` # # if [ -z "${show_eisportal_user}" ] # then # mecho "DB admin user for remotehost ${remotehost} not existing, nothing to remove" # else # mecho -info -n "Removing remote user privileges for host ${remotehost}... " # ${mysql_base_dir}/bin/mysql -D mysql -u backup -p${mysql_pass} -e "REVOKE ALL PRIVILEGES ON * . * FROM ${EISPORTAL_DB_ADMIN_USER}@${remotehost}; " # ${mysql_base_dir}/bin/mysql -D mysql -u backup -p${mysql_pass} -e "REVOKE ALL PRIVILEGES ON ${EISPORTAL_DB_NAME} . * FROM ${EISPORTAL_DB_ADMIN_USER}@${remotehost}; " # mecho -info "Done." # # mecho -info -n "Removing remote user for host ${remotehost}... " # ${mysql_base_dir}/bin/mysql -D mysql -u backup -p${mysql_pass} -e "DROP USER ${EISPORTAL_DB_ADMIN_USER}@${remotehost}; " # mecho -info "Done." # fi # fi /var/install/bin/eisportal-tools-remotehost-remove ${remotehost} # end idx -le ${EISPORTAL_REMOTEHOST_N} idx=`/usr/bin/expr ${idx} + 1` done fi else ### ------------------------------------------------------------------------- ### use given password mysql_pass=${EISPORTAL_DB_ADMIN_PASS} user=${EISPORTAL_DB_ADMIN_USER} fi yesRemoveNow=`/var/install/bin/ask "Remove database?" "y"` if [ "${yesRemoveNow}" = "yes" ] then mecho -info -n "Removing database... " # ${mysql_base_dir}/bin/mysql -h ${EISPORTAL_DB_HOST} -D mysql -u backup -p${mysql_pass} -e "DROP DATABASE ${EISPORTAL_DB_NAME}; " # ${mysql_base_dir}/bin/mysql -h ${EISPORTAL_DB_HOST} -D mysql -u ${EISPORTAL_DB_ADMIN_USER} -p${EISPORTAL_DB_ADMIN_PASS} -e "DROP DATABASE ${EISPORTAL_DB_NAME}; " ${mysql_base_dir}/bin/mysql -h ${EISPORTAL_DB_HOST} -D mysql -u ${user} -p${mysql_pass} -e "DROP DATABASE ${EISPORTAL_DB_NAME}; " mecho -info "Done." else mecho -info "Database not removed" fi if [ "${EISPORTAL_DB_LOCATION_LOCAL}" = "yes" ] then ### ------------------------------------------------------------------------- ### get backup password mysql_pass=`grep passwd= ${mysql_data_dir}/backup.pwd | sed "s/passwd=//g"` yesRemoveNow=`/var/install/bin/ask "Remove database admin user?" "y"` if [ "${yesRemoveNow}" = "yes" ] then mecho -info -n "Removing admin user privileges... " ${mysql_base_dir}/bin/mysql -D mysql -u backup -p${mysql_pass} -e "REVOKE ALL PRIVILEGES ON * . * FROM ${EISPORTAL_DB_ADMIN_USER}@${EISPORTAL_DB_HOST}; " ${mysql_base_dir}/bin/mysql -D mysql -u backup -p${mysql_pass} -e "REVOKE ALL PRIVILEGES ON ${EISPORTAL_DB_NAME} . * FROM ${EISPORTAL_DB_ADMIN_USER}@${EISPORTAL_DB_HOST}; " mecho -info "Done." mecho -info -n "Removing admin user... " ${mysql_base_dir}/bin/mysql -D mysql -u backup -p${mysql_pass} -e "DROP USER ${EISPORTAL_DB_ADMIN_USER}@${EISPORTAL_DB_HOST}; " mecho -info "Done." else mecho -info "Admin user not removed" fi fi fi # check for mysql ### ------------------------------------------------------------------------- ### remove package from menu system / remove all menu and config files ### ------------------------------------------------------------------------- /var/install/bin/del-menu setup.services.menu setup.services.${package_name}.menu ### ------------------------------------------------------------------------- ### remove config file ### ------------------------------------------------------------------------- rm -f /etc/config.d/${package_name} rm -f /etc/backup.d/${package_name}* rm -f /etc/filelist.d/${package_name}-files.txt rm -rf /public/${package_name} ### ------------------------------------------------------------------------- ### remove program files ### ------------------------------------------------------------------------- rm -f /var/install/bin/${package_name}-* ### ------------------------------------------------------------------------- ### remove cron jobs ### ------------------------------------------------------------------------- ### ------------------------------------------------------------------------- ### remove user and group ### ------------------------------------------------------------------------- ### ------------------------------------------------------------------------- ### remove deinstall script ### ------------------------------------------------------------------------- rm -f /var/install/deinstall/${package_name} ### ------------------------------------------------------------------------- echo exit 0