From c12e6c7c7a400a60a9a4ee1ca06f8dca3f7698b2 Mon Sep 17 00:00:00 2001 From: fortuna Date: Thu, 28 Mar 2019 18:32:08 -0400 Subject: [PATCH 01/11] Add flags for hostname and ports --- .../install_scripts/install_server.sh | 102 +++++++++++++++--- 1 file changed, 87 insertions(+), 15 deletions(-) diff --git a/src/server_manager/install_scripts/install_server.sh b/src/server_manager/install_scripts/install_server.sh index feaf8f78..618e8175 100755 --- a/src/server_manager/install_scripts/install_server.sh +++ b/src/server_manager/install_scripts/install_server.sh @@ -19,7 +19,7 @@ # SB_IMAGE: Shadowbox Docker image to install, e.g. quay.io/outline/shadowbox:nightly # SB_API_PORT: The port number of the management API. # SHADOWBOX_DIR: Directory for persistent Shadowbox state. -# SB_PUBLIC_IP: The public IP address for Shadowbox. +# SB_PUBLIC_IP: The public hostname for Shadowbox. # ACCESS_CONFIG: The location of the access config text file. # SB_DEFAULT_SERVER_NAME: Default name for this server, e.g. "Outline server New York". # This name will be used for the server until the admins updates the name @@ -174,7 +174,6 @@ function finish { log_error "\nSorry! Something went wrong. If you can't figure this out, please copy and paste all this output into the Outline Manager screen, and send it to us, to see if we can help you." fi } -trap finish EXIT function get_random_port { local num=0 # Init to an invalid value, to prevent "unbound variable" errors. @@ -213,7 +212,7 @@ function generate_certificate() { readonly SB_PRIVATE_KEY_FILE="${CERTIFICATE_NAME}.key" declare -a openssl_req_flags=( -x509 -nodes -days 36500 -newkey rsa:2048 - -subj "/CN=${SB_PUBLIC_IP}" + -subj "/CN=${PUBLIC_HOSTNAME}" -keyout "${SB_PRIVATE_KEY_FILE}" -out "${SB_CERTIFICATE_FILE}" ) openssl req "${openssl_req_flags[@]}" >/dev/null 2>&1 @@ -229,13 +228,29 @@ function generate_certificate_fingerprint() { output_config "certSha256:$CERT_HEX_FINGERPRINT" } +function join() { + local IFS="$1" + shift + echo "$*" +} + +function write_config() { + declare -a config=() + if [[ -n $FLAGS_PORT_FOR_KEYS ]]; then + config+=("\"portForNewAccessKeys\":$FLAGS_PORT_FOR_KEYS") + fi + echo "{"$(join , "${config[@]}")"}" > $STATE_DIR/shadowbox_server_config.json +} + function start_shadowbox() { + # TODO(fortuna): Write PUBLIC_HOSTNAME and PORT_FOR_API to config file, + # rather than pass in the environment. declare -a docker_shadowbox_flags=( --name shadowbox --restart=always --net=host -v "${STATE_DIR}:${STATE_DIR}" -e "SB_STATE_DIR=${STATE_DIR}" - -e "SB_PUBLIC_IP=${SB_PUBLIC_IP}" - -e "SB_API_PORT=${SB_API_PORT}" + -e "SB_PUBLIC_IP=${PUBLIC_HOSTNAME}" + -e "SB_API_PORT=${PORT_FOR_API}" -e "SB_API_PREFIX=${SB_API_PREFIX}" -e "SB_CERTIFICATE_FILE=${SB_CERTIFICATE_FILE}" -e "SB_PRIVATE_KEY_FILE=${SB_PRIVATE_KEY_FILE}" @@ -312,7 +327,7 @@ function check_firewall() { FIREWALL_STATUS="\ You won’t be able to access it externally, despite your server being correctly set up, because there's a firewall (in this machine, your router or cloud -provider) that is preventing incoming connections to ports ${SB_API_PORT} and ${ACCESS_KEY_PORT}." +provider) that is preventing incoming connections to ports ${PORT_FOR_API} and ${ACCESS_KEY_PORT}." else FIREWALL_STATUS="\ If you have connection problems, it may be that your router or cloud provider @@ -322,7 +337,7 @@ blocks inbound connections, even though your machine seems to allow them." $FIREWALL_STATUS Make sure to open the following ports on your firewall, router or cloud provider: -- Management port ${SB_API_PORT}, for TCP +- Management port ${PORT_FOR_API}, for TCP - Access key port ${ACCESS_KEY_PORT}, for TCP and UDP " } @@ -340,15 +355,15 @@ install_shadowbox() { chmod u+s $SHADOWBOX_DIR log_for_sentry "Setting API port" - readonly SB_API_PORT="${SB_API_PORT:-$(get_random_port)}" + readonly PORT_FOR_API="${FLAGS_PORT_FOR_API:-${SB_API_PORT:-$(get_random_port)}}" readonly ACCESS_CONFIG=${ACCESS_CONFIG:-$SHADOWBOX_DIR/access.txt} readonly SB_IMAGE=${SB_IMAGE:-quay.io/outline/shadowbox:stable} - log_for_sentry "Setting SB_PUBLIC_IP" + log_for_sentry "Setting PUBLIC_HOSTNAME" # TODO(fortuna): Make sure this is IPv4 - readonly SB_PUBLIC_IP=${SB_PUBLIC_IP:-$(curl -4s https://ipinfo.io/ip)} + PUBLIC_HOSTNAME=${FLAGS_HOSTNAME:-${SB_PUBLIC_IP:-$(curl -4s https://ipinfo.io/ip)}} - if [[ -z $SB_PUBLIC_IP ]]; then + if [[ -z $PUBLIC_HOSTNAME ]]; then local readonly MSG="Failed to determine the server's IP address." log_error "$MSG" log_for_sentry "$MSG" @@ -366,6 +381,8 @@ install_shadowbox() { run_step "Generating secret key" generate_secret_key run_step "Generating TLS certificate" generate_certificate run_step "Generating SHA-256 certificate fingerprint" generate_certificate_fingerprint + run_step "Writing config" write_config + # TODO(dborkan): if the script fails after docker run, it will continue to fail # as the names shadowbox and watchtower will already be in use. Consider # deleting the container in the case of failure (e.g. using a trap, or @@ -374,8 +391,8 @@ install_shadowbox() { # TODO(fortuna): Don't wait for Shadowbox to run this. run_step "Starting Watchtower" start_watchtower - readonly PUBLIC_API_URL="https://${SB_PUBLIC_IP}:${SB_API_PORT}/${SB_API_PREFIX}" - readonly LOCAL_API_URL="https://localhost:${SB_API_PORT}/${SB_API_PREFIX}" + readonly PUBLIC_API_URL="https://${PUBLIC_HOSTNAME}:${PORT_FOR_API}/${SB_API_PREFIX}" + readonly LOCAL_API_URL="https://localhost:${PORT_FOR_API}/${SB_API_PREFIX}" run_step "Waiting for Outline server to be healthy" wait_shadowbox run_step "Creating first user" create_first_user run_step "Adding API URL to config" add_api_url_to_config @@ -406,5 +423,60 @@ ${FIREWALL_STATUS} END_OF_SERVER_OUTPUT } # end of install_shadowbox -# Wrapped in a function for some protection against half-downloads. -install_shadowbox +function display_usage() { + echo Usage: install_server.sh [--hostname ] [--port-for-api ] [--port-for-keys ] + echo + echo --hostname The hostname to be used to access the management API and access keys. +} + +function read_param() { + if (( "$#" < 2 )); then + log_error "Missing $1 value" + display_usage + exit 1 + fi + echo $2 +} + +function parse_flags() { + local PARAMS="" + while [[ "$#" > 0 && ! "$1" == "--" ]]; do + case "$1" in + --hostname) + FLAGS_HOSTNAME=$(read_param "$@") + shift + ;; + --port-for-api) + FLAGS_PORT_FOR_API=$(read_param "$@") + shift + ;; + --port-for-keys) + FLAGS_PORT_FOR_KEYS=$(read_param "$@") + shift + ;; + -*|--*=) # unsupported flags + log_error "Unsupported flag $1" + display_usage + exit 1 + ;; + *) # preserve positional arguments + PARAMS="$PARAMS '$1'" + ;; + esac + shift + done + if (( FLAGS_PORT_FOR_API == FLAGS_PORT_FOR_KEYS )); then + log_error "Port for management API must be different from port for access keys" + exit 1 + fi + # set positional arguments in their proper place + eval set -- "$PARAMS" +} + +function main() { + trap finish EXIT + parse_flags "$@" + install_shadowbox +} + +main "$@" \ No newline at end of file From 2a00fe5a17381e614c596f2d12d713dab0665495 Mon Sep 17 00:00:00 2001 From: fortuna Date: Thu, 28 Mar 2019 18:37:42 -0400 Subject: [PATCH 02/11] Cosmetic changes --- .../install_scripts/install_server.sh | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/server_manager/install_scripts/install_server.sh b/src/server_manager/install_scripts/install_server.sh index 618e8175..ac03a1c9 100755 --- a/src/server_manager/install_scripts/install_server.sh +++ b/src/server_manager/install_scripts/install_server.sh @@ -12,14 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Script to install a shadowbox docker container, a watchtower docker container -# (to automatically update shadowbox), and to create a new shadowbox user. +# Script to install the Outline Server docker container, a watchtower docker container +# (to automatically update the server), and to create a new Outline user. # You may set the following environment variables, overriding their defaults: -# SB_IMAGE: Shadowbox Docker image to install, e.g. quay.io/outline/shadowbox:nightly +# SB_IMAGE: The Outline Server Docker image to install, e.g. quay.io/outline/shadowbox:nightly # SB_API_PORT: The port number of the management API. -# SHADOWBOX_DIR: Directory for persistent Shadowbox state. -# SB_PUBLIC_IP: The public hostname for Shadowbox. +# SHADOWBOX_DIR: Directory for persistent Outline Server state. +# SB_PUBLIC_IP: The public hostname for the Outline Server. # ACCESS_CONFIG: The location of the access config text file. # SB_DEFAULT_SERVER_NAME: Default name for this server, e.g. "Outline server New York". # This name will be used for the server until the admins updates the name @@ -34,6 +34,14 @@ set -euo pipefail +function display_usage() { + echo Usage: install_server.sh [--hostname ] [--port-for-api ] [--port-for-keys ] + echo + echo --hostname The hostname to be used to access the management API and access keys + echo --port-for-api The port number for the management API + echo --port-for-keys The port number for the access keys +} + readonly SENTRY_LOG_FILE=${SENTRY_LOG_FILE:-} function log_error() { @@ -189,7 +197,7 @@ function create_persisted_state_dir() { chmod g+s "${STATE_DIR}" } -# Generate a secret key for access to the shadowbox API and store it in a tag. +# Generate a secret key for access to the Management API and store it in a tag. # 16 bytes = 128 bits of entropy should be plenty for this use. function safe_base64() { # Implements URL-safe base64 of stdin, stripping trailing = chars. @@ -296,7 +304,7 @@ function start_watchtower() { fi } -# Waits for Shadowbox to be up and healthy +# Waits for the service to be up and healthy function wait_shadowbox() { # We use insecure connection because our threat model doesn't include localhost port # interception and our certificate doesn't have localhost as a subject alternative name @@ -423,12 +431,6 @@ ${FIREWALL_STATUS} END_OF_SERVER_OUTPUT } # end of install_shadowbox -function display_usage() { - echo Usage: install_server.sh [--hostname ] [--port-for-api ] [--port-for-keys ] - echo - echo --hostname The hostname to be used to access the management API and access keys. -} - function read_param() { if (( "$#" < 2 )); then log_error "Missing $1 value" From 174410ee1f42685f733afb6a3d80956bbef75c90 Mon Sep 17 00:00:00 2001 From: fortuna Date: Thu, 28 Mar 2019 18:41:56 -0400 Subject: [PATCH 03/11] Add deprecation notice --- src/server_manager/install_scripts/install_server.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/server_manager/install_scripts/install_server.sh b/src/server_manager/install_scripts/install_server.sh index ac03a1c9..5dbade08 100755 --- a/src/server_manager/install_scripts/install_server.sh +++ b/src/server_manager/install_scripts/install_server.sh @@ -17,9 +17,7 @@ # You may set the following environment variables, overriding their defaults: # SB_IMAGE: The Outline Server Docker image to install, e.g. quay.io/outline/shadowbox:nightly -# SB_API_PORT: The port number of the management API. # SHADOWBOX_DIR: Directory for persistent Outline Server state. -# SB_PUBLIC_IP: The public hostname for the Outline Server. # ACCESS_CONFIG: The location of the access config text file. # SB_DEFAULT_SERVER_NAME: Default name for this server, e.g. "Outline server New York". # This name will be used for the server until the admins updates the name @@ -29,6 +27,10 @@ # only by do_install_server.sh. # WATCHTOWER_REFRESH_SECONDS: refresh interval in seconds to check for updates, # defaults to 3600. +# +# Deprecated: +# SB_PUBLIC_IP: Use the --hostname flag instead +# SB_API_PORT: Use the --port-for-api flag instead # Requires curl and docker to be installed From e4447ef388091915ccfce2c0d92c4a9b936bcdf4 Mon Sep 17 00:00:00 2001 From: fortuna Date: Fri, 29 Mar 2019 19:11:39 -0400 Subject: [PATCH 04/11] Address review comments --- .../install_scripts/install_server.sh | 96 +++++++++++-------- 1 file changed, 55 insertions(+), 41 deletions(-) diff --git a/src/server_manager/install_scripts/install_server.sh b/src/server_manager/install_scripts/install_server.sh index 5dbade08..8ce20fab 100755 --- a/src/server_manager/install_scripts/install_server.sh +++ b/src/server_manager/install_scripts/install_server.sh @@ -37,11 +37,13 @@ set -euo pipefail function display_usage() { - echo Usage: install_server.sh [--hostname ] [--port-for-api ] [--port-for-keys ] - echo - echo --hostname The hostname to be used to access the management API and access keys - echo --port-for-api The port number for the management API - echo --port-for-keys The port number for the access keys + cat <] [--port-for-api ] [--port-for-keys ] + + --hostname The hostname to be used to access the management API and access keys + --port-for-api The port number for the management API + --port-for-keys The port number for the access keys +EOF } readonly SENTRY_LOG_FILE=${SENTRY_LOG_FILE:-} @@ -246,21 +248,23 @@ function join() { function write_config() { declare -a config=() - if [[ -n $FLAGS_PORT_FOR_KEYS ]]; then - config+=("\"portForNewAccessKeys\":$FLAGS_PORT_FOR_KEYS") + if [[ $FLAGS_KEYS_PORT != 0 ]]; then + config+=("\"portForNewAccessKeys\":$FLAGS_KEYS_PORT") + fi + if [[ ${#config[@]} > 0 ]]; then + echo "{"$(join , "${config[@]}")"}" > $STATE_DIR/shadowbox_server_config.json fi - echo "{"$(join , "${config[@]}")"}" > $STATE_DIR/shadowbox_server_config.json } function start_shadowbox() { - # TODO(fortuna): Write PUBLIC_HOSTNAME and PORT_FOR_API to config file, + # TODO(fortuna): Write PUBLIC_HOSTNAME and API_PORT to config file, # rather than pass in the environment. declare -a docker_shadowbox_flags=( --name shadowbox --restart=always --net=host -v "${STATE_DIR}:${STATE_DIR}" -e "SB_STATE_DIR=${STATE_DIR}" -e "SB_PUBLIC_IP=${PUBLIC_HOSTNAME}" - -e "SB_API_PORT=${PORT_FOR_API}" + -e "SB_API_PORT=${API_PORT}" -e "SB_API_PREFIX=${SB_API_PREFIX}" -e "SB_CERTIFICATE_FILE=${SB_CERTIFICATE_FILE}" -e "SB_PRIVATE_KEY_FILE=${SB_PRIVATE_KEY_FILE}" @@ -337,7 +341,7 @@ function check_firewall() { FIREWALL_STATUS="\ You won’t be able to access it externally, despite your server being correctly set up, because there's a firewall (in this machine, your router or cloud -provider) that is preventing incoming connections to ports ${PORT_FOR_API} and ${ACCESS_KEY_PORT}." +provider) that is preventing incoming connections to ports ${API_PORT} and ${ACCESS_KEY_PORT}." else FIREWALL_STATUS="\ If you have connection problems, it may be that your router or cloud provider @@ -347,7 +351,7 @@ blocks inbound connections, even though your machine seems to allow them." $FIREWALL_STATUS Make sure to open the following ports on your firewall, router or cloud provider: -- Management port ${PORT_FOR_API}, for TCP +- Management port ${API_PORT}, for TCP - Access key port ${ACCESS_KEY_PORT}, for TCP and UDP " } @@ -365,7 +369,10 @@ install_shadowbox() { chmod u+s $SHADOWBOX_DIR log_for_sentry "Setting API port" - readonly PORT_FOR_API="${FLAGS_PORT_FOR_API:-${SB_API_PORT:-$(get_random_port)}}" + API_PORT="${FLAGS_API_PORT}" + if [[ $API_PORT == 0 ]]; then + API_PORT = ${SB_API_PORT:-$(get_random_port)} + fi readonly ACCESS_CONFIG=${ACCESS_CONFIG:-$SHADOWBOX_DIR/access.txt} readonly SB_IMAGE=${SB_IMAGE:-quay.io/outline/shadowbox:stable} @@ -401,8 +408,8 @@ install_shadowbox() { # TODO(fortuna): Don't wait for Shadowbox to run this. run_step "Starting Watchtower" start_watchtower - readonly PUBLIC_API_URL="https://${PUBLIC_HOSTNAME}:${PORT_FOR_API}/${SB_API_PREFIX}" - readonly LOCAL_API_URL="https://localhost:${PORT_FOR_API}/${SB_API_PREFIX}" + readonly PUBLIC_API_URL="https://${PUBLIC_HOSTNAME}:${API_PORT}/${SB_API_PREFIX}" + readonly LOCAL_API_URL="https://localhost:${API_PORT}/${SB_API_PREFIX}" run_step "Waiting for Outline server to be healthy" wait_shadowbox run_step "Creating first user" create_first_user run_step "Adding API URL to config" add_api_url_to_config @@ -433,48 +440,55 @@ ${FIREWALL_STATUS} END_OF_SERVER_OUTPUT } # end of install_shadowbox -function read_param() { - if (( "$#" < 2 )); then - log_error "Missing $1 value" - display_usage - exit 1 - fi - echo $2 +function is_valid_port() { + (( 0 < "$1" && "$1" <= 65535 )) } function parse_flags() { - local PARAMS="" - while [[ "$#" > 0 && ! "$1" == "--" ]]; do - case "$1" in + eval set -- $(getopt --longoptions hostname:,api-port:,keys-port: -n $0 -- $0 "$@") + declare -g FLAGS_HOSTNAME="" + declare -gi FLAGS_API_PORT=0 + declare -gi FLAGS_KEYS_PORT=0 + + while [[ "$#" > 0 ]]; do + local flag=$1 + shift + case "$flag" in --hostname) - FLAGS_HOSTNAME=$(read_param "$@") + FLAGS_HOSTNAME=${1} shift ;; - --port-for-api) - FLAGS_PORT_FOR_API=$(read_param "$@") + --api-port) + FLAGS_API_PORT=${1} shift + if ! is_valid_port $FLAGS_API_PORT; then + log_error "Invalid value for $flag: $FLAGS_API_PORT" + exit 1 + fi ;; - --port-for-keys) - FLAGS_PORT_FOR_KEYS=$(read_param "$@") + --keys-port) + FLAGS_KEYS_PORT=$1 shift + if ! is_valid_port $FLAGS_KEYS_PORT; then + log_error "Invalid value for $flag: $FLAGS_KEYS_PORT" + exit 1 + fi ;; - -*|--*=) # unsupported flags - log_error "Unsupported flag $1" + --) + break + ;; + *) # This should not happen + log_error "Unsupported flag $flag" display_usage exit 1 ;; - *) # preserve positional arguments - PARAMS="$PARAMS '$1'" - ;; esac - shift done - if (( FLAGS_PORT_FOR_API == FLAGS_PORT_FOR_KEYS )); then - log_error "Port for management API must be different from port for access keys" + if [[ $FLAGS_API_PORT != 0 && $FLAGS_API_PORT == $FLAGS_KEYS_PORT ]]; then + log_error "--api-port must be different from --keys-port" exit 1 fi - # set positional arguments in their proper place - eval set -- "$PARAMS" + return 0 } function main() { @@ -483,4 +497,4 @@ function main() { install_shadowbox } -main "$@" \ No newline at end of file +main "$@" From 9bdfd6b8cbaec810faac2619fe3666508709ee02 Mon Sep 17 00:00:00 2001 From: fortuna Date: Fri, 29 Mar 2019 19:12:52 -0400 Subject: [PATCH 05/11] usage fix --- src/server_manager/install_scripts/install_server.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/server_manager/install_scripts/install_server.sh b/src/server_manager/install_scripts/install_server.sh index 8ce20fab..df1d9d51 100755 --- a/src/server_manager/install_scripts/install_server.sh +++ b/src/server_manager/install_scripts/install_server.sh @@ -30,7 +30,7 @@ # # Deprecated: # SB_PUBLIC_IP: Use the --hostname flag instead -# SB_API_PORT: Use the --port-for-api flag instead +# SB_API_PORT: Use the --apit-port flag instead # Requires curl and docker to be installed @@ -38,11 +38,11 @@ set -euo pipefail function display_usage() { cat <] [--port-for-api ] [--port-for-keys ] +Usage: install_server.sh [--hostname ] [--apit-port ] [--keys-port ] - --hostname The hostname to be used to access the management API and access keys - --port-for-api The port number for the management API - --port-for-keys The port number for the access keys + --hostname The hostname to be used to access the management API and access keys + --api-port The port number for the management API + --keys-port The port number for the access keys EOF } From 7088ac54f98612c2541e48c13e926471412232bc Mon Sep 17 00:00:00 2001 From: Vinicius Fortuna Date: Tue, 2 Apr 2019 18:14:36 +0200 Subject: [PATCH 06/11] Fix typo --- src/server_manager/install_scripts/install_server.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server_manager/install_scripts/install_server.sh b/src/server_manager/install_scripts/install_server.sh index df1d9d51..a6dc7101 100755 --- a/src/server_manager/install_scripts/install_server.sh +++ b/src/server_manager/install_scripts/install_server.sh @@ -30,7 +30,7 @@ # # Deprecated: # SB_PUBLIC_IP: Use the --hostname flag instead -# SB_API_PORT: Use the --apit-port flag instead +# SB_API_PORT: Use the --api-port flag instead # Requires curl and docker to be installed @@ -38,7 +38,7 @@ set -euo pipefail function display_usage() { cat <] [--apit-port ] [--keys-port ] +Usage: install_server.sh [--hostname ] [--api-port ] [--keys-port ] --hostname The hostname to be used to access the management API and access keys --api-port The port number for the management API From c244868359c8a17c406b40bb6843613e2d5e542e Mon Sep 17 00:00:00 2001 From: fortuna Date: Mon, 8 Apr 2019 18:04:55 -0400 Subject: [PATCH 07/11] Fix API_PORT assignment --- src/server_manager/install_scripts/install_server.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server_manager/install_scripts/install_server.sh b/src/server_manager/install_scripts/install_server.sh index a6dc7101..b8e58fcd 100755 --- a/src/server_manager/install_scripts/install_server.sh +++ b/src/server_manager/install_scripts/install_server.sh @@ -371,7 +371,7 @@ install_shadowbox() { log_for_sentry "Setting API port" API_PORT="${FLAGS_API_PORT}" if [[ $API_PORT == 0 ]]; then - API_PORT = ${SB_API_PORT:-$(get_random_port)} + API_PORT=${SB_API_PORT:-$(get_random_port)} fi readonly ACCESS_CONFIG=${ACCESS_CONFIG:-$SHADOWBOX_DIR/access.txt} readonly SB_IMAGE=${SB_IMAGE:-quay.io/outline/shadowbox:stable} From d19a5afcb8f337b26639f4f12d29d105a7e09565 Mon Sep 17 00:00:00 2001 From: fortuna Date: Mon, 8 Apr 2019 18:19:27 -0400 Subject: [PATCH 08/11] separate params from eval --- src/server_manager/install_scripts/install_server.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/server_manager/install_scripts/install_server.sh b/src/server_manager/install_scripts/install_server.sh index b8e58fcd..cf72be27 100755 --- a/src/server_manager/install_scripts/install_server.sh +++ b/src/server_manager/install_scripts/install_server.sh @@ -445,7 +445,8 @@ function is_valid_port() { } function parse_flags() { - eval set -- $(getopt --longoptions hostname:,api-port:,keys-port: -n $0 -- $0 "$@") + local params=$(getopt --longoptions hostname:,api-port:,keys-port: -n $0 -- $0 "$@") + eval set -- $params declare -g FLAGS_HOSTNAME="" declare -gi FLAGS_API_PORT=0 declare -gi FLAGS_KEYS_PORT=0 From 5c22848bbbe1d5e964f61ca6b588f06148848c4a Mon Sep 17 00:00:00 2001 From: fortuna Date: Mon, 8 Apr 2019 18:23:28 -0400 Subject: [PATCH 09/11] Make getopt fail on bad param --- src/server_manager/install_scripts/install_server.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server_manager/install_scripts/install_server.sh b/src/server_manager/install_scripts/install_server.sh index cf72be27..f8f4f7af 100755 --- a/src/server_manager/install_scripts/install_server.sh +++ b/src/server_manager/install_scripts/install_server.sh @@ -445,7 +445,7 @@ function is_valid_port() { } function parse_flags() { - local params=$(getopt --longoptions hostname:,api-port:,keys-port: -n $0 -- $0 "$@") + local params=$(getopt --longoptions hostname:,api-port:,keys-port: -n $0 -- $0 "$@" || exit 1) eval set -- $params declare -g FLAGS_HOSTNAME="" declare -gi FLAGS_API_PORT=0 From 6faa9e4ab4fae253217a599514c94ec6d4b59fb6 Mon Sep 17 00:00:00 2001 From: fortuna Date: Mon, 8 Apr 2019 18:51:05 -0400 Subject: [PATCH 10/11] Fix error handling --- src/server_manager/install_scripts/install_server.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/server_manager/install_scripts/install_server.sh b/src/server_manager/install_scripts/install_server.sh index f8f4f7af..c38d99dd 100755 --- a/src/server_manager/install_scripts/install_server.sh +++ b/src/server_manager/install_scripts/install_server.sh @@ -445,7 +445,8 @@ function is_valid_port() { } function parse_flags() { - local params=$(getopt --longoptions hostname:,api-port:,keys-port: -n $0 -- $0 "$@" || exit 1) + params=$(getopt --longoptions hostname:,api-port:,keys-port: -n $0 -- $0 "$@") + [[ $? == 0 ]] || exit 1 eval set -- $params declare -g FLAGS_HOSTNAME="" declare -gi FLAGS_API_PORT=0 From 25264299db4e79916a9484116975d4f9d0522956 Mon Sep 17 00:00:00 2001 From: fortuna Date: Mon, 8 Apr 2019 18:53:57 -0400 Subject: [PATCH 11/11] Update README --- src/shadowbox/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/shadowbox/README.md b/src/shadowbox/README.md index 9ecfac87..4a0de944 100644 --- a/src/shadowbox/README.md +++ b/src/shadowbox/README.md @@ -14,6 +14,11 @@ To install and run Shadowbox on your own server, run sudo bash -c "$(wget -qO- https://raw.githubusercontent.com/Jigsaw-Code/outline-server/master/src/server_manager/install_scripts/install_server.sh)" ``` +You can specify flags to customize the installation. For example, to use hostname `myserver.com` and the port 443 for access keys, you can run: +``` +sudo bash -c "$(wget -qO- https://raw.githubusercontent.com/Jigsaw-Code/outline-server/master/src/server_manager/install_scripts/install_server.sh)" install_server.sh --hostname=myserver.com --keys-port=443 +``` + Use `sudo --preserve-env` if you need to pass environment variables. Use `bash -x` if you need to debug the installation. ## Running from source code