From a0d920bfcbe6d46dfe18fe502ca8e809af5c21b9 Mon Sep 17 00:00:00 2001 From: basilhendroff <63370329+basilhendroff@users.noreply.github.com> Date: Tue, 28 Jul 2020 16:46:15 +0800 Subject: [PATCH] Update caddy-jail.sh --- caddy-jail.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/caddy-jail.sh b/caddy-jail.sh index 7c46957..c83c3ab 100644 --- a/caddy-jail.sh +++ b/caddy-jail.sh @@ -20,13 +20,18 @@ JAIL_INTERFACES="" DEFAULT_GW_IP="" INTERFACE="vnet0" VNET="on" +POOL_PATH="" JAIL_NAME="caddy" +STANDALONE_CERT=0 +SELFSIGNED_CERT=0 +DNS_CERT=0 +NO_CERT=0 + JAILS_MOUNT=$(zfs get -H -o value mountpoint $(iocage get -p)/iocage) SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "${SCRIPT}") -. "${SCRIPTPATH}"/caddy-config INCLUDES_PATH="${SCRIPTPATH}"/includes RELEASE=$(freebsd-version | sed "s/STABLE/RELEASE/g" | sed "s/-p[0-9]*//") @@ -37,6 +42,59 @@ if ! [ -e "${SCRIPTPATH}"/nextcloud-config ]; then exit 1 fi +# Check that necessary variables were set by nextcloud-config +if [ -z "${JAIL_IP}" ]; then + echo 'Configuration error: JAIL_IP must be set' + exit 1 +fi +if [ -z "${JAIL_INTERFACES}" ]; then + echo 'JAIL_INTERFACES not set, defaulting to: vnet0:bridge0' + JAIL_INTERFACES="vnet0:bridge0" +fi +if [ -z "${DEFAULT_GW_IP}" ]; then + echo 'Configuration error: DEFAULT_GW_IP must be set' + exit 1 +fi +if [ -z "${POOL_PATH}" ]; then + echo 'Configuration error: POOL_PATH must be set' + exit 1 +fi +if [ -z "${TIME_ZONE}" ]; then + echo 'Configuration error: TIME_ZONE must be set' + exit 1 +fi +if [ -z "${HOST_NAME}" ]; then + echo 'Configuration error: HOST_NAME must be set' + exit 1 +fi +if [ $STANDALONE_CERT -eq 0 ] && [ $DNS_CERT -eq 0 ] && [ $NO_CERT -eq 0 ] && [ $SELFSIGNED_CERT -eq 0 ]; then + echo 'Configuration error: Either STANDALONE_CERT, DNS_CERT, NO_CERT,' + echo 'or SELFSIGNED_CERT must be set to 1.' + exit 1 +fi +if [ $STANDALONE_CERT -eq 1 ] && [ $DNS_CERT -eq 1 ] ; then + echo 'Configuration error: Only one of STANDALONE_CERT and DNS_CERT' + echo 'may be set to 1.' + exit 1 +fi + +if [ $DNS_CERT -eq 1 ] && [ -z "${DNS_PLUGIN}" ] ; then + echo "DNS_PLUGIN must be set to a supported DNS provider." + echo "See https://caddyserver.com/docs under the heading of \"DNS Providers\" for list." + echo "Be sure to omit the prefix of \"tls.dns.\"." + exit 1 +fi +#if [ $DNS_CERT -eq 1 ] && [ -z "${DNS_ENV}" ] ; then +# echo "DNS_ENV must be set to a your DNS provider\'s authentication credentials." +# echo "See https://caddyserver.com/docs under the heading of \"DNS Providers\" for more." +# exit 1 +#fi + +#if [ $DNS_CERT -eq 1 ] ; then +# DL_FLAGS="tls.dns.${DNS_PLUGIN}" +# DNS_SETTING="dns ${DNS_PLUGIN}" +#fi + ##### # # Jail Creation