-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathupdate-remmina.sh
More file actions
executable file
·69 lines (63 loc) · 1.87 KB
/
Copy pathupdate-remmina.sh
File metadata and controls
executable file
·69 lines (63 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env bash
# Desccription: Script for generating .remmina files to SSH tunnel VNC console on ganeti nodes
# Dependencies: jq, curl, genders
# Written by scellef, 27 Apr 2017
ganetiUrl="https://example.com:5080/2/instances"
remminaDir="${HOME}/.local/share/remmina"
function error { IFS='\n' printf >&2 "[1;31mERROR: %s[0m\n" "$*" ;}
function success { IFS='\n' printf >&2 "[1;32mSUCCESS: %s[0m\n" "$*" ;}
function warning { IFS='\n' printf >&2 "[1;33mWARNING: %s[0m\n" "$*" ;}
function prompt { IFS='\n' printf >&2 "[1;36m%s[0m\n" "$*" ;}
function quit { prompt "Exiting..." ; exit 0 ;}
function check_dependencies {
command -v curl 2> /dev/null >&2 || error "'curl' not in your PATH."
command -v jq 2> /dev/null >&2 || error "'jq' not in your PATH."
command -v nodeattr 2> /dev/null >&2 || error "'nodeattr' not in your PATH."
}
if [ $@ ] ; then
instances=("$@")
else
instances=( $(nodeattr -s virt=ganeti) )
fi
for instance in ${instances[*]} ; do
server=$(curl -sk ${ganetiUrl}/${instance} | jq '[.pnode,.network_port|tostring]|join(":")')
if [ $server == "null:null" ] ; then
warning "$instance not found. Is this a ganeti instance?"
else
sed -e "s/INSTANCE/$instance/" -e "s/SERVER/$server/" -e 's/"//g' << EOF > ${remminaDir}/${instance}.remmina \
&& success "Remmina configuration file for '$instance' written!" \
|| error "Could not write configuration file for '$instance'!"
[remmina]
keymap=
ssh_auth=2
quality=9
disableencryption=0
postcommand=
ssh_privatekey=${HOME}/.ssh/id_rsa
viewmode=1
ssh_charset=UTF-8
window_maximize=0
password=
group=Ganeti
name=INSTANCE
precommand=
proxy=
ssh_username=$USER
ssh_loopback=1
viewonly=0
disableclipboard=0
protocol=VNC
ssh_server=
window_width=874
window_height=875
ssh_enabled=1
username=$USER
showcursor=0
disablepasswordstoring=0
colordepth=32
server=SERVER
disableserverinput=0
EOF
fi
done
quit