From 5188b15c3c53e0675d1c275c46b31fd265015c55 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 29 Mar 2017 10:50:38 +0200 Subject: [LighttpdHttps] Support setting HTTPS redirection This implements #3058 --- scripts/install-https | 58 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 12 deletions(-) (limited to 'scripts/install-https') diff --git a/scripts/install-https b/scripts/install-https index ad77a97..121fb0e 100755 --- a/scripts/install-https +++ b/scripts/install-https @@ -1,7 +1,8 @@ #!/bin/bash -CERTFILE="/etc/lighttpd/server.pem" -CHAINFILE="/etc/lighttpd/chain.pem" +declare -rg CERTFILE="/etc/lighttpd/server.pem" +declare -rg CHAINFILE="/etc/lighttpd/chain.pem" +declare -rg REDIR_FLAG="/etc/lighttpd/redirect.flag" op_disable () { @@ -76,20 +77,53 @@ generate_dh () fi } -OP=$1 -shift +setup_redirect () +{ + if [ -n "$REDIR" ]; then + touch "$REDIR_FLAG" + else + rm -f -- "$REDIR_FLAG" + fi +} -case "$OP" in - --random) op_random "$@" ;; - --test) op_test "$@" ;; - --import) op_import "$@" ;; - --disable) op_disable ;; +RE_ONLY= +REDIR= +while true; do + case "$1" in + --redirect-only) + RE_ONLY=tru + ;; + --redirect) + REDIR=truh + ;; *) - echo "Invalid operation: $1" - exit 1 + break ;; -esac + esac + shift +done + +setup_redirect + +if [ -z "$RE_ONLY" ]; then + + OP=$1 + shift + + case "$OP" in + --random) op_random "$@" ;; + --test) op_test "$@" ;; + --import) op_import "$@" ;; + --disable) op_disable ;; + *) + echo "Invalid operation: $1" + exit 1 + ;; + esac + +fi +sleep .5 systemctl restart lighttpd exit 0 -- cgit v1.2.3-55-g7522