8 debug() { #change to false to disable debugging
9 true && echo "$*" >>debug
12 # this program is supposed to be symlinked into a http root directory
13 # we will use the http root as object storage (data directory) and call sub
14 # programs from the directory in which the real executable resides
15 # therefore we need to identify the code and data directories _EXEC and _STOR
18 while [ -L "$real" ]; do
19 real="$(stat -c %N "$real" |sed -r "s:..*. -> .(.*).$:\1:")"
22 _EXEC="$(dirname "$real")" #execution directory
23 _STOR="$(dirname "$call")" #storage directory
25 debug "Execution dir: $_EXEC"
26 debug "Storage dir: $_STOR"
28 [ -w "$_EXEC" ] && [ -d "$_EXEC" ] || die "storage directory must be writable"
30 # create directories for object storage
31 for each in "$_STOR"/{vcard,mappings,courses}; do
32 [ ! -e "$each" ] && mkdir "$each"
33 [ -w "$each" ] && [ -d "$each" ] || die "storage $each must be a writable directory"
36 # create htaccess file
37 [ -f .htaccess ] || cat >.htaccess <<EOF
39 AddHandler cgi-script .cgi
40 DirectoryIndex index.cgi
42 [ -f .htaccess ] || die "no htaccess file present and unable to create one"