mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-15 06:49:56 +00:00
Bug fixes
This commit is contained in:
1 parent
562749bae8
commit
3391ec8ea9
9 files changed
+157
-166
No files matched your search
@@ -32,7 +32,7 @@ function get_latest_release(){
|
||||
# -----------------------------------------------------------
|
||||
function get_access_token(){
|
||||
local_echo -n "Getting access token..."
|
||||
curl_until_http_200 http://$1:$2@$3:$4/security/api/restsecurity/access_token
|
||||
curl_until_response "200" http://$1:$2@$3:$4/security/api/restsecurity/access_token
|
||||
curl_wrapper -X GET "http://$1:$2@$3:$4/security/api/restsecurity/access_token" | get_attribute '.access_token'
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ function get_access_token(){
|
||||
# -----------------------------------------------------------
|
||||
function create_event(){
|
||||
local_echo -n "Creating event with name $4..."
|
||||
curl_until_http_401 http://$2:$3/sailingserver/api/v1/events/createEvent
|
||||
curl_until_response "401" http://$2:$3/sailingserver/api/v1/events/createEvent
|
||||
curl_wrapper -X POST -H "Authorization: Bearer $1" "http://$2:$3/sailingserver/api/v1/events/createEvent" --data "eventName=$4" --data "venuename=Default" --data "createregatta=false" | get_attribute '.eventid'
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ function create_target_group(){
|
||||
local_echo "Creating target group $1..."
|
||||
local target_group_name=$(only_letters_numbers_dash $1)
|
||||
local vpc_id=$(get_default_vpc_id)
|
||||
aws_wrapper elbv2 create-target-group --name $target_group_name --protocol "$target_group_protocol" \
|
||||
--port $target_group_port --vpc-id $vpc_id | get_attribute '.TargetGroups[0].TargetGroupArn'
|
||||
aws_wrapper elbv2 create-target-group --name $target_group_name --protocol "HTTPS" \
|
||||
--port "443" --vpc-id $vpc_id | get_attribute '.TargetGroups[0].TargetGroupArn'
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------
|
||||
|
||||
@@ -177,7 +177,7 @@ function init_resources(){
|
||||
|
||||
if ! is_exists ~/.aws-automation/config; then
|
||||
local_echo "Creating ~/.aws-automation/config..."
|
||||
create_configuration
|
||||
create_global_configuration
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ function create_region_configuration(){
|
||||
echo -e $config > ~/.aws-automation/config-$region
|
||||
}
|
||||
|
||||
function create_configuration(){
|
||||
function create_global_configuration(){
|
||||
mkdir -p ~/.aws-automation
|
||||
touch ~/.aws-automation/config
|
||||
|
||||
@@ -215,113 +215,3 @@ function set_config_variable(){
|
||||
function get_config_variable(){
|
||||
./lib/build-config.sh --bash ~/.aws-automation/config-$region "$1"
|
||||
}
|
||||
|
||||
function require_image_id(){
|
||||
require_variable "" image_id "" "$image_id_ask_message" "false" "false" $CHOOSE_FROM_IMAGES
|
||||
}
|
||||
|
||||
function require_event_name(){
|
||||
require_variable "$event_name_param" event_name "" "$event_name_ask_message" "true" "false"
|
||||
}
|
||||
|
||||
function require_instance_security_group_id(){
|
||||
require_variable "" instance_security_group_id "" "$instance_security_group_id_ask_message" "false" "false" $CHOOSE_FROM_SECURITY_GROUPS
|
||||
}
|
||||
|
||||
function require_load_balancer(){
|
||||
require_variable "" load_balancer "" "$load_balancer_ask_message" "false" "false" $CHOOSE_FROM_LOAD_BALANCERS
|
||||
}
|
||||
|
||||
function require_instance(){
|
||||
require_variable "" instance "" "$instance_ask_message" "false" "false" $CHOOSE_FROM_INSTANCES
|
||||
}
|
||||
|
||||
function require_region(){
|
||||
require_variable "$region_param" region "$default_region" "$region_ask_message" "false" "false"
|
||||
}
|
||||
|
||||
function require_instance_type(){
|
||||
require_variable "$instance_type_param" instance_type "$default_instance_type" "$instance_type_ask_message" "false" "false"
|
||||
|
||||
}
|
||||
function require_instance_name(){
|
||||
require_variable "$instance_name_param" instance_name "$default_instance_name" "$instance_name_ask_message" "false" "false"
|
||||
}
|
||||
|
||||
function require_instance_short_name(){
|
||||
require_variable "$instance_short_name_param" instance_short_name "$default_instance_short_name" "$instance_short_name_ask_message" "false" "false"
|
||||
}
|
||||
|
||||
function require_key_name(){
|
||||
if [ -z ${key_file+x} ] || [ ! -z "$key_file" ]; then
|
||||
require_variable "$key_name_param" key_name "$default_key_name" "$key_name_ask_message" "true" "false"
|
||||
fi
|
||||
}
|
||||
|
||||
function require_key_file(){
|
||||
if [ -z ${key_name+x} ] || [ ! -z "$key_name" ]; then
|
||||
require_variable "$key_file_param" key_file "$default_key_file" "$key_file_ask_message" "true" "false"
|
||||
fi
|
||||
}
|
||||
|
||||
function require_new_admin_password(){
|
||||
require_variable "$new_admin_password_param" new_admin_password "$default_new_admin_password" "$new_admin_password_ask_message" "true" "true"
|
||||
}
|
||||
|
||||
function require_user_username(){
|
||||
if [ ! -z ${user_password+x} ] || [ ! -z "$user_password" ]; then
|
||||
require_variable "$user_username_param" user_username "$default_user_username" "$user_username_ask_message" "true" "false"
|
||||
fi
|
||||
}
|
||||
|
||||
function require_user_password(){
|
||||
if [ ! -z ${user_name+x} ] || [ ! -z "$user_name" ]; then
|
||||
require_variable "$user_password_param" user_password "$default_user_password" "$user_password_ask_message" "true" "true"
|
||||
fi
|
||||
}
|
||||
|
||||
function require_ssh_user(){
|
||||
require_variable "$ssh_user_param" ssh_user "$default_ssh_user" "$ssh_user_ask_message" "false" "false"
|
||||
}
|
||||
|
||||
function require_super_instance(){
|
||||
require_variable "$super_instance_param" super_instance "$default_super_instance" "$super_instance_message" "false" "false" $CHOOSE_FROM_INSTANCES
|
||||
}
|
||||
|
||||
function require_description(){
|
||||
require_variable "$description_param" description "" "$description_message" "true" "false"
|
||||
}
|
||||
|
||||
function require_contact_person(){
|
||||
require_variable "$contact_person_param" contact_person "$default_contact_person" "$contact_person_message" "true" "false"
|
||||
}
|
||||
|
||||
function require_contact_email(){
|
||||
require_variable "$contact_email_param" contact_email "$default_contact_email" "$contact_email_message" "true" "false"
|
||||
}
|
||||
|
||||
function require_build_version(){
|
||||
require_variable "$build_version_param" build_version "$latest_release" "$build_version_message" "false" "false"
|
||||
}
|
||||
|
||||
instance_ask_message="Please enter an instance to use: "
|
||||
event_name_ask_message="Please enter an event name (leave blank to skip event creation):"
|
||||
instance_security_group_id_ask_message="Please select the security group for the instance: "
|
||||
load_balancer_ask_message="Please select/enter the load balancer dns name: "
|
||||
region_ask_message="Please enter the region you want to use (e.g. eu-west-2): "
|
||||
instance_type_ask_message="Please enter the instance type (e.g. t2.medium): "
|
||||
key_name_ask_message="Please enter the name of your keypair to connect to the instance (e.g. leon-keypair). Leave blank to use ~/.ssh key: "
|
||||
instance_name_ask_message="Please enter a name for the instance: (e.g \"WC Santander 2017\"): "
|
||||
instance_short_name_ask_message="Please enter a short name for the instance (e.g. \"wcs17\"): "
|
||||
key_file_ask_message="Please enter the file path of the keypair or leave empty to use ~/.ssh key: "
|
||||
new_admin_password_ask_message="Please enter a new password for the admin user (leave blank to skip password change): "
|
||||
mongo_db_host_ask_message="Please enter the ip adress of the mongo db server: "
|
||||
mongo_db_port_ask_message="Please enter the port of the mongo db server: "
|
||||
user_username_ask_message="Please enter the username of your new user (leave blank to skip user creation): "
|
||||
user_password_ask_message="Please enter the password of your new user (leave blank to skip user creation): "
|
||||
ssh_user_ask_message="Please enter the ssh user to connect to the instance: "
|
||||
super_instance_message="Please select/enter the dns name of the superior instance: "
|
||||
description_message="Please enter a description for the server (leave blank to skip): "
|
||||
contact_person_message="Please enter the name of a contact person (leave blank to skip): "
|
||||
contact_email_message="Please enter the email of the contact person (leave blank to skip): "
|
||||
build_version_message="Please enter a build version to use (releases.sapsailing.com): "
|
||||
@@ -1,6 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
declare -g DISPLAY_SUCCESS_FOR_THIS_COMMAND="true"
|
||||
HTTP_RETRY_INTERVAL=5
|
||||
TIMEOUT=300
|
||||
|
||||
# -----------------------------------------------------------
|
||||
# Does the error checking for curl commands.
|
||||
# Captures response and http code of curl command into variable $out.
|
||||
@@ -79,30 +82,16 @@ function ssh_wrapper(){
|
||||
# -----------------------------------------------------------
|
||||
# Executes curl command until status code is 200
|
||||
# -----------------------------------------------------------
|
||||
function curl_until_http_200(){
|
||||
function curl_until_response(){
|
||||
response_code=$1
|
||||
shift
|
||||
start_time="$(date -u +%s)"
|
||||
while [[ $(curl -s -o /dev/null -w ''%{http_code}'' --connect-timeout $http_retry_interval "$@") != "200" ]];
|
||||
while [[ $(curl -s -o /dev/null -w ''%{http_code}'' --connect-timeout $HTTP_RETRY_INTERVAL "$@") != "$response_code" ]];
|
||||
do
|
||||
fail_on_timeout $start_time
|
||||
|
||||
local_echo -n "."
|
||||
sleep $http_retry_interval;
|
||||
done
|
||||
local_echo ""
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------
|
||||
# Executes curl command until status code is 401.
|
||||
# TODO: Fix code duplication (curl_until_http_200, curl_until_http_401)
|
||||
# -----------------------------------------------------------
|
||||
function curl_until_http_401(){
|
||||
start_time="$(date -u +%s)"
|
||||
while [[ $(curl -s -o /dev/null -w ''%{http_code}'' --connect-timeout $http_retry_interval "$@") != "401" ]];
|
||||
do
|
||||
fail_on_timeout $start_time
|
||||
|
||||
local_echo -n "."
|
||||
sleep $http_retry_interval;
|
||||
sleep $HTTP_RETRY_INTERVAL;
|
||||
done
|
||||
local_echo ""
|
||||
}
|
||||
@@ -114,13 +103,13 @@ function do_until_true(){
|
||||
fail_on_timeout $start_time
|
||||
|
||||
echo -n .
|
||||
sleep $http_retry_interval
|
||||
sleep $HTTP_RETRY_INTERVAL
|
||||
done
|
||||
}
|
||||
|
||||
function fail_on_timeout(){
|
||||
end_time="$(date -u +%s)"
|
||||
if [ "$(($end_time-$1))" -gt 180 ]; then
|
||||
if [ "$(($end_time-$1))" -gt $TIMEOUT ]; then
|
||||
error "TIMEOUT"
|
||||
safeExit
|
||||
fi
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
instance_ask_message="Please enter an instance to use: "
|
||||
event_name_ask_message="Please enter an event name (leave blank to skip event creation):"
|
||||
instance_security_group_id_ask_message="Please select the security group for the instance: "
|
||||
load_balancer_ask_message="Please select/enter the load balancer dns name: "
|
||||
region_ask_message="Please enter the region you want to use (e.g. eu-west-2): "
|
||||
instance_type_ask_message="Please enter the instance type (e.g. t2.medium): "
|
||||
key_name_ask_message="Please enter the name of your keypair to user for the instance (e.g. leon-keypair). "
|
||||
instance_name_ask_message="Please enter a name for the instance: (e.g \"WC Santander 2017\"): "
|
||||
instance_short_name_ask_message="Please enter a short name for the instance (e.g. \"wcs17\"): "
|
||||
key_file_ask_message="Please enter the file path of the keypair or leave empty to use ~/.ssh key: "
|
||||
new_admin_password_ask_message="Please enter a new password for the admin user (leave blank to skip password change): "
|
||||
mongo_db_host_ask_message="Please enter the ip adress of the mongo db server: "
|
||||
mongo_db_port_ask_message="Please enter the port of the mongo db server: "
|
||||
user_username_ask_message="Please enter the username of your new user (leave blank to skip user creation): "
|
||||
user_password_ask_message="Please enter the password of your new user (leave blank to skip user creation): "
|
||||
ssh_user_ask_message="Please enter the ssh user to connect to the instance: "
|
||||
super_instance_message="Please select/enter the dns name of the superior instance: "
|
||||
description_message="Please enter a description for the server (leave blank to skip): "
|
||||
contact_person_message="Please enter the name of a contact person (leave blank to skip): "
|
||||
contact_email_message="Please enter the email of the contact person (leave blank to skip): "
|
||||
build_version_message="Please enter a build version to use (releases.sapsailing.com): "
|
||||
|
||||
|
||||
function require_image_id(){
|
||||
require_variable "" image_id "" "$image_id_ask_message" "false" "false" $CHOOSE_FROM_IMAGES
|
||||
}
|
||||
|
||||
function require_event_name(){
|
||||
require_variable "$event_name_param" event_name "" "$event_name_ask_message" "true" "false"
|
||||
}
|
||||
|
||||
function require_instance_security_group_id(){
|
||||
require_variable "" instance_security_group_id "" "$instance_security_group_id_ask_message" "false" "false" $CHOOSE_FROM_SECURITY_GROUPS
|
||||
}
|
||||
|
||||
function require_load_balancer(){
|
||||
require_variable "" load_balancer "" "$load_balancer_ask_message" "false" "false" $CHOOSE_FROM_LOAD_BALANCERS
|
||||
}
|
||||
|
||||
function require_instance(){
|
||||
require_variable "" instance "" "$instance_ask_message" "false" "false" $CHOOSE_FROM_INSTANCES
|
||||
}
|
||||
|
||||
function require_region(){
|
||||
require_variable "$region_param" region "$default_region" "$region_ask_message" "false" "false"
|
||||
}
|
||||
|
||||
function require_instance_type(){
|
||||
require_variable "$instance_type_param" instance_type "$default_instance_type" "$instance_type_ask_message" "false" "false"
|
||||
|
||||
}
|
||||
function require_instance_name(){
|
||||
require_variable "$instance_name_param" instance_name "$script_start_time" "$instance_name_ask_message" "false" "false"
|
||||
}
|
||||
|
||||
function require_instance_short_name(){
|
||||
require_variable "$instance_short_name_param" instance_short_name "$timestamp" "$instance_short_name_ask_message" "false" "false"
|
||||
}
|
||||
|
||||
function require_key_name(){
|
||||
require_variable "$key_name_param" key_name "$default_key_name" "$key_name_ask_message" "false" "false"
|
||||
}
|
||||
|
||||
function require_key_file(){
|
||||
require_variable "$key_file_param" key_file "$default_key_file" "$key_file_ask_message" "true" "false"
|
||||
}
|
||||
|
||||
function require_new_admin_password(){
|
||||
require_variable "$new_admin_password_param" new_admin_password "$default_new_admin_password" "$new_admin_password_ask_message" "true" "true"
|
||||
}
|
||||
|
||||
function require_user_username(){
|
||||
if [ ! -z ${user_password+x} ] || [ ! -z "$user_password" ]; then
|
||||
require_variable "$user_username_param" user_username "$default_user_username" "$user_username_ask_message" "true" "false"
|
||||
fi
|
||||
}
|
||||
|
||||
function require_user_password(){
|
||||
if [ ! -z ${user_name+x} ] || [ ! -z "$user_name" ]; then
|
||||
require_variable "$user_password_param" user_password "$default_user_password" "$user_password_ask_message" "true" "true"
|
||||
fi
|
||||
}
|
||||
|
||||
function require_ssh_user(){
|
||||
require_variable "$ssh_user_param" ssh_user "$default_ssh_user" "$ssh_user_ask_message" "false" "false"
|
||||
}
|
||||
|
||||
function require_super_instance(){
|
||||
require_variable "$super_instance_param" super_instance "$default_super_instance" "$super_instance_message" "false" "false" $CHOOSE_FROM_INSTANCES
|
||||
}
|
||||
|
||||
function require_description(){
|
||||
require_variable "$description_param" description "" "$description_message" "true" "false"
|
||||
}
|
||||
|
||||
function require_contact_person(){
|
||||
require_variable "$contact_person_param" contact_person "$default_contact_person" "$contact_person_message" "true" "false"
|
||||
}
|
||||
|
||||
function require_contact_email(){
|
||||
require_variable "$contact_email_param" contact_email "$default_contact_email" "$contact_email_message" "true" "false"
|
||||
}
|
||||
|
||||
function require_build_version(){
|
||||
require_variable "$build_version_param" build_version "$latest_release" "$build_version_message" "false" "false"
|
||||
}
|
||||
@@ -1,7 +1,11 @@
|
||||
declare -- OLD_RESOURCE_JSON="{\"ResourceARN\":\"arn:aws:acm:eu-west-2:017363970217:certificate/d2ae17b0-75ed-4b56-ac12-a80f9e5c493d\",\"Tags\":[{\"Value\":\"true\",\"Key\":\"AutoDiscover\"}]}
|
||||
{\"ResourceARN\":\"arn:aws:ec2:eu-west-2:017363970217:image/ami-39f3e25d\",\"Tags\":[{\"Value\":\"true\",\"Key\":\"AutoDiscover\"}]}
|
||||
{\"ResourceARN\":\"arn:aws:ec2:eu-west-2:017363970217:instance/i-02abdf10071ce9ce6\",\"Tags\":[{\"Value\":\"2018-02-14 06:57:30\",\"Key\":\"Name\"}]}
|
||||
{\"ResourceARN\":\"arn:aws:ec2:eu-west-2:017363970217:instance/i-04eeb1346463540c5\",\"Tags\":[{\"Value\":\"123\",\"Key\":\"Name\"}]}
|
||||
{\"ResourceARN\":\"arn:aws:ec2:eu-west-2:017363970217:instance/i-05f2fda5ce72c2b36\",\"Tags\":[{\"Value\":\"2018-02-14 07:22:33\",\"Key\":\"Name\"}]}
|
||||
{\"ResourceARN\":\"arn:aws:ec2:eu-west-2:017363970217:instance/i-068b644ad5fbe6e5f\",\"Tags\":[{\"Value\":\"12\",\"Key\":\"Name\"}]}
|
||||
{\"ResourceARN\":\"arn:aws:ec2:eu-west-2:017363970217:instance/i-08803ecb16560b18a\",\"Tags\":[{\"Value\":\"2018-02-14 07:15:26\",\"Key\":\"Name\"}]}
|
||||
{\"ResourceARN\":\"arn:aws:ec2:eu-west-2:017363970217:instance/i-08e4a99e69f6d8dce\",\"Tags\":[{\"Value\":\"2018-02-14 07:07:20\",\"Key\":\"Name\"}]}
|
||||
{\"ResourceARN\":\"arn:aws:ec2:eu-west-2:017363970217:instance/i-09330d7744ebef9b3\",\"Tags\":[{\"Value\":\"123\",\"Key\":\"Name\"}]}
|
||||
{\"ResourceARN\":\"arn:aws:ec2:eu-west-2:017363970217:instance/i-096a32ca8c28bedbb\",\"Tags\":[{\"Value\":\"MongoDB\",\"Key\":\"Name\"}]}
|
||||
{\"ResourceARN\":\"arn:aws:ec2:eu-west-2:017363970217:instance/i-0a65849491dfc8562\",\"Tags\":[{\"Value\":\"yxc\",\"Key\":\"Name\"}]}
|
||||
@@ -13,4 +17,4 @@ declare -- OLD_RESOURCE_JSON="{\"ResourceARN\":\"arn:aws:acm:eu-west-2:017363970
|
||||
{\"ResourceARN\":\"arn:aws:ec2:eu-west-2:017363970217:security-group/sg-871732ee\",\"Tags\":[{\"Value\":\"true\",\"Key\":\"AutoDiscover\"},{\"Value\":\"appSecurityGroup\",\"Key\":\"Name\"}]}
|
||||
{\"ResourceARN\":\"arn:aws:ec2:eu-west-2:017363970217:security-group/sg-9732d6ff\",\"Tags\":[{\"Value\":\"test\",\"Key\":\"Name\"}]}
|
||||
{\"ResourceARN\":\"arn:aws:elasticloadbalancing:eu-west-2:017363970217:loadbalancer/app/DummyALB/da70f61a914fc50a\",\"Tags\":[{\"Value\":\"true\",\"Key\":\"AutoDiscover\"}]}"
|
||||
declare -A RESOURCE_MAP=([arn:aws:ec2:eu-west-2:017363970217:instance/i-096a32ca8c28bedbb]="MongoDB,false" [arn:aws:ec2:eu-west-2:017363970217:instance/i-04eeb1346463540c5]="123,false" [arn:aws:ec2:eu-west-2:017363970217:instance/i-09330d7744ebef9b3]="123,false" [arn:aws:ec2:eu-west-2:017363970217:instance/i-0f2e26f9a7860e680]="123,false" [arn:aws:acm:eu-west-2:017363970217:certificate/d2ae17b0-75ed-4b56-ac12-a80f9e5c493d]="Unnamed,true" [arn:aws:elasticloadbalancing:eu-west-2:017363970217:loadbalancer/app/DummyALB/da70f61a914fc50a]="Unnamed,true" [arn:aws:ec2:eu-west-2:017363970217:image/ami-39f3e25d]="Unnamed,true" [arn:aws:ec2:eu-west-2:017363970217:security-group/sg-74c92d1c]="Unnamed,true" [arn:aws:ec2:eu-west-2:017363970217:security-group/sg-871732ee]="appSecurityGroup,true" [arn:aws:ec2:eu-west-2:017363970217:instance/i-0a65849491dfc8562]="yxc,false" [arn:aws:ec2:eu-west-2:017363970217:security-group/sg-9732d6ff]="test,false" [arn:aws:ec2:eu-west-2:017363970217:instance/i-068b644ad5fbe6e5f]="12,false" [arn:aws:ec2:eu-west-2:017363970217:instance/i-0f5308bf09c42d7f9]="123,false" [arn:aws:ec2:eu-west-2:017363970217:instance/i-0c57f03afc68de24c]="Multi Instance,true" [arn:aws:ec2:eu-west-2:017363970217:security-group/sg-7f0c2916]="Database and Messaging,false" )
|
||||
declare -A RESOURCE_MAP=([arn:aws:ec2:eu-west-2:017363970217:instance/i-096a32ca8c28bedbb]="MongoDB,false" [arn:aws:ec2:eu-west-2:017363970217:instance/i-08803ecb16560b18a]="2018-02-14 07:15:26,false" [arn:aws:ec2:eu-west-2:017363970217:instance/i-04eeb1346463540c5]="123,false" [arn:aws:ec2:eu-west-2:017363970217:instance/i-09330d7744ebef9b3]="123,false" [arn:aws:ec2:eu-west-2:017363970217:instance/i-02abdf10071ce9ce6]="2018-02-14 06:57:30,false" [arn:aws:ec2:eu-west-2:017363970217:instance/i-0f2e26f9a7860e680]="123,false" [arn:aws:acm:eu-west-2:017363970217:certificate/d2ae17b0-75ed-4b56-ac12-a80f9e5c493d]="Unnamed,true" [arn:aws:elasticloadbalancing:eu-west-2:017363970217:loadbalancer/app/DummyALB/da70f61a914fc50a]="Unnamed,true" [arn:aws:ec2:eu-west-2:017363970217:image/ami-39f3e25d]="Unnamed,true" [arn:aws:ec2:eu-west-2:017363970217:instance/i-05f2fda5ce72c2b36]="2018-02-14 07:22:33,false" [arn:aws:ec2:eu-west-2:017363970217:security-group/sg-74c92d1c]="Unnamed,true" [arn:aws:ec2:eu-west-2:017363970217:security-group/sg-871732ee]="appSecurityGroup,true" [arn:aws:ec2:eu-west-2:017363970217:instance/i-0a65849491dfc8562]="yxc,false" [arn:aws:ec2:eu-west-2:017363970217:security-group/sg-9732d6ff]="test,false" [arn:aws:ec2:eu-west-2:017363970217:instance/i-068b644ad5fbe6e5f]="12,false" [arn:aws:ec2:eu-west-2:017363970217:instance/i-0f5308bf09c42d7f9]="123,false" [arn:aws:ec2:eu-west-2:017363970217:instance/i-0c57f03afc68de24c]="Multi Instance,true" [arn:aws:ec2:eu-west-2:017363970217:instance/i-08e4a99e69f6d8dce]="2018-02-14 07:07:20,false" [arn:aws:ec2:eu-west-2:017363970217:security-group/sg-7f0c2916]="Database and Messaging,false" )
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
function instance_start(){
|
||||
instance_require
|
||||
instance_preview
|
||||
instance_execute
|
||||
}
|
||||
|
||||
@@ -30,6 +31,19 @@ function instance_require(){
|
||||
require_user_password
|
||||
}
|
||||
|
||||
function instance_preview(){
|
||||
header "Preview"
|
||||
user_data=$(build_user_data)
|
||||
local_echo "An instance will be created with the following specifications: "
|
||||
local_echo "To be implemented..."
|
||||
seek_confirmation "Do you want to continue?"
|
||||
if is_confirmed; then
|
||||
break
|
||||
else
|
||||
break
|
||||
fi
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------
|
||||
# Execute instance scenario
|
||||
# @param $1 user data
|
||||
@@ -38,7 +52,6 @@ function instance_execute() {
|
||||
|
||||
header "Instance Initialization"
|
||||
|
||||
local user_data=$(build_user_data)
|
||||
instance_id=$(create_instance "$user_data")
|
||||
public_dns_name=$(get_public_dns_name $instance_id)
|
||||
wait_for_ssh_connection $ssh_user $public_dns_name
|
||||
@@ -47,6 +60,10 @@ function instance_execute() {
|
||||
|
||||
local port="8888"
|
||||
configure_application $public_dns_name $port $event_name $new_admin_password $user_username $user_pass
|
||||
|
||||
header "Conclusion"
|
||||
|
||||
success "Instance should be reachable through $public_dns_name."
|
||||
}
|
||||
|
||||
function build_user_data(){
|
||||
|
||||
@@ -26,7 +26,7 @@ function shared_instance_require(){
|
||||
require_new_admin_password
|
||||
require_user_username
|
||||
require_user_password
|
||||
|
||||
require_ssh_user
|
||||
require_contact_person
|
||||
require_contact_email
|
||||
require_description
|
||||
@@ -46,8 +46,8 @@ function shared_instance_check_preconditions(){
|
||||
|
||||
local instance_id=$(get_instance_id $super_instance)
|
||||
|
||||
echo "Checking if instance has tag: 'ssh_user'."
|
||||
ssh_user=$(exit_on_fail get_tag_value_for_key $instance_id "ssh_user")
|
||||
# echo "Checking if instance has tag: 'ssh_user'."
|
||||
# ssh_user=$(exit_on_fail get_tag_value_for_key $instance_id "ssh_user")
|
||||
|
||||
echo "Checking if directory $server_dir exists already..."
|
||||
exit_on_fail execute_remote "[ ! -d $server_dir ]"
|
||||
@@ -55,10 +55,9 @@ function shared_instance_check_preconditions(){
|
||||
echo "Checking if ssh connection $ssh_user@$super_instance is working..."
|
||||
exit_on_fail execute_remote ls
|
||||
|
||||
echo "Checking if super instance has user data.\
|
||||
The instance should not have any user data set, otherwise the refreshInstance script will not work properly."
|
||||
|
||||
exit_on_fail [ $(get_user_data_from_instance $instance_id) == "None" ]
|
||||
# echo "Checking if super instance has user data.\
|
||||
# The instance should not have any user data set, otherwise the refreshInstance script will not work properly."
|
||||
# exit_on_fail [ $(get_user_data_from_instance $instance_id) == "None" ]
|
||||
}
|
||||
|
||||
function shared_instance_execute() {
|
||||
@@ -75,13 +74,13 @@ function shared_instance_execute() {
|
||||
exit_on_fail execute_remote mkdir $server_dir
|
||||
|
||||
local_echo "Getting next unused SERVER_PORT..."
|
||||
local server_port=$(find_first_unused_port "SERVER_PORT" $default_server_port)
|
||||
local server_port=$(find_first_unused_port "SERVER_PORT" "8888")
|
||||
|
||||
local_echo "Getting next unused TELNET_PORT..."
|
||||
local telnet_port=$(find_first_unused_port "TELNET_PORT" $default_telnet_port)
|
||||
local telnet_port=$(find_first_unused_port "TELNET_PORT" "14900")
|
||||
|
||||
local_echo "Getting next unused EXPEDITION_PORT..."
|
||||
local expedition_port=$(find_first_unused_port "EXPEDITION_PORT" $default_expedition_port)
|
||||
local expedition_port=$(find_first_unused_port "EXPEDITION_PORT" "2000")
|
||||
|
||||
# copy refreshInstance.sh from /servers/server to sub instance directory
|
||||
local_echo "Copying $refreshInstance_file to $server_dir..."
|
||||
@@ -129,7 +128,7 @@ function shared_instance_execute() {
|
||||
|
||||
header "Event and user creation"
|
||||
|
||||
event_id=$(configure_application $super_instance $port $event_name $new_admin_password $user_username $user_password)
|
||||
event_id=$(configure_application $super_instance $server_port $event_name $new_admin_password $user_username $user_password)
|
||||
|
||||
header "Configuring ALB"
|
||||
|
||||
@@ -146,10 +145,6 @@ function shared_instance_execute() {
|
||||
execute_remote_root "echo -e \"\n# $instance_short_name (${description:-"Unknown"}, ${contact_person:-"Unknown"}, ${contact_email:-"Unknown"})\" >> $events_conf"
|
||||
append_macro_to_001_events_conf "$domain" "$event_id" "root" "$super_instance" "$server_port"
|
||||
|
||||
local_echo "Reloading httpd..."
|
||||
execute_remote_root "apachectl configtest >/dev/null 2>&1"
|
||||
out=$(execute_remote_root "/etc/init.d/httpd reload")
|
||||
|
||||
header "Conclusion"
|
||||
|
||||
success "Sub instance should be reachable through https://$domain."
|
||||
|
||||
@@ -1,18 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
latest_release=$(get_latest_release)
|
||||
autoDiscoverResourceTagName='AutoDiscover'
|
||||
target_group_protocol='HTTPS'
|
||||
target_group_port='443'
|
||||
ssh_retry_interval=2
|
||||
http_retry_interval=5
|
||||
default_instance_name="$script_start_time"
|
||||
default_instance_short_name="$timestamp"
|
||||
events_conf='/etc/httpd/conf.d/001-events.conf'
|
||||
default_server_port='8888'
|
||||
default_telnet_port='14900'
|
||||
default_expedition_port='2000'
|
||||
|
||||
scriptName=`basename $0` #Set Script Name variable
|
||||
scriptBasename="$(basename ${scriptName} .sh)" # Strips '.sh' from scriptName
|
||||
declare -r script_start_time=$(LC_ALL=C date +"%Y-%m-%d %H:%M:%S") # Returns: 2015-06-15 22:34:40
|
||||
|
||||
Reference in new issue
Block a user