# along with Confetti. If not, see <http://www.gnu.org/licenses/>.
export LC_ALL=de_DE.UTF-8
-
-# basic functions
-die() {
- echo "$*" >/dev/stderr
- exit 1
-}
-debug() { #change to false to disable debugging
- #true && echo "$*" >>debug
- true && [ -n "$*" ] && echo -E "$*" >>/dev/stderr
- true && [ -z "$*" ] && tee /dev/stderr
-}
+DBG_ENABLED=false
+DBG_FILE=/dev/stderr
# this program is supposed to be symlinked into a http root directory
# we will use the http root as object storage (data directory) and call sub
_EXEC="$(dirname "$real")" #execution directory
_DATA="$(dirname "$call")" #storage directory
-[ -w "$_DATA" ] && [ -d "$_DATA" ] || die "storage directory must be writable"
+# put debug options in the local.opts file
+[ -r "$_DATA/local.opts" ] && . "$_DATA/local.opts"
+
+# basic functions
+debug() { #change to false to disable debugging
+ if [ "$DBG_ENABLED" = true -a -n "$*" ]; then
+ echo -E "$*" >>"$DBG_FILE"
+ elif [ "$DBG_ENABLED" = true -a -z "$*" ]; then
+ tee -a "$DBG_FILE"
+ elif [ -z "$*" ]; then
+ cat
+ fi
+}
+
+die() {
+ debug "$*"
+ echo -E "$*" >>/dev/stderr
+ exit 1
+}
# create directories for object storage
+[ -w "$_DATA" ] && [ -d "$_DATA" ] || die "storage directory must be writable"
+
for each in "$_DATA"/{vcard,ical,cache,temp,mappings}; do
[ ! -e "$each" ] && mkdir "$each"
[ -w "$each" ] && [ -d "$each" ] || die "storage $each must be a writable directory"
[ -f .htaccess ] || die "no htaccess file present and unable to create one"
. "$_EXEC/cgi.sh"
-
cgi_get
. "$_EXEC/constants.sh"
--- /dev/null
+# This file is meaningless in the exec directory
+# You can copy it to your data directory (usually
+# your HTTP root) to set per instance debug
+# options and the like
+# beware that the file is sourced as a shell script
+
+DBG_ENABLED=false
+DBG_FILE=/dev/stderr