forked from ISPsystem/isp-maintenance
		
	Fix: help message, init func and ssh-add cmd in --crt
This commit is contained in:
		
							parent
							
								
									da3e61eccb
								
							
						
					
					
						commit
						6c6df42e7f
					
				| @ -6,7 +6,7 @@ | ||||
| 
 | ||||
| # INIT GLOBAL VARIABLES: | ||||
| _VERSION="0.1.0" | ||||
| _SCRIPT_NAME="$0" | ||||
| _SCRIPT_NAME="$(basename $0)" | ||||
| _GO_CMD="go3" | ||||
| _DEBUG_MODE=false | ||||
| 
 | ||||
| @ -65,20 +65,21 @@ help() { | ||||
| 	printf "                                                              \n" | ||||
| 	printf "Examples:                                                     \n" | ||||
| 	printf "                                                              \n" | ||||
| 	printf "./gogo.sh --init | init config file                           \n" | ||||
| 	printf "./gogo.sh --crt  | get ssh certificate for go3 connections    \n" | ||||
| 	printf "${script} --init | init config file                           \n" | ||||
| 	printf "${script} --crt  | get ssh certificate for go3 connections    \n" | ||||
| 	printf "                                                              \n" | ||||
| 	printf "./gogo.sh --bill my.example.com                               \n" | ||||
| 	printf "./gogo.sh --vm 0.0.0.0 --ssh | only ssh access                \n" | ||||
| 	printf "./gogo.sh --vm 0.0.0.0 --tty | use mgrctl interactive         \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 --tty | use mgrctl interactive         \n" | ||||
| 	printf "                                                              \n" | ||||
| 	printf "./gogo.sh --dci 0.0.0.0 --mgrctl user access --id 3 --count 5 \n" | ||||
| 	printf "./gogo.sh --dci 0.0.0.0 --mgrctl user ls --admins             \n" | ||||
| 	printf "./gogo.sh --dci 0.0.0.0 --mgrctl user --help                  \n" | ||||
| 	printf "./gogo.sh --vm 0.0.0.0 --port 22122 --mgrctl user ls --admins \n" | ||||
| 	printf "./gogo.sh --dns ns1.example.com --web-port 1501               \n" | ||||
| 	printf "./gogo.sh --dns ns1.example.com --port 22122 --web-port 1501  \n" | ||||
| 	printf "./gogo.sh --bill my.example.com --port 22 --web-port 1501     \n" | ||||
| 	printf "${script} --dci 0.0.0.0 --mgrctl user access --id 3 --count 5 \n" | ||||
| 	printf "${script} --dci 0.0.0.0 --mgrctl user ls --admins             \n" | ||||
| 	printf "${script} --dci 0.0.0.0 --mgrctl user --help                  \n" | ||||
| 	printf "${script} --vm 0.0.0.0 --port 22122 --mgrctl user ls --admins \n" | ||||
| 	printf "${script} --vm 0.0.0.0 --tty --mgrctl user ls --admins        \n" | ||||
| 	printf "${script} --dns ns1.example.com --web-port 1501               \n" | ||||
| 	printf "${script} --dns ns1.example.com --port 22122 --web-port 1501  \n" | ||||
| 	printf "${script} --bill my.example.com --port 22 --web-port 1501     \n" | ||||
| 	printf "                                                              \n" | ||||
| 	printf "Options:                                                      \n" | ||||
| 	printf "                                                              \n" | ||||
| @ -86,6 +87,7 @@ help() { | ||||
| 	printf " --port     | -p       ssh port,   default 22                 \n" | ||||
| 	printf " --web-port | -wp      web port,   default 443                \n" | ||||
| 	printf " --go/--go3            go version, default go3                \n" | ||||
| 	printf " --ssh                 open only ssh session                  \n" | ||||
| 	printf " --tty                 for vm6/dci6 echo cmd for run container\n" | ||||
| 	printf " --mgrctl [args]       for vm6/dci6 customize access params   \n" | ||||
| 	printf "                                                              \n" | ||||
| @ -104,12 +106,12 @@ continue_handler() { | ||||
| # Init script configuration file: | ||||
| init_config() { | ||||
| 	# Lables: | ||||
| 	local warning=$(colorize RED "WARNING! ") | ||||
| 	local success=$(colorize GREEN "SUCCESS! ") | ||||
| 	local warning=$(colorize RED "WARNING!") | ||||
| 	local success=$(colorize GREEN "SUCCESS!") | ||||
| 	local script_name=$(colorize GREEN "${_SCRIPT_NAME}") | ||||
| 	# check if config file exists: | ||||
| 	if [ -f $_CONFIG ]; then | ||||
| 		echo "${warning}: Config file is already exists" | ||||
| 		echo "${warning} Config file is already exists" | ||||
| 		echo "New initialization rewrites current config" | ||||
| 		continue_handler | ||||
| 	fi | ||||
| @ -133,7 +135,9 @@ SSH_CRT_FILE=$_SSH_CRT_FILE | ||||
| MGRCTL_IMAGE=$_MGRCTL_IMAGE | ||||
| DEBUG_MODE=false | ||||
| EOF | ||||
| 	echo "${success}: Config file was created, run ${script_name} again" | ||||
| 	echo "" | ||||
| 	echo "${success} Config file was created, run ${script_name} again" | ||||
| 	echo "" | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| @ -373,7 +377,7 @@ set_ssh_agent() { | ||||
| renewal_crt() { | ||||
| 	export VAULT_ADDR=$_VAULT_SERVER_ADDR | ||||
| 	get_vault_crt $_VAULT_SSH_PUBLIC_KEY $_SSH_CRT_FILE | ||||
| 	set_ssh_agent $SSH_PRIVATE_KEY_PATH | ||||
| 	set_ssh_agent $_SSH_PRIVATE_KEY_PATH | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| @ -386,6 +390,13 @@ optparser() { | ||||
| 		help | ||||
| 		exit 2 | ||||
| 	fi | ||||
| 	# run init config if flag --init and exit: | ||||
| 	if [[ "$1" == "--init" ]]; then | ||||
| 		init_config | ||||
| 		exit 0 | ||||
| 	fi | ||||
| 	# load config from config file: | ||||
| 	load_config | ||||
| 	# parse opts: | ||||
| 	while [ ! -z "$1" ]; do | ||||
| 		case "$1" in | ||||
| @ -426,10 +437,6 @@ optparser() { | ||||
| 					_IS_SSH_ONLY=true | ||||
| 				fi | ||||
| 				;; | ||||
| 			--init|-i) | ||||
| 				init_config | ||||
| 				exit 0 | ||||
| 				;; | ||||
| 			--crt|-c) | ||||
| 				renewal_crt | ||||
| 				exit 0 | ||||
| @ -456,7 +463,6 @@ optparser() { | ||||
| 
 | ||||
| # Entrypoint: | ||||
| main() { | ||||
| 	load_config | ||||
| 	optparser $@ | ||||
| 	get_access | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user