view packaging/linux-installer-uninstall.inc @ 1240:17aa7cf0bedd

(help-admin) Added new help page about installation, server and gui.
author Emanuel Schuetze <emanuel@intevation.de>
date Wed, 24 Sep 2014 17:50:09 +0200
parents 55c13de88b1e
children 014586ef8a84
line wrap: on
line source
#-*-sh-*-

###INCLUDE:linux-installer-uninstall.l10n-de

rm_empty_dirs()
{
  # Args: $1 - DIRECTORY
  #
  # Recursively remove DIRECTORY and all it _parent_ directories as
  # long as they are empty.
  local directory="$1"
  while [ -d "$directory" -a -z "$(ls 2>/dev/null -A "$directory")" ] ; do
    getxt "Deleting empty directory '%s' ...\n" "$directory"
    rmdir "$directory"
    directory=`dirname "$directory"`
  done
}

rm_files()
{
  for file in "$@" ; do
    if [ -e "$file" ] ; then
        getxt "Deleting '%s' ...\n" "$file"
        rm "$file"
    fi
  done
}

remove_cronjob()
{
  setup_cronjob deinstall
}

deinstall_certs_and_config()
{
  local cinst="${oldinstcfg[PREFIX]}/bin/trustbridge-certificate-installer"
  local certlist=`ls 2>/dev/null -1  ${instdata_path}/list-installed.txt`

  getxt "Uninstalling certificates ...\n"

  if [ -f "$certlist" ] ; then
      getxt "Using certificate list '%s'.\n" "$certlist"
      if [ -x "$cinst" ] ; then
          "$cinst" "list=$certlist" "choices=uninstall"
      else
        getxt >&2 "WARNING: can't execute %s for certificate deinstallation.\n" "$cinst"
      fi
      rm_files "$certlist"
  else
    getxt "No certificate list found.  Nothing to do.\n"
  fi

  rm_files "${CFGPATH}/TrustBridge.ini"
  rm_empty_dirs "${CFGPATH}"
}

deinstall_etc()
{
  getxt "Removing cron job ...\n"
  remove_cronjob

  getxt "Removing certificate lists from: %s:\n" "$instdata_path"
  rm_files "$instdata_path"/list-2*.txt

  local tbcfg_files=( "${CFGPATH}/trustbridge-tray-starter.cfg"
                      "$instcfg_file" )

  getxt "Removing configuration files:\n"
  rm_files "${tbcfg_files[@]}"
  rm_empty_dirs "$instcfg_path"
  rm_empty_dirs "${CFGPATH}"

  getxt "Removing PID file from: %s:\n" "$instdata_path"
  rm_files "$instdata_path"/*.pid
  rm_empty_dirs "$instdata_path"

  getxt "Removing TrustBridge from autostart\n"
  rm_files "${autostart_path}/trustbridge.desktop"
  update-desktop-database 2>&1 || true

  getxt "Removing TrustBridge from start menu\n"
  rm_files "${startmenu_path}/trustbridge.desktop"
}

deinstall()
{
  if [ "${oldinstcfg[PREFIX]}" ] ; then
      getxt "Really deinstall TrustBridge from '%s'? [y/n]\n" "${oldinstcfg[PREFIX]}"
      yorn || exit 0
      local certlist=`ls 2>/dev/null -1  ${instdata_path}/list-installed.txt`
      if [ -f "$certlist" ] ; then
        getxt "Do you also want to remove the certificates installed by TrustBridge? [y/n]\n"
        yorn && deinstall_certs_and_config
      fi
      local deinstdir="${oldinstcfg[PREFIX]}/bin"
      getxt "Deinstalling from '%s'.\n" "${oldinstcfg[PREFIX]}"
      for file in $BINNAMES ; do
        local path="${deinstdir}/$file"
        getxt "Deleting '%s' ...\n" "$path"
        rm "$path" || getxt >&2 "WARNING: Could not delete: '%s'!\n" "$path"
      done
      rm_empty_dirs "$deinstdir"

      # images
      deinstdir="${oldinstcfg[PREFIX]}/share/doc/trustbridge/_images"
      for file in $HELPNAMES_IMG; do
        local path="${deinstdir}/$file"
        if [ -f "$path" ]; then
          getxt "Deleting '%s' ...\n" "$path"
          rm "$path" || getxt >&2 "WARNING: Could not delete: '%s'!\n" "$path"
        fi
      done
      rm_empty_dirs "$deinstdir"

      # Javascript sources
      deinstdir="${oldinstcfg[PREFIX]}/share/doc/trustbridge/_sources"
      for file in $HELPNAMES_SOURCES; do
        local path="${deinstdir}/$file"
        if [ -f "$path" ]; then
          getxt "Deleting '%s' ...\n" "$path"
          rm "$path" || getxt >&2 "WARNING: Could not delete: '%s'!\n" "$path"
        fi
      done
      rm_empty_dirs "$deinstdir"

      # Static files
      deinstdir="${oldinstcfg[PREFIX]}/share/doc/trustbridge/_static"
      for file in $HELPNAMES_STATIC; do
        local path="${deinstdir}/$file"
        if [ -f "$path" ]; then
          getxt "Deleting '%s' ...\n" "$path"
          rm "$path" || getxt >&2 "WARNING: Could not delete: '%s'!\n" "$path"
        fi
      done
      rm_empty_dirs "$deinstdir"

      # The actual html
      deinstdir="${oldinstcfg[PREFIX]}/share/doc/trustbridge"
      for file in $HELPNAMES; do
        local path="${deinstdir}/$file"
        if [ -f "$path" ]; then
          getxt "Deleting '%s' ...\n" "$path"
          rm "$path" || getxt >&2 "WARNING: Could not delete: '%s'!\n" "$path"
        fi
      done
      rm_empty_dirs "$deinstdir"
      deinstdir="${oldinstcfg[PREFIX]}/share/pixmaps/trustbridge"
      getxt "Deinstalling from '%s'.\n" "${oldinstcfg[PREFIX]}"
      for file in $ICONNAME; do
        local path="${deinstdir}/$file"
        getxt "Deleting '%s' ...\n" "$path"
        rm "$path" || getxt >&2 "WARNING: Could not delete: '%s'!\n" "$path"
      done
      deinstdir="${oldinstcfg[PREFIX]}/share/pixmaps/trustbridge"
      rm_empty_dirs "$deinstdir"
      deinstdir="${oldinstcfg[PREFIX]}/share/pixmaps"
      rm_empty_dirs "$deinstdir"
      deinstdir="${oldinstcfg[PREFIX]}/share"
      rm_empty_dirs "$deinstdir"
      deinstall_etc
      getxt "Deinstallation finished.\n"
  else
    getxt "No current installation found!  No harm done.\n"
  fi
}

http://wald.intevation.org/projects/trustbridge/