File: kopano-presence.init.rhel

package info (click to toggle)
kopanocore 8.7.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 15,400 kB
  • sloc: cpp: 175,422; python: 24,623; perl: 7,319; php: 6,056; sh: 2,172; makefile: 1,294; xml: 45; ansic: 1
file content (107 lines) | stat: -rw-r--r-- 2,124 bytes parent folder | download
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
#
# kopano-presence Kopano Groupware Core Presence Daemon
#
# chkconfig: 345 86 24
# processname: /usr/sbin/kopano-presence
# config: /etc/kopano/presence.cfg
# pidfile: /var/run/kopano/presence.pid
# SPDX-License-Identifier: AGPL-3.0-only
### BEGIN INIT INFO
# Provides: kopano-presence
# Required-Start: $local_fs $network $remote_fs $syslog
# Required-Stop: $local_fs $network $remote_fs $syslog
# Should-Start: kopano-server
# Should-Stop: kopano-server
# Short-Description: Kopano Core Presence Daemon
### END INIT INFO

PRESENCECONFIG=/etc/kopano/presence.cfg
PRESENCEPROGRAM=/usr/sbin/kopano-presence

# Sanity checks.
[ -x $PRESENCEPROGRAM ] || exit 0

PRESENCECONFIG_OPT=""
[ ! -z $PRESENCECONFIG -a -f $PRESENCECONFIG ] && PRESENCECONFIG_OPT="-c $PRESENCECONFIG"

# Switch to C, like at boot time.
unset LANG LC_CTYPE LC_NUMERIC LC_COLLATE LC_MESSAGES LC_ALL

# Source function library.
. /etc/rc.d/init.d/functions

RETVAL=0
presence=`basename $PRESENCEPROGRAM`
lockfile=/var/lock/subsys/$presence
pidfile=/var/run/kopano/presence.pid

start() {
	# Start in background, always succeeds
	echo -n $"Starting $presence: "
	install -dm0775 -o kopano -g kopano /var/run/kopano
	daemon --pidfile="$pidfile" $PRESENCEPROGRAM $PRESENCECONFIG_OPT >/dev/null 2>&1
	RETVAL=$?
	unset LC_ALL LANG
	echo
	[ $RETVAL -eq 0 ] && touch $lockfile

	return $RETVAL
}

stop() {
	echo -n $"Stopping $presence: "
	killproc -p "$pidfile"
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f $lockfile $pidfile

	return $RETVAL
}

restart() {
	stop
	start
}

reload() {
	echo -n $"Restarting $presence: "
	killproc -p "$pidfile" -SIGHUP
	RETVAL=$?
	echo

	return $RETVAL
}

# See how we were called.
case "$1" in
    start)
		start
		;;
    stop)
		stop
		;;
    status)
		echo -n $"kopano-presence "
		status -p "$pidfile"
		RETVAL=$?
		;;
    restart|force-reload)
		restart
		;;
    condrestart|try-restart)
		if [ -f ${pidfile} ]; then
			stop
			start
		fi
		;;
    reload)
		reload
		;;
    *)
		echo $"Usage: $presence {start|stop|status|reload|restart|condrestart|force-reload|try-restart}"
		RETVAL=1
		;;
esac

exit $RETVAL