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.
44 lines
666 B
Bash
44 lines
666 B
Bash
#!/bin/sh
|
|
|
|
different_server() {
|
|
IP=$(printf "" | dmenu -i -p "Enter host:")
|
|
# Would you like to add this to saved servers?
|
|
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
|