view packaging/linux-installer-uninstall.inc @ 1179:3e7ac50b04da

(help) Updated search box title.
author Emanuel Schuetze <emanuel@intevation.de>
date Mon, 22 Sep 2014 12:39:16 +0200
parents c13ac2c9851d
children c8f698ca6355
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()
{
  local cinst="${oldinstcfg[PREFIX]}/bin/cinst"
  local certlist=`ls 2>/dev/null -1  ${instdata_path}/list-installed.txt`

  getxt "Uninstalling certificates ...\n"

  if [ "$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
  else
    getxt "No certificate list found.  Nothing to do.\n"
  fi
}

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

  # FIXME (issue133): delete all files created by the application.
  local tbcfg_files=( "${instcfg_path}/TrustBridge.ini"
                      "${instcfg_path}/trustbridge-tray-starter.cfg"
                      "$instcfg_file" )

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

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

  getxt "Removing configuration files:\n"
  rm_files "${tbcfg_files[@]}"
  rm_empty_dirs "$instcfg_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
      deinstall_certs
      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/