7
7
# Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/desktop-lite.md
8
8
# Maintainer: The VS Code and Codespaces Teams
9
9
#
10
- # Syntax: ./desktop-lite-debian.sh [non-root user] [vnc password] [install no vnc flag]
10
+ # Syntax: ./desktop-lite-debian.sh [non-root user] [Desktop password] [Install web client flag] [VNC port] [Web Port ]
11
11
12
12
USERNAME=${1:- " automatic" }
13
13
VNC_PASSWORD=${2:- " vscode" }
14
14
INSTALL_NOVNC=${3:- " true" }
15
+ VNC_PORT=" ${4:- 5901} "
16
+ NOVNC_PORT=" ${5:- 6080} "
15
17
16
18
NOVNC_VERSION=1.2.0
17
19
WEBSOCKETIFY_VERSION=0.10.0
@@ -77,6 +79,71 @@ if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
77
79
elif [ " ${USERNAME} " = " none" ] || ! id -u ${USERNAME} > /dev/null 2>&1 ; then
78
80
USERNAME=root
79
81
fi
82
+ # Add default Fluxbox config files if none are already present
83
+ fluxbox_apps=" $( cat \
84
+ << 'EOF '
85
+ [transient] (role=GtkFileChooserDialog)
86
+ [Dimensions] {70% 70%}
87
+ [Position] (CENTER) {0 0}
88
+ [end]
89
+ EOF
90
+ ) "
91
+
92
+ fluxbox_init=" $( cat \
93
+ << 'EOF '
94
+ session.configVersion: 13
95
+ session.menuFile: ~/.fluxbox/menu
96
+ session.keyFile: ~/.fluxbox/keys
97
+ session.styleFile: /usr/share/fluxbox/styles/qnx-photon
98
+ session.screen0.workspaces: 1
99
+ session.screen0.workspacewarping: false
100
+ session.screen0.toolbar.widthPercent: 100
101
+ session.screen0.strftimeFormat: %a %l:%M %p
102
+ session.screen0.toolbar.tools: RootMenu, clock, iconbar, systemtray
103
+ session.screen0.workspaceNames: One,
104
+ EOF
105
+ ) "
106
+
107
+ fluxbox_menu=" $( cat \
108
+ << 'EOF '
109
+ [begin] ( Application Menu )
110
+ [exec] (File Manager) { nautilus ~ } <>
111
+ [exec] (Text Editor) { mousepad } <>
112
+ [exec] (Terminal) { tilix -w ~ -e $(readlink -f /proc/$$/exe) -il } <>
113
+ [exec] (Web Browser) { x-www-browser --disable-dev-shm-usage } <>
114
+ [submenu] (System) {}
115
+ [exec] (Set Resolution) { tilix -t "Set Resolution" -e bash /usr/local/bin/set-resolution } <>
116
+ [exec] (Edit Application Menu) { mousepad ~/.fluxbox/menu } <>
117
+ [exec] (Passwords and Keys) { seahorse } <>
118
+ [exec] (Top Processes) { tilix -t "Top" -e htop } <>
119
+ [exec] (Disk Utilization) { tilix -t "Disk Utilization" -e ncdu / } <>
120
+ [exec] (Editres) {editres} <>
121
+ [exec] (Xfontsel) {xfontsel} <>
122
+ [exec] (Xkill) {xkill} <>
123
+ [exec] (Xrefresh) {xrefresh} <>
124
+ [end]
125
+ [config] (Configuration)
126
+ [workspaces] (Workspaces)
127
+ [end]
128
+ EOF
129
+ ) "
130
+
131
+ # Copy config files if the don't already exist
132
+ copy_fluxbox_config () {
133
+ local target_dir=" $1 "
134
+ mkdir -p " ${target_dir} /.fluxbox"
135
+ touch " ${target_dir} /.Xmodmap"
136
+ if [ ! -e " ${target_dir} /.fluxbox/apps" ]; then
137
+ echo " ${fluxbox_apps} " > " ${target_dir} /.fluxbox/apps"
138
+ fi
139
+ if [ ! -e " ${target_dir} /.fluxbox/init" ]; then
140
+ echo " ${fluxbox_init} " > " ${target_dir} /.fluxbox/init"
141
+ fi
142
+ if [ ! -e " ${target_dir} /.fluxbox/menu" ]; then
143
+ echo " ${fluxbox_menu} " > " ${target_dir} /.fluxbox/menu"
144
+ fi
145
+ }
146
+
80
147
81
148
# Function to run apt-get if needed
82
149
apt_get_update_if_needed ()
@@ -163,11 +230,10 @@ if [ "${INSTALL_NOVNC}" = "true" ] && [ ! -d "/usr/local/novnc" ]; then
163
230
fi
164
231
165
232
# Set up folders for scripts and init files
166
- mkdir -p /var/run/dbus /usr/local/etc/vscode-dev-containers/ /root/.fluxbox
233
+ mkdir -p /var/run/dbus /usr/local/etc/vscode-dev-containers/
167
234
168
235
# Script to change resolution of desktop
169
- tee /usr/local/bin/set-resolution > /dev/null \
170
- << EOF
236
+ cat << EOF > /usr/local/bin/set-resolution
171
237
#!/bin/bash
172
238
RESOLUTION=\$ {1:-\$ {VNC_RESOLUTION:-1920x1080}}
173
239
DPI=\$ {2:-\$ {VNC_DPI:-96}}
@@ -204,8 +270,7 @@ echo -e "\nSuccess!\n"
204
270
EOF
205
271
206
272
# Container ENTRYPOINT script
207
- tee /usr/local/share/desktop-init.sh > /dev/null \
208
- << EOF
273
+ cat << EOF > /usr/local/share/desktop-init.sh
209
274
#!/bin/bash
210
275
211
276
USERNAME=${USERNAME}
@@ -286,11 +351,11 @@ sudoIf chown root:\${USERNAME} /tmp/.X11-unix
286
351
if [ "\$ (echo "\$ {VNC_RESOLUTION}" | tr -cd 'x' | wc -c)" = "1" ]; then VNC_RESOLUTION=\$ {VNC_RESOLUTION}x16; fi
287
352
screen_geometry="\$ {VNC_RESOLUTION%*x*}"
288
353
screen_depth="\$ {VNC_RESOLUTION##*x}"
289
- startInBackgroundIfNotRunning "Xtigervnc" sudoUserIf "tigervncserver \$ {DISPLAY} -geometry \$ {screen_geometry} -depth \$ {screen_depth} -rfbport \ $ {VNC_PORT:-5901 } -dpi \$ {VNC_DPI:-96} -localhost -desktop fluxbox -fg -passwd /usr/local/etc/vscode-dev-containers/vnc-passwd"
354
+ startInBackgroundIfNotRunning "Xtigervnc" sudoUserIf "tigervncserver \$ {DISPLAY} -geometry \$ {screen_geometry} -depth \$ {screen_depth} -rfbport ${VNC_PORT} -dpi \$ {VNC_DPI:-96} -localhost -desktop fluxbox -fg -passwd /usr/local/etc/vscode-dev-containers/vnc-passwd"
290
355
291
356
# Spin up noVNC if installed and not runnning.
292
357
if [ -d "/usr/local/novnc" ] && [ "\$ (ps -ef | grep /usr/local/novnc/noVNC*/utils/launch.sh | grep -v grep)" = "" ]; then
293
- keepRunningInBackground "noVNC" sudoIf "/usr/local/novnc/noVNC*/utils/launch.sh --listen \ $ {NOVNC_PORT:-6080 } --vnc localhost:\ $ {VNC_PORT:-5901 }"
358
+ keepRunningInBackground "noVNC" sudoIf "/usr/local/novnc/noVNC*/utils/launch.sh --listen ${NOVNC_PORT} --vnc localhost:${VNC_PORT} "
294
359
log "noVNC started."
295
360
else
296
361
log "noVNC is already running or not installed."
@@ -303,61 +368,26 @@ log "** SCRIPT EXIT **"
303
368
EOF
304
369
305
370
echo " ${VNC_PASSWORD} " | vncpasswd -f > /usr/local/etc/vscode-dev-containers/vnc-passwd
306
- touch /root/.Xmodmap
307
371
chmod +x /usr/local/share/desktop-init.sh /usr/local/bin/set-resolution
308
372
309
- tee /root/.fluxbox/apps > /dev/null \
310
- << EOF
311
- [transient] (role=GtkFileChooserDialog)
312
- [Dimensions] {70% 70%}
313
- [Position] (CENTER) {0 0}
314
- [end]
315
- EOF
373
+ # Set up fluxbox config
374
+ copy_fluxbox_config " /root"
375
+ if [ " ${USERNAME} " != " root" ]; then
376
+ copy_fluxbox_config " /home/${USERNAME} "
377
+ chown -R ${USERNAME} /home/${USERNAME} /.Xmodmap /home/${USERNAME} /.fluxbox
378
+ fi
316
379
317
- tee /root/.fluxbox/init > /dev/null \
318
- << EOF
319
- session.configVersion: 13
320
- session.menuFile: ~/.fluxbox/menu
321
- session.keyFile: ~/.fluxbox/keys
322
- session.styleFile: /usr/share/fluxbox/styles/qnx-photon
323
- session.screen0.workspaces: 1
324
- session.screen0.workspacewarping: false
325
- session.screen0.toolbar.widthPercent: 100
326
- session.screen0.strftimeFormat: %a %l:%M %p
327
- session.screen0.toolbar.tools: RootMenu, clock, iconbar, systemtray
328
- session.screen0.workspaceNames: One,
329
- EOF
380
+ cat << EOF
330
381
331
- tee /root/.fluxbox/menu > /dev/null \
332
- << EOF
333
- [begin] ( Application Menu )
334
- [exec] (File Manager) { nautilus ~ } <>
335
- [exec] (Text Editor) { mousepad } <>
336
- [exec] (Terminal) { tilix -w ~ -e $( readlink -f /proc/$$ /exe) -il } <>
337
- [exec] (Web Browser) { x-www-browser --disable-dev-shm-usage } <>
338
- [submenu] (System) {}
339
- [exec] (Set Resolution) { tilix -t "Set Resolution" -e bash /usr/local/bin/set-resolution } <>
340
- [exec] (Edit Application Menu) { mousepad ~/.fluxbox/menu } <>
341
- [exec] (Passwords and Keys) { seahorse } <>
342
- [exec] (Top Processes) { tilix -t "Top" -e htop } <>
343
- [exec] (Disk Utilization) { tilix -t "Disk Utilization" -e ncdu / } <>
344
- [exec] (Editres) {editres} <>
345
- [exec] (Xfontsel) {xfontsel} <>
346
- [exec] (Xkill) {xkill} <>
347
- [exec] (Xrefresh) {xrefresh} <>
348
- [end]
349
- [config] (Configuration)
350
- [workspaces] (Workspaces)
351
- [end]
352
- EOF
353
382
354
- # Set up non-root user (if one exists)
355
- if [ " ${USERNAME} " != " root" ]; then
356
- touch /home/${USERNAME} /.Xmodmap
357
- cp -R /root/.fluxbox /home/${USERNAME}
358
- chown -R ${USERNAME} :${USERNAME} /home/${USERNAME} /.Xmodmap /home/${USERNAME} /.fluxbox
359
- chown ${USERNAME} :root /usr/local/share/desktop-init.sh /usr/local/bin/set-resolution /usr/local/etc/vscode-dev-containers/vnc-passwd
360
- fi
383
+ You now have a working desktop! Connect to in one of the following ways:
384
+
385
+ - Forward port ${NOVNC_PORT} and use a web browser start the noVNC client (recommended)
386
+ - Forward port ${VNC_PORT} using VS Code client and connect using a VNC Viewer
387
+
388
+ In both cases, use the password "${VNC_PASSWORD} " when connecting
361
389
362
- echo " Done!"
390
+ (*) Done!
391
+
392
+ EOF
363
393
0 commit comments