summaryrefslogtreecommitdiff
path: root/audio/ices-cc/rc.ices-cc
blob: 002f6254bf2c333951b17e083af660aea6079e68 (plain)
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
76
77
78
79
80
#!/bin/sh

# Start/stop/restart ices-cc as a daemon
# Copyright (c) 2011 Antonio Hernández Blas <hba.nihilismus@gmail.com>

#
#            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
#                    Version 2, December 2004
#
# Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
#
# Everyone is permitted to copy and distribute verbatim or modified
# copies of this license document, and changing it is allowed as long
# as the name is changed.
#
#            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
#   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
#
#  0. You just DO WHAT THE FUCK YOU WANT TO.
#

CONF='/etc/ices-cc.conf'
BASEDIR='/var/log/ices-cc'
CMMD="/usr/bin/ices-cc -B -c $CONF -D $BASEDIR"

ices_start() {
  if [ -x /usr/bin/ices-cc ]; then
    if [ -f $CONF ]; then
      PIDOF=$(pgrep -f "$CMMD")
      if [ ! -z "$PIDOF" ]; then
        echo "Error, ices is already running as daemon."
      else
        echo "Starting ices as daemon:  $CMMD"
        /bin/su - ices -c "$CMMD"
      fi
    else
      echo "Error, file $CONF does not exist."
    fi
  fi
}

ices_stop() {
  PIDOF=$(pgrep -f "$CMMD")
  if [ -z $PIDOF ]; then
    echo "Error, ices-cc is not running as daemon."
  else
    echo "Stoping ices-cc as daemon:  kill -s SIGINT $PIDOF"
    /bin/kill -s SIGINT $PIDOF
  fi
}

ices_status() {
  PIDOF=$(pgrep -f "$CMMD")
  if [ ! -z "$PIDOF" ]; then
    echo "ices-cc is running as daemon."
  else
    echo "ices-cc is not running as daemon."
  fi
}

case $1 in
  start)
    ices_start
  ;;
  stop)
    ices_stop
  ;;
  restart)
    ices_stop
    sleep 3
    ices_start
  ;;
  status)
    ices_status
  ;;
  *)
    echo "Usage $0 {start|stop|restart|status}"
    exit 1
  ;;
esac