summaryrefslogtreecommitdiffstats
path: root/pki/base/tps/apache/apachectl
blob: fc054e7e7f582d294751ba0ceff59e01d97ee9e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#!/bin/sh
#
# --- BEGIN COPYRIGHT BLOCK ---
#
# Copyright 2000-2004 The Apache Software Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# 
# Copyright (C) 2007 Red Hat, Inc.
# All rights reserved.
# --- END COPYRIGHT BLOCK ---
#

#
#  NOTICE:  This "apachectl" script has been modified to support the
#           Token Processing System (TPS).
#

# Initialize environment variables
LD_LIBRARY_PATH=[SYSTEM_USER_LIBRARIES]:[SYSTEM_LIBRARIES]:${LD_LIBRARY_PATH}
LD_LIBRARY_PATH=[SECURITY_LIBRARIES]:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH

# see if httpd is linked with the openldap libraries - we need to override them
OS=`pkiname`
if [ $OS = "Linux" ]; then
   hasopenldap=0

   /usr/bin/ldd $httpd 2>&1 | grep libldap- > /dev/null 2>&1 && hasopenldap=1

   if [ $hasopenldap -eq 1 ] ; then
       LD_PRELOAD="[SYSTEM_USER_LIBRARIES]/libldap50.so"
       LD_PRELOAD="[SYSTEM_USER_LIBRARIES]/libssl3.so ${LD_PRELOAD}"
       export LD_PRELOAD
   fi
fi

#
# Apache control script designed to allow an easy command line interface
# to controlling Apache.  Written by Marc Slemko, 1997/08/23
# 
# The exit codes returned are:
#   XXX this doc is no longer correct now that the interesting
#   XXX functions are handled by [INSTANCE_ID]
#       0 - operation completed successfully
#       1 - 
#       2 - usage error
#       3 - [INSTANCE_ID] could not be started
#       4 - [INSTANCE_ID] could not be stopped
#       5 - [INSTANCE_ID] could not be started during a restart
#       6 - [INSTANCE_ID] could not be restarted during a restart
#       7 - [INSTANCE_ID] could not be restarted during a graceful restart
#       8 - configuration syntax error
#
# When multiple arguments are given, only the error from the _last_
# one is reported.  Run "apachectl help" for usage info
#
ARGV="$@"
#
# |||||||||||||||||||| START CONFIGURATION SECTION  ||||||||||||||||||||
# --------------------                              --------------------
# 

#
# a command that outputs a formatted text version of the HTML at the
# url given on the command line.  Designed for lynx, however other
# programs may work.  
if [ -x /usr/bin/links ]; then
    LYNX="links -dump"
elif [ -x /usr/bin/lynx ]; then
    LYNX="lynx -dump"
else
    LYNX="none"
fi

#
# the URL to your server's mod_status status page.  If you do not
# have one, then status and fullstatus will not work.
STATUSURL="http://localhost:80/server-status"
#
# Set this variable to a command that increases the maximum
# number of file descriptors allowed per child process. This is
# critical for configurations that use many file descriptors,
# such as mass vhosting, or a multithreaded server.
ULIMIT_MAX_FILES="ulimit -S -n `ulimit -H -n`"

########################################################################
#   This section contains modified content of "/etc/sysconfig/httpd"   #
########################################################################
# Configuration file for the [INSTANCE_ID] service.

#
# The default processing model (MPM) is the process-based
# 'prefork' model.  A thread-based model, 'worker', is also
# available, but does not work with some modules (such as PHP).
# The service must be stopped before changing this variable.
#
HTTPD=[FORTITUDE_DIR]/sbin/httpd.worker

#
# To pass additional options (for instance, -D definitions) to the
# httpd binary at startup, set OPTIONS here.
#
OPTIONS="-f [HTTPD_CONF]"

#
# By default, the httpd process is started in the C locale; to 
# change the locale in which the server runs, the HTTPD_LANG
# variable can be set.
#
HTTPD_LANG=C
########################################################################
#                                                                      #
########################################################################

# Set the maximum number of file descriptors allowed per child process.
if [ "x$ULIMIT_MAX_FILES" != "x" ] ; then
    $ULIMIT_MAX_FILES
fi

ERROR=0
if [ "x$ARGV" = "x" ] ; then 
    ARGV="-h"
fi

function checklynx() {
if [ "$LYNX" = "none" ]; then
    echo "The 'links' package is required for this functionality."
    exit 8
fi
}

function testconfig() {
# [INSTANCE_ID] is denied terminal access in SELinux, so run in the
# current context to get stdout from $HTTPD -t.
if test -x /usr/sbin/selinuxenabled && /usr/sbin/selinuxenabled; then
    runcon -- `id -Z` $HTTPD $OPTIONS -t
else
    $HTTPD $OPTIONS -t
fi
ERROR=$?
}

case $ARGV in
restart|graceful)
    if $HTTPD -t >&/dev/null; then
        $HTTPD $OPTIONS -k $ARGV
        ERROR=$?
    else
        echo "apachectl: Configuration syntax error, will not run \"$ARGV\":"
        testconfig
    fi
    ;;
start|stop)
    $HTTPD $OPTIONS -k $ARGV
    ERROR=$?
    ;;
startssl|sslstart|start-SSL)
    $HTTPD $OPTIONS -DSSL -k start
    ERROR=$?
    ;;
configtest)
    testconfig
    ;;
status)
    checklynx
    $LYNX $STATUSURL | awk ' /process$/ { print; exit } { print } '
    ;;
fullstatus)
    checklynx
    $LYNX $STATUSURL
    ;;
*)
    $HTTPD $OPTIONS $ARGV
    ERROR=$?
esac

exit $ERROR