You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
872 B
Bash

#!/bin/sh
add_server() {
add_host=$(printf "No\nYes" | dmenu -i -p "Would you like to add this to saved servers?")
case "$add_host" in
"Yes")
;;
"No")
;;
esac
}
different_server() {
IP=$(printf "" | dmenu -i -p "Enter host:")
# Would you like to add this to saved servers?
# Connect to the server via ssh
st -e ssh $IP
}
select_ssh() {
DNSSTRING=''
INPUT=~/.local/bin/dmenu/sshservers.csv
# Loop the CSV
while IFS=, read -r dns ip
do
DNSSTRING="$dns\n$DNSSTRING"
done < $INPUT
# Dmenu Prompt
server=$(printf "$DNSSTRING\nunlisted" | dmenu -i -p "Server:")
# Bad practise, but to test it works
while IFS=, read -r dns ip
do
case "$server" in
$dns)
st -e ssh $ip;;
"unlisted")
different_server
break;;
esac
done < $INPUT
}
case "$1" in
"thinkcentre")
internal_thinkcentre;;
*)
select_ssh;;
esac