#!/bin/sh
# Filename:      grml2hd-utils
# Purpose:       frontend for grml2hd-utils-scripts
# Authors:       grml-team (grml.org), (c) Michael Prokop <mika(at)grml.org>
# Bug-Reports:   see http://grml.org/bugs/
# License:       This file is licensed under the GPL v2.
################################################################################

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

LANG=C
LC_ALL=C
PN=`basename "$0"`

if [[ $1 == '-force' ]]; then
  FORCE='-force'
  FORCEMSG="
Attention! Option force is active: installing/removing packages without any further questions!

"
else
  FORCE=''
fi

main(){
MENU=$(dialog --stdout --clear --cancel-label 'Exit' --default-item 'Exit' --title "$PN" \
        --menu "This script is a frontend for the grml2hd-utils-scripts. Select the program you want to use from the menu.

Notice: network access required for installation of software packages.

If you do not know what to do at this stage just exit the script via pressing enter.

Select tasks you want to execute now:" 0 0 0 \
"Useful" "Install some (general) useful packages (e.g. multimedia stuff)" \
"Office" "Install packages useful for office-related work" \
"Server" "Remove server packages" \
"grml2hd-fix" "Some small fixes for a grml2hd installation" \
"Exit" "Exit this program.")

retval=$?
case $retval in
  0)
        if [ $MENU == Useful ]; then
          install-packages-useful $FORCE
        fi

        if [ $MENU == Office ]; then
          install-packages-office $FORCE
        fi

        if [ $MENU == Server ]; then
          remove-packages-server $FORCE
        fi

        if [ $MENU == grml2hd-fix ]; then
          grml2hd-fix
        fi

        if [ $MENU == Exit ]; then
          exit
        fi
        ;;
  1)
        echo "Exit selected" ; exit 1
        ;;
  255)
        echo "ESC pressed." ; exit 1
        ;;
esac
}

while true; do
  main
done

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