|
1 #!/sbin/runscript |
|
2 # Copyright 1999-2013 Gentoo Foundation |
|
3 # Distributed under the terms of the GNU General Public License v2 |
|
4 # $Header: /var/cvsroot/gentoo-x86/www-apps/tt-rss/files/ttrssd.initd-r1,v 1.1 2013/03/24 10:22:25 scarabeus Exp $ |
|
5 |
|
6 depend() { |
|
7 need logger net |
|
8 after postgres mysql |
|
9 } |
|
10 |
|
11 LOGFILE=${LOGFILE:-"/var/log/ttrssd.log"} |
|
12 TTRSSD_USER=${TTRSSD_USER:-"ttrssd"} |
|
13 TTRSSD_GROUP=${TTRSSD_GROUP:-"ttrssd"} |
|
14 INSTANCE_FOLDERS="cache cache/htmlpurifier cache/magpie cache/simplepie cache/images cache/export lock feed-icons" |
|
15 |
|
16 checkconfig() { |
|
17 local instance dir |
|
18 |
|
19 # check instances |
|
20 if [ -z "${INSTANCE_DIRS}" ]; then |
|
21 eerror "There is no defined instance directory in /etc/conf.d/ttrssd" |
|
22 return 1 |
|
23 fi |
|
24 |
|
25 # verify log file accessibility |
|
26 if [ ! -e "${LOGFILE}" ]; then |
|
27 touch "${LOGFILE}" || return 1 |
|
28 fi |
|
29 chown "${TTRSSD_USER}":"${TTRSSD_GROUP}" "${LOGFILE}" || return 1 |
|
30 |
|
31 # check instances for errors |
|
32 for instance in ${INSTANCE_DIRS}; do |
|
33 if [ ! -f "${instance}/update_daemon2.php" ]; then |
|
34 eerror "\"${instance}\" does not contain update_daemon2.php script." |
|
35 eerror "Please check your installation or the INSTANCE_DIRS variable." |
|
36 return 1 |
|
37 fi |
|
38 |
|
39 # FIXME: This should be done by webapp-config during install |
|
40 for dir in ${INSTANCE_FOLDERS}; do |
|
41 if [ -d "${instance}/${dir}" ]; then |
|
42 chgrp -R "${TTRSSD_GROUP}" "${instance}/${dir}" || return 1 |
|
43 chmod -R g+w "${instance}/${dir}" || return 1 |
|
44 fi |
|
45 done |
|
46 done |
|
47 } |
|
48 |
|
49 start () { |
|
50 local instance |
|
51 |
|
52 checkconfig || return 1 |
|
53 |
|
54 for instance in ${INSTANCE_DIRS}; do |
|
55 ebegin "Starting TT-RSS update daemon in \"${instance}\"" |
|
56 start-stop-daemon --start --user "${TTRSSD_USER}":"${TTRSSD_GROUP}" --background \ |
|
57 --stdout "${LOGFILE}" --stderr "${LOGFILE}" \ |
|
58 --exec /usr/bin/php -- -f "${instance}/update_daemon2.php" |
|
59 eend $? |
|
60 done |
|
61 } |
|
62 |
|
63 stop() { |
|
64 local instance |
|
65 |
|
66 for instance in ${INSTANCE_DIRS}; do |
|
67 ebegin "Stopping TT-RSS update daemon in \"${instance}\"" |
|
68 start-stop-daemon --stop \ |
|
69 --exec /usr/bin/php -- -f "${instance}/update_daemon2.php" |
|
70 eend $? |
|
71 rm -f ${instance}/lock/*.lock |
|
72 done |
|
73 } |