From owner-svn-ports-head@freebsd.org Sun Mar 28 19:34:04 2021 Return-Path: Delivered-To: svn-ports-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 67FFD5AC004; Sun, 28 Mar 2021 19:34:04 +0000 (UTC) (envelope-from adamw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4F7m9S2VWCz3H1v; Sun, 28 Mar 2021 19:34:04 +0000 (UTC) (envelope-from adamw@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4866A25B2F; Sun, 28 Mar 2021 19:34:04 +0000 (UTC) (envelope-from adamw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 12SJY47w047815; Sun, 28 Mar 2021 19:34:04 GMT (envelope-from adamw@FreeBSD.org) Received: (from adamw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 12SJY3rw047810; Sun, 28 Mar 2021 19:34:03 GMT (envelope-from adamw@FreeBSD.org) Message-Id: <202103281934.12SJY3rw047810@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adamw set sender to adamw@FreeBSD.org using -f From: Adam Weinberger Date: Sun, 28 Mar 2021 19:34:03 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r569408 - in head: . www/caddy www/caddy/files X-SVN-Group: ports-head X-SVN-Commit-Author: adamw X-SVN-Commit-Paths: in head: . www/caddy www/caddy/files X-SVN-Commit-Revision: 569408 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-head@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: SVN commit messages for the ports tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Mar 2021 19:34:04 -0000 Author: adamw Date: Sun Mar 28 19:34:02 2021 New Revision: 569408 URL: https://svnweb.freebsd.org/changeset/ports/569408 Log: www/caddy: Change all caddy runtime locations Thanks to work by scf, the caddy rc(8) script has been completely rewritten and substantially improved, though this necessitated changing all runtime locations. Most importantly: - The runtime log now lives in /var/log/caddy/ instead of /var/log, so that the logdir can be null-mounted - Automatic SSL certs are now stored in /var/db/caddy/data/caddy, instead of /root/.local/share/caddy Caddy uses freedesktop.org's XDG base dir specification, which conflicts quite spectacularly with FreeBSD's hier(7). The most sensible thing to do was to put the runtime data stores into /var/db/caddy, though XDG needs XDG_DATA_HOME and XDG_CONFIG_HOME to be separate dirs and caddy will create a .../caddy subdir in each of them. Added: head/www/caddy/files/pkg-message.in (contents, props changed) Modified: head/UPDATING head/www/caddy/Makefile head/www/caddy/files/Caddyfile.sample.in head/www/caddy/files/caddy.in Modified: head/UPDATING ============================================================================== --- head/UPDATING Sun Mar 28 19:31:00 2021 (r569407) +++ head/UPDATING Sun Mar 28 19:34:02 2021 (r569408) @@ -5,6 +5,24 @@ they are unavoidable. You should get into the habit of checking this file for changes each time you update your ports collection, before attempting any port upgrades. +20210328: + AFFECTS: users of www/caddy + AUTHOR: adamw@FreeBSD.org + + The default locations for caddy runtime files have changed. + + - Caddy's runtime log is now /var/log/caddy/caddy.log + (was /var/log/caddy.log) + + - Automatic SSL certs are now stored in /var/db/caddy/data/caddy + (was /root/.local/share/caddy) + + - Configuration autosaves are now stored in /var/db/caddy/config/caddy + (was /root/.config/caddy) + + You can change these defaults. See /usr/local/etc/rc.d/caddy for the + list of settings. + 20210322: AFFECTS: users of net/wireguard AUTHOR: decke@FreeBSD.org Modified: head/www/caddy/Makefile ============================================================================== --- head/www/caddy/Makefile Sun Mar 28 19:31:00 2021 (r569407) +++ head/www/caddy/Makefile Sun Mar 28 19:34:02 2021 (r569408) @@ -4,6 +4,7 @@ PORTNAME= caddy DISTVERSIONPREFIX= v DISTVERSION= 2.3.0 +PORTREVISION= 1 CATEGORIES= www DIST_SUBDIR= caddy @@ -19,7 +20,7 @@ USES= go:modules USE_RC_SUBR= caddy GO_TARGET= ./cmd/caddy -SUB_FILES= caddy Caddyfile.sample +SUB_FILES= Caddyfile.sample caddy pkg-message PLIST_FILES= bin/${PORTNAME} \ "@sample ${ETCDIR_REL}/Caddyfile.sample" Modified: head/www/caddy/files/Caddyfile.sample.in ============================================================================== --- head/www/caddy/files/Caddyfile.sample.in Sun Mar 28 19:31:00 2021 (r569407) +++ head/www/caddy/files/Caddyfile.sample.in Sun Mar 28 19:34:02 2021 (r569408) @@ -1,25 +1,35 @@ # The Caddyfile is an easy way to configure your Caddy web server. # -# Unless the file starts with a global options block, the first -# uncommented line is always the address of your site. -# # To use your own domain name (with automatic HTTPS), first make # sure your domain's A/AAAA DNS records are properly pointed to # this machine's public IP, then replace the line below with your # domain name. -localhost -# Set this path to your site's directory. -root * %%WWWDIR%% +# Unless the file starts with a global options block, the first +# uncommented line is always the address of your site. +# +localhost { + # Set this path to your site's directory: + root * %%WWWDIR%% -# Enable the static file server. -file_server + # Enable the static file server: + file_server -# Another common task is to set up a reverse proxy: -# reverse_proxy localhost:8080 + # Set up a reverse proxy: + # reverse_proxy localhost:8080 -# Or serve a PHP site through php-fpm: -# php_fastcgi localhost:9000 + # Serve a PHP site through php-fpm: + # php_fastcgi localhost:9000 + + # Enable logging: + log { + output file /var/log/caddy/access.log + # Caddy's structured log format: + format json + # Or, for Common Log Format: + # format single_field common_log + } +} # Caddy will automatically obtain ACME certs for domains # example.com { Modified: head/www/caddy/files/caddy.in ============================================================================== --- head/www/caddy/files/caddy.in Sun Mar 28 19:31:00 2021 (r569407) +++ head/www/caddy/files/caddy.in Sun Mar 28 19:34:02 2021 (r569408) @@ -7,15 +7,28 @@ # REQUIRE: LOGIN DAEMON NETWORKING # KEYWORD: shutdown -# Add the following lines to /etc/rc.conf.local or /etc/rc.conf -# to enable this service: -# caddy_enable (bool): Set to NO by default. Set it to YES to enable caddy. +# To enable caddy, add 'caddy_enable="YES"' to /etc/rc.conf or +# /etc/rc.conf.local + +# Optional settings: +# caddy_config (string): Full path to caddy config file +# (%%ETCDIR%%/Caddyfile) +# caddy_adapter (string): Config adapter type (caddyfile) +# caddy_directory (string): Root for caddy storage (ACME certs, etc.) +# (/var/db/caddy) +# caddy_extra_flags (string): Extra flags passed to caddy start +# caddy_logdir (string): Where caddy logs are stored +# (/var/log/caddy) +# caddy_logfile (string): Location of process log (${caddy_logdir}/caddy.log) +# This is for startup/shutdown/error messages. +# To create an access log, see: +# https://caddyserver.com/docs/caddyfile/directives/log +# caddy_user (user): User to run caddy (root) +# caddy_group (group): Group to run caddy (wheel) # -# caddy_config (string): (Optional) Full path to caddy config file -# caddy_adapter (string): (Optional) Adapter type if the configuration is not in caddyfile format -# caddy_extra_flags (string): (Optional) Flags passed to caddy start -# caddy_logfile (string): Location of process log. This is for startup/shutdown/error messages. -# To create an access log, see https://caddyserver.com/docs/caddyfile/directives/log +# This script will honor XDG_CONFIG_HOME/XDG_DATA_HOME. Caddy will create a +# .../caddy subdir in each of those. By default, they are subdirs of /var/db/caddy. +# See https://caddyserver.com/docs/conventions#data-directory . /etc/rc.subr @@ -27,23 +40,73 @@ load_rc_config $name # Defaults : ${caddy_enable:=NO} -: ${caddy_config:=%%ETCDIR%%/Caddyfile} : ${caddy_adapter:=caddyfile} +: ${caddy_config:=%%ETCDIR%%/Caddyfile} +: ${caddy_directory:=/var/db/caddy} : ${caddy_extra_flags:=""} -: ${caddy_logfile="/var/log/caddy.log"} +: ${caddy_logdir:="/var/log/${name}"} +: ${caddy_logfile:="${caddy_logdir}/${name}.log"} +: ${caddy_user:="root"} +: ${caddy_group:="wheel"} +# Config and base directories +: ${XDG_CONFIG_HOME:="${caddy_directory}/config"} +: ${XDG_DATA_HOME:="${caddy_directory}/data"} +export XDG_CONFIG_HOME XDG_DATA_HOME + command="%%PREFIX%%/bin/${name}" caddy_flags="--config ${caddy_config} --adapter ${caddy_adapter}" -pidfile="/var/run/${name}.pid" +pidfile="/var/run/${name}/${name}.pid" required_files="${caddy_config} ${command}" +start_precmd="caddy_precmd" +start_cmd="caddy_start" +stop_cmd="caddy_stop" + # Extra Commands extra_commands="configtest reload" +configtest_cmd="caddy_command validate ${caddy_flags}" +reload_cmd="caddy_command reload ${caddy_flags}" -configtest_cmd="${command} validate ${caddy_flags}" -reload_cmd="${command} reload ${caddy_flags}" -start_cmd="${command} start ${caddy_flags} ${caddy_extra_flags} --pidfile ${pidfile} >> ${caddy_logfile} 2>&1" -stop_cmd="${command} stop" +caddy_command() +{ + /usr/bin/su -m "${caddy_user}" -c "${command} $*" +} + +caddy_precmd() +{ + # Create required directories and set permissions + /usr/bin/install -d -m 755 -o "${caddy_user}" -g "${caddy_group}" ${caddy_directory} + /usr/bin/install -d -m 700 -o "${caddy_user}" -g "${caddy_group}" ${caddy_directory}/config + /usr/bin/install -d -m 700 -o "${caddy_user}" -g "${caddy_group}" ${caddy_directory}/data + /usr/bin/install -d -m 755 -o "${caddy_user}" -g "${caddy_group}" ${caddy_logdir} + /usr/bin/install -d -m 700 -o "${caddy_user}" -g "${caddy_group}" /var/run/caddy +} + +caddy_start() +{ + echo -n "Starting caddy... " + /usr/bin/su -m ${caddy_user} -c "${command} start ${caddy_flags} \ + ${caddy_extra_flags} --pidfile ${pidfile}" >> ${caddy_logfile} 2>&1 + if [ $? -eq 0 ] && ps -ax -o pid | grep -q "$(cat ${pidfile})"; then + echo "done" + echo "Log: ${caddy_logfile}" + else + echo "Error: Caddy failed to start" + echo "Check the caddy log: ${caddy_logfile}" + fi +} + +caddy_stop() +{ + echo -n "Stopping caddy... " + if caddy_command stop; then + echo "done" + else + echo "Error: Unable to stop caddy" + echo "Check the caddy log: ${caddy_logfile}" + fi +} run_rc_command "$1" Added: head/www/caddy/files/pkg-message.in ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/www/caddy/files/pkg-message.in Sun Mar 28 19:34:02 2021 (r569408) @@ -0,0 +1,41 @@ +[ +{ + type: install + message: <