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

Aus
(Ausgelagert)
 
KKeine Bearbeitungszusammenfassung
 
(8 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 2: Zeile 2:
#!/bin/sh
#!/bin/sh
#
#
# starts "Tiny Tiny Rss"ses update daemon
# starts "Tiny Tiny RSS"ses update daemon
# put it into /usr/local/etc/rc.d/
# put it into /usr/local/etc/rc.d/ with the suffix .sh
# chmod 755 on it
# chmod 755 on it


TTRSS_PATH=/var/services/web/ttrss
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 ()
getPID ()
{
{
ps|grep "/usr/bin/php $TTRSS_PATH/update.php -daemon"|grep -v grep|awk '{print $1}'
ps w|grep "$DM_CMD"|grep -v grep|awk '{print $1}'
return $?
return $?
}
}


start_daemon () {
start_daemon () {
su -m nobody -c "(trap '' SIGHUP SIGINT SIGQUIT && /usr/bin/php $TTRSS_PATH/update.php --daemon >> /dev/null 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
}  
}  


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


Zeile 23: 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
/usr/syno/etc/rc.d/S04crond.sh stop
synoservicectl --reload crond
/usr/syno/etc/rc.d/S04crond.sh start
fi
fi
;;
;;
stop)
stop)
kill `getPID`
kill `getPID`
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
;;
status)
if [ -z `getPID` ]; then
echo "daemon is not running."
else
echo "daemon is running."
fi
fi
sed -i -e "\\%$cronLine% d" /etc/crontab
/usr/syno/etc/rc.d/S04crond.sh stop
/usr/syno/etc/rc.d/S04crond.sh start
;;
;;
*)
*)
echo "Wrong argument. Usage: $0 start|stop"
echo "Wrong argument. Usage: $0 start|stop|status"
;;
;;
esac
esac
</pre>
</pre>
==Links==
*[http://www.synology.com/support/3rd_party_app_int.php 3rd-Party Apps Developer Guide]

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