Installation von Tiny Tiny RSS/Start-Stop-Skript

Aus
Version vom 24. März 2013, 19:21 Uhr von EL Duderino (Diskussion | Beiträge) (Ausgelagert)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
#!/bin/sh
#
# starts "Tiny Tiny Rss"ses update daemon
# put it into /usr/local/etc/rc.d/
# chmod 755 on it

TTRSS_PATH=/var/services/web/ttrss
getPID ()
{
	ps|grep "/usr/bin/php $TTRSS_PATH/update.php -daemon"|grep -v grep|awk '{print $1}'
	return $?
}

start_daemon () {
	su -m nobody -c "(trap '' SIGHUP SIGINT SIGQUIT && /usr/bin/php $TTRSS_PATH/update.php --daemon >> /dev/null 2>&1) &"
	return $?
} 

cronLine="*	*	*	*	*	root	"`realpath $0`" cron"

case $1 in
start)
	start_daemon
	stat=`getPID`
	if [ -z "$stat" ]; then
		echo "$cronLine" >> /etc/crontab
		/usr/syno/etc/rc.d/S04crond.sh stop
		/usr/syno/etc/rc.d/S04crond.sh start
	fi
	;;
stop)
	kill `getPID`
	;;
cron)
	stat=`getPID`
	if [ -z "$stat" ]; then
		start_daemon
	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"
	;;
esac