#!/bin/bash
# Kanotix-Control-Center
# by Andreas Loibl <andreas@andreas-loibl.de>
# License: GPL
SEARCHPATH="/usr/share/knxcc"

export TEXTDOMAINDIR="/usr/share/locale"
export TEXTDOMAIN=knxccscript

MODULES="\\"; export MODULES
function register_module()
{
MODULES="$MODULES
\"$1\" \"$2\" \\"
}

BACKDIR="$PWD"
cd "$SEARCHPATH"

module="$1"; shift
if [ ! "$module" ]; then
   # Include all Modules
   for module in $(find modules -name '*.bm')
   do
      . "$module" || exit 3
   done
   # source User-Interface
   . "modules/interface"
else
   # Include supplied Module
   . modules/"$module".bm || exit 3
   action="$1"; shift
   if [ "$action" ]; then
      "$action" "$@"
      RC=$?
      if [ $RC -ne 0 ]; then
         exit $RC
      fi
   fi
fi

cd "$BACKDIR"

exit 0
# exitcodes
cat <<=  1>&2
0: OK
1: UID not root
2: Usage (wrong syntax?)
3: Module not found
4: Module: bad sub/function
=
