**スクリプト [#i184a752]

#contents

----
***起動スクリプト(nginx) [#k2dd0a50]
 #!/bin/bash
 #
 # nginx        Startup script for the nginx
 #
 # chkconfig: - 85 15
 # description: Sample script.
 # processname: nginx
 # pidfile: /usr/local/nginx/logs/nginx.pid
 # config: /usr/local/nginx/conf/nginx.conf
 #
 
 # Source function library.
 . /etc/rc.d/init.d/functions
 
 if [ -f /etc/sysconfig/nginx ]; then
         . /etc/sysconfig/nginx
 fi
 
 nginx=${HTTPD-/usr/local/nginx/sbin/nginx}
 prog=nginx
 pidfile=${PIDFILE-/usr/local/nginx/logs/nginx.pid}
 lockfile=${LOCKFILE-/var/lock/subsys/nginx}
 RETVAL=0
 
 start() {
         echo -n $"Starting $prog: "
         daemon --pidfile=${pidfile} $nginx $OPTIONS
         RETVAL=$?
         echo
         [ $RETVAL = 0 ] && touch ${lockfile}
         return $RETVAL
 }
 stop() {
         echo -n $"Stopping $prog: "
         #killproc -p ${pidfile} $nginx
         $nginx -s stop
         RETVAL=$?
         echo
         [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
 }
 reload() {
         echo -n $"Reloading $prog: "
         #killproc -p ${pidfile} $nginx -HUP
         $nginx -s reload
         RETVAL=$?
         echo
 }
 
 # See how we were called.
 case "$1" in
   start)
         start
         ;;
   stop)
         stop
         ;;
   status)
         if ! test -f ${pidfile}; then
             echo $prog is stopped
             RETVAL=3
         else
             status -p {$pidfile} $nginx
             RETVAL=$?
         fi
         ;;
   restart)
         stop
         start
         ;;
   condrestart)
         if test -f ${pidfile} && status -p ${pidfile} $nginx >&/dev/null; then
                 stop
                 start
         fi
         ;;
   reload)
         reload
         ;;
   configtest)
         $nginx $OPTIONS -t
         RETVAL=$?
         ;;
   graceful)
         echo -n $"Gracefully restarting $prog: "
         $nginx $OPTIONS -s reload
         RETVAL=$?
         echo
         ;;
    graceful-stop)
          $nginx $OPTIONS -s quit
          RETVAL=$?
          ;;
   *)
         echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|graceful|help|configtest}"
         exit 1
 esac
 
 exit $RETVAL

***起動スクリプト(fcgi-spawn) [#wcb013e3]
systemctl用の部分はコメントアウト。
 #!/bin/sh
 #
 # spawn-fcgi   Start and stop FastCGI processes
 #
 # chkconfig:   - 80 20
 # description: Spawn FastCGI scripts to be used by web servers
 
 ### BEGIN INIT INFO
 # Provides:
 # Required-Start: $local_fs $network $syslog $remote_fs $named
 # Required-Stop:
 # Should-Start:
 # Should-Stop:
 # Default-Start:
 # Default-Stop: 0 1 2 3 4 5 6
 # Short-Description: Start and stop FastCGI processes
 # Description:       Spawn FastCGI scripts to be used by web servers
 ### END INIT INFO
 
 # Source function library.
 . /etc/rc.d/init.d/functions
 
 exec="/usr/local/bin/spawn-fcgi"
 prog="spawn-fcgi"
 config="/etc/sysconfig/spawn-fcgi"
 pidfile="/usr/local/munin/var/run/munin/spawn-fcgi.pid"
 
 [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
 
 lockfile=/var/lock/subsys/$prog
 
 start() {
     [ -x $exec ] || exit 5
     [ -f $config ] || exit 6
     echo -n $"Starting $prog: "
     # Just in case this is left over with wrong ownership
     [ -n "${SOCKET}" -a -S "${SOCKET}" ] && rm -f ${SOCKET}
     daemon --pidfile=$pidfile $exec $OPTIONS
     retval=$?
     echo
     [ $retval -eq 0 ] && touch $lockfile
     return $retval
 }
 
 stop() {
     echo -n $"Stopping $prog: "
     killproc -p $pidfile $prog
     # Remove the socket in order to never leave it with wrong ownership
     [ -n "${SOCKET}" -a -S "${SOCKET}" ] && rm -f ${SOCKET}
     retval=$?
     echo
     [ $retval -eq 0 ] && rm -f $lockfile
     return $retval
 }
 
 restart() {
     stop
     start
 }
 
 reload() {
     restart
 }
 
 force_reload() {
     restart
 }
 
 rh_status() {
     # run checks to determine if the service is running or use generic status
     status $prog
 }
 
 rh_status_q() {
     rh_status &>/dev/null
 }
 
 
 case "$1" in
     start)
         #rh_status_q && exit 0
         $1
         ;;
     stop)
         #rh_status_q || exit 0
         $1
         ;;
     restart)
         $1
         ;;
     reload)
         #rh_status_q || exit 7
         $1
         ;;
     force-reload)
         force_reload
         ;;
     status)
         #rh_status
         ;;
     condrestart|try-restart)
         #rh_status_q || exit 0
         restart
         ;;
     *)
         echo $"Usage: $0 {start|stop|status|restart|condrestart|try- restart|reload|force-reload}"
         exit 2
 esac
 exit $?

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS