手敲的一個nginx代碼

  1 #!/bin/sh
  2 #source function library
  3 /etc/rc.d/init.d/functions
  4
  5 #source networking configuration
  6 /etc/sysconfig/network
  7
  8 #Check that networking is up
  9 [ ${NETWORKING} = "no"] && exit 0
 10
 11 RETVAL=0
 12 prog="nginx"
 13
 14 nginxDir=/usr/local/nginx
 15 nginxd=$nginxDir/sbin/nginx
 16 nginxConf=$nginxDir/conf/nginx.conf
 17 nginxPid=$nginxDir/nginx.pid
 18
 19 nginx_check()
 20 {
 21         if[[ -e $nginxPid ]];
 22                 ps aux | grep -v grep| grep -q nginx
 23         if(($?==0)); then
 24                 echo "$prog already runing..."
 25                 exit 1
 26         else
 27                 rm -rf $nginxPid &>/dev/null
 28         fi
 29         fi
 30
 31 }
 32 start()
 33 {
 34         nginx_check
 35         if(($? !=0)); then
 36                 true
 37         else
 38                 echo -n $"Start $prog;"
 39                 daemon $nginxd -c $nginxConf
 40                 RETVAL=$?
 41                 echo
 42                 [$RETVAL=0] && touch /var/lock/subsys/nginx
 43                 return $RETVAL
 44         fi
 45
 46
 47
 48 }
 49
 50 stop()
 51 {
 52         echo -n $"Stopping $prog:"
 53         killproc $nginxd
 54         RETVAL =$?
 55
 56         echo
 57         [$RETVAL=0] && rm -f /var/lock/subsys/nginx $nginxPid
 58 }
 59
 60 reload()
 61 {
 62         echo -n $"Reloading $prog:"
 63         killproc $nginxd -HUP
 64         RETVAL=$?
 65         echo
 66
 67 }
 68
 69 monitor()
 70 {
 71         status $prog &>/dev/null
 72         if(($? == 0)); then
 73                 RETVAL=0
 74         else
 75                 RETVAL=7
 76         fi
 77 }
 78
 79 case "$1" in
 80         start)
 81                 start
 82                 ;;
 83         stop)
 84                 stop
 85                 ;;
 86         restart)
 87                 stop
 88                 start
 89                 ;;
 90         reload)
 91                 reload
 92                 ;;
 93         status)
 94                 status $prog
 95                 RETVAL=$?
 96                 ;;
 97         monitor)
 98                 monitor
 99                 ;;
100         *)

 

運行報錯:

/tmp/nginxd.sh: line 9: [: missing `]'
/tmp/nginxd.sh: line 29: syntax error near unexpected token `fi'
/tmp/nginxd.sh: line 29: `      fi'

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章