set -eE -o pipefail
trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
+shopt -s nullglob # used in apache config file expansion
+
usage() {
cat <<EOF
Usage: ${0##*/} [OPTIONS] [EXTRA_SETTINGS_FILE] DOMAIN
$HOME/webservercerts, if the other options aren't set.
-f [ADDR:]PORT Enable proxy to [ADDR:]PORT. ADDR default is 127.0.0.1
-i Insecure, no ssl
--p PORT Main port to listen on, default 443
--r DocumentRoot
+-p PORT Main port to listen on, default 443. 80 implies -i.
+-r DIR DocumentRoot
-h|--help Print help and exit
Note: Uses GNU getopt options parsing style
listen_port=false
cd /etc/apache2
conf_files=(apache2.conf)
+
+
+if [[ $port == 80 ]]; then
+ ssl=false
+ # remove any thats hanging around
+ rm -f $redir_file
+fi
+
for (( i=0; i < ${#conf_files[@]}; i++ )); do
f="${conf_files[i]}"
- # note: globs are expanded here:
+ # note: globs are expanded here.
conf_files+=( $(sed -rn "s,^\s*Include(Optional)?\s+(\S+).*,\2,p" "$f") )
case $(readlink -f "$f") in
$vhost_file|$redir_file) continue ;;
EOF
fi
+
+
if $ssl; then
certbot_ssl_conf=/etc/letsencrypt/options-ssl-apache.conf
cat >>$vhost_file <<EOF
EOF
sleep 1
fi
-fi
+fi # end if $ssl
+
cat >>$vhost_file <<EOF
ErrorLog \${APACHE_LOG_DIR}/error.log
CustomLog \${APACHE_LOG_DIR}/access.log vhost_time_combined
$HOME/webservercerts, if the other options aren't set.
-f [ADDR:]PORT Enable proxy to [ADDR:]PORT. ADDR default is 127.0.0.1
-p PORT Port to listen on, default 443
--r DocumentRoot
+-r DIR DocumentRoot
-h|--help Print help and exit
TODO: add https redir site.