File: kopano-dagent.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 (110 lines) | stat: -rw-r--r-- 2,207 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
108
109
110
#!/bin/bash
#
# kopano-dagent Kopano Groupware Core Delivery Agent
#
# chkconfig: - 86 24
# processname: /usr/sbin/kopano-dagent
# config: /etc/kopano/dagent.cfg
# pidfile: /var/run/kopano/dagent.pid
# SPDX-License-Identifier: AGPL-3.0-only
### BEGIN INIT INFO
# Provides: kopano-dagent
# 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 Groupware Core Delivery Agent
### END INIT INFO

DAGENTCONFIG=/etc/kopano/dagent.cfg
DAGENTPROGRAM=/usr/sbin/kopano-dagent

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

# the -d option is required to run LMTP mode deamonized
DAGENTCONFIG_OPT="-d"
[ ! -z $DAGENTCONFIG -a -f $DAGENTCONFIG ] && DAGENTCONFIG_OPT="$DAGENTCONFIG_OPT -c $DAGENTCONFIG"

# 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
dagent=`basename $DAGENTPROGRAM`
lockfile=/var/lock/subsys/$dagent
pidfile=/var/run/kopano/dagent.pid

start() {
	# Start in background, always succeeds
	echo -n $"Starting $dagent: "
	install -dm0775 -o kopano -g kopano /var/run/kopano
	if [ -f /opt/rh/rh-php56/enable ]; then
		. /opt/rh/rh-php56/enable
	fi
	daemon --pidfile="$pidfile" $DAGENTPROGRAM $DAGENTCONFIG_OPT
	RETVAL=$?
	unset LC_ALL LANG
	echo
	[ $RETVAL -eq 0 ] && touch $lockfile

	return $RETVAL
}

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

	return $RETVAL
}

restart() {
	stop
	start
}

reload() {
	echo -n $"Restarting $dagent: "
	killproc $DAGENTPROGRAM -SIGHUP
	RETVAL=$?
	echo

	return $RETVAL
}

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

exit $RETVAL