summaryrefslogtreecommitdiff
path: root/system/cfengine/rc.cfservd
blob: 68db3261ab9ec6e60c8d44c1dd0655dd1d168401 (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
#!/bin/sh

# start/stop/restart/reload cfservd

# 'cfservd' looks for a configuration file cfservd.conf by default.

# Note: this daemon doesn't actually need to run under the root account,
# assuming an account named 'cfservd' exists, one way of configuring it
# to use its own account would be to to run 'cfkey' and 'cfagent' ones
# which creates the ~/.cfagent subdir then start the service with:
# /bin/su - cfservd -c /usr/sbin/cfservd

# Start cfservd:
cfservd_start() {
  if [ -x /usr/sbin/cfservd ]; then
    # Make sure localhost keys exist first
    if [ ! -f /var/cfengine/ppkeys/localhost.priv ]; then
      /usr/sbin/cfkey
    fi
    echo "Starting Cfengine:  /usr/sbin/cfservd"
    /usr/sbin/cfservd
  fi
}

# Stop cfservd:
cfservd_stop() {
  /bin/killall cfservd 2> /dev/null
}

# Restart cfservd:
cfservd_restart() {
  cfservd_stop
  sleep 1
  cfservd_start
}

# Reload cfservd:
cfservd_reload() {
  /bin/killall -HUP cfservd
}

case "$1" in
'start')
  cfservd_start
  ;;
'stop')
  cfservd_stop
  ;;
'restart')
  cfservd_restart
  ;;
'reload')
  cfservd_reload
  ;;
*)
  echo "usage $0 start|stop|restart|reload"
esac