diff --git a/config.env b/config.env index 5cf43cb..2040da9 100644 --- a/config.env +++ b/config.env @@ -18,6 +18,13 @@ # ZEALOT_CERT= # ZEALOT_CERT_KEY= +# Force SSL setting and do not ask when running ./deploy +# Can be one of "letsencrypt", "self-signed", or "false" +# ZEALOT_FORCE_SSL=false + +# Port to use if SSL is disabled +# ZEALOT_NO_SSL_PORT=80 + ###################################### # 账户 ###################################### diff --git a/deploy b/deploy index fca4d32..d0bce07 100755 --- a/deploy +++ b/deploy @@ -10,6 +10,9 @@ set -eE +if [ -e "./env.sh" ]; then + source "./env.sh" +fi source "$(dirname $0)/scripts/function.sh" source "scripts/load-cli-parser.sh" diff --git a/env.sample.sh b/env.sample.sh new file mode 100644 index 0000000..61a768b --- /dev/null +++ b/env.sample.sh @@ -0,0 +1,11 @@ +# Sample env.sh. Rename to env.sh to use +# These setting bypass user input and hard set the values into .env upon running ./deploy + +# Set SSL to "false", "letsencrypt", or "self-signed" +# export ZEALOT_FORCE_SSL=false + +# Set the external port for zealot to run on if not using SSL +# export ZEALOT_NO_SSL_PORT=8008 + +# Set the location of the zealot data to either "docker" or "local" +# export ZEALOT_FORCE_VOLUME=docker \ No newline at end of file diff --git a/scripts/configure-cert.sh b/scripts/configure-cert.sh index c1b9115..16a9bc0 100755 --- a/scripts/configure-cert.sh +++ b/scripts/configure-cert.sh @@ -92,6 +92,28 @@ check_or_generate_selfsigned_ssl () { ## Start deploy flow ## choose_deploy () { + set +u + echo "ZEALOT_FORCE_SSL=${ZEALOT_FORCE_SSL}" + if [ -n $ZEALOT_FORCE_SSL ]; then + case "$ZEALOT_FORCE_SSL" in + "letsencrypt" ) + check_or_configure_letsencrypt_ssl;; + "self-signed" ) + check_or_generate_selfsigned_ssl;; + "false" ) + SSL_NAME=false + ;; + * ) + echo "Invalid ZEALOT_FORCE_SSL value, Quitting" + exit + ;; + esac + echo "${_endgroup}" + set -u + return + fi + set -u + printf "How do you deploy?\n\ Use [L]et's Encryt SSL (default)\n\ Use [S]elf-signed SSL\n\ diff --git a/scripts/configure-volumes.sh b/scripts/configure-volumes.sh index 611a7ef..50feee2 100755 --- a/scripts/configure-volumes.sh +++ b/scripts/configure-volumes.sh @@ -52,6 +52,25 @@ configure_local_docker_volumes() { } choose_volumes () { + set +u + echo "ZEALOT_FORCE_VOLUME=${ZEALOT_FORCE_VOLUME}" + + if [ -n "$ZEALOT_FORCE_VOLUME" ]; then + case "$ZEALOT_FORCE_VOLUME" in + "docker" ) + create_docker_volumes;; + "local" ) + configure_local_docker_volumes;; + * ) + echo "Invalid ZEALOT_FORCE_VOLUME value, Quitting" + exit + ;; + esac + set -u + return + fi + set -u + printf "Which way do you choose to storage zealot data?\n\ Use Docker [V]olumes (default)\n\ Use [L]ocal file system\n" diff --git a/scripts/generate-compose-file.sh b/scripts/generate-compose-file.sh index f2ad8c1..bc8f8b4 100755 --- a/scripts/generate-compose-file.sh +++ b/scripts/generate-compose-file.sh @@ -1,5 +1,7 @@ echo "${_group}Generating docker-compose.file ..." +ZEALOT_NO_SSL_PORT=${ZEALOT_NO_SSL_PORT:-"80"} + if [ -f "$DOCKER_COMPOSE_FILE" ]; then echo "File already exists, skipped" else @@ -14,7 +16,7 @@ else if [ "$ZEALOT_USE_SSL" == "false" ]; then echo " ports:" >> $DOCKER_COMPOSE_FILE - echo ' - "80:80"' >> $DOCKER_COMPOSE_FILE + echo ' - "'"${ZEALOT_NO_SSL_PORT}"':80"' >> $DOCKER_COMPOSE_FILE else cat $TEMPLATE_DOCKER_COMPOSE_PATH/cert.yml >> $DOCKER_COMPOSE_FILE fi