Skip to content

Commit

Permalink
net/endlessh: Add log rotation
Browse files Browse the repository at this point in the history
PR:	256286
  • Loading branch information
Sp1l committed May 31, 2021
1 parent 164f996 commit 3aa7a82
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
9 changes: 7 additions & 2 deletions net/endlessh/Makefile
Expand Up @@ -15,14 +15,19 @@ 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
${REINPLACE_CMD} 's|/etc/endlessh/config|${PREFIX}/etc/endlessh.conf|' \
${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 <bsd.port.mk>
3 changes: 2 additions & 1 deletion net/endlessh/files/endlessh.in
Expand Up @@ -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
11 changes: 11 additions & 0 deletions 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
17 changes: 14 additions & 3 deletions net/endlessh/pkg-message → net/endlessh/files/pkg-message.in
Expand Up @@ -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: <<EOD

Link (or copy) endlessh.newsyslog.conf to %%PREFIX%%/newsyslog.conf.d/
to take care of log rotation.

ln -s %%PREFIX%%/etc/endlessh.newsyslog.conf %%PREFIX%%/etc/newsyslog.conf.d/

EOD
]

0 comments on commit 3aa7a82

Please sign in to comment.