summaryrefslogtreecommitdiff
blob: c370ba4b2ee3c849918af20e2669d7e5ca14a219 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/sbin/runscript
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

sogod_bin=""
sogod_port=""

depend() {
	need net
	after pg_autovacuum postgresql mysql
	after slapd
	after mta
	after memcached
}

checkconfig() {
	if [ -f "/etc/GNUstep/GNUstep.conf" ]; then
		source /etc/GNUstep/GNUstep.conf
	else
		eerror "Can't find /etc/GNUstep/GNUstep.conf"
		return 1
	fi
	if [ -x "${HOME}/${GNUSTEP_USER_DIR_ADMIN_TOOLS}/sogod" ]; then
		sogod_bin="${HOME}/${GNUSTEP_USER_DIR_ADMIN_TOOLS}/sogod"
	elif [ -x "${GNUSTEP_LOCAL_ADMIN_TOOLS}/sogod" ]; then
		sogod_bin="${GNUSTEP_LOCAL_ADMIN_TOOLS}/sogod"
	elif [ -x "${GNUSTEP_SYSTEM_ADMIN_TOOLS}/sogod" ]; then
		sogod_bin="${GNUSTEP_SYSTEM_ADMIN_TOOLS}/sogod"
	elif [ -x "${GNUSTEP_NETWORK_ADMIN_TOOLS}/sogod" ]; then
		sogod_bin="${GNUSTEP_SYSTEM_ADMIN_TOOLS}/sogod"
	else
		eerror "Can't find sogod"
		return 1
	fi
	if [ -f "${GNUSTEP_MAKEFILES}/GNUstep.sh" ]; then
		source "${GNUSTEP_MAKEFILES}/GNUstep.sh"
	else
		eerror "Can't find ${GNUSTEP_MAKEFILES}/GNUstep.sh"
		return 1
	fi
	sogod_port="$(defaults -u sogo read sogod WOPort 2>/dev/null)"
	if [ "${?}" -eq 0 ]; then
		sogod_port="${sogod_port##* }"
		if [ "$((${sogod_port}+1-1))" != "${sogod_port}" ]; then
			sogod_port="20000"
		fi
	else
		sogod_port="20000"
	fi
	touch /var/log/sogod.log
	chown sogo /var/log/sogod.log
}

start() {
	checkconfig || return 1
	ebegin "Starting SOGo service"
	start-stop-daemon \
		--start \
		--exec ${sogod_bin} \
		--chuid sogo \
		--make-pidfile \
		--background \
		--pidfile /var/run/sogod.pid \
		-- -WOPort ${sogod_port}
	eend ${?}
}

stop() {
	ebegin "Stopping SOGo service"
	start-stop-daemon --stop \
		--pidfile /var/run/sogod.pid
	eend ${?}
}