summaryrefslogtreecommitdiff
blob: f3496389c42d3797d119126d2623f5b98622a13f (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
#!/sbin/runscript

LOGFILE=/var/log/ttrssd.log

depend() {
	need logger net
}

start () {
	ebegin "Starting TT-RSS update daemon(s)"
	[ -z "${INSTANCE_DIRS}" ] && { echo "No instance directories specified in /etc/conf.d/ttrssd."; exit 1; }

	# Make sure the log file can be written to
	touch ${LOGFILE} && chown ttrssd ${LOGFILE}

	for INSTANCE_DIR in ${INSTANCE_DIRS}; do
		[ -f "${INSTANCE_DIR}/update_daemon2.php" ] || continue
		einfo "  ${INSTANCE_DIR}"

		# Since I have no idea how I could do this during the webapp-config installation,
		# lets do it during start up...
		for DIR in cache cache/htmlpurifier cache/magpie cache/simplepie lock icons; do
			chgrp ttrssd "${INSTANCE_DIR}/${DIR}"
			chmod g+w "${INSTANCE_DIR}/${DIR}"
		done

		# Finally run the PHP script
		start-stop-daemon --start -u ttrssd:ttrssd -b \
		                  -1 /var/log/ttrssd.log -2 /var/log/ttrssd.log \
		                  -x /usr/bin/php "${INSTANCE_DIR}/update_daemon2.php"
	done
	eend $?
}

stop() {
	ebegin "Stopping TT-RSS update daemon(s)"
	for INSTANCE_DIR in ${INSTANCE_DIRS}; do
		[ -f "${INSTANCE_DIR}/update_daemon2.php" ] || continue
		einfo "  ${INSTANCE_DIR}"
		start-stop-daemon --stop -x /usr/bin/php "${INSTANCE_DIR}/update_daemon2.php"
	done
	eend $?
}