feat: support USER

This commit is contained in:
Doro Wu 2018-03-08 10:29:48 +08:00
parent b1d1d2994c
commit b8f8d21f1d
4 changed files with 43 additions and 18 deletions

View file

@ -12,7 +12,7 @@ RUN apt-get update \
&& apt-get update \
&& apt-get install -y --no-install-recommends --allow-unauthenticated \
supervisor \
openssh-server pwgen sudo vim-tiny \
sudo vim-tiny \
net-tools \
lxde x11vnc xvfb \
gtk2-engines-murrine ttf-ubuntu-font-family \

View file

@ -42,17 +42,26 @@ A prompt will ask password either in the browser or vnc viewer.
Screen Resolution
------------------
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
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
```
docker run -it --rm -p 6080:80 -e RESOLUTION=1920x1080 dorowu/ubuntu-desktop-lxde-vnc
```
Default User
------------------
The default user is `root`. You may change the user and password respectively by `USER` and `PASSWORD` environment variable, for example,
```
docker run -it --rm -p 6080:80 -e USER=doro -e PASSWORD=password dorowu/ubuntu-desktop-lxde-vnc
```
Troubleshooting and FAQ
==================
1. boot2docker connection issue, https://github.com/fcwu/docker-ubuntu-vnc-desktop/issues/2
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
License

View file

@ -5,11 +5,11 @@ command=/usr/bin/Xvfb :1 -screen 0 1024x768x16
user=root
autostart=true
autorestart=true
stopsignal=QUIT
stopsignal=KILL
stdout_logfile=/var/log/xvfb.log
redirect_stderr=true
[program:lxsession]
[program:wm]
priority=15
directory=/root
command=/usr/bin/openbox
@ -23,28 +23,27 @@ redirect_stderr=true
[program:lxpanel]
priority=15
directory=/root
directory=%HOME%
command=/usr/bin/lxpanel --profile LXDE
user=root
user=%USER%
autostart=true
autorestart=true
stopsignal=QUIT
environment=DISPLAY=":1",HOME="/root",USER="root"
environment=DISPLAY=":1",HOME="%HOME%",USER="%USER%"
stdout_logfile=/var/log/lxpanel.log
redirect_stderr=true
[program:pcmanfm]
priority=15
directory=/root
directory=%HOME%
command=/usr/bin/pcmanfm --desktop --profile LXDE
user=root
user=%USER%
autostart=true
autorestart=true
stopsignal=QUIT
environment=DISPLAY=":1",HOME="/root",USER="root"
environment=DISPLAY=":1",HOME="%HOME%",USER="%USER%"
stdout_logfile=/var/log/pcmanfm.log
[program:x11vnc]
priority=20
directory=/

View file

@ -1,11 +1,5 @@
#!/bin/bash
mkdir -p /var/run/sshd
chown -R root:root /root
mkdir -p /root/.config/pcmanfm/LXDE/
cp /usr/share/doro-lxde-wallpapers/desktop-items-0.conf /root/.config/pcmanfm/LXDE/
if [ -n "$VNC_PASSWORD" ]; then
echo -n "$VNC_PASSWORD" > /.password1
x11vnc -storepasswd $(cat /.password1) /.password2
@ -18,6 +12,29 @@ if [ -n "$RESOLUTION" ]; then
sed -i "s/1024x768/$RESOLUTION/" /etc/supervisor/conf.d/supervisord.conf
fi
USER=${USER:-root}
HOME=/root
if [ "$USER" != "root" ]; then
useradd --create-home --shell /bin/bash --user-group --groups adm,sudo $USER
if [ -z "$PASSWORD" ]; then
echo set default password to \"ubuntu\"
PASSWORD=ubuntu
fi
HOME=/home/$USER
echo "$USER:$PASSWORD" | chpasswd
cp -r /root/.gtkrc-2.0 ${HOME}
fi
sed -i "s|%USER%|$USER|" /etc/supervisor/conf.d/supervisord.conf
sed -i "s|%HOME%|$HOME|" /etc/supervisor/conf.d/supervisord.conf
# home folder
mkdir -p $HOME/.config/pcmanfm/LXDE/
ln -sf /usr/share/doro-lxde-wallpapers/desktop-items-0.conf $HOME/.config/pcmanfm/LXDE/
chown -R $USER:$USER $HOME
# clearup
PASSWORD=
cd /usr/lib/web && ./run.py 2>&1 &
nginx -c /etc/nginx/nginx.conf
exec /bin/tini -- /usr/bin/supervisord -n