blob: 06099234795ec707ce236784e82c6bb133c1be72 (
plain)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
property=1
while [ -n "$property" ]; do
property=$(qvm-prefs "$qube" | dmenu-unlinked -l 45 -p "$qube:" | cut -f1 -d\ )
if [ -n "$property" ]; then
case $property in
autostart)
value=$(printf 'False\nTrue' | dmenu-unlinked -i -p "Set autostart of $qube to:");;
debug)
value=$(printf 'False\nTrue' | dmenu-unlinked -i -p "Set debug mode of $qube to:");;
default_dispvm)
if [ -z "$LIST_DISPTEMP" ]; then
# [mediocre] Look up disposable templates in a very slow way because qvm-ls does not offer a flag for them
for n in $(qvm-ls --raw-data -O NAME,FLAGS | grep '|a.....-.$' | cut -d '|' -f1); do
qvm-prefs "$n" template_for_dispvms | grep -q True &&
LIST_DISPTEMP="$LIST_DISPTEMP\n$n"
done
fi
value=$(printf "(Default)\n(None)$LIST_DISPTEMP" | dmenu-unlinked -l 50 -p "Select default dispvm for $qube:");;
default_user)
value=$(echo --default | dmenu-unlinked -p "Enter the name of the default user for $qube:");;
include_in_backups)
value=$(printf 'False\nTrue' | dmenu-unlinked -i -p "Include $qube in backups?");;
kernel)
value=$(printf "(Default)\n(None)" | dmenu-unlinked -l 2 -p "Enter the kernel to be used by $qube:");;
kernelopts)
value=$(echo --default | dmenu-unlinked -p "Enter the kernel options for $qube:") &&
nyprompt "Set kernel options for $qube to \"$value\"?" || unset value;;
label)
if qvm-check -q --running "$qube"; then
echo Go back... | dmenu-unlinked -p "$qube needs to be powered off, in order to change its label." > /dev/null 2>&1
else
value=$(printf 'Purple\nBlue\nGray\nGreen\nYellow\nOrange\nRed\nBlack' | dmenu-unlinked -i -l 8 -p "Select label for $qube:" | awk '{print tolower($0)}')
fi;;
mac)
value=$(echo --default | dmenu-unlinked -p "Enter the MAC address for $qube:") &&
nyprompt "Set MAC address of $qube to $value?" || unset value;;
maxmem)
value=$(echo --default | dmenu-unlinked -p "Enter the maximum amount of memory in MB to be allocated to $qube. Setting it to 0 will disable dynamic memory balancing.") &&
if nyprompt "Set maximum memory of $qube to $value MB?"; then
# For linux qubes, initial memory can not be less than one tenth of maxmem
# so we will automatically set the minimum allowed value.
# Users can still overwrite this manually via fqvm_prefs - memory.
minmem=$(( $value / 10 ))
[ "$(qvm-prefs $qube memory)" -lt "$minmem" ] && qvm-prefs "$qube" memory "$minmem"
else
unset value
fi;;
memory)
value=$(echo --default | dmenu-unlinked -p "Enter the amount of initial memory in MB to be allocated to $qube:") &&
nyprompt "Set initial memory of $qube to $value MB?" || unset value;;
netvm)
get_list netvm
value=$(printf "(Default)\n(None)\n$list" | dmenu-unlinked -l 50 -p "Select netvm for $qube:");;
provides_network)
value=$(printf 'False\nTrue' | dmenu-unlinked -i -p "Should $qube provide networking to other qubes?");;
qrexec_timeout)
value=$(echo --default | dmenu-unlinked -p "Enter the time in seconds, after which qrexec connection attempts are deemed a failure for $qube:") &&
nyprompt "Set qrexec timeout for $qube to $value seconds?" || unset value;;
shutdown_timeout)
value=$(echo --default | dmenu-unlinked -p "Enter the time in seconds to wait for shutdown, after which $qube may be forcefully powered off:") &&
nyprompt "Set shutdown timeout for $qube to $value seconds?" || unset value;;
template)
if qvm-check -q --running "$qube"; then
echo Go back... | dmenu-unlinked -p "$qube needs to be powered off, in order to change its template." > /dev/null 2>&1
else
get_list template
value=$(printf "(Default)\n$list" | dmenu-unlinked -l 50 -p "Select template for $qube:") &&
(sleep 2 && qvm-appmenus -q --update "$qube"&)
fi;;
template_for_dispvms)
value=$(printf 'False\nTrue' | dmenu-unlinked -i -p "Should $qube be used as a template for disposable qubes?");;
vcpus)
value=$(echo --default | dmenu-unlinked -p "Enter the number of CPU cores that should be made available to $qube:") &&
nyprompt "Set number of CPU cores available to $qube to $value?" || unset value;;
virt_mode)
value=$(printf 'PVH\nHVM\nPV' | dmenu-unlinked -i -l 3 -p "Select virtualisation mode for $qube:");;
*)
esac
if [ -n "$value" ]; then
if [ "$value" = '(None)' ]; then value=''
elif [ "$value" = '(Default)' ]; then value=--default
fi
qvm-prefs "$qube" "$property" "$value" ||
echo Go back... | dmenu-unlinked -p "Error: Failed to set $property to '$value'!" > /dev/null 2>&1
unset value
fi
fi
done
|