3 # Copyright 2014 Paul Hänsch
5 # This file is part of Confetti.
7 # Confetti is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # Confetti is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with Confetti. If not, see <http://www.gnu.org/licenses/>.
20 export LC_ALL=de_DE.UTF-8
24 # this program is supposed to be symlinked into a http root directory
25 # we will use the http root as object storage (data directory) and call sub
26 # programs from the directory in which the real executable resides
27 # therefore we need to identify the code and data directories _EXEC and _DATA
29 real="$(readlink -f $call)"
30 _EXEC="$(dirname "$real")" #execution directory
31 _DATA="$(dirname "$call")" #storage directory
33 # put debug options in the local.opts file
34 [ -r "$_DATA/local.opts" ] && . "$_DATA/local.opts"
37 debug() { #change to false to disable debugging
38 if [ "$DBG_ENABLED" = true -a -n "$*" ]; then
39 echo -E "$*" >>"$DBG_FILE"
40 elif [ "$DBG_ENABLED" = true -a -z "$*" ]; then
42 elif [ -z "$*" ]; then
49 echo -E "$*" >>/dev/stderr
53 # create directories for object storage
54 [ -w "$_DATA" ] && [ -d "$_DATA" ] || die "storage directory must be writable"
56 for each in "$_DATA"/{vcard,ical,cache,temp,mappings}; do
57 [ ! -e "$each" ] && mkdir "$each"
58 [ -w "$each" ] && [ -d "$each" ] || die "storage $each must be a writable directory"
60 touch "$_DATA/mappings/attendance"
62 # create htaccess file
63 [ -f .htaccess ] || cat >.htaccess <<EOF
65 AddHandler cgi-script .cgi
66 DirectoryIndex index.cgi
68 [ -f .htaccess ] || die "no htaccess file present and unable to create one"
73 . "$_EXEC/constants.sh"
75 if [ -n "$_GET[\"action\"]" ]; then
77 elif [ -n "$_GET[\"export\"]" ]; then