1#!/bin/sh
2
3# Licensed to the Apache Software Foundation (ASF) under one or more
4# contributor license agreements.  See the NOTICE file distributed with
5# this work for additional information regarding copyright ownership.
6# The ASF licenses this file to You under the Apache License, Version 2.0
7# (the "License"); you may not use this file except in compliance with
8# the License.  You may obtain a copy of the License at
9#
10#     http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17
18# -----------------------------------------------------------------------------
19# Stop script for the CATALINA Server
20# -----------------------------------------------------------------------------
21
22# Better OS/400 detection: see Bugzilla 31132
23os400=false
24case "`uname`" in
25OS400*) os400=true;;
26esac
27
28# resolve links - $0 may be a softlink
29PRG="$0"
30
31while [ -h "$PRG" ] ; do
32  ls=`ls -ld "$PRG"`
33  link=`expr "$ls" : '.*-> \(.*\)$'`
34  if expr "$link" : '/.*' > /dev/null; then
35    PRG="$link"
36  else
37    PRG=`dirname "$PRG"`/"$link"
38  fi
39done
40
41PRGDIR=`dirname "$PRG"`
42EXECUTABLE=catalina.sh
43
44# Check that target executable exists
45if $os400; then
46  # -x will Only work on the os400 if the files are:
47  # 1. owned by the user
48  # 2. owned by the PRIMARY group of the user
49  # this will not work if the user belongs in secondary groups
50  eval
51else
52  if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then
53    echo "Cannot find $PRGDIR/$EXECUTABLE"
54    echo "The file is absent or does not have execute permission"
55    echo "This file is needed to run this program"
56    exit 1
57  fi
58fi
59
60exec "$PRGDIR"/"$EXECUTABLE" stop "$@"
61