File: kopano-gateway.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 (106 lines) | stat: -rw-r--r-- 2,094 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
#!/bin/bash
#
# kopano-gateway Kopano Groupware Core POP3/IMAP Gateway
#
# chkconfig: 345 86 24
# processname: /usr/sbin/kopano-gateway
# config: /etc/kopano/gateway.cfg
# pidfile: /var/run/kopano/gateway.pid
# SPDX-License-Identifier: AGPL-3.0-only
### BEGIN INIT INFO
# Provides: kopano-gateway
# 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 POP3/IMAP Gateway
### END INIT INFO

GATEWAYCONFIG=/etc/kopano/gateway.cfg
GATEWAYPROGRAM=/usr/sbin/kopano-gateway

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

GATEWAYCONFIG_OPT=""
[ ! -z $GATEWAYCONFIG -a -f $GATEWAYCONFIG ] && GATEWAYCONFIG_OPT="-c $GATEWAYCONFIG"

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

start() {
	# Start in background, always succeeds
	echo -n $"Starting $gateway: "
	install -dm0775 -o kopano -g kopano /var/run/kopano
	daemon --pidfile="$pidfile" $GATEWAYPROGRAM $GATEWAYCONFIG_OPT
	RETVAL=$?
	unset LC_ALL LANG
	echo
	[ $RETVAL -eq 0 ] && touch $lockfile

	return $RETVAL
}

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

	return $RETVAL
}

restart() {
	stop
	start
}

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

	return $RETVAL
}

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

exit $RETVAL