www-apps/tt-rss/files/ttrssd.initd
author Da Risk <da_risk@elyzion.net>
Wed, 03 Apr 2013 11:26:19 +0200
changeset 75 70eb8924b719
permissions -rw-r--r--
Update tt-rss to latest version

#!/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 cache/images cache/export lock feed-icons; do
			[ -d "${INSTANCE_DIR}/${DIR}" ] && chgrp ttrssd "${INSTANCE_DIR}/${DIR}"
			[ -d "${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" && \
			rm -f ${INSTANCE_DIR}/lock/*.lock
	done
	eend $?
}