Debian Codegraph @

etc/config.pl

raw
1 # /etc/qemu-web-desktop/config.pl: Configuration for qemu-web-desktop
2 #
3 # It is recommended to overload specific configuration in separate *.pl files
4 # located in /etc/qemu-web-desktop/config.d/
5 #
6 # Think about editing the /usr/share/qemu-web-desktop/html/desktop/index.html
7 # to comment/un-comment sections (GPU, oneshot, user scripts, ...).
8 #
9 # This file contains the following sections:
10 # - WHERE THINGS ARE
11 # - MACHINE DEFAULT SETTINGS
12 # - SERVICE CONTRAINTS
13 # - USER AUTHENTICATION
14 # - WEB SERVICE APPEARANCE
15 #
16 # Full documentation at:
17 # https://gitlab.com/soleil-data-treatment/soleil-software-projects/qemu-web-desktop
18 #
19 # When relevant, the equivalent OpenStack naming is indicated (as documented
20 # in https://docs.openstack.org/nova/latest/configuration/config.html)
21
22
23
24
25 # SECTION: WHERE THINGS ARE ----------------------------------------------------
26 # adapt to Darwin/Apple macos (brew)
27 my $p="";
28 if ($^O eq 'darwin') {
29 $p="/opt/homebrew"; # WARNING: brew is not available for www user/macos. Must add static path.
30 $ENV{PATH} = "$p/bin:" . $ENV{PATH}; # add brew commands to search path
31 # `brew --prefix`;
32 }
33
34 # Name of service, used as directory and e.g. http://127.0.0.1/qemu-web-desktop
35 $config{service} = "qemu-web-desktop"; # change if you move/rename the service
36
37 # Full path to service HTML root (e.g. landing page)
38 $config{dir_html} = "$p/usr/share/$config{service}/html";
39
40 # Full path to root of the service area (for data and VM)
41 $config{dir_service} = "$p/var/lib/$config{service}";
42
43 # Full path to machines (ISO,VM)
44 $config{dir_machines} = "$config{dir_service}/machines";
45
46 # Full path to snapshots and temporary files OpenStack DEFAULT.instances_path
47 $config{dir_snapshots} = "$config{dir_service}/snapshots";
48
49 # Full path to snapshot config/lock files. Must NOT be accessible from http://
50 # e.g. /tmp to store "desktop_XXXXXXXX.json" files
51 #
52 # NOTE: apache has a protection in:
53 # /etc/systemd/system/multi-user.target.wants/apache2.service
54 # PrivateTmp=true
55 # which creates a '/tmp' in e.g. /tmp/systemd-private-*-apache2.service-*/
56 $config{dir_cfg} = File::Spec->tmpdir(); # OpenStack DEFAULT.tempdir
57
58 # Full path to noVNC, e.g. "/usr/share/novnc". Must contain "vnc.html"
59 $config{dir_novnc} = "$p/usr/share/novnc";
60
61 # Websockify command, e.g. "/usr/bin/websockify"
62 $config{dir_websockify} = "websockify";
63
64 # LOG file (record START/STOP and errors). File must exist and be RW.
65 $config{service_logfile} = "$p/var/log/$config{service}.log";
66
67
68 # SECTION: MACHINE DEFAULT SETTINGS --------------------------------------------
69
70 # Max session life time in sec. 1 day is 86400 s. Highly recommended.
71 # Use 0 to disable (infinite). This value bounds the selectable life-time from the form.
72 $config{snapshot_lifetime} = 86400*4;
73
74 # Default nb of CPU per session.
75 $config{snapshot_alloc_cpu} = 1; # QEMU -smp; OpenStack DEFAULT.initial_cpu_allocation_ratio
76
77 # Default nb of RAM per session (in GB).
78 $config{snapshot_alloc_mem} = 4; # QEMU -m; OpenStack DEFAULT.initial_ram_allocation_ratio
79
80 # Default size of disk per session (in GB). Only for ISO machines.
81 $config{snapshot_alloc_disk} = 30.0; # OpenStack DEFAULT.initial_disk_allocation_ratio
82
83 # Option to work on master images. When not writable, still use a backing snapshot.
84 $config{snapshot_use_master} = 0;
85
86 # Default machine to run
87 $config{machine} = '-';
88
89 # QEMU executable. Default 'auto' is set from native host (only for arm64 and x86_64).
90 # Adapt to the architecture you run on.
91 # qemu-system-x86_64 on x86_64 (intel/amd64)
92 # qemu-system-aarch64 on ARM (arm64, incl. Apple/Silicon)
93 $config{qemu_exec} = "auto";
94
95 # QEMU options. Default 'auto' uses best settings. Otherwise, we suggest:
96 # For native x86: "-M pc,accel=kvm -enable-kvm -cpu host,kvm=off -vga virtio -device virtio-gpu"
97 # For native ARM "-M virt -enable-kvm -cpu host -device virtio-gpu -bios $EFI"
98 # For Apple/ARM: "-M virt,accel=hvf -cpu host -device virtio-gpu -bios $EFI"
99 # Else use: "-M virt" (may require an EFI file)
100 # EFI files are provided by e.g. qemu-efi-aarch64
101 $config{qemu_exec_options} = "auto";
102
103 # Boot delay before displaying the connection URL [sec]
104 $config{boot_delay} = 5;
105
106 # Set a list of mounts to export into VMs.
107 # These are tested for existence before mounting. The QEMU mount_tag is set to
108 # The last word of mount path prepended with 'host_'.
109 # Use e.g. `mount -t 9p -o trans=virtio,access=client host_media /mnt/media` in guest.
110 my @mounts = ('/mnt','/media');
111 $config{dir_mounts} = [@mounts];
112
113
114
115
116 # SECTION: SERVICE CONTRAINTS --------------------------------------------------
117
118 # Max amount [0-1] of CPU load. Deny service when above.
119 $config{service_max_load} = 0.8 ;
120
121 # Max number of active sessions. Deny service when above.
122 $config{service_max_session_nb} = 10; # OpenStack config DEFAULT.max_concurrent_snapshots ?
123
124 # Max number of active sessions per user. Deny service when above.
125 $config{service_max_session_nb_per_user} = 3;
126
127 # Max number of active CPU fraction per user. Deny service when above.
128 $config{service_max_cpu_fraction_nb_per_user}= 0.3;
129
130 # Max number of active memory fraction per user. Deny service when above.
131 $config{service_max_mem_fraction_nb_per_user}= 0.3;
132
133 # Max number of gpu per user. Deny service when above.
134 $config{service_max_gpu_nb_per_user} = 1;
135
136 # The base port for the VNC screen (on 127.0.0.1 loopback interface).
137 # The VNC port is chosen randomly up to service_port_vnc+service_max_session_nb
138 $config{service_port_vnc} = 5901; # OpenStack config vmware.vnc_port
139
140 # The port where the VNC screens are broadcasted (e.g. 6080 for websockify)
141 # Use 0 to select a random base port
142 # If you tune the reverse proxy, make sure this port is the same as e.g.
143 # 'ProxyPass /alias ws://127.0.0.1:6080/' from the web server
144 # in e.g. /etc/apache2/conf-available/qemu-web-desktop.conf
145 $config{service_port} = 6080; # OpenStack vnc.novncproxy_port
146
147 # On RedHat-based systems, in case you update these, issue for each new PORT
148 # semanage port -a -t http_port_t -p tcp PORT
149
150 # Use a single websockify port with tokens, or a port range.
151 # 0: websockify uses only one port (recommended, except when using 'oneshot' sessions)
152 # 1: the websockify port is chosen randomly up to service_port+service_max_session_nb
153 # which is not possible if you use a reverse proxy.
154 $config{service_port_multiple} = 0; # when true, use one websockify per instance
155
156 # Prefer single-shot sessions. Only a single connection is allowed.
157 # Any disconnect immediately ends the session. This is NOT recommended.
158 # When set, also un-comment the landing page section.
159 $config{oneshot} = 0; # when true, all sessions are one-shot
160
161 # In case there is a reverse proxy for the generated VNC/websocket, specify it here.
162 # You may use:
163 # "" use ":$session{port}" (forced when 'service_port_multiple=1')
164 # In this case the reverse proxy is not active.
165 # ":service_port" fixed port
166 # "/alias" reverse proxy corresponding with e.g.
167 # 'ProxyPass /alias ws://127.0.0.1:6080/' from the web server
168 # in e.g. /etc/apache2/conf-available/qemu-web-desktop.conf
169 # The final session URL is shown as e.g.:
170 # http://$session{server_name}$config{service_reverse_proxy}/vnc.html ...
171 # WARNING: not supported under macos
172 if ($^O eq 'darwin') {
173 $config{service_reverse_proxy} = ""; # reverse proxy not supported on MacOS
174 } else {
175 $config{service_reverse_proxy} = "/darts"; # "" or ":port" or "/alias"
176 }
177
178 # In case there is a proxy server to pass, specify it here
179 $config{service_proxy} = ""; # "http://195.221.0.35:8080/";
180
181 # A list of other servers to be used when current one does not have enough resources
182 # Can be a server name, IP, including protocol (http, https). Indicate a
183 # comma-separated list. All of URL, server names and IP are allowed.
184 # e.g. 'https://grades-01.synchrotron-soleil.fr,https://re-grades-01.exp.synchrotron-soleil.fr';
185 $config{fallback_servers} = '';
186
187 # The max length of user customization script (URL length)
188 $config{service_max_script_length}= 65535; # e.g. 65535
189
190 # Scripts to execute when any VM starts. Supports Linux and Windows guests.
191 # See: https://libguestfs.org/virt-customize.1.html --commands-from-file
192 # Can be specifyed as:
193 # "http://some/url"
194 # "/some/local/path/to/script"
195 # "exec: some commands" separated with EOL or ';'
196 # "virt-customize: commands" separated with EOL
197 # The symbols `@USER@` `@PW@` `@SESSION_NAME@` and `@VM@` are replaced by the user
198 # name, password, the session ID, and the virtual machine name.
199 #
200 # In addition, when the above script description is preceded by `if(EXPR):`
201 # the given expression is evaluated with Perl and the script is only executed
202 # when result is True. The `EXPR` condition may use the `@...@` symbols above.
203 #
204 # Scripts are executed at boot, in background, as root.
205 # It is possible to define as many scripts as needed. Strings are separated by ','
206 #
207 # WARNING: not supported under macos
208 my @config_scripts=("");
209 $config{config_script} = [@config_scripts];
210
211 # A list of GPU PCI addresses NOT to be used, as returned by lspci e.g.
212 # "06:05.0,00:1b.0". Items can be separated by spaces or commas.
213 # WARNING: not supported under macos (no GPU support)
214 $config{gpu_blacklist} = "";
215
216
217
218
219 # SECTION: USER AUTHENTICATION -------------------------------------------------
220
221 # The name of the SMTP server, and optional port.
222 # When empty, no email is needed
223 # The SMTP server is used to send emails, and check user credentials.
224 $config{smtp_server} = ''; # "smtp.synchrotron-soleil.fr";
225
226 # The SMTP port e.g. 25, 465, 587, or left blank
227 # and indicate if SMTP uses encryption
228 $config{smtp_port} = 587;
229 $config{smtp_use_ssl} = 'starttls'; # 'starttls' or blank
230
231 # The name of the IMAP server, and optional port.
232 # When empty, no email is needed
233 # The IMAP server is used to check user credentials.
234 $config{imap_server} = ''; # 'smtp.synchrotron-soleil.fr';
235
236 # The IMAP port e.g. 143 or 993, or left blank
237 $config{imap_port} = 993;
238
239 # The name of the LDAP server.
240 # The LDAP server is used to check user credentials.
241 $config{ldap_server} = ''; # 195.221.10.1';
242 $config{ldap_port} = 389; # default is 389
243 $config{ldap_domain} = 'EXP'; # DC
244
245 # The email address of the sender of the messages on the SMTP server.
246 $config{email_from} = ''; # '[email protected]';
247
248 # The password for the sender on the SMTP server, or left blank when none.
249 $config{email_passwd} = "";
250
251 # The method to use for sending messages. Can be:
252 # auto use the provided smtp/email settings to decide what to do
253 # SSL use the SMTP server, port SSL, and email_from with email_passwd
254 # port just use the server with given SMTP port
255 # simple just use the server, and port 25
256 $config{email_method} = "auto";
257
258 # ** How to check users **
259 # WARNING: WHEN NO AUTHENTICATION MECHANISM IS SET, ALL USERS CAN CONNECT. :WARNING
260
261 # The default authentication, must have openssh (apt install openssh-server)
262 $config{check_user_with_local} = 0;
263
264 # The email authentication is less secure. Use it with caution.
265 # The only test is for an "email"-like input, but not actual valid / registered email.
266 # When authenticated with email, only single-shot sessions can be launched.
267 $config{check_user_with_email} = 0; # send URL via email.
268 $config{check_user_with_imap} = 0;
269
270 # In case of IMAP error "Unable to connect to <server>: SSL connect attempt
271 # failed error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol.""
272 # See:
273 # https://stackoverflow.com/questions/53058362/openssl-v1-1-1-ssl-choose-client-version-unsupported-protocol
274
275 $config{check_user_with_smtp} = 0;
276 $config{check_user_with_ldap} = 0;
277
278 # Force to send information via email, which implies valid user email.
279 # The VNC token is sent only via email, not displayed in printed message.
280 # When activated you need to:
281 # - use any of 'check_user_with_email=1' or 'check_user_with_imap=1' or 'check_user_with_ldap=1' with valid email information
282 # - properly configure the 'smtp_server' and 'smtp_port'
283 $config{check_user_mfa} = 0; # activate MFA/2FA
284
285 # Custom user authentication.
286 # When defined, this authenticator is ALWAYS executed (whatever be the other
287 # authenticator results).
288 #
289 # First, specify a function that should get (user, pw, authenticated, session_ref)
290 # as arguments and return a string starting by "SUCCESS" or "FAILED". The default
291 # return value should be the previous authenticator results.
292 # Any "SUCCESS" in the returned string fully qualifies the authentication.
293 #
294 # sub check_user_func {
295 # my $user = shift;
296 # my $pw = shift;
297 # my $authenticated = shift; # previous authenticator results
298 # my $session_ref = shift;
299 # if (not $session_ref) { return $authenticated; }
300 # my %session = %{ $session_ref };
301 # my $res = "";
302 #
303 # res = "SUCCESS: [Custom] $user authenticated.";
304 #
305 # res = "FAILED: [Custom] $user failed authentication.";
306 #
307 # return "$authenticated and $res";
308 # }
309 #
310 # Then send its reference to the configuration:
311 #
312 # $config{check_user_custom} = \&check_user_func;
313 #
314 # or directly as an anonymous function
315 #
316 # $config{check_user_custom} = sub { };
317
318 $config{check_user_custom} = "";
319
320
321 # Encryption (HTTPS). Set these to valid 'crt' and 'key' files with proper certificates
322 # to allow secured encryption of websockify/novnc. The CRT and KEY should both be set.
323 # WARNING: after setting these, KILL any running websockify: sudo killall websockify
324 # OpenStack DEFAULT.key DEFAULT.cert
325 $config{certificate_crt} = ''; # '/etc/apache2/certificate/apache-certificate.crt';
326 $config{certificate_key} = ''; # '/etc/apache2/certificate/apache.key';
327
328 # Set the list of 'admin' users that can access the Monitoring pages.
329 # These must also be identified with their credentials.
330 my @admin = (''); # ('admin1,'admin2')
331 $config{user_admin} = [@admin];
332
333
334
335
336 # SECTION: WEB SERVICE APPEARANCE -------------------------------------------------------
337
338 # The level of HTML generation.
339 # 0: minimalist level: nearly no information except the CONNECT, SHARE and STOP buttons.
340 # 1: normal level: slightly more information, with some notes, and life-time.
341 # 2: verbose level: a lot of technical information
342 $config{layout_level} = 1; # 0='minimalist', 1='normal', 2='verbose'
343
344 # The 'title' of the generated web page (h1 tag), also used for the footer
345 $config{layout_title} = 'Data Analysis Remote Treatment Service';
346
347 # A Header (top) web page for generated html content. Default is used when empty.
348 # Can be given as a file path or a string with HTML, e.g. a logo reference.
349 # The default is e.g. <a href=service_url><img src=DARTS_logo></a>
350 # The layout_title above is appended in a H1 tag when no H1 is specified.
351 $config{layout_header}=''; # e.g. /etc/qemu-web-desktop/config.d/header.html
352
353 # A Footer (bottom) web page for generated html content. Default is used when empty.
354 # Can be given as a file path or a string with HTML, e.g. a URL link.
355 # The default is e.g. <small><a href=service_url></small>
356 $config{layout_footer}=''; # e.g. /etc/qemu-web-desktop/config.d/footer.html
357
358 # noVNC Screen rescale/resize: can be 'scale' (fixed ratio) or 'remote' (scales to browser size)
359 $config{layout_resize}='remote';
360
361 # KEEP THIS LINE!
362 1;