#! /bin/bash
#
# The System Manager
# An Administration Tool For UNIX
#
# Copyright (c) 1994 Stuart Herbert
# Released under the GNU GPL v2
#
# Bugs/comments/contributions to S.Herbert@Sheffield.ac.uk

function RemoveIt()
{
  pushd . > /dev/null
  cd /var/adm/sysman
  REMOVE $1
  popd > /dev/null
}

function main()
{
  InfoBox "Making list of modules ... please wait"
  if [ -f $SysmanFile1 ]; then
    rm -f $SysmanFile1
  fi
  pushd . > /dev/null
  cd /var/adm/sysman/install/MANIFEST
  for x in * ; do
    echo -n "$x $x off " >> $SysmanFile1
  done
  popd > /dev/null
  Dialog --checklist "Please select a module(s) to remove." 20 71 13 `cat $SysmanFile1` 2> $SysmanFile1
  if [ -s $SysmanFile1 ]; then
    MenuLine="`cat $SysmanFile1 | tr -d "\042"`"
    clear
    for x in $MenuLine ; do
      RemoveIt $x
    done
    MsgBox "You should now select UPDATE to rebuild the menus."
  else
    Abort "No modules will be removed."
  fi
}

# main code
if [ -n "$1" ]; then
  case "$1" in
    --SysmanInstall)
      echo "Y : Y : REMOVE : Remove A Module :$0"
      exit
      ;;
    --SysmanAuthor)
      echo "REMOVE : Remove A Module"
      echo "Copyright (c) Stuart Herbert"
      exit
      ;;
  esac
else
  main
fi

# clean up here
for x in $SysmanFile1 $SysmanFile2 $SysmanFile3 ; do
  if [ -f $x ]; then rm -f $x ; fi
done

# that's it, folks
