echo is_uid=`/usr/bin/id | /usr/bin/awk -F\= {'print $2'} | /usr/bin/awk -F\( {'print $1'}` if [ $is_uid -ne 0 ] ; then echo "You are not logged on as root" exit ; fi # DNS, name server, bind ; case "$1" in 'dns'|'bind'|'named') if [ -f "/usr/local/etc/named.pid" ] ; then named_pid=`cat /usr/local/etc/named.pid` kill -HUP $named_pid echo "DNS restarted $named_pid" /usr/bin/ps -ef | /usr/bin/fgrep -v grep | /usr/bin/fgrep -v restart | /usr/bin/fgrep name | /usr/bin/awk {'print $9'} else echo "You don't seem to be running the BIND nameserver" echo "with a pid in /usr/local/etc/bind.conf" fi ;; 'apache'|'http'|'httpd'|'web') if [ -f "/usr/local/apache/logs/httpd.pid" ] ; then httpd_pid=`cat /usr/local/apache/logs/httpd.pid` else httpd_pid="not in /usr/local/apache/logs/httpd.pid" fi if [ -f "/usr/local/apache/bin/apachectl" ] ; then /usr/local/apache/bin/apachectl restart echo "Apache restarting" sleep 1 ; /usr/bin/ps -ef | /usr/bin/fgrep -v grep | /usr/bin/fgrep -v restart | /usr/bin/fgrep apach | /usr/bin/awk {'print $8'} echo "Parent process is $httpd_pid" else echo "You don't have the apachectl file in /usr/local/apache/bin" fi ;; 'mail'|'sendmail') sendmail_pid=0 if [ -f /etc/mail/sendmail.pid ]; then sendmail_pid=`/usr/bin/head -1 /etc/mail/sendmail.pid` kill -HUP $sendmail_pid echo "Sendmail restarted $sendmail_pid" /usr/bin/ps -ef | /usr/bin/fgrep -v grep | /usr/bin/fgrep -v restart | /usr/bin/fgrep mail | /usr/bin/awk {'print $8 " " $9 " " $10'} echo $sendmail_pid fi if [ -f /var/run/sendmail.pid ]; then sendmail_pid=`/usr/bin/head -1 /var/run/sendmail.pid` kill -HUP $sendmail_pid echo "Sendmail restarted $sendmail_pid" /usr/bin/ps -ef | /usr/bin/fgrep -v grep | /usr/bin/fgrep -v restart | /usr/bin/fgrep mail | /usr/bin/awk {'print $8 " " $9 " " $10'} echo $sendmail_pid fi if [ $sendmail_pid -eq 0 ]; then echo "You don't have the sendmail parent process" echo "number in /etc/mail/sendmail.pid" echo "or in /var/run/sendmail.pid" fi ;; 'syslog') if [ -f /etc/syslog.pid ] ; then syslog_pid=`cat /etc/syslog.pid` kill -HUP $syslog_pid echo "Syslog restarted $syslog_pid" /usr/bin/ps -ef | /usr/bin/fgrep -v grep | /usr/bin/fgrep -v restart | /usr/bin/fgrep syslog | /usr/bin/awk {'print $9'} else echo "/etc/syslog.pid does not exist" fi ;; 'inetd') pkill -HUP inetd echo "Inetd restarted $inetd_pid" /usr/bin/ps -ef | /usr/bin/fgrep -v grep | /usr/bin/fgrep -v restart | /usr/bin/fgrep inetd | /usr/bin/awk {'print $8 " " $9 " " $10'} ;; *) echo "Syntax Error -> restart option" echo "restart apache|bind|dns|http|httpd|inetd|mail|named|syslog|web" echo ;; esac echo exit
Recent Comments