diff --git a/GIDs b/GIDs --- a/GIDs +++ b/GIDs @@ -797,7 +797,7 @@ _geodns:*:853: ebusd:*:854: opensearch:*:855: -# free: 856 +ttrssd:*:856: # free: 857 # free: 858 # free: 859 diff --git a/UIDs b/UIDs --- a/UIDs +++ b/UIDs @@ -803,7 +803,7 @@ _geodns:*:853:853::0:0:GeoDNS User:/var/empty:/usr/sbin/nologin ebusd:*:854:854::0:0:eBUS Daemon user:/nonexistent:/usr/sbin/nologin opensearch:*:855:855::0:0:opensearch user:/nonexistent:/usr/sbin/nologin -# free: 856 +ttrssd:*:856:856::0:0:ttrssd user:/nonexistent:/usr/sbin/nologin # free: 857 # free: 858 # free: 859 diff --git a/www/tt-rss/Makefile b/www/tt-rss/Makefile --- a/www/tt-rss/Makefile +++ b/www/tt-rss/Makefile @@ -37,11 +37,14 @@ # pgsql: php-pgsql php-pdo_pgsql # # from Mk/Uses/php.mk create sub vars for mysqli/pdo_mysql pgsql/pdo_pgsql values -SUB_FILES= config.php httpd-tt-rss.conf pkg-message +SUB_FILES= config.php httpd-tt-rss.conf pkg-message start.sh SUB_LIST= MYSQL_DEPS="${mysqli_DEPENDS:T} ${pdo_mysql_DEPENDS:T}" \ PGSQL_DEPS="${pgsql_DEPENDS:T} ${pdo_pgsql_DEPENDS:T}" \ WWWOWN=${WWWOWN} +USERS= ttrssd +GROUPS= ttrssd + PLIST_SUB= WWWGRP=${WWWGRP} \ WWWOWN=${WWWOWN} @@ -63,12 +66,37 @@ "! -name LICENSE ! -name .empty ! -name Jenkinsfile") ${RM} -r ${STAGEDIR}${WWWDIR}/debian ${INSTALL_DATA} ${WRKDIR}/httpd-tt-rss.conf ${STAGEDIR}${DATADIR} - ${ECHO} "${OPSYS}:${PORTVERSION}:${GL_TAGNAME:C/^(.{11}).*$/\1/W}}" > \ + ${ECHO} "${OPSYS}:${PORTVERSION}:${GL_TAGNAME:C/^(.{11}).*$/\1/W}" > \ "${STAGEDIR}${WWWDIR}/version_static.txt" ${RM} ${STAGEDIR}${WWWDIR}/config.php-dist ${INSTALL_DATA} ${WRKDIR}/config.php \ ${STAGEDIR}${WWWDIR}/config.php.sample ${INSTALL_DATA} ${FILESDIR}/newsyslog.sample \ ${STAGEDIR}${EXAMPLESDIR} + ${INSTALL_DATA} ${WRKDIR}/start.sh ${STAGEDIR}${WWWDIR} + ${MKDIR} ${STAGEDIR}/var/log/ttrssd + ${MKDIR} ${STAGEDIR}/var/run/ttrssd + + ${MKDIR} ${STAGEDIR}/var/tt-rss + ${MV} ${STAGEDIR}${WWWDIR}/cache \ + ${STAGEDIR}${WWWDIR}/feed-icons \ + ${STAGEDIR}${WWWDIR}/lock \ + ${STAGEDIR}/var/tt-rss + + ${MKDIR} ${STAGEDIR}/var/tt-rss/local/ + ${MV} ${STAGEDIR}${WWWDIR}/plugins.local \ + ${STAGEDIR}${WWWDIR}/templates.local \ + ${STAGEDIR}${WWWDIR}/themes.local \ + ${STAGEDIR}/var/tt-rss/local + + ${MKDIR} ${STAGEDIR}/var/tt-rss/local/plugins/af_comics + ${MV} ${STAGEDIR}${WWWDIR}/plugins/af_comics/filters.local \ + ${STAGEDIR}/var/tt-rss/local/plugins/af_comics + + ${RLN} ${STAGEDIR}/var/tt-rss/local/plugins.local ${STAGEDIR}${WWWDIR} + ${RLN} ${STAGEDIR}/var/tt-rss/local/templates.local ${STAGEDIR}${WWWDIR} + ${RLN} ${STAGEDIR}/var/tt-rss/local/themes.local ${STAGEDIR}${WWWDIR} + ${RLN} ${STAGEDIR}/var/tt-rss/local/plugins/af_comics/filters.local \ + ${STAGEDIR}${WWWDIR}/plugins/af_comics .include diff --git a/www/tt-rss/files/config.php.in b/www/tt-rss/files/config.php.in --- a/www/tt-rss/files/config.php.in +++ b/www/tt-rss/files/config.php.in @@ -21,6 +21,10 @@ # Required for plugin installer usage of git putenv("PATH=%%LOCALBASE%%/bin/:" . getenv("PATH")); + putenv('TTRSS_CACHE_DIR=/var/tt-rss/cache'); + putenv('TTRSS_ICONS_DIR=/var/tt-rss/feed-icons'); + putenv('TTRSS_LOCK_DIRECTORY=/var/tt-rss/lock'); + #putenv('TTRSS_SINGLE_USER_MODE=true'); #putenv('TTRSS_SELF_URL_PATH='); diff --git a/www/tt-rss/files/newsyslog.sample b/www/tt-rss/files/newsyslog.sample --- a/www/tt-rss/files/newsyslog.sample +++ b/www/tt-rss/files/newsyslog.sample @@ -1 +1 @@ -/var/log/ttrssd.log root:wheel 644 3 * $W0 JC /var/run/ttrssd.pid +/var/log/ttrssd/ttrssd.log ttrssd:ttrssd 660 3 * $W0 JC /var/run/ttrssd/ttrssd.pid diff --git a/www/tt-rss/files/start.sh.in b/www/tt-rss/files/start.sh.in new file mode 100644 --- /dev/null +++ b/www/tt-rss/files/start.sh.in @@ -0,0 +1,12 @@ +#!/bin/sh + +trap 'kill -INT $child' INT +trap 'kill -TERM $child' TERM + +%%WWWDIR%%/update.php --update-schema=force-yes +%%WWWDIR%%/update_daemon2.php & + +child="$!" + +wait "$child" + diff --git a/www/tt-rss/files/ttrssd.in b/www/tt-rss/files/ttrssd.in --- a/www/tt-rss/files/ttrssd.in +++ b/www/tt-rss/files/ttrssd.in @@ -17,27 +17,30 @@ # read settings, set default values load_rc_config "${name}" -: ${ttrssd_enable="NO"} +: ${ttrssd_enable=NO} +: ${ttrssd_user="$name"} +: ${ttrssd_group="$name"} long_name="Tiny Tiny RSS updating feeds daemon." required_files="%%WWWDIR%%/config.php" -pidfile="/var/run/${name}.pid" -cpidfile="/var/run/${name}_child.pid" +pidfile="/var/run/${name}/${name}.pid" +cpidfile="/var/run/${name}/${name}_child.pid" phpcli="%%LOCALBASE%%/bin/php" initdb_php="%%WWWDIR%%/update.php" phpupd="%%WWWDIR%%/update_daemon2.php" -ttrssd_log="/var/log/${name}.log" +ttrssd_log="/var/log/${name}/${name}.log" +ttrssd_cmd="%%WWWDIR%%/start.sh" +ttrssd_umask="0003" command="/usr/sbin/daemon" -command_args="-rR 10 -H -u %%WWWOWN%% \ - -P $pidfile -p $cpidfile \ - -o $ttrssd_log sh -c \ - '$initdb_php --update-schema=force-yes; \ - $phpupd;'" +command_args="-rR 10 -H -P $pidfile -p $cpidfile \ + -o $ttrssd_log $ttrssd_cmd" +start_precmd="${name}_start_precmd" stop_cmd="${name}_stop" + # daemon doesn't process signals if it lacks a child process. # See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277959 ttrssd_stop() { @@ -46,7 +49,7 @@ local signal="TERM" pid_daemon=$(check_pidfile ${pidfile} ${command}) - pid_child=$(check_pidfile ${cpidfile} ${phpcli}) + pid_child=$(check_pidfile ${cpidfile} /bin/sh) if [ -n "$pid_daemon" ]; then echo "Stopping ${name}." @@ -67,4 +70,15 @@ fi } +ttrssd_start_precmd() +{ + # daemon defaults to 0600 when using -o + if [ -f "$ttrssd_log" ]; then + if ! chown "$ttrssd_user" "$ttrssd_log"; then + echo "Setting ${ttrssd_log} owner failed" + exit 1 + fi + fi +} + run_rc_command "$1" diff --git a/www/tt-rss/pkg-plist b/www/tt-rss/pkg-plist --- a/www/tt-rss/pkg-plist +++ b/www/tt-rss/pkg-plist @@ -1,29 +1,47 @@ %%DATADIR%%/httpd-tt-rss.conf +@dir /var/tt-rss @sample %%EXAMPLESDIR%%/newsyslog.sample etc/newsyslog.conf.d/ttrssd.conf -@group %%WWWGRP%% -@mode ug=rx +@dir etc/newsyslog.conf.d +@group ttrssd +@mode 0454 +%%WWWDIR%%/start.sh +@owner %%WWWOWN%% %%WWWDIR%%/update.php %%WWWDIR%%/update_daemon2.php -@group @mode -@owner %%WWWOWN%% -@mode 0400 +@mode 0440 @sample %%WWWDIR%%/config.php.sample -@mode -@dir %%WWWDIR%%/cache -@dir %%WWWDIR%%/cache/export -@dir %%WWWDIR%%/cache/feeds -@dir %%WWWDIR%%/cache/images -@dir %%WWWDIR%%/cache/upload -@dir %%WWWDIR%%/feed-icons -@dir %%WWWDIR%%/lock -@dir %%WWWDIR%%/plugins.local -@dir %%WWWDIR%%/plugins/af_comics/filters.local -@dir %%WWWDIR%%/templates.local -@dir %%WWWDIR%%/themes.local +@mode 0770 +@dir /var/tt-rss/cache +@dir /var/tt-rss/cache/export +@dir /var/tt-rss/cache/feeds +@dir /var/tt-rss/cache/images +@dir /var/tt-rss/cache/upload +@dir /var/tt-rss/feed-icons +@dir /var/tt-rss/lock +@group +@mode 0700 +@dir /var/tt-rss/local/plugins.local +@dir /var/tt-rss/local/plugins/af_comics/filters.local +@dir /var/tt-rss/local/templates.local +@dir /var/tt-rss/local/themes.local @owner +@group ttrssd +@mode 775 +@dir /var/log/ttrssd +@dir /var/run/ttrssd +@dir /var/tt-rss/local +@dir /var/tt-rss/local/plugins +@dir /var/tt-rss/local/plugins/af_comics @group @mode +%%WWWDIR%%/plugins.local +%%WWWDIR%%/plugins/af_comics/filters.local +%%WWWDIR%%/templates.local +%%WWWDIR%%/themes.local +/var/tt-rss/feed-icons/index.html +/var/tt-rss/local/plugins.local/index.html +/var/tt-rss/local/templates.local/index.html %%WWWDIR%%/CONTRIBUTING.md %%WWWDIR%%/COPYING %%WWWDIR%%/README.md @@ -88,7 +106,6 @@ %%WWWDIR%%/composer.json %%WWWDIR%%/composer.lock %%WWWDIR%%/docker-compose.yml -%%WWWDIR%%/feed-icons/index.html %%WWWDIR%%/gulpfile.js %%WWWDIR%%/images/blank_icon.gif %%WWWDIR%%/images/favicon-512px.png @@ -1992,7 +2009,6 @@ %%WWWDIR%%/package.json %%WWWDIR%%/phpstan.neon %%WWWDIR%%/phpunit.xml -%%WWWDIR%%/plugins.local/index.html %%WWWDIR%%/plugins/af_comics/af_comics_template.php %%WWWDIR%%/plugins/af_comics/filter_base.php %%WWWDIR%%/plugins/af_comics/filters/af_comics_cad.php @@ -2337,7 +2353,6 @@ %%WWWDIR%%/sql/pgsql/migrations/145.sql %%WWWDIR%%/sql/pgsql/migrations/146.sql %%WWWDIR%%/sql/pgsql/migrations/147.sql -%%WWWDIR%%/templates.local/index.html %%WWWDIR%%/templates/digest_template.txt %%WWWDIR%%/templates/digest_template_html.txt %%WWWDIR%%/templates/email_article_template.txt