X-Git-Url: http://git.plutz.net/?p=busy;a=blobdiff_plain;f=index.cgi;fp=index.cgi;h=618fac41982ebbe15e90c5bb4caa5ecb38589abb;hp=932a763a26acfc453e53172adad4cc7101bef56d;hb=d41ccbb56b8ebf2b7f317a5b35f2b04725a2005d;hpb=4b4c7d8bb74e863b0928ebb9aa6c3f42130b8102 diff --git a/index.cgi b/index.cgi index 932a763..618fac4 100755 --- a/index.cgi +++ b/index.cgi @@ -18,18 +18,9 @@ # You should have received a copy of the GNU Affero General Public License # along with Busy. If not, see . -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 -} +export LC_ALL=C LANG=C +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 @@ -40,9 +31,28 @@ real="$(readlink -f $call)" _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() { + echo -E "$*" + exit 1 +} # create directories for object storage +[ -w "$_DATA" ] && [ -d "$_DATA" ] || die "storage directory must be writable" + for each in "$_DATA"/{Home,Tasks,Wiki,QRcodes}; do [ ! -e "$each" ] && mkdir "$each" [ -w "$each" ] && [ -d "$each" ] || die "storage $each must be a writable directory"