mirror of
https://github.com/neoromantique/dotfiles.git
synced 2026-03-14 06:02:54 +03:00
Add (terrible) custom handler for ssh
This commit is contained in:
@@ -1,25 +1,25 @@
|
||||
#!/bin/bash
|
||||
# Copied from: https://git.john.me.tz/jpm/scripts
|
||||
# Passwordless sudo required
|
||||
# David Aizenberg
|
||||
# 2020
|
||||
|
||||
res=$(echo "SecurEdge|homelab|bohdan|Disconnect|Restart" | rofi -sep "|" -dmenu -i -p 'OpenVPN: ' "" -theme Arc-Dark -columns 9 -width 45 -l 1 -hide-scrollbar -eh 1 -location 0 -auto-select -no-fullscreen)
|
||||
|
||||
if [ $res = "SecurEdge" ]; then
|
||||
if [ "$res" = "SecurEdge" ]; then
|
||||
sudo /usr/bin/systemctl stop openvpn@*
|
||||
sudo /usr/bin/systemctl start openvpn@SecurEdge
|
||||
elif [ $res = "homelab" ]; then
|
||||
elif [ "$res" = "homelab" ]; then
|
||||
sudo /usr/bin/systemctl stop openvpn@*
|
||||
sudo /usr/bin/systemctl start openvpn@homelab
|
||||
elif [ $res = "bohdan" ]; then
|
||||
elif [ "$res" = "bohdan" ]; then
|
||||
sudo /usr/bin/systemctl stop openvpn@*
|
||||
sudo /usr/bin/systemctl start openvpn@bogdan
|
||||
elif [ $res = "Disconnect" ]; then
|
||||
elif [ "$res" = "Disconnect" ]; then
|
||||
sudo /usr/bin/systemctl stop openvpn@*
|
||||
elif [ $res = "Restart" ]; then
|
||||
elif [ "$res" = "Restart" ]; then
|
||||
sudo /usr/bin/systemctl restart openvpn@*
|
||||
fi
|
||||
|
||||
if [ "$(pgrep -c i3blocks)" -gt 0 ]; then
|
||||
if [ ! -z "$res" ] && [ "$(pgrep -c i3blocks)" -gt 0 ]; then
|
||||
sleep 2s
|
||||
pkill -SIGRTMIN+10 i3blocks
|
||||
sleep 2s
|
||||
|
||||
26
scripts/rofi/rofi-ssh.sh
Executable file
26
scripts/rofi/rofi-ssh.sh
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
# David Aizenberg
|
||||
# 2020
|
||||
# hosts file format, comma separated
|
||||
# hostname, port, pretty_name, path_to_key user
|
||||
|
||||
|
||||
hostsFile='/home/david/.ssh/ssh.hosts'
|
||||
lines=20
|
||||
|
||||
while read host; do
|
||||
|
||||
if [[ ! ${host:0:1} = \# ]]; then
|
||||
if [ ! -z "$host" ]; then
|
||||
hosts+=$(echo $host | awk -F, '{print $3}')'|'
|
||||
fi
|
||||
fi
|
||||
|
||||
done <$hostsFile
|
||||
|
||||
res=$(echo "${hosts::-1}" | rofi -sep "|" -dmenu -i -p 'SSH: ' "" -theme Arc-Dark -columns 1 -width 45 -l "$lines" -hide-scrollbar -eh1 -location 0 -auto-select -no-fullscreen)
|
||||
if [ ! -z "$res" ]; then
|
||||
connectString=$(cat $hostsFile | grep "$res" | awk -F, '{print "ssh " $5 "@" $1 " -p " $2 " -i " $4}')
|
||||
xfce4-terminal -e "$connectString"
|
||||
fi
|
||||
exit 0
|
||||
Reference in New Issue
Block a user