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 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550
|
#!/bin/bash
#
# For RedHat (thanks to Sudhaker Raj):
# chkconfig: 345 95 05
# description: Starts and stops the XAMPP \
# used to control Apache, MySQL, ProFTPD.
###############################################################################
# Copyright 2002-2005 by Kai 'Oswald' Seidler, oswald@apachefriends.org, GPL-licensed
function testport() {
if netstat -an | egrep ":$1 .*LISTEN" > /dev/null
then
return 0
else
return 1
fi
}
function testrun() {
if test -f $1
then
pid=`cat $1`
if ps ax 2>/dev/null | egrep "^ *$pid.*$2" > /dev/null
then
return 0
else
rm $1
return 1
fi
else
return 1
fi
}
function osguess() {
if test -f /etc/redhat-release
then
if egrep "9 " /etc/redhat-release > /dev/null
then
echo "rh9"
return 0
fi
else
echo "unknown"
return 0
fi
}
de="false"
case $LANG in
de*) de="true";;
esac
# we need root to run
if test "`id -u`" -ne 0
then
$de && echo "XAMPP muss als root aufgerufen werden!"
$de || echo "You need to start XAMPP as root!"
exit
fi
# do we have that new red hat linux 9 with posix native threads?
if test "`osguess`" = "rh9"
then
# for now disable PNTL. if PNTL gets more popular we will support it. - oswald [8apr3]
export LD_ASSUME_KERNEL=2.2.5
#echo "XAMPP: DISABLE PNTL..."
fi
export LD_LIBRARY_PATH=/opt/lampp/lib:$LD_LIBRARY_PATH
# Do we use Oracle? If yes, add Oracle's lib directory to LD_LIBRARY_PATH - oswald [6jul5]
if test -f /opt/lampp/etc/lampp/oraclelib
then
export LD_LIBRARY_PATH=`cat /opt/lampp/etc/lampp/oraclelib`:$LD_LIBRARY_PATH
fi
iswebmin="false";
if test -d /opt/lampp/webmin
then
iswebmin="true";
fi
version=`cat /opt/lampp/lib/VERSION`
bon="[1m"
boff="[m"
lc="/opt/lampp/etc/lampp"
case $1 in
"start")
$de && echo "Starte XAMPP fuer Linux $version..."
$de || echo "Starting XAMPP for Linux $version..."
/opt/lampp/share/lampp/nogroupcheck
$0 startapache %
$0 startmysql %
$0 startftp %
$iswebmin && $0 startwebmin %
/opt/lampp/share/lampp/alladdons start
$de && echo "XAMPP fuer Linux gestartet."
$de || echo "XAMPP for Linux started."
;;
"reload")
$0 reloadapache
$0 reloadmysql
$0 reloadftp
/opt/lampp/share/lampp/alladdons reload
;;
"stopssl")
if test -f $lc/startssl
then
if test -f /opt/lampp/logs/httpd.pid
then
$0 stopapache
rm $lc/startssl
$0 startapache
else
$de && echo "XAMPP: XAMPP-Apache laeuft gar nicht."
$de || echo "XAMPP: XAMPP-Apache is not running."
rm $lc/startssl
fi
else
$de && echo "XAMPP: SSL laeuft nicht!"
$de || echo "XAMPP: SSL isn't running!"
fi
;;
"startssl")
if testrun /opt/lampp/logs/httpd.pid httpd
then
if test -f $lc/startssl
then
$de && echo "XAMPP: SSL laeuft bereits!"
$de || echo "XAMPP: SSL is already running!"
else
$0 stopapache
touch $lc/startssl
$0 startapache
fi
else
touch $lc/startssl
$0 startapache
fi
;;
"startapache")
if testrun /opt/lampp/logs/httpd.pid httpd
then
$de && echo "XAMPP: XAMPP-Apache laeuft bereits."
$de || echo "XAMPP: XAMPP-Apache is already running."
else
if testport 80
then
$de && echo "XAMPP: Ein anderer Webserver laeuft bereits."
$de || echo "XAMPP: Another web server daemon is already running."
else
case `$0 phpstatus` in
5*) xampp_apachedefine="$xampp_apachedefine -DPHP5"
$de && phpextra="(und PHP5)"
$de || phpextra="(and PHP5)"
;;
4*) xampp_apachedefine="$xampp_apachedefine -DPHP4"
$de && phpextra="(und PHP4)"
$de || phpextra="(and PHP4)"
;;
esac
if test -f $lc/startssl
then
if testport 443
then
$de && echo "XAMPP: Ein anderer Webserver mit SSL laeuft bereits."
$de || echo "XAMPP: Another web server daemon with SSL is already running."
else
$de && echo "XAMPP: Starte Apache mit SSL $phpextra..."
$de || echo "XAMPP: Starting Apache with SSL $phpextra..."
/opt/lampp/bin/apachectl -k start -DSSL $xampp_apachedefine > /dev/null 2> /opt/lampp/logs/apachestart.log
fi
else
$de && echo "XAMPP: Starte Apache..."
$de || echo "XAMPP: Starting Apache..."
/opt/lampp/bin/apachectl -k start $xampp_apachedefine > /dev/null 2> /opt/lampp/logs/apachestart.log
fi
error=$?
if test $error -gt 0
then
$de && echo "XAMPP: ${bon}Fehler $error beim Starten vom Apache!${boff}"
$de || echo "XAMPP: ${bon}Error $error! Couldn't start Apache!${boff}"
/opt/lampp/share/lampp/diagnose apache
fi
fi
fi
;;
"startmysql")
if testrun /opt/lampp/var/mysql/`/bin/hostname`.pid mysqld
then
$de && echo "XAMPP: XAMPP-MySQL laeuft bereits."
$de || echo "XAMPP: XAMPP-MySQL is already running."
else
if testport 3306
then
$de && echo "XAMPP: Ein anderer MySQL daemon laeuft bereits."
$de || echo "XAMPP: Another MySQL daemon is already running."
else
/opt/lampp/bin/mysql.server start > /dev/null &
$de && echo "XAMPP: Starte MySQL..."
$de || echo "XAMPP: Starting MySQL..."
fi
fi
;;
"startwebmin")
if $iswebmin
then
if test "$2" != "%"
then
touch $lc/startwebmin
fi
if test -f $lc/startwebmin
then
if testrun /opt/lampp/var/webmin/miniserv.pid miniserv
then
$de && echo "XAMPP: Webmin laeuft bereits."
$de || echo "XAMPP: Webmin is already running."
else
$de && echo "XAMPP: Starte Webmin..."
$de || echo "XAMPP: Starting Webmin..."
/opt/lampp/etc/webmin/start quiet
fi
fi
else
$de && echo "XAMPP: Webmin ist nicht installiert."
$de || echo "XAMPP: Webmin isn't installed."
fi
;;
"stopwebmin")
if $iswebmin
then
if test -f $lc/startwebmin
then
if testrun /opt/lampp/var/webmin/miniserv.pid miniserv
then
$de && echo "XAMPP: Stoppe Webmin..."
$de || echo "XAMPP: Stopping Webmin..."
/opt/lampp/etc/webmin/stop quiet
else
$de && echo "XAMPP: XAMPP-Webmin laeuft gar nicht."
$de || echo "XAMPP: XAMPP-Webmin is not running."
fi
if test "$2" != "%"
then
rm $lc/startwebmin 2> /dev/null
fi
fi
else
$de && echo "XAMPP: Webmin ist nicht installiert."
$de || echo "XAMPP: Webmin isn't installed."
fi
;;
"startftp")
if test "$2" != "%"
then
touch $lc/startftp
fi
if test -f $lc/startftp
then
if testrun /opt/lampp/var/proftpd.pid proftpd
then
$de && echo "XAMPP: XAMPP-ProFTPD laeuft bereits."
$de || echo "XAMPP: XAMPP-ProFTPD is already running."
else
if testport 21
then
$de && echo "XAMPP: Ein anderer FTP daemon laeuft bereits."
$de || echo "XAMPP: Another FTP daemon is already running."
else
$de && echo "XAMPP: Starte ProFTPD..."
$de || echo "XAMPP: Starting ProFTPD..."
/opt/lampp/sbin/proftpd > /opt/lampp/var/proftpd/start.err 2>&1
error=$?
if test $error -gt 0
then
echo "XAMPP: `cat /opt/lampp/var/proftpd/start.err`"
$de && echo "XAMPP: ${bon}Fehler $error beim Starten von ProFTPD!${boff}"
$de || echo "XAMPP: ${bon}Error $error! Couln't start ProFTPD!${boff}"
fi
fi
fi
fi
;;
"stop")
$de && echo "Stoppe XAMPP fuer Linux $version..."
$de || echo "Stopping XAMPP for Linux $version..."
$0 stopapache %
$0 stopmysql %
$0 stopftp %
$iswebmin && $0 stopwebmin %
/opt/lampp/share/lampp/alladdons stop
$de && echo "XAMPP beendet."
$de || echo "XAMPP stopped."
;;
"stopapache")
if test -f /opt/lampp/logs/httpd.pid
then
if test -f $lc/startssl
then
$de && echo "XAMPP: Stoppe Apache mit SSL..."
$de || echo "XAMPP: Stopping Apache with SSL..."
else
$de && echo "XAMPP: Stoppe Apache..."
$de || echo "XAMPP: Stopping Apache..."
fi
# Thanks to Emilio Paolini <ep@im-netz.de> for the next 12 lines - Oswald, 30sep04
case `$0 phpstatus` in
5*) xampp_apachedefine="$xampp_apachedefine -D PHP5"
$de && phpextra="(und PHP5)"
$de || phpextra="(and PHP5)"
;;
4*) xampp_apachedefine="$xampp_apachedefine -D PHP4"
$de && phpextra="(und PHP4)"
$de || phpextra="(and PHP4)"
;;
esac
/opt/lampp/bin/apachectl $xampp_apachedefine -k stop > /dev/null
sleep 2
#test -f /opt/lampp/logs/httpd.pid && rm /opt/lampp/logs/httpd.pid
else
$de && echo "XAMPP: XAMPP-Apache laeuft gar nicht."
$de || echo "XAMPP: XAMPP-Apache is not running."
fi
;;
"reloadapache")
if test -f /opt/lampp/logs/httpd.pid
then
kill -USR1 `cat /opt/lampp/logs/httpd.pid`
$de && echo "XAMPP: Aktualisiere Apache..."
$de || echo "XAMPP: Reload Apache..."
else
$de && echo "XAMPP: Apache laeuft nicht..."
$de || echo "XAMPP: Apache isn't running..."
fi
;;
"stopmysql")
if test -f /opt/lampp/var/mysql/`/bin/hostname`.pid
then
/opt/lampp/bin/mysql.server stop > /dev/null 2>&1 &
$de && echo "XAMPP: Stoppe MySQL..."
$de || echo "XAMPP: Stopping MySQL..."
sleep 2
test -f /opt/lampp/var/mysql/`/bin/hostname`.pid && rm /opt/lampp/var/mysql/`/bin/hostname`.pid
else
$de && echo "XAMPP: XAMPP-MySQL laeuft gar nicht."
$de || echo "XAMPP: XAMPP-MySQL is not running."
fi
;;
"reloadmysql")
if test -f /opt/lampp/var/mysql/`/bin/hostname`.pid
then
h="`/bin/hostname`"
kill -HUP `cat /opt/lampp/var/mysql/$h.pid`
$de && echo "XAMPP: Aktualisiere MySQL..."
$de || echo "XAMPP: Reload MySQL..."
else
$de && echo "XAMPP: MySQL laeuft nicht..."
$de || echo "XAMPP: MySQL isn't running..."
fi
;;
"stopftp")
if test -f /opt/lampp/var/proftpd.pid
then
kill `cat /opt/lampp/var/proftpd.pid`
$de && echo "XAMPP: Stoppe ProFTPD..."
$de || echo "XAMPP: Stopping ProFTPD..."
else
if test -f $lc/startftp
then
$de && echo "XAMPP: XAMPP-ProFTPD laeuft gar nicht."
$de || echo "XAMPP: XAMPP-ProFTPD is not running."
fi
fi
if test "$2" != "%"
then
rm $lc/startftp 2> /dev/null
fi
;;
"reloadftp")
if test -f /opt/lampp/var/proftpd.pid
then
kill -HUP `cat /opt/lampp/var/proftpd.pid`
$de && echo "XAMPP: Aktualisiere ProFTPD..."
$de || echo "XAMPP: Reload ProFTPD..."
else
$de && echo "XAMPP: ProFTPD laeuft gar nicht..."
$de || echo "XAMPP: ProFTPD isn't running..."
fi
;;
"wizard")
/opt/lampp/bin/php /opt/lampp/share/lampp/wizard.php
;;
"restartapache")
$0 stopapache
sleep 4
$0 startapache
;;
"restart")
$0 stop
sleep 4
$0 start
;;
"security")
/opt/lampp/share/lampp/checkall
;;
"oci8")
/opt/lampp/share/lampp/oci8install
;;
"backup")
/opt/lampp/share/lampp/backup $2
;;
"php4")
/opt/lampp/share/lampp/activatephp 4.4.0
;;
"php5")
/opt/lampp/share/lampp/activatephp 5.0.5
;;
"phpstatus")
/opt/lampp/share/lampp/phpstatus
;;
"status")
echo "Not yet implemented."
;;
"statusraw")
. /opt/lampp/share/lampp/statusraw
;;
start*|stop*|reload*|status*|restart*)
/opt/lampp/share/lampp/addons $*
;;
"version")
$de && echo "Version: XAMPP fuer Linux $version"
$de || echo "Version: XAMPP for Linux $version"
;;
*) if $de
then
echo "Aufruf: $0 <Aktion>"
echo ""
echo " start Starte XAMPP (Apache, MySQL und evtl. weitere)"
echo " startapache Starte nur den Apache"
echo " startssl Starte nur die SSL-Unterstuetzung des Apache"
echo " startmysql Starte nur den MySQL"
echo " startftp Starte nur den ProFTPD"
$iswebmin && echo " startwebmin Starte nur Webmin"
echo ""
echo " stop Stoppe XAMPP (Apache, MySQL und evtl. weitere)"
echo " stopapache Stoppe nur den Apache"
echo " stopssl Stoppe nur die SSL-Unterstuetzung des Apache"
echo " stopmysql Stoppe nur den MySQL"
echo " stopftp Stoppe nur den ProFTPD"
$iswebmin && echo " stopwebmin Stoppe nur Webmin"
echo ""
echo " reload Aktualisiere XAMPP (Apache, MySQL und evtl. weitere)"
echo " reloadapache Aktualisiere nur den Apache"
echo " reloadmysql Aktualisiere nur den MySQL"
echo " reloadftp Aktualisiere nur den ProFTPD"
echo ""
echo " restart Stoppe und starte XAMPP"
echo " security Überpruefe XAMPPs Sicherheit"
echo ""
echo " php5 Aktiviere PHP5"
echo " php4 Aktiviere PHP4"
echo " phpstatus Welches PHP ist aktiv?"
echo ""
echo " backup Backup der XAMPP-Konfig, Logs und Daten erstellen"
echo ""
else
echo "Usage: $0 <action>"
echo ""
echo " start Start XAMPP (Apache, MySQL and eventually others)"
echo " startapache Start only Apache"
echo " startssl Start only SSL support"
echo " startmysql Start only MySQL"
echo " startftp Start only ProFTPD"
$iswebmin && echo " startwebmin Start only Webmin"
echo ""
echo " stop Stop XAMPP (Apache, MySQL and eventually others)"
echo " stopapache Stop only Apache"
echo " stopssl Stop only SSL support"
echo " stopmysql Stop only MySQL"
echo " stopftp Stop only ProFTPD"
$iswebmin && echo " stopwebmin Stop only Webmin"
echo ""
echo " reload Reload XAMPP (Apache, MySQL and eventually others)"
echo " reloadapache Reload only Apache"
echo " reloadmysql Reload only MySQL"
echo " reloadftp Reload only ProFTPD"
echo ""
echo " restart Stop and start XAMPP"
echo " security Check XAMPP's security"
echo ""
echo " php5 Activate PHP5"
echo " php4 Activate PHP4"
echo " phpstatus Which version of PHP is active?"
echo ""
echo " backup Make backup file of your XAMPP config, log and data files"
echo ""
fi
;;
esac |
Partager