#!/bin/bash
# *******************************************************************
# **  @file skeleton.sh - template for user scripts run by eisman
# **
# **  Creation:     2016-09-10 dv
# **  Last update:  $Id: skeleton.sh 43399 2016-09-18 16:46:22Z hbfl $
# **
# **  Copyright (c) 2016-2017 the eisfair team, team(at)eisfair(dot)org
# **
# **  This program is free software; you can redistribute it and/or modify
# **  it under the terms of the GNU General Public License as published by
# **  the Free Software Foundation; either version 2 of the License, or
# **  (at your option) any later version.
# *******************************************************************

. /var/install/include/eislib
. /var/install/include/eismanlib

command="skeleton"


# *******************************************************************
# **  show help on arguments and possible options
# **  @param  n/a
# **  @return n/a
# *******************************************************************

show_help()
{
cat <<EOF

This is a template for user scripts run by eisman

usage: eisman run ${command} [OPTIONS]

options:
   --help      show this help screen

EOF
}


# *******************************************************************
# **  main program
# *******************************************************************
main()
{
    # check if we are running under eisman control. If not use eisman
    # frontend to run the script using the run command
    if ! eisman checklock
    then
        # not running under eisman control!
        eisman run "${command}" "${@}"
        exit $?
    fi

    # read command line args
    while [ "${1:0:2}" = "--" ]
    do
        case $1 in
        --help)
            show_help
            exit 0
            ;;
        *)
            echo "error: unknown option \"$1\"!" >&2
            echo ""
            show_help
            exit 1
            ;;
        esac
    done
}

main "${@}"
