Import from upstream 2.29

This commit is contained in:
2023-04-27 12:44:23 -07:00
commit eb3efcc450
51 changed files with 18219 additions and 0 deletions

19
scripts/500.thttpd-rotate Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
#
# thttpd-rotate - nightly script to rotate thttpd's log files on FreeBSD
#
# This goes in /etc/periodic/daily. It rotates the log files and then
# tells thttpd to re-open its log file.
cd /usr/local/www/chroot/logs
rm -f thttpd_log.7.gz
mv thttpd_log.6.gz thttpd_log.7.gz
mv thttpd_log.5.gz thttpd_log.6.gz
mv thttpd_log.4.gz thttpd_log.5.gz
mv thttpd_log.3.gz thttpd_log.4.gz
mv thttpd_log.2.gz thttpd_log.3.gz
mv thttpd_log.1.gz thttpd_log.2.gz
mv thttpd_log thttpd_log.1
kill -HUP `cat /var/run/thttpd.pid`
sleep 1
gzip -f thttpd_log.1

47
scripts/thttpd.sh Executable file
View File

@ -0,0 +1,47 @@
#!/bin/sh
#
# thttpd.sh - startup script for thttpd on FreeBSD
#
# This should be manually installed as:
# /usr/local/etc/rc.d/thttpd
# It gets run at boot-time.
#
# Variables available:
# thttpd_enable='YES'
# thttpd_program='/usr/local/sbin/thttpd'
# thttpd_pidfile='/var/run/thttpd.pid'
# thttpd_devfs=...
# thttpd_flags=...
#
# PROVIDE: thttpd
# REQUIRE: LOGIN FILESYSTEMS
# KEYWORD: shutdown
. /etc/rc.subr
name='thttpd'
rcvar='thttpd_enable'
start_precmd='thttpd_precmd'
stop_cmd='thttpd_stop'
thttpd_enable_defval='NO'
load_rc_config "$name"
command="${thttpd_program:-/usr/local/sbin/${name}}"
pidfile="${thttpd_pidfile:-/var/run/${name}.pid}"
command_args="-i ${pidfile}"
thttpd_precmd ()
{
if [ -n "$thttpd_devfs" ] ; then
mount -t devfs devfs "$thttpd_devfs"
devfs -m "$thttpd_devfs" rule -s 1 applyset
devfs -m "$thttpd_devfs" rule -s 2 applyset
fi
}
thttpd_stop ()
{
kill -USR1 `cat "$pidfile"`
}
run_rc_command "$1"

23
scripts/thttpd_wrapper Executable file
View File

@ -0,0 +1,23 @@
#!/bin/sh
#
# thttpd_wrapper - wrapper script for thttpd on FreeBSD
#
# This goes in /usr/local/sbin. It backgrounds itself, and then runs
# thttpd in a loop. If thttpd exits then the script restarts it automatically.
#
# The -D flag tells thttpd to *not* put itself into the background,
# and the -C flag tells it to get the rest of its configuration from
# the specified config file.
(
while true ; do
/usr/local/sbin/thttpd -D -C /usr/local/www/thttpd_config
if [ -f /var/run/nologin ] ; then
exit
fi
sleep 10
egrep ' thttpd[:\[]' /var/log/messages |
tail -33 |
mail -s "thttpd on `hostname` restarted" root
done
) &