Skip to content

Commit b8f8d21

Browse files
committed
feat: support USER
1 parent b1d1d29 commit b8f8d21

File tree

4 files changed

+43
-18
lines changed

4 files changed

+43
-18
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ RUN apt-get update \
1212
&& apt-get update \
1313
&& apt-get install -y --no-install-recommends --allow-unauthenticated \
1414
supervisor \
15-
openssh-server pwgen sudo vim-tiny \
15+
sudo vim-tiny \
1616
net-tools \
1717
lxde x11vnc xvfb \
1818
gtk2-engines-murrine ttf-ubuntu-font-family \

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,26 @@ A prompt will ask password either in the browser or vnc viewer.
4242
Screen Resolution
4343
------------------
4444

45-
Resolution of virtual desktop adapts browser window size when first connecting the server. You may choose a fixed resolution by passing `RESOLUTION` environment variable, for example
45+
The Resolution of virtual desktop adapts browser window size when first connecting the server. You may choose a fixed resolution by passing `RESOLUTION` environment variable, for example
4646

4747
```
4848
docker run -it --rm -p 6080:80 -e RESOLUTION=1920x1080 dorowu/ubuntu-desktop-lxde-vnc
4949
```
5050

51+
52+
Default User
53+
------------------
54+
55+
The default user is `root`. You may change the user and password respectively by `USER` and `PASSWORD` environment variable, for example,
56+
57+
```
58+
docker run -it --rm -p 6080:80 -e USER=doro -e PASSWORD=password dorowu/ubuntu-desktop-lxde-vnc
59+
```
60+
5161
Troubleshooting and FAQ
5262
==================
5363

5464
1. boot2docker connection issue, https://github.com/fcwu/docker-ubuntu-vnc-desktop/issues/2
55-
2. Screen resolution is fitted to browser's window size when first connecting to the desktop. If you would like to change resolution, you have to re-create the container
5665

5766

5867
License

image/etc/supervisor/conf.d/supervisord.conf

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ command=/usr/bin/Xvfb :1 -screen 0 1024x768x16
55
user=root
66
autostart=true
77
autorestart=true
8-
stopsignal=QUIT
8+
stopsignal=KILL
99
stdout_logfile=/var/log/xvfb.log
1010
redirect_stderr=true
1111

12-
[program:lxsession]
12+
[program:wm]
1313
priority=15
1414
directory=/root
1515
command=/usr/bin/openbox
@@ -23,28 +23,27 @@ redirect_stderr=true
2323

2424
[program:lxpanel]
2525
priority=15
26-
directory=/root
26+
directory=%HOME%
2727
command=/usr/bin/lxpanel --profile LXDE
28-
user=root
28+
user=%USER%
2929
autostart=true
3030
autorestart=true
3131
stopsignal=QUIT
32-
environment=DISPLAY=":1",HOME="/root",USER="root"
32+
environment=DISPLAY=":1",HOME="%HOME%",USER="%USER%"
3333
stdout_logfile=/var/log/lxpanel.log
3434
redirect_stderr=true
3535

3636
[program:pcmanfm]
3737
priority=15
38-
directory=/root
38+
directory=%HOME%
3939
command=/usr/bin/pcmanfm --desktop --profile LXDE
40-
user=root
40+
user=%USER%
4141
autostart=true
4242
autorestart=true
4343
stopsignal=QUIT
44-
environment=DISPLAY=":1",HOME="/root",USER="root"
44+
environment=DISPLAY=":1",HOME="%HOME%",USER="%USER%"
4545
stdout_logfile=/var/log/pcmanfm.log
4646

47-
4847
[program:x11vnc]
4948
priority=20
5049
directory=/

image/startup.sh

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
#!/bin/bash
22

3-
mkdir -p /var/run/sshd
4-
5-
chown -R root:root /root
6-
mkdir -p /root/.config/pcmanfm/LXDE/
7-
cp /usr/share/doro-lxde-wallpapers/desktop-items-0.conf /root/.config/pcmanfm/LXDE/
8-
93
if [ -n "$VNC_PASSWORD" ]; then
104
echo -n "$VNC_PASSWORD" > /.password1
115
x11vnc -storepasswd $(cat /.password1) /.password2
@@ -18,6 +12,29 @@ if [ -n "$RESOLUTION" ]; then
1812
sed -i "s/1024x768/$RESOLUTION/" /etc/supervisor/conf.d/supervisord.conf
1913
fi
2014

15+
USER=${USER:-root}
16+
HOME=/root
17+
if [ "$USER" != "root" ]; then
18+
useradd --create-home --shell /bin/bash --user-group --groups adm,sudo $USER
19+
if [ -z "$PASSWORD" ]; then
20+
echo set default password to \"ubuntu\"
21+
PASSWORD=ubuntu
22+
fi
23+
HOME=/home/$USER
24+
echo "$USER:$PASSWORD" | chpasswd
25+
cp -r /root/.gtkrc-2.0 ${HOME}
26+
fi
27+
sed -i "s|%USER%|$USER|" /etc/supervisor/conf.d/supervisord.conf
28+
sed -i "s|%HOME%|$HOME|" /etc/supervisor/conf.d/supervisord.conf
29+
30+
# home folder
31+
mkdir -p $HOME/.config/pcmanfm/LXDE/
32+
ln -sf /usr/share/doro-lxde-wallpapers/desktop-items-0.conf $HOME/.config/pcmanfm/LXDE/
33+
chown -R $USER:$USER $HOME
34+
35+
# clearup
36+
PASSWORD=
37+
2138
cd /usr/lib/web && ./run.py 2>&1 &
2239
nginx -c /etc/nginx/nginx.conf
2340
exec /bin/tini -- /usr/bin/supervisord -n

0 commit comments

Comments
 (0)