Added gui
This commit is contained in:
parent
4e452e26d7
commit
48373e6be6
|
@ -0,0 +1,82 @@
|
|||
#!/bin/sh
|
||||
|
||||
server_address="tilde.town!tilde.team"
|
||||
login=""
|
||||
ssh_dir="$HOME/.ssh"
|
||||
priv_key_path=" "
|
||||
|
||||
get_field(){
|
||||
field_num="$1"
|
||||
info="$2"
|
||||
|
||||
echo "$info" | cut -f "$field_num" -d '|'
|
||||
}
|
||||
|
||||
error_box(){
|
||||
error_text="$1"
|
||||
echo "Error: $error_text"
|
||||
yad \
|
||||
--width "250" \
|
||||
--image "dialog-error" \
|
||||
--title "Error!" \
|
||||
--text "$error_text"
|
||||
}
|
||||
|
||||
info_box(){
|
||||
info_text="$1"
|
||||
echo "$info_text"
|
||||
yad \
|
||||
--no-buttons \
|
||||
--width "250" \
|
||||
--image "dialog-info" \
|
||||
--title "Info" \
|
||||
--text "$info_text"
|
||||
}
|
||||
|
||||
get_info() {
|
||||
error_num="0"
|
||||
error_msg=""
|
||||
info=$(yad \
|
||||
--title="New server setup" \
|
||||
--text="Add a new server" \
|
||||
--form \
|
||||
--field="Server":CB \
|
||||
--field="Login" \
|
||||
--field="SSH Directory":DIR \
|
||||
--field="Private key":FL \
|
||||
"$server_address" "$login" "$ssh_dir" "$priv_key_path")
|
||||
|
||||
server_address=$(get_field "1" "$info")
|
||||
login=$(get_field "2" "$info")
|
||||
ssh_dir=$(get_field "3" "$info")
|
||||
priv_key_path=$(get_field "4" "$info")
|
||||
|
||||
if test -z "$login"
|
||||
then
|
||||
error_msg="No login provided!"
|
||||
error_num=$(( error_num + 1))
|
||||
fi
|
||||
|
||||
if test -d "$(echo "$priv_key_path" | sed 's/\/ *$//')"
|
||||
then
|
||||
error_msg="$error_msg\nNo private key provided!"
|
||||
error_num=$(( error_num + 1))
|
||||
fi
|
||||
|
||||
if [ $error_num -gt '0' ]
|
||||
then
|
||||
error_box "$error_msg"
|
||||
get_info
|
||||
fi
|
||||
}
|
||||
|
||||
test_info() {
|
||||
info_box "Attempting to log in with the provided credentials"
|
||||
if ssh -qF "$ssh_temp_config" "$server_name" exit
|
||||
then
|
||||
info_box "Login success! writing config..."
|
||||
fi
|
||||
}
|
||||
|
||||
get_info
|
||||
test_info
|
Loading…
Reference in New Issue