#!/bin/bash
# This file is part of the PyOWS-WMS-Server package (= program).
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# author(s): Sebastian Holler
#
# Copyright (c)2008 by Sebastian Holler
# for document references, used in this source code: see
# This script runs grass commands (via stdin) XOR scripts (via $1) inside
# GRASS shell environment.
# Note: It's assumed, that you've set the variables GISBASE, GISDBASE and
# LOCATION_NAME properly in the run-up to this script.
# set environment variables:
export SHELL_LOCK=$$
export PYWMS_TMP_PREFIX="pywmstmp-"
export SHELL_TMPDIR="/tmp/${PYWMS_TMP_PREFIX}${SHELL_LOCK}"
# if no argument ($1) available, scan stdin:
if [ "$1" == "" ]; then
# get commands from stdin pipe and execute them in a subshell:
cat /dev/stdin | /bin/bash
else
# get script name or command via argument/parameter ($1) and run it:
$1
fi