From 1c9150801f433020cea14a3d4e80bfb032afd294 Mon Sep 17 00:00:00 2001 From: Jeff Atwood Date: Wed, 20 Apr 2016 12:50:30 -0700 Subject: [PATCH] remove SSH command, improve valid check --- launcher | 66 ++++++++++++-------------------------------------------- 1 file changed, 14 insertions(+), 52 deletions(-) diff --git a/launcher b/launcher index 2e05e2c..b2bcaf8 100755 --- a/launcher +++ b/launcher @@ -58,7 +58,6 @@ usage () { echo " restart: Restart a container" echo " destroy: Stop and remove a container" echo " enter: Use nsenter to enter a container" - echo " ssh: Start a bash shell in a running container" echo " logs: Docker logs for container" echo " bootstrap: Bootstrap a container for the config based on a template" echo " rebuild: Rebuild a container (destroy old, bootstrap, start new)" @@ -223,28 +222,6 @@ else user_args="" fi -get_ssh_pub_key() { - local ${ssh_key_locations} - ssh_key_locations=( - ~/.ssh/id_ed25519.pub - ~/.ssh/id_ecdsa.pub - ~/.ssh/id_rsa.pub - ~/.ssh/id_dsa.pub - ~core/.ssh/authorized_keys - ) - - local $keyfile - for keyfile in "${ssh_key_locations[@]}"; do - if [[ -e ${keyfile} ]] ; then - ssh_pub_key="$(cat ${keyfile})" - return 0 - fi - done - - return 0 -} - - install_docker() { echo "Docker is not installed, you will need to install Docker in order to run Discourse" @@ -307,7 +284,6 @@ set_template_info() { templates=`cat $config_file | $docker_path run $user_args --rm -i -a stdin -a stdout $image ruby -e \ "require 'yaml'; puts YAML.load(STDIN.readlines.join)['templates']"` - arrTemplates=(${templates// / }) config_data=$(cat $config_file) @@ -589,26 +565,28 @@ run_start(){ } -mail_config_check(){ - mail_config_verbose=0 # 1 prints mail config to stdout - mail_config="ok" - for x in DISCOURSE_SMTP_ADDRESS DISCOURSE_SMTP_USER_NAME DISCOURSE_SMTP_PASSWORD +valid_config_check(){ + valid_config="y" + for x in DISCOURSE_SMTP_ADDRESS DISCOURSE_SMTP_USER_NAME DISCOURSE_SMTP_PASSWORD \ + DISCOURSE_DEVELOPER_EMAILS DISCOURSE_HOSTNAME do mail_var=`grep "^ $x:" $config_file` result=$? if (( result == 0 )) then - if [ "$mail_config_verbose" -eq 1 ]; then - echo "$mail_var" + if [[ $mail_var = *"example.com"* ]] + then + echo "Warning: $x left at incorrect default of example.com" + valid_config="n" fi else echo "Warning: $x not configured." - mail_config="dubious" + valid_config="n" fi done - if [ -t 0 ] && [ "$mail_config" != "ok" ]; then + if [ -t 0 ] && [ "$valid_config" != "y" ]; then echo - read -p "Press ENTER to continue, or Ctrl-C to exit and fix your mail config." + read -p "Press ENTER to continue, or Ctrl-C to exit and edit your config." fi } @@ -618,12 +596,11 @@ run_bootstrap(){ check_resources fi - mail_config_check - + # is our configuration valid? + valid_config_check + host_run - get_ssh_pub_key - # Is the image available? # If not, pull it here so the user is aware what's happening. $docker_path history $image >/dev/null 2>&1 || $docker_path pull $image @@ -653,8 +630,6 @@ run_bootstrap(){ echo $run_command - env=("${env[@]}" "-e" "SSH_PUB_KEY=$ssh_pub_key") - (exec echo "$input" | $docker_path run $user_args $links "${env[@]}" -e DOCKER_HOST_IP=$docker_ip --cidfile $cidbootstrap -i -a stdin -a stdout -a stderr $volumes $image \ /bin/bash -c "$run_command") \ || ($docker_path rm `cat $cidbootstrap` && rm $cidbootstrap) @@ -680,19 +655,6 @@ case "$command" in exec $docker_path exec -it $config /bin/bash --login ;; - ssh) - existing=`$docker_path ps | awk '{ print $1, $(NF) }' | grep " $config$" | awk '{ print $1 }'` - - if [[ ! -z $existing ]]; then - address="`$docker_path port $config 22`" - split=(${address//:/ }) - exec ssh -o StrictHostKeyChecking=no root@${split[0]} -p ${split[1]} - else - echo "$config is not running!" - exit 1 - fi - ;; - stop) run_stop exit 0 -- 2.25.1