hi, all, i had write a #!/sbin/runscript script, but status will not turn to
"started", is there some error in this script or this is a bug?
THX all of you.



source code first (i want to start a bash script with runscript):
+---------------------------------------------------------------------------------------------------------------------------------------
 |    #!/sbin/runscript
 |    #file name: test
 |    .....<in start() {>
 |        start-stop-daemon -S -p "${PIDFILE}" -m -b -a "${EXECFILE}" --
--Pidfile "${PIDFILE}"
 |    .....
+---------------------------------------------------------------------------------------------------------------------------------------
sudo ./test start
    * Starting Test ...  [ ok ]
sudo ./test start
    * Starting Test ...
    process already running.
sudo ./test stop
    * WARNING:  test has not yet been started.
sudo ./test status
    * status:  stopped
but the bash script is running, and the $PIDFILE had filled with correct pid
number, so ,i can;t stop it with runscript.



in another way to write this script, but use bash this time, it totaly OK.



[FULL source code of these scripts]
+---------------------------------------------------------------------------------------------------------------------------------------
 |
 | #file name: test
 | #!/sbin/runscript
 | PIDFILE=/tmp/runsc/pid/test.pid
 | EXECFILE=/tmp/runsc/testbash1
 |
 | depend() {
 |         need net
 | }
 |
 | start() {
 |      ebegin "Starting Test"
 |      start-stop-daemon -S -p "${PIDFILE}" -m -b -a "${EXECFILE}" --
--Pidfile
"${PIDFILE}"

 |      eend
$?
 |      #return
0
 |
}

 |
 | stop() {
 |      echo "stop daemon"
 |      ebegin "Stopping Test"
 |      start-stop-daemon -K  -p "${PIDFILE}" -a "${EXECFILE}"
 |      #cat "${PIDFILE}" | xargs -i kill '{}'
 |      eend $?
 |
 | }
 |
 | status() {
 |      if [ -a "${PIDFILE}" ]; then
 |              echo "exit file"
 |              return 0;
 |      else
 |              echo "not exit file"
 |              return 1;
 |      fi
 | }
 |
+---------------------------------------------------------------------------------------------------------------------------------------
 |
 | #file name: test.sh
 |
#!/bin/bash

 |
PIDFILE=/tmp/runsc/pid/test.pid

 |
EXECFILE=/tmp/runsc/testbash1

 |

 | start()
{
 |      echo "Starting
Test"
 |      echo start-stop-daemon -S -p "${PIDFILE}" -m -b -a "${EXECFILE}" --
--Pidfile
"${PIDFILE}"
 |      #return
0
 |
}

 |

 | stop()
{
 |      echo "stop
daemon"
 |      echo "Stopping
Test"
 |      #start-stop-daemon -K -o  -p
"${PIDFILE}"
 |      cat "${PIDFILE}" | xargs -i kill
'{}'
 |
}

 |

 | status()
{
 |      if [ -a "${PIDFILE}" ];
then
 |              echo "exit
file"
 |              return
0;
 |
else
 |              echo "not exit
file"
 |              return 1;
 |      fi
 | }
 |
 | case "$1" in
 |      start)
 |              start
 |      ;;
 |      stop)
 |              stop
 |      ;;
 |      status)
 |              status
 |      ;;
 |      *)
 |      echo "Usage: $0 {start|stop|restart|force-reload|make}" >&2
 |      exit 1
 |      ;;
 | esac
 |
+---------------------------------------------------------------------------------------------------------------------------------------
 |
 | #file name: testbash1
 | #!/bin/bash
 | while true; do
 |      #echo '$pid_file='$pid_file
 |      echo "a" >> /tmp/runsc/pid/output.log; sleep 1
 |      echo "aa" >> /tmp/runsc/pid/output.log; sleep 1
 |      echo "aaa" >> /tmp/runsc/pid/output.log; sleep 1
 |      echo "aaaa" >> /tmp/runsc/pid/output.log; sleep 1
 |      echo "aaaaa" >> /tmp/runsc/pid/output.log; sleep 1
 | done
 |
+---------------------------------------------------------------------------------------------------------------------------------------

Reply via email to