Installation von Tiny Tiny RSS/Start-Stop-Skript: Unterschied zwischen den Versionen
Aus
KKeine Bearbeitungszusammenfassung |
KKeine Bearbeitungszusammenfassung |
||
(Eine dazwischenliegende Version desselben Benutzers wird nicht angezeigt) | |||
Zeile 6: | Zeile 6: | ||
# chmod 755 on it | # 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 () | getPID () | ||
{ | { | ||
ps|grep "$DM_CMD"|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 | 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 | # It is VERY important that the tabs in the next line are preserved! | ||
cronLine="* * * * * root "`realpath $0`" cron" | cronLine="* * * * * root "`realpath $0`" cron" | ||
Zeile 34: | Zeile 41: | ||
start) | start) | ||
start_daemon | start_daemon | ||
if [ $? -ne 0 ]; then | |||
if [ - | |||
echo "$cronLine" >> /etc/crontab | echo "$cronLine" >> /etc/crontab | ||
synoservicectl --reload crond | |||
fi | fi | ||
;; | ;; | ||
stop) | stop) | ||
kill `getPID` | |||
if [ $? -eq 0 ]; then | |||
echo "`date` - Stopped daemon" >> "$LOG" | |||
fi | |||
;; | ;; | ||
cron) | cron) | ||
start_daemon | |||
if [ - | 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 | fi | ||
;; | ;; | ||
*) | *) | ||
echo "Wrong argument. Usage: $0 start|stop" | echo "Wrong argument. Usage: $0 start|stop|status" | ||
;; | ;; | ||
esac | esac |
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