tunnelier tidying

This commit is contained in:
q
2017-08-20 00:06:24 +03:00
parent a288287aaf
commit d70d240cf5

View File

@@ -72,7 +72,7 @@ function list_all_ssh() {
read -t 600 inputpid read -t 600 inputpid
[[ "$inputpid" =~ $number_re ]] && { [[ "$inputpid" =~ $number_re ]] && {
kill $inputpid ask_to_kill $inputpid
} }
} }
@@ -99,6 +99,13 @@ function run_command() {
eval $( get_command "$1" ) eval $( get_command "$1" )
} }
function ask_to_kill() {
printf "${colRow}\nPID: $1\n k kill\n t terminate${colZ}\n"
read -t 600 input2
[[ "$input2" = "k" ]] && kill $1
[[ "$input2" = "t" ]] && kill -9 $1
}
[[ -n "$2" ]] && { [[ -n "$2" ]] && {
run_args "$@" run_args "$@"
@@ -131,12 +138,9 @@ while true; do
this_pid="$( get_pid "${ids[$j]}" )" this_pid="$( get_pid "${ids[$j]}" )"
[[ -n "$this_pid" ]] && { [[ -n "$this_pid" ]] && {
# PID exists, ask to kill # PID exists, ask to kill
printf "\n ${colRow}k kill\n t terminate${colZ}\n" ask_to_kill "$this_pid"
read -t 600 input2
[[ "$input2" = "k" ]] && kill $( get_pid "${ids[$j]}" )
[[ "$input2" = "t" ]] && kill -9 $( get_pid "${ids[$j]}" )
} }
[[ -z "$this_pid" ]] && { [[ -z "$this_pid" ]] && {
# PID empty, run # PID empty, run
run_command "${ids[$j]}" run_command "${ids[$j]}"
sleep 1 sleep 1