From 3aa7a82534ec67d837a2e305480b45007f3d9b15 Mon Sep 17 00:00:00 2001 From: Bernard Spil Date: Mon, 31 May 2021 11:24:30 +0000 Subject: [PATCH] net/endlessh: Add log rotation PR: 256286 --- net/endlessh/Makefile | 9 +++++++-- net/endlessh/files/endlessh.in | 3 ++- net/endlessh/files/endlessh.newsyslog.conf | 11 +++++++++++ .../{pkg-message => files/pkg-message.in} | 17 ++++++++++++++--- 4 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 net/endlessh/files/endlessh.newsyslog.conf rename net/endlessh/{pkg-message => files/pkg-message.in} (52%) diff --git a/net/endlessh/Makefile b/net/endlessh/Makefile index 8a0319f8f77c..66636d3ea333 100644 --- a/net/endlessh/Makefile +++ b/net/endlessh/Makefile @@ -15,7 +15,10 @@ GH_ACCOUNT= skeeto PLIST_FILES= bin/endlessh \ man/man1/endlessh.1.gz \ - "@sample ${PREFIX}/etc/endlessh.conf.sample" + "@sample ${PREFIX}/etc/endlessh.conf.sample" \ + ${PREFIX}/etc/endlessh.newsyslog.conf + +SUB_FILES= pkg-message post-patch: ${REINPLACE_CMD} 's|share/man|man|;s|/usr/local|${PREFIX}|' ${WRKSRC}/Makefile @@ -23,6 +26,8 @@ post-patch: ${WRKSRC}/endlessh.c ${WRKSRC}/endlessh.1 post-install: - ${INSTALL_DATA} ${FILESDIR}/endlessh.conf.sample ${STAGEDIR}${PREFIX}/etc/ + ${INSTALL_DATA} ${FILESDIR}/endlessh.newsyslog.conf \ + ${FILESDIR}/endlessh.conf.sample ${STAGEDIR}${PREFIX}/etc/ + ${STRIP} ${STAGEDIR}${PREFIX}/bin/endlessh .include diff --git a/net/endlessh/files/endlessh.in b/net/endlessh/files/endlessh.in index f54ab6b46f4e..abc5ec9d59cf 100644 --- a/net/endlessh/files/endlessh.in +++ b/net/endlessh/files/endlessh.in @@ -26,8 +26,9 @@ load_rc_config $name : ${endlessh_logfile:=/var/log/endlessh.log} pidfile=/var/run/endlessh.pid +daemonpidfile=/var/run/daemon_endlessh.pid procname="%%PREFIX%%/bin/endlessh" command=/usr/sbin/daemon -command_args='-p ${pidfile} -u ${endlessh_daemonuser} -o ${endlessh_logfile} ${procname} -f ${endlessh_config} ${endlessh_args}' +command_args='-p ${pidfile} -P ${daemonpidfile} -u ${endlessh_daemonuser} -Ho ${endlessh_logfile} ${procname} -f ${endlessh_config} ${endlessh_args}' run_rc_command $1 diff --git a/net/endlessh/files/endlessh.newsyslog.conf b/net/endlessh/files/endlessh.newsyslog.conf new file mode 100644 index 000000000000..e50538e4dcf4 --- /dev/null +++ b/net/endlessh/files/endlessh.newsyslog.conf @@ -0,0 +1,11 @@ +# newsyslog configuration file for endlessh(1) +# +# Link (or copy) endlessh.newsyslog.conf to /usr/local/etc/newsyslog.conf.d/ +# to take care of log rotation. +# +# ln -s /usr/local/etc/endlessh.newsyslog.conf /usr/local/etc/newsyslog.conf.d +# +# See newsyslog.conf(5) for details. +# +# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num] +/var/log/endlessh.log root:wheel 600 7 * @T00 G /var/run/daemon_endlessh.pid SIGHUP diff --git a/net/endlessh/pkg-message b/net/endlessh/files/pkg-message.in similarity index 52% rename from net/endlessh/pkg-message rename to net/endlessh/files/pkg-message.in index c34ff0613686..3dea43343029 100644 --- a/net/endlessh/pkg-message +++ b/net/endlessh/files/pkg-message.in @@ -11,11 +11,22 @@ To see the connections set LogLevel 1 in endlessh.conf or add "-v" to endlessh_args. Sending SIGUSR1 to endlessh (pkill USR1 endlessh) will add statistics to the /var/log/endlessh.log file -Neither endlessh nor daemon support rotating the logfile, use periodic or -cron to copy the logfile and truncate it using +Link (or copy) endlessh.newsyslog.conf to ${PREFIX}/newsyslog.conf.d/ +to take care of log rotation. - $ echo -n > /var/log/endlessh.log +ln -s ${PREFIX}/etc/endlessh.newsyslog.conf $PREFIX}/etc/newsyslog.conf.d/ EOD } +, +{ + type: upgrade + message: <