File: p3scan-init.d

package info (click to toggle)
p3scan 2:2.1-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,568 kB
  • ctags: 2,371
  • sloc: ansic: 12,072; makefile: 253; sh: 234
file content (75 lines) | stat: -rw-r--r-- 1,573 bytes parent folder | download | duplicates (5)
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
#!/bin/bash
#
# p3scan startup script
#
# usage: p3scan { start | stop | restart | status }
#
# Jack S. Lai - laitcg@cox.net
. /etc/sysconfig/init
pretty(){
   echo -en $CMDTITLE
   if $CMD 2> /dev/null; then
      $MOVE_TO_COL
      echo -en "["
      $SETCOLOR_SUCCESS
      echo -en "  OK  \c"
      $SETCOLOR_NORMAL
      echo "]"
   else
      $MOVE_TO_COL
      echo -en "["
      $SETCOLOR_FAILURE
      echo -en "FAILED\c"
      $SETCOLOR_NORMAL
      echo "]"
   fi
}

case "$1" in
   start)
      # Start p3scan
      echo -en "Starting p3scan"
      /usr/sbin/p3scan &
      $MOVE_TO_COL
      echo -en "["
      $SETCOLOR_SUCCESS
      echo -en "  OK  \c"
      $SETCOLOR_NORMAL
      echo "]"
      ;;
   stop)
      # Stop p3scan
      if [ -a /var/run/p3scan/p3scan.pid ]; then
         CMDTITLE="Stopping p3scan"
         CMD="kill `cat /var/run/p3scan/p3scan.pid` &>/dev/null"
         pretty
         rm -f /var/run/p3scan/p3scan.pid
      else
         echo -en "Stopping p3scan"
         killall p3scan &>/dev/null
         $MOVE_TO_COL
         echo -en "["
         $SETCOLOR_WARNING
         echo -en "  OK  \c"
         $SETCOLOR_NORMAL
         echo "]"
      fi
      ;;
   status)
      # p3scan status
      if [ -a /var/run/p3scan/p3scan.pid ]; then
         PID=`cat /var/run/p3scan/p3scan.pid`
         echo "p3scan OK, running: $PID"
      else
         echo "p3scan is stopped"
      fi
      ;;
   restart)
      $0 stop
      $0 start
      ;;
   *)
      echo "Usage: p3scan { start | stop | restart | status }"
      exit 1
esac
exit 0