3 # Copyright 2014, 2015 Paul Hänsch
5 # This file is part of shcgi.
7 # shcgi 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 # shcgi 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 shcgi. If not, see <http://www.gnu.org/licenses/>.
20 export LC_ALL=C LANG=C
23 # create directories for object storage
25 [ -d "$_DATA" -a -w "$_DATA" ] || die "storage directory must be writable"
27 [ ! -e "$_DATA/$each" ] && mkdir "$_DATA/$each"
28 [ -d "$_DATA/$each" -a -w "$_DATA/$each" ] || die "storage \"$_DATA/$each\" must be a writable directory"
32 # this program is supposed to be symlinked into a http root directory
33 # we will use the http root as object storage (data directory) and call sub
34 # programs from the directory in which the real executable resides
35 # therefore we need to identify the code and data directories _EXEC and _DATA
37 real="$(readlink -f $call)"
38 _DATA="$(dirname "$call")" #storage directory
39 _EXEC="${real%/shcgi/index.cgi}" #execution directory
41 # put debug options in the local.opts file
42 . "$_EXEC/shcgi/debug.sh"
43 [ -r "$_DATA/local.opts" ] && . "$_DATA/local.opts"
45 . "$_EXEC/shcgi/cgi.sh"
48 [ -x "$_EXEC/globals.sh" ] && . "$_EXEC/globals.sh"
50 if [ -n "${_GET[action]}" ]; then
51 . "$_EXEC/shcgi/action.sh"
53 . "$_EXEC/shcgi/page.sh"