Installation von Tiny Tiny RSS/Start-Stop-Skript: Unterschied zwischen den Versionen

Aus Synology Wiki
Wechseln zu: Navigation, Suche
K (auf DSM 5 angepasst)
K
 
Zeile 6: Zeile 6:
 
# chmod 755 on it
 
# chmod 755 on it
  
# Here, /var/services/web/ttrss/ must be changed to the directory that you installed Tiny Tiny RSS into
+
PHP="/usr/bin/php"
DM_CMD="/usr/bin/php /var/services/web/ttrss/update.php --daemon"
+
# This must be changed to the directory you installed Tiny Tiny RSS into.
 +
TTRSS_DIR=/var/services/web/tt-rss
 +
# If you need more logging information, remove --quiet.
 +
DAMON_OPTS=--quiet
 +
WEBUSER=http #nobody for DSM 4.x
 +
 
 +
# If you need logging information, you can change LOGFILE to another file.
 +
# It must be writable by the user $WEBUSER.
 +
LOGFILE=/dev/null
 +
 
 +
DM_CMD="$PHP ${TTRSS_DIR}/update.php --daemon $DAMON_OPTS"
 +
 
 
getPID ()
 
getPID ()
 
{
 
{
ps|grep "$DM_CMD"|grep -v grep|awk '{print $1}'
+
ps w|grep "$DM_CMD"|grep -v grep|awk '{print $1}'
 
return $?
 
return $?
 
}
 
}
  
# If you need logging information, you can change LOGFILE to another file.
 
# It must be writable by the user nobody.
 
# If you need some sensible logging information, remove the parameter --quiet.
 
LOGFILE=/dev/null
 
 
start_daemon () {
 
start_daemon () {
su -m http -c "(trap '' SIGHUP && $DM_CMD --quiet >> $LOGFILE 2>&1) &"
+
su -m $WEBUSER -c "(trap '' SIGHUP && $DM_CMD >> $LOGFILE 2>&1) &"
return $?
+
local RES=$?
 +
if [ $RES -eq 0 ]; then
 +
echo "`date` - Started daemon" >> "$LOG"
 +
fi
 +
return $RES
 
}  
 
}  
  
reset_crond () {
 
ps |grep /usr/sbin/crond|grep -v grep|awk '{print $1}'|xargs kill -HUP
 
return $?
 
}
 
  
 
# It is VERY important that the tabs in the next line are preserved!
 
# It is VERY important that the tabs in the next line are preserved!
Zeile 34: Zeile 41:
 
start)
 
start)
 
start_daemon
 
start_daemon
stat=`getPID`
+
if [ $? -ne 0 ]; then
if [ -z "$stat" ]; then
+
 
echo "$cronLine" >> /etc/crontab
 
echo "$cronLine" >> /etc/crontab
reset_crond
+
synoservicectl --reload crond
 
fi
 
fi
 
;;
 
;;
 
stop)
 
stop)
PID=`getPID`
+
kill `getPID`
kill $PID
+
if [ $? -eq 0 ]; then
 +
echo "`date` - Stopped daemon" >> "$LOG"
 +
fi
 
;;
 
;;
 
cron)
 
cron)
stat=`getPID`
+
start_daemon
if [ -z "$stat" ]; then
+
if [ $? -eq 0 ]; then
start_daemon
+
sed -i -e "\\%$cronLine% d" /etc/crontab
 +
synoservicectl --reload crond
 
fi
 
fi
sed -i -e "\\%$cronLine% d" /etc/crontab
 
reset_crond
 
 
;;
 
;;
 
status)
 
status)
stat=`getPID`
+
if [ -z `getPID` ]; then
if [ -z "$stat" ]; then
+
 
echo "daemon is not running."
 
echo "daemon is not running."
 
else
 
else

Aktuelle Version vom 23. April 2014, 22:21 Uhr

#!/bin/sh
#
# starts "Tiny Tiny RSS"ses update daemon
# put it into /usr/local/etc/rc.d/ with the suffix .sh
# chmod 755 on it

PHP="/usr/bin/php"
# This must be changed to the directory you installed Tiny Tiny RSS into.
TTRSS_DIR=/var/services/web/tt-rss
# If you need more logging information, remove --quiet.
DAMON_OPTS=--quiet
WEBUSER=http #nobody for DSM 4.x

# If you need logging information, you can change LOGFILE to another file.
# It must be writable by the user $WEBUSER.
LOGFILE=/dev/null

DM_CMD="$PHP ${TTRSS_DIR}/update.php --daemon $DAMON_OPTS"

getPID ()
{
	ps w|grep "$DM_CMD"|grep -v grep|awk '{print $1}'
	return $?
}

start_daemon () {
	su -m $WEBUSER -c "(trap '' SIGHUP && $DM_CMD >> $LOGFILE 2>&1) &"
	local RES=$?
	if [ $RES -eq 0 ]; then
		echo "`date` - Started daemon" >> "$LOG"
	fi
	return $RES
} 


# It is VERY important that the tabs in the next line are preserved!
cronLine="*	*	*	*	*	root	"`realpath $0`" cron"

case $1 in
start)
	start_daemon
	if [ $? -ne 0 ]; then
		echo "$cronLine" >> /etc/crontab
		synoservicectl --reload crond
	fi
	;;
stop)
	kill `getPID`
	if [ $? -eq 0 ]; then
		echo "`date` - Stopped daemon" >> "$LOG"
	fi
	;;
cron)
	start_daemon
	if [ $? -eq 0 ]; then
		sed -i -e "\\%$cronLine% d" /etc/crontab
		synoservicectl --reload crond
	fi
	;;
status)
	if [ -z `getPID` ]; then
		echo "daemon is not running."
	else
		echo "daemon is running."
	fi
	;;
*)
	echo "Wrong argument. Usage: $0 start|stop|status"
	;;
esac

Links