-export LANG=C
-export LC_ALL=C
-
-ARG=${1:-"meh"}
-# While this check can be done in the following case, some assumptions
-# down there are easier if we sorted out calls without an arg before.
-if [[ ${ARG} == meh ]]; then
- cat - <<EOF
+export LANG=C.UTF-8
+export LC_ALL=C.UTF-8
+
+# import the general variable set.
+export SCRIPTVARS=/srv/ftp-master.debian.org/dak/config/debian/vars
+. $SCRIPTVARS
+
+# One arg please
+declare -lr ARG=${1:-"meh"}
+
+# program name is the (lower cased) first argument.
+PROGRAM="${ARG}"
+
+# And the following types of cronscripts exists
+declare -lr POSSIBLEARGS='+(unchecked|dinstall|hourly|daily|weekly|monthly|yearly)'
+
+# set DEBUG if you want to see a little more logs (needs to be used more)
+DEBUG=${DEBUG:-0}
+
+# Check if the argument is a known one. If so, lock us so that only
+# one copy of the type of cronscript runs. The $type.tasks file is
+# mandantory, so use that for locking.
+case ${ARG} in
+ ${POSSIBLEARGS})
+ # Only one of me should ever run.
+ FLOCKER=${FLOCKER:-""}
+ [ "${FLOCKER}" != "${configdir}/${PROGRAM}.tasks" ] && exec env FLOCKER="${configdir}/${PROGRAM}.tasks" flock -E 0 -en "${configdir}/${PROGRAM}.tasks" "$0" "$@" || :
+ ;;
+ *)
+ cat - <<EOF