www-apps/tt-rss/files/ttrssd.initd
changeset 75 70eb8924b719
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/www-apps/tt-rss/files/ttrssd.initd	Wed Apr 03 11:26:19 2013 +0200
@@ -0,0 +1,45 @@
+#!/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 $?
+}