From 3b212f2bf3fca05c2f08f483ec2f5ad232858de9 Mon Sep 17 00:00:00 2001 From: Nicolas Duchon Date: Thu, 8 Feb 2018 23:57:50 +0100 Subject: [PATCH] Minor edits for coding style consistency --- app/entrypoint.sh | 11 ++++------- app/functions.sh | 8 ++++---- app/letsencrypt_service | 12 ++++++------ 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/app/entrypoint.sh b/app/entrypoint.sh index d02a784..8c048da 100755 --- a/app/entrypoint.sh +++ b/app/entrypoint.sh @@ -4,8 +4,8 @@ set -u if [[ -n "${ACME_TOS_HASH:-}" ]]; then - echo -n "The ACME_TOS_HASH environment variable is no longer used by simp_le " - echo "and has been deprecated. simp_le now implicitly agree to the ACME CA ToS." + echo "Info: the ACME_TOS_HASH environment variable is no longer used by simp_le and has been deprecated." + echo "simp_le now implicitly agree to the ACME CA ToS." fi DOCKER_PROVIDER=${DOCKER_PROVIDER:-docker} @@ -34,11 +34,8 @@ function check_docker_socket { if [[ $DOCKER_HOST == unix://* ]]; then socket_file=${DOCKER_HOST#unix://} if [[ ! -S $socket_file ]]; then - cat >&2 <<-EOT -ERROR: you need to share your Docker host socket with a volume at $socket_file -Typically you should run your container with: \`-v /var/run/docker.sock:$socket_file:ro\` -See the documentation at http://git.io/vZaGJ -EOT + echo "Error: you need to share your Docker host socket with a volume at $socket_file" >&2 + echo "Typically you should run your container with: '-v /var/run/docker.sock:$socket_file:ro'" >&2 exit 1 fi fi diff --git a/app/functions.sh b/app/functions.sh index 5b56f83..6c34c20 100644 --- a/app/functions.sh +++ b/app/functions.sh @@ -27,7 +27,7 @@ function check_two_containers_case() { return 0 } -add_location_configuration() { +function add_location_configuration { local domain="${1:-}" [[ -z "$domain" || ! -f "${VHOST_DIR}/${domain}" ]] && domain=default [[ -f "${VHOST_DIR}/${domain}" && \ @@ -40,7 +40,7 @@ add_location_configuration() { return 1 } -remove_all_location_configurations() { +function remove_all_location_configurations { local old_shopt_options=$(shopt -p) # Backup shopt options shopt -s nullglob for file in "${VHOST_DIR}"/*; do @@ -105,7 +105,7 @@ function get_nginx_proxy_container { } ## Nginx -reload_nginx() { +function reload_nginx { local _docker_gen_container=$(get_docker_gen_container) local _nginx_proxy_container=$(get_nginx_proxy_container) @@ -130,6 +130,6 @@ reload_nginx() { } # Convert argument to lowercase (bash 4 only) -function lc() { +function lc { echo "${@,,}" } diff --git a/app/letsencrypt_service b/app/letsencrypt_service index fdb500f..0dc5370 100755 --- a/app/letsencrypt_service +++ b/app/letsencrypt_service @@ -11,14 +11,14 @@ DEFAULT_KEY_SIZE=4096 REUSE_ACCOUNT_KEYS="$(lc ${REUSE_ACCOUNT_KEYS:-true})" REUSE_PRIVATE_KEYS="$(lc ${REUSE_PRIVATE_KEYS:-false})" -create_link() { +function create_link { local -r target=${1?missing target argument} local -r source=${2?missing source argument} [[ -f "$target" ]] && return 1 ln -sf "$source" "$target" } -create_links() { +function create_links { local -r base_domain=${1?missing base_domain argument} local -r domain=${2?missing base_domain argument} @@ -99,11 +99,11 @@ function cleanup_links { fi } -update_certs() { +function update_certs { check_two_containers_case && (check_nginx_proxy_container_run || return) - [[ ! -f "$DIR"/letsencrypt_service_data ]] && return + [[ -f "$DIR"/letsencrypt_service_data ]] || return # Load relevant container settings unset LETSENCRYPT_CONTAINERS @@ -178,7 +178,7 @@ update_certs() { # Create directory for the first domain mkdir -p /etc/nginx/certs/$base_domain - pushd /etc/nginx/certs/$base_domain + pushd /etc/nginx/certs/$base_domain || return for domain in "${!hosts_array}"; do # Add all the domains to certificate @@ -223,7 +223,7 @@ update_certs() { fi fi - popd + popd || return for altnames in "${hosts_array_expanded[@]:1}"; do # Remove old CN domain that now are altnames