#!/bin/bash
#
#-----------------------------------------------------------------------------
# -x = debugging on (xtrace)
# -h = Remember the location of commands as they
# are looked up for execution. This is
# enabled by default.
# -p = Turn on privileged mode. In this mode, the
# $ENV and $BASH_ENV files are not processed,
# shell functions are not inherited from the
# environment, and the SHELLOPTS variable, if
# it appears in the environment, is ignored.
#
# (read 'man set' for full info on options)
set -h -p -x
#
# konfigurierbare Variablen:
#
#-----------------------------------------------------------------------------
# interne Arbeitsvariablen:
declare -r Me="${0##*/}" # Pfadnamen entfernen
#declare -r Who="${Me#*.}" # Datei-Endung entfernen
declare -r Who=$(basename $Me .sh) # Datei-Endung entfernen
#declare -r ConfigFile="~/${Who}.conf" # Konfigurations-Datei: privat
declare -r ConfigFile="./${Who}.conf" # Konfigurations-Datei: privat
# oder:
# declare -r ConfigFile="/etc/${Who}.conf" # Konfigurations-Datei: System
declare -r MyPID="$$" # PID des aktuellen Prozesses
declare -r MyFiles="/tmp/${Who}" # Grund-Name fuer tmp.-Dateien
declare -r WorkFlag="${MyFiles}.MenAtWork" # LOCK-Datei
# logfiles fuehren
exec 1>> /var/log/${Who}.log
exec 2>> /var/log/${Who}.err
#
# weitere Variablen-Deklarationen
#
#-----------------------------------------------------------------------------
# Unterprogramme/Funktionen
#
#-----------------------------------------------------------------------------
# Main()
#
# andere Programm-Kopie aktiv
[ -f ${WorkFlag} ] && exit 1
# Aufraeumen sicherstellen
trap " rm -f ${MyFiles}* ; exit " 0 1 2 3 9 15
# Aktivitaet signalisieren
echo ${MyPID} >${WorkFlag}
# sollte nie passieren ...
[ -w ${WorkFlag} ] || exit 1
# Konfig-Datei einlesen
[ -s ${ConfigFile} ] && . ${ConfigFile}
# Parse args
# wenn argumente uebergeben werden
# den folgen while-block einkommentieren
# und etwas sinvollen darin tun.
#while [ "$1" ]; do
# optarg=""
# opt=""
# case "$1" in
# -*=*)
# opt=`echo "$1" | sed 's/=.*//'`
# optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'`
# ;;
# *)
# opt=$1
# ;;
# esac
#
# case $opt in
# -u)
# shift; # shift the '-u'
# MYUSER=$1
# shift; # shift the val
# ;;
#
# --user)
# MYUSER=$optarg;
# shift; # shift the '--user=val'
# ;;
#
# -h|*)
# echo "my help text "
# exit 1
# ;;
# esac
#done
#
# Anweisungen
#
#-----------------------------------------------------------------------------
#_EoF_