forked from ISPsystem/isp-maintenance
		
	update: new config support DE go server and --test option
This commit is contained in:
		
							parent
							
								
									5815c84b07
								
							
						
					
					
						commit
						ba6dd53f6c
					
				@ -5,7 +5,7 @@
 | 
				
			|||||||
# -- -- -- -- -- --
 | 
					# -- -- -- -- -- --
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# INIT GLOBAL VARIABLES:
 | 
					# INIT GLOBAL VARIABLES:
 | 
				
			||||||
_VERSION="0.1.0"
 | 
					_VERSION="0.1.1"
 | 
				
			||||||
_SCRIPT_NAME="$(basename $0)"
 | 
					_SCRIPT_NAME="$(basename $0)"
 | 
				
			||||||
_GO_CMD="go3"
 | 
					_GO_CMD="go3"
 | 
				
			||||||
_DEBUG_MODE=false
 | 
					_DEBUG_MODE=false
 | 
				
			||||||
@ -67,6 +67,7 @@ help() {
 | 
				
			|||||||
	printf "                                                                   \n"
 | 
						printf "                                                                   \n"
 | 
				
			||||||
	printf "${script} --init | init config file                                \n"
 | 
						printf "${script} --init | init config file                                \n"
 | 
				
			||||||
	printf "${script} --crt  | get ssh certificate for go3 connections         \n"
 | 
						printf "${script} --crt  | get ssh certificate for go3 connections         \n"
 | 
				
			||||||
 | 
						printf "${script} --test | check go3 connection availability               \n"
 | 
				
			||||||
	printf "                                                                   \n"
 | 
						printf "                                                                   \n"
 | 
				
			||||||
	printf "${script} --bill my.example.com                                    \n"
 | 
						printf "${script} --bill my.example.com                                    \n"
 | 
				
			||||||
	printf "${script} --vm 0.0.0.0 --ssh | only ssh access                     \n"
 | 
						printf "${script} --vm 0.0.0.0 --ssh | only ssh access                     \n"
 | 
				
			||||||
@ -90,8 +91,10 @@ help() {
 | 
				
			|||||||
	printf " --tty              for vm6/dci6 echo cmd for run container        \n"
 | 
						printf " --tty              for vm6/dci6 echo cmd for run container        \n"
 | 
				
			||||||
	printf " --mgrctl [args]    for vm6/dci6 customize access params           \n"
 | 
						printf " --mgrctl [args]    for vm6/dci6 customize access params           \n"
 | 
				
			||||||
	printf "                                                                   \n"
 | 
						printf "                                                                   \n"
 | 
				
			||||||
 | 
						printf "Single options:                                                    \n"
 | 
				
			||||||
	printf " --init     | -i    generate configuration                         \n"
 | 
						printf " --init     | -i    generate configuration                         \n"
 | 
				
			||||||
	printf " --crt      | -c    generate ssh cert                              \n"
 | 
						printf " --crt      | -c    generate ssh cert                              \n"
 | 
				
			||||||
 | 
						printf " --test     | -t    check go3 connection availability              \n"
 | 
				
			||||||
	printf " --version  | -v    print version                                  \n"
 | 
						printf " --version  | -v    print version                                  \n"
 | 
				
			||||||
	printf " --help     | -h    print this message and exit                    \n"
 | 
						printf " --help     | -h    print this message and exit                    \n"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -115,7 +118,9 @@ init_config() {
 | 
				
			|||||||
		continue_handler
 | 
							continue_handler
 | 
				
			||||||
	fi
 | 
						fi
 | 
				
			||||||
	# get user unputs:
 | 
						# get user unputs:
 | 
				
			||||||
	read -p "Enter go server address: "            _GO_SERVER_ADDR
 | 
						read -p "Enter russian go server address: "    _GO_SERVER_ADDR_RUSSIAN
 | 
				
			||||||
 | 
						read -p "Enter germany go server address: "    _GO_SERVER_ADDR_GERMANY
 | 
				
			||||||
 | 
						read -p "Enter test go server address: "       _GO_SERVER_ADDR_TEST
 | 
				
			||||||
	read -p "Enter vault server address: "         _VAULT_SERVER_ADDR
 | 
						read -p "Enter vault server address: "         _VAULT_SERVER_ADDR
 | 
				
			||||||
	read -p "Enter username: "                     _SSH_PRIVATE_KEY_USER
 | 
						read -p "Enter username: "                     _SSH_PRIVATE_KEY_USER
 | 
				
			||||||
	read -p "Enter full path to ssh private key: " _SSH_PRIVATE_KEY_PATH
 | 
						read -p "Enter full path to ssh private key: " _SSH_PRIVATE_KEY_PATH
 | 
				
			||||||
@ -125,7 +130,9 @@ init_config() {
 | 
				
			|||||||
	# save config:
 | 
						# save config:
 | 
				
			||||||
	mkdir -p $_CONFIG_DIR
 | 
						mkdir -p $_CONFIG_DIR
 | 
				
			||||||
	cat << EOF > "${_CONFIG}"
 | 
						cat << EOF > "${_CONFIG}"
 | 
				
			||||||
GO_SERVER_ADDR=$_GO_SERVER_ADDR
 | 
					GO_SERVER_ADDR_RUSSIAN=$_GO_SERVER_ADDR_RUSSIAN
 | 
				
			||||||
 | 
					GO_SERVER_ADDR_GERMANY=$_GO_SERVER_ADDR_GERMANY
 | 
				
			||||||
 | 
					GO_SERVER_ADDR_TEST=$_GO_SERVER_ADDR_TEST
 | 
				
			||||||
VAULT_SERVER_ADDR=$_VAULT_SERVER_ADDR
 | 
					VAULT_SERVER_ADDR=$_VAULT_SERVER_ADDR
 | 
				
			||||||
SSH_PRIVATE_KEY_USER=$_SSH_PRIVATE_KEY_USER
 | 
					SSH_PRIVATE_KEY_USER=$_SSH_PRIVATE_KEY_USER
 | 
				
			||||||
SSH_PRIVATE_KEY_PATH=$_SSH_PRIVATE_KEY_PATH
 | 
					SSH_PRIVATE_KEY_PATH=$_SSH_PRIVATE_KEY_PATH
 | 
				
			||||||
@ -156,9 +163,16 @@ load_config() {
 | 
				
			|||||||
	
 | 
						
 | 
				
			||||||
	while IFS="=" read -r key value; do
 | 
						while IFS="=" read -r key value; do
 | 
				
			||||||
		case "$key" in
 | 
							case "$key" in
 | 
				
			||||||
			"GO_SERVER_ADDR") 
 | 
								"GO_SERVER_ADDR_RUSSIAN")
 | 
				
			||||||
 | 
									_GO_SERVER_ADDR_RUSSIAN="$value"
 | 
				
			||||||
				_GO_SERVER_ADDR="$value"
 | 
									_GO_SERVER_ADDR="$value"
 | 
				
			||||||
				;;
 | 
									;;
 | 
				
			||||||
 | 
								"GO_SERVER_ADDR_GERMANY")
 | 
				
			||||||
 | 
									_GO_SERVER_ADDR_GERMANY="$value"
 | 
				
			||||||
 | 
									;;
 | 
				
			||||||
 | 
								"GO_SERVER_ADDR_TEST")
 | 
				
			||||||
 | 
									_GO_SERVER_ADDR_TEST="$value"
 | 
				
			||||||
 | 
									;;
 | 
				
			||||||
			"VAULT_SERVER_ADDR")
 | 
								"VAULT_SERVER_ADDR")
 | 
				
			||||||
				_VAULT_SERVER_ADDR="$value"
 | 
									_VAULT_SERVER_ADDR="$value"
 | 
				
			||||||
				;;
 | 
									;;
 | 
				
			||||||
@ -380,6 +394,24 @@ renewal_crt() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					test_go3_connection() {
 | 
				
			||||||
 | 
						# force only ssh connections without platform features:
 | 
				
			||||||
 | 
						_IS_SSH_ONLY=true
 | 
				
			||||||
 | 
						# set fake client address:
 | 
				
			||||||
 | 
						_PLATFORM_IP_ADDR="${_GO_SERVER_ADDR_TEST}"
 | 
				
			||||||
 | 
						_PLATFORM_SSH_PORT=22
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						echo "Run TEST: $_GO_SERVER_ADDR_RUSSIAN connection"
 | 
				
			||||||
 | 
						get_access
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						echo "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						echo "Run TEST: $_GO_SERVER_ADDR_GERMANY connection"
 | 
				
			||||||
 | 
						_GO_SERVER_ADDR="${_GO_SERVER_ADDR_GERMANY}"
 | 
				
			||||||
 | 
						get_access
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Parse user options
 | 
					# Parse user options
 | 
				
			||||||
optparser() {
 | 
					optparser() {
 | 
				
			||||||
	# count user-passed options:
 | 
						# count user-passed options:
 | 
				
			||||||
@ -420,6 +452,9 @@ optparser() {
 | 
				
			|||||||
			--go|--go3)
 | 
								--go|--go3)
 | 
				
			||||||
				_GO_CMD=$(sed 's~[^[:alnum:]/]\+~~g' <<< "$1")
 | 
									_GO_CMD=$(sed 's~[^[:alnum:]/]\+~~g' <<< "$1")
 | 
				
			||||||
				;;
 | 
									;;
 | 
				
			||||||
 | 
								--de)
 | 
				
			||||||
 | 
									_GO_SERVER_ADDR="${_GO_SERVER_ADDR_GERMANY}"
 | 
				
			||||||
 | 
									;;
 | 
				
			||||||
			--mgrctl|--tty|--ssh)
 | 
								--mgrctl|--tty|--ssh)
 | 
				
			||||||
				if [[ "$1" == "--mgrctl" ]]; then
 | 
									if [[ "$1" == "--mgrctl" ]]; then
 | 
				
			||||||
					_IS_MGRCTL_ARGS=true
 | 
										_IS_MGRCTL_ARGS=true
 | 
				
			||||||
@ -440,6 +475,10 @@ optparser() {
 | 
				
			|||||||
				renewal_crt
 | 
									renewal_crt
 | 
				
			||||||
				exit 0
 | 
									exit 0
 | 
				
			||||||
				;;
 | 
									;;
 | 
				
			||||||
 | 
								--test|-t)
 | 
				
			||||||
 | 
									test_go3_connection
 | 
				
			||||||
 | 
									exit 0
 | 
				
			||||||
 | 
									;;
 | 
				
			||||||
			--help|-h)
 | 
								--help|-h)
 | 
				
			||||||
				help
 | 
									help
 | 
				
			||||||
				exit 0
 | 
									exit 0
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user