#!/bin/sh # ---------------------------------------------------------------------------- # /var/install/deinstall/bcstorage - deinstall script # # Creation : 2010-01-23 starwarsfan # Last update: $Id$ # # Copyright (c) 2010 the eisfair team, # # 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 # Set package name packageName=bcstorage # Set filelist filelist=/etc/filelist.d/bcstorage-files.txt # Check if this is an update if [ "${1}" == "update" ] then mecho -info "Updating package 'bcstorage' (removing previous version)" update=true # ---------------------------------------------------------------------- # Add everything to this list what should _not_ be removed during an # update. This can be folders too, but let the bash expand their content # using an '*' like 'foo/bar/*'. The entries listet here must be given # on the file list of the package. All other stuff must be remove by hand # using an additional line like 'rm /foo/bar/foobar.txt'. filesToLeave="etc/config.d/bcstorage etc/backup.d/bcstorage* etc/filelist.d/bcstorage-files.txt var/install/deinstall/bcstorage" else mecho -info "Removing package 'bcstorage'" update=false filesToLeave='' fi # ---------------------------------------------------------------------------- # Remove package content except some special files if it's an update # instead of a deinstallation # ---------------------------------------------------------------------------- while read id perm user group package file do # ------------------------------------------------ # Remove file only if it is not on the ignore list removeCurrentFile=true for currentFileToLeave in ${filesToLeave} do if [ "${currentFileToLeave}" == "${file}" ] then removeCurrentFile=false break fi done if ${removeCurrentFile} then case ${id} in b|u) if [ "${file}" != "tmp/install.sh" -a "${file}" != "tmp/preinstall.sh" ] then rm -f /${file} fi ;; f) # Remove directories rmdir --ignore-fail-on-non-empty /${file} ;; esac fi done < ${filelist} # ---------------------------------------------------------------------------- # Check files and default config must be removed separately because they # are not on the file list if the package is used as it was created by # create-package-new.sh, they are created dynamically during installation. # ---------------------------------------------------------------------------- rm -f /etc/check.d/bcstorage* rm -f /etc/default.d/bcstorage* # ---------------------------------------------------------------------------- # Stop remove for update only # ---------------------------------------------------------------------------- if ${update} then exit 0 fi # ---------------------------------------------------------------------------- # Remove package from menu system / remove all menu and config files # ---------------------------------------------------------------------------- /var/install/bin/del-menu setup.services.bacula.menu setup.services.bacula.${packageName}.menu if [ `ls -1 /var/install/menu/ | grep "setup\.services\.bacula\.[^\.]*\.menu" | wc -l` -eq 0 ] then # --------------------------------------- # No more components of bacula installed, # so remove the main menu entry /var/install/bin/del-menu setup.services.menu setup.services.bacula.menu rm -f /var/install/menu/setup.services.bacula.menu fi # ---------------------------------------------------------------------------- # Remove working directory # ---------------------------------------------------------------------------- if [ -f /etc/config.d/${packageName} ] then . /etc/config.d/${packageName} if [ -d "${BCSTORAGE_WORKING_DIR}" ] then rm -fR ${BCSTORAGE_WORKING_DIR} fi else mecho -info "Configuration file for ${packageName} not found, so the working directory" mecho -info "could not be removed! You should check this by hand." fi # ---------------------------------------------------------------------------- # Remove config file # ---------------------------------------------------------------------------- rm -f /etc/config.d/${packageName}* rm -f /etc/backup.d/${packageName}* rm -f /etc/filelist.d/${packageName}-files.txt rm -f /etc/bacula-sd* # ---------------------------------------------------------------------------- # Remove deinstall script # ---------------------------------------------------------------------------- rm -f /var/install/deinstall/${packageName} # ---------------------------------------------------------------------------- exit 0