1b7636541ae073249896073ad4db5fd1a816ab79
[gd/samba-autobuild/.git] / ctdb / config / events.d / 31.clamd
1 #!/bin/sh
2 # event script to manage clamd in a cluster environment
3
4 [ -n "$CTDB_BASE" ] || \
5     CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; dirname "$PWD")
6
7 . "${CTDB_BASE}/functions"
8
9 detect_init_style
10
11 case $CTDB_INIT_STYLE in
12 redhat)
13         service_name="clamd"
14         # service_config is used by loadconfig()
15         # shellcheck disable=SC2034
16         service_config="clamd"
17         ;;
18 *)
19         service_name="clamav"
20         # service_config is used by loadconfig()
21         # shellcheck disable=SC2034
22         service_config="clamav"
23         ;;
24 esac
25
26 loadconfig
27
28 is_ctdb_managed_service || exit 0
29
30 case "$1" in
31 startup)
32         service "$service_name" stop > /dev/null 2>&1
33         service "$service_name" start || exit $?
34         ;;
35
36 shutdown)
37         service "$service_name"_stop
38         ;;
39
40 monitor)
41         ctdb_check_unix_socket "$CTDB_CLAMD_SOCKET" || exit $?
42         ;;
43 esac
44
45 exit 0