File indexing completed on 2026-04-10 08:39:08
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045 ARGV="$@"
0046
0047
0048
0049
0050
0051 @@virtual_env_setup@@
0052
0053
0054 PROGNAME='python -u @@install_purelib@@/pandaserver/test/SchemaChecker.py'
0055
0056
0057 HTTPD='/usr/sbin/httpd'
0058
0059
0060 PID_OLD=/var/log/panda/panda_server_httpd.pid
0061 PID_NEW=/var/run/panda/panda_server_httpd.pid
0062
0063
0064
0065
0066 if [ -x /usr/bin/links ]; then
0067 LYNX="links -dump"
0068 elif [ -x /usr/bin/lynx ]; then
0069 LYNX="lynx -dump"
0070 else
0071 LYNX="none"
0072 fi
0073
0074
0075
0076
0077 STATUSURL="http://localhost:25080/server-status"
0078
0079
0080 if [ -r /etc/sysconfig/panda_server ]; then
0081 . /etc/sysconfig/panda_server
0082 fi
0083
0084 ERROR=0
0085 if [ "x$ARGV" = "x" ] ; then
0086 ARGV="-h"
0087 fi
0088
0089
0090
0091 function check_schema() {
0092 return_string=`$PROGNAME`
0093 if [[ "$return_string" =~ .*OK ]]; then
0094 return 0
0095 else
0096 echo $return_string
0097 return 1
0098 fi
0099 }
0100
0101 function check13() {
0102
0103 GONE="(ServerType|BindAddress|Port|AddModule|ClearModuleList|"
0104 GONE="${GONE}AgentLog|RefererLog|RefererIgnore|FancyIndexing|"
0105 GONE="${GONE}AccessConfig|ResourceConfig)"
0106 if grep -Eiq "^[[:space:]]*($GONE)" /etc/httpd/conf/httpd.conf; then
0107 echo "$0: Apache 1.3 configuration directives found"
0108 echo "$0: please read /usr/share/doc/httpd-2.0.52/migration.html"
0109 exit 2
0110 fi
0111 }
0112
0113 function checklynx() {
0114 if [ "$LYNX" = "none" ]; then
0115 echo "The 'links' package is required for this functionality."
0116 exit 8
0117 fi
0118 }
0119
0120 function testconfig() {
0121
0122
0123 if test -x /usr/sbin/selinuxenabled && /usr/sbin/selinuxenabled; then
0124 runcon -- `id -Z` $HTTPD $OPTIONS -t
0125 else
0126 $HTTPD $OPTIONS -t
0127 fi
0128 ERROR=$?
0129 }
0130
0131 function check_pidfile () {
0132 if [ -r $PID_OLD ]; then
0133 COMSTR=`echo $HTTPD $OPTIONS -k $ARGV`
0134 COMSTR=`echo $COMSTR | sed -e 's/ //g'`
0135 PSOUT=`ps -f -p \`cat $PID_OLD\` | cat | tail -1`
0136 PSOUT=`echo $PSOUT | sed -e 's/ //g'`
0137 if [ ! `echo $PSOUT | grep $COMSTR` ]; then
0138 echo "check pid: deleting $PID_OLD"
0139 rm -rf $PID_OLD
0140 retval=0
0141 else
0142 echo "check pid: httpd is running"
0143 retval=1
0144 fi
0145 elif [ -r $PID_NEW ]; then
0146 COMSTR=`echo $HTTPD $OPTIONS -k $ARGV`
0147 COMSTR=`echo $COMSTR | sed -e 's/ //g'`
0148 PSOUT=`ps -f -p \`cat $PID_NEW\` | cat | tail -1`
0149 PSOUT=`echo $PSOUT | sed -e 's/ //g'`
0150 if [ ! `echo $PSOUT | grep $COMSTR` ]; then
0151 echo "check pid: deleting $PID_NEW"
0152 rm -rf $PID_NEW
0153 retval=0
0154 else
0155 echo "check pid: httpd is running"
0156 retval=1
0157 fi
0158 else
0159 echo "check_pid: no httpd"
0160 retval=0
0161 fi
0162 return "$retval"
0163 }
0164
0165 function kill_remaining_httpd () {
0166 COMSTR=`echo $HTTPD $OPTIONS -k`
0167 COMSTR=`echo $COMSTR | sed -e 's/ //g'`
0168 USERID=`ps ax o user:16,cmd | awk '{out=gensub(/ /, "", "g", $0); print $1"\t"out}' | grep $COMSTR | grep -v root | head -n1 | awk '{print $1}'`
0169 if [ -n "$USERID" ]; then
0170 echo trying to killall remaining httpd processes with uid=$USERID
0171 killall -q -v -s SIGKILL -u $USERID `basename $HTTPD`
0172 else
0173 echo all set as no remaining httpd
0174 fi
0175 }
0176
0177 case $ARGV in
0178 restart|graceful)
0179 if $HTTPD -t >&/dev/null; then
0180 $HTTPD $OPTIONS -k $ARGV
0181 ERROR=$?
0182 else
0183 echo "apachectl: Configuration syntax error, will not run \"$ARGV\":"
0184 testconfig
0185 fi
0186 ;;
0187 start|stop)
0188 echo "$ARGV PanDA httpd"
0189 check13
0190 case $ARGV in
0191 start)
0192 check_schema
0193 check_pidfile
0194 esac
0195 for itry in `seq 1 100`
0196 do
0197 echo $ARGV trying $itry
0198 $HTTPD $OPTIONS -k $ARGV
0199 ERROR=$?
0200 sleep 5
0201 if [ $ERROR = 0 ]; then
0202 check_pidfile
0203 retval=$?
0204 case $ARGV in
0205 start)
0206 if [ "$retval" == 1 ]
0207 then
0208 echo $ARGV done
0209 break
0210 fi
0211 ;;
0212 stop)
0213 if [ "$retval" == 0 ]
0214 then
0215 echo $ARGV done
0216 break
0217 fi
0218 ;;
0219 esac
0220 fi
0221 sleep 10
0222 done
0223 case $ARGV in
0224 stop)
0225 kill_remaining_httpd
0226 esac
0227 ;;
0228 startssl|sslstart|start-SSL)
0229 check13
0230 $HTTPD $OPTIONS -DSSL -k start
0231 ERROR=$?
0232 ;;
0233 configtest)
0234 testconfig
0235 ;;
0236 status)
0237 checklynx
0238 $LYNX $STATUSURL | awk ' /process$/ { print; exit } { print } '
0239 ;;
0240 fullstatus)
0241 checklynx
0242 $LYNX $STATUSURL
0243 ;;
0244 *)
0245 $HTTPD $OPTIONS $ARGV
0246 ERROR=$?
0247 esac
0248
0249 exit $ERROR