Skip to content

Commit

Permalink
Add ZEALOT_FORCE_SSL, ZEALOT_FORCE_VOLUME, and ZEALOT_NO_SSL_PORT
Browse files Browse the repository at this point in the history
These are env vars read in from an optional env.sh file
  • Loading branch information
paullinator committed Aug 8, 2024
1 parent 46bfcde commit 278f87c
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 1 deletion.
7 changes: 7 additions & 0 deletions config.env
Original file line number Diff line number Diff line change
Expand Up @@ -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

######################################
# 账户
######################################
Expand Down
3 changes: 3 additions & 0 deletions deploy
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 11 additions & 0 deletions env.sample.sh
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions scripts/configure-cert.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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\
Expand Down
19 changes: 19 additions & 0 deletions scripts/configure-volumes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 3 additions & 1 deletion scripts/generate-compose-file.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down

0 comments on commit 278f87c

Please sign in to comment.