blob: 6d66e09570a428a88245deeee162ea6a0fb6c47d (
plain) (
blame)
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
|
#! /bin/sh
#
# $FreeBSD$
#
# PROVIDE: ttrssd
# REQUIRE: LOGIN mysql postgresql
# KEYWORD: shutdown
# Add the following line to /etc/rc.conf to enable `ttrssd':
#
#ttrssd_enable="YES"
#
. /etc/rc.subr
name="ttrssd"
rcvar=ttrssd_enable
# read settings, set default values
load_rc_config "${name}"
: ${ttrssd_enable="NO"}
required_files="%%WWWDIR%%/config.php"
pidfile="/var/run/${name}.pid"
phpcli="%%LOCALBASE%%/bin/php"
command_interpreter=$phpcli
long_name="Tiny Tiny RSS updating feeds daemon."
phpupd="update_daemon2.php"
ttrssd_log="/var/log/${name}.log"
ttrssd_user="%%WWWOWN%%"
%%DBLOCAL%%start_precmd=${name}_prestart
start_cmd=${name}_start
stop_cmd=${name}_stop
%%MYSQL%%CHECK_CMD="%%LOCALBASE%%/bin/mysqladmin -u mysqld ping"
%%MYSQL%%CHECK_MSG="${name}: mysqladmin command failed; mysql not ready?"
# Waiting for pg_isready when 9.3 is the default
%%PGSQL%%CHECK_CMD="%%LOCALBASE%%/etc/rc.d/postgresql status"
%%PGSQL%%CHECK_MSG="${name}: postgresql status failed; postgresql not ready?"
ttrssd_start() {
[ -x $phpcli ] || (echo "$phpcli not found"; exit 1)
[ -f $pidfile ] && (echo "$name already running?"; exit 2)
echo "Starting $long_name"
(cd %%WWWDIR%% && su -fm $ttrssd_user -c "./$phpupd" > $ttrssd_log &) && \
echo $$ > $pidfile
}
ttrssd_stop() {
[ -f $pidfile ] || (echo "$name not running?"; exit 1)
echo "Stopping $long_name"
kill `ps ax | grep $phpupd | grep -v grep | awk '{print $1}'`
rm -f $pidfile
}
ttrssd_prestart() {
local _count=0
while : ; do
$CHECK_CMD > /dev/null 2>&1 && return
_count=$(( $_count + 1 ))
if [ $_count -gt 10 ]; then
err 1 $CHECK_MSG
fi
sleep 1
done
}
run_rc_command "$1"
|