#!/bin/sh
# Filename:      remove-packages-server
# Purpose:       remove server packages from system
# Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
# Bug-Reports:   see http://grml.org/bugs/
# License:       This file is licensed under the GPL v2.
# Latest change: Mon Aug 07 21:23:24 CEST 2006 [mika]
################################################################################

if [ $UID != 0 ]; then
  echo "You do not have root permissions. Please run this script as user root. Exiting."
  exit -1
fi

PN=$(basename "$0")
TMPFILE=$(mktemp)

# return 1 if value is *not* set so we purge only packages which are not selected
checkvalue(){
  if grep -q $1 "$TMPFILE" ; then
    return 1
  else
    return 0
  fi
}

interface(){
  dialog --cr-wrap --clear --title "${PN}" --checklist "Which packages would you like to keep?

Some packages are useful only for server systems. Some other packages provide cron jobs you probably do not want to run. It is recommended to remove those packages.

Tip: You can disable running this script inside grml2hd via running 'NOSWREMOVAL=1 grml2hd ...'.
Take a look at 'grml2hd-utils'!

If you do not know what to do at this stage just continue and use the default values.

Select packages which should *not* be removed from your system, deactivated packages will be removed:" 0 0 0 \
  "apache2"  "next generation of the well known HTTP server" on  \
  "backup2l" "low-maintenance backup/restore tool for mountable media" off \
  "backup-manager" "command-line backup tool" off \
  "bind9"  "Internet Domain Name Server" off  \
  "cracklib-runtime" "runtime for cpm: console tool to manage passwords" off \
  "ctrlproxy"  "An IRC proxy with multiserver support" off  \
  "debarchiver" "Tool to handle debian package archives" off \
  "dhcp3-server"  "DHCP server for automatic IP address assignment" off  \
  "dirmngr"  "server for managing certificate revocation lists" off  \
  "dirvish" "Filesystem based backup system using rsync" off \
  "dropbear"  "lightweight SSH2 server" off  \
  "filetraq" "Small utility to keep track of changes in config files" off \
  "fnord"  "yet another small httpd" off  \
  "freeradius\*"  "a high-performance and highly configurable RADIUS server" off  \
  "gsm-utils" "GSM mobile phone access applications" off \
  "icecast2"  "Ogg Vorbis and MP3 streaming media server" off  \
  "mixmaster" "Anonymous remailer client and server" off \
  "nsd"  "authoritative name domain server" off  \
  "opie-server"  "OPIE programs for maintaining an OTP key file" off  \
  "partimage-server"  "server to use partimage across a network" off  \
  "pdns-server"  "extremely powerful and versatile nameserver" off  \
  "pptpd"  "PoPToP Point to Point Tunneling Server" off  \
  "rinetd"  "Internet TCP redirection server" off  \
  "samba"  "a LanManager-like file and printer server" on  \
  "slapd"  "OpenLDAP server" off  \
  "snort" "Flexible Network Intrusion Detection System" off \
  "sn"  "Small NNTP server for leaf sites" off  \
  "squid"  "Internet Object Cache (WWW proxy cache)" off  \
  "telnetd-ssl"  "The telnet server with SSL encryption support" off  \
  "tftpd-hpa"  "HPA's tftp server" off 2>$TMPFILE
}

  interface
  retval=$?
  case $retval in
   0)
    LIST=""
    for service in apache2 backup2l backup-manager bind9 cracklib-runtime      \
                   ctrlproxy debarchiver dhcp3-server dirmngr dirvish dropbear \
                   filetraq fnord freeradius\* gsm-utils icecast2 mixmaster    \
                   nsd opie-server partimage-server pdns-server pptpd rinetd   \
                   samba slapd snort sn squid telnetd-ssl tftpd-hpa
    do
      checkvalue $service && LIST="$LIST $service"
    done
    apt-get --purge remove $LIST
    ;;
   1)
    echo "Cancel pressed."
    ;;
   255)
    echo "ESC pressed."
    ;;
  esac

rm -f $TMPFILE

## END OF FILE #################################################################
