Skip to content

Support headless startup, x11vnc, noVNC and process control #177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ RUN apt update && apt install -y \
pev \
sudo \
vim \
xdotool \
supervisor \
x11vnc \
novnc \
xvfb \
fluxbox \
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -fr /tmp/*
Expand Down
25 changes: 25 additions & 0 deletions container_root/bin/wechat-monitor
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
# ref: https://github.com/ChisBread/wechat-box/blob/master/root/bin/wechat-monitor
function errmonitor() {
while :
do
for i in `xdotool search --onlyvisible --class WeChat.exe`
do
NAME=`xdotool getwindowname $i`
echo "window name: $NAME"
if [ "$NAME" == "" ] || [ "$NAME" == "微信电脑版更新" ]; then
xdotool windowunmap $i
fi
done
for i in `xdotool search --onlyvisible --class wine`
do
NAME=`xdotool getwindowname $i`
echo "window name: $NAME"
if [ "$NAME" == "程序错误" ]; then
xdotool windowkill $i
fi
done
sleep 2
done
}
errmonitor
37 changes: 35 additions & 2 deletions container_root/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,32 @@ function setupFontDpi () {
/f \
> /dev/null 2>&1
}

function startVNC () {
VNC_DISPLAY_WIDTH=${VNC_DISPLAY_WIDTH:-1280}
VNC_DISPLAY_HEIGHT=${VNC_DISPLAY_HEIGHT:-720}
# VNC_DISPLAY for multi xserver
VNC_DISPLAY=${VNC_DISPLAY:-${DISPLAY:-:0}}
NOVNC_PORT=${NOVNC_PORT:-8080}
# TODO:
# use xf86 instead of xvfb
# https://bugs.chromium.org/p/chromium/issues/detail?id=596125
# https://github.com/freedesktop/xorg-xf86-video-dummy
[ ! -f /etc/supervisord.d/xvfb.conf ] \
&& mv /etc/supervisord.d/xvfb.conf.disable /etc/supervisord.d/xvfb.conf \
&& mv /etc/supervisord.d/wechat-monitor.conf.disable /etc/supervisord.d/wechat-monitor.conf
[ -d /tmp/.X11-unix ] \
&& mv /etc/supervisord.d/xvfb.conf /etc/supervisord.d/xvfb.conf.disable \
&& mv /etc/supervisord.d/wechat-monitor.conf /etc/supervisord.d/wechat-monitor.conf.disable
echo "[DoChat] VNCServer Starting..."
exec sudo -E bash -c \
"DISPLAY=${VNC_DISPLAY} NOVNC_PORT=${NOVNC_PORT} \
VNC_DISPLAY_WIDTH=${VNC_DISPLAY_WIDTH} VNC_DISPLAY_HEIGHT=${VNC_DISPLAY_HEIGHT} \
supervisord -c /etc/supervisord.conf -l /var/log/supervisord.log" &
while true; do
[ -d /tmp/.X11-unix ] && break
sleep 1
done
}
#
# WeChat
#
Expand All @@ -39,7 +64,15 @@ function startWechat () {

/dochat/patch-hosts.sh
/dochat/disable-upgrade.sh

VNC_SERVER=${VNC_SERVER:-no}
[ ! -d /tmp/.X11-unix ] \
&& echo "[DoChat] Headless mode. Dummy DISPLAY=${DISPLAY:-:0}" \
&& export DISPLAY=${DISPLAY:-:0}
case $VNC_SERVER in
true|yes|y|1)
startVNC
;;
esac
if [ -n "$DOCHAT_DEBUG" ]; then
unset WINEDEBUG
wine reg query 'HKEY_CURRENT_USER\Software\Tencent\WeChat' || echo 'Register for Wechat not found ?'
Expand Down
5 changes: 5 additions & 0 deletions container_root/etc/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[supervisord]
nodaemon=true

[include]
files = /etc/supervisord.d/*.conf
3 changes: 3 additions & 0 deletions container_root/etc/supervisord.d/fluxbox.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[program:fluxbox]
command=fluxbox
autorestart=true
3 changes: 3 additions & 0 deletions container_root/etc/supervisord.d/websockify.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[program:websockify]
command=websockify --web /usr/share/novnc %(ENV_NOVNC_PORT)s localhost:5900
autorestart=true
3 changes: 3 additions & 0 deletions container_root/etc/supervisord.d/wechat-monitor.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[program:wechat-monitor]
command=wechat-monitor
autorestart=true
3 changes: 3 additions & 0 deletions container_root/etc/supervisord.d/x11vnc.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[program:x11vnc]
command=x11vnc -forever -shared
autorestart=true
3 changes: 3 additions & 0 deletions container_root/etc/supervisord.d/xvfb.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[program:xvfb]
command=Xvfb %(ENV_DISPLAY)s -screen 0 "%(ENV_VNC_DISPLAY_WIDTH)s"x"%(ENV_VNC_DISPLAY_HEIGHT)s"x24 -listen tcp -ac
autorestart=true