diff --git a/src/Dockerfile b/src/Dockerfile index 0860152..39f0435 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -22,7 +22,7 @@ FROM scratch as files COPY --from=Xvnc /usr/lib64/xorg/protocol.txt /usr/lib64/xorg/protocol.txt COPY --from=bin2 /src/webhookd /usr/local/webhook/webhookd - +FROM scratch as files2 # COPY --chown=root:root ./src ADD src/dot /etc/skel ADD src/etc /etc @@ -132,12 +132,14 @@ ENV \ # TODO: setRange; 再由客户端自行指定所要的端口; VNC_OFFSET=0 \ VNC_LIMIT=1 \ - VNC_INIT="23=mate,25=xfce,26=flux" \ - # VNC_INIT="21=gnome,22=plama,23=mate,24=cinna,25=xfce,26=flux" \ + VNC_INIT="" \ + # VNC_INIT="23|mate,24|cinna,25|xfce,26|flux" \ + # VNC_INIT="21|gnome,22|plama,23|mate,24|cinna,25|xfce,26|flux" \ # L=zh_CN \ TZ=Asia/Shanghai COPY --from=files / / +COPY --from=files2 / / RUN bash /xconf.sh "param|${AUDIO}" "param|${FULL}" # /home/headless/.config权限.. COPY --chown=headless:headless src/f/.config/emp${FULL} /home/headless/.config/ diff --git a/src/index.tpl.html b/src/index.tpl.html index eebd0df..4e04c2b 100644 --- a/src/index.tpl.html +++ b/src/index.tpl.html @@ -73,7 +73,7 @@
VNC_PASS:
- \n\n\n" >> /usr/local/novnc/index.html + # echo -e "\n\n\n" >> /usr/local/novnc/index.html # view - rm -f /tmp/xrdp-sesOne*.conf + rm -f $tmpDir/xrdp-sesOne*.conf && rm -f $tmpDir/novncHtml*.htm cat /etc/xrdp/xrdp.ini |grep "^\[Xvnc" } +function errExit(){ + echo "err: $1" + exit 1 +} case "$1" in entry) doStart ;; *) - echo "oth.." + # curl -s "localhost:8000/xdict?act=add&id=21&name=gnome" + # curl -s "localhost:10083/xdict?id=31&name=test31" + echo "id=$id, name=$name" + test -z "$id" && errExit "id is empty" + test -z "$name" && errExit "name is empty" + + # judge exist + match=$(cat $cur/xdict.txt |sort -u |grep -v "^#\|^$" |grep "^$id|") + ! test -z "$match" && errExit "id allready exit in xdict.txt" + + # setVNC + echo "$id|$name|xxJson" >> /usr/local/webhook/scripts/xdict.txt + oneVnc "$id" "$name" + # supervisorctl reread + supervisorctl update + + # echo "oth.." ;; esac diff --git a/src/xrdp.conf b/src/xrdp.conf index 4670cab..af22f42 100644 --- a/src/xrdp.conf +++ b/src/xrdp.conf @@ -57,7 +57,7 @@ redirect_stderr=true # environment=DISPLAY=:_DISP_,HOME=/home/headless # priority=35 # user=headless -# command=/xvnc.sh _DISP_ +# command=/xvnc.sh xvnc _DISP_ # stdout_logfile=/dev/fd/1 # stdout_logfile_maxbytes=0 # redirect_stderr=true @@ -65,7 +65,7 @@ redirect_stderr=true # environment=DISPLAY=:_DISP_,HOME=/home/headless # priority=36 # user=headless -# command=/xrec.sh _DISP_ +# command=/xvnc.sh xrec _DISP_ # stdout_logfile=/dev/fd/1 # stdout_logfile_maxbytes=0 # redirect_stderr=true diff --git a/src/xrec.sh b/src/xrec.sh deleted file mode 100755 index 9037eda..0000000 --- a/src/xrec.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -offsetLimitIndex=$1 -BCS_PORT=${BCS_PORT:-9222} -offsetLimitIndex=${offsetLimitIndex:-99} -echo "offsetLimitIndex: $offsetLimitIndex" - - -# go:recordmp3> go:record+lame > just parec+lame -url="localhost:$BCS_PORT/display$offsetLimitIndex-audio.mp3?stream=true&advertise=true" -exec parec --format=s16le -d xrdp-sink.monitor |lame -r -ab 52 - - \ - | curl -k -H "Transfer-Encoding: chunked" -X POST -T - "$url" - diff --git a/src/xvnc.sh b/src/xvnc.sh index 8baff44..65e99a0 100755 --- a/src/xvnc.sh +++ b/src/xvnc.sh @@ -1,21 +1,40 @@ #!/bin/bash -offsetLimitIndex=$1 +offsetLimitIndex=$2 offsetLimitIndex=${offsetLimitIndex:-99} -echo "offsetLimitIndex: $offsetLimitIndex" +BCS_PORT=${BCS_PORT:-9222} +indexName=$(cat /usr/local/webhook/scripts/xdict.txt |sort -u |grep -v "^#\|^$" |grep $offsetLimitIndex |cut -d'|' -f2) +echo "indexInfo: $offsetLimitIndex-$indexName, BCS_PORT: $BCS_PORT" -# PULSE################################################# -touch /var/run/dbus/system_bus_socket && chmod 777 /var/run/dbus/system_bus_socket; #>>pulse: conn dbus err. -# pulseaudio --exit-idle-time=-1 & -port=$(expr 4700 + $offsetLimitIndex) #4713 -pa="/tmp/pulse-$port.pa" -cat /etc/pulse/default.pa > $pa; sed -i "s/4700/$port/g" $pa -pulseaudio --exit-idle-time=-1 -nF $pa & +function startXvnc(){ + # PULSE################################################# + # touch /var/run/dbus/system_bus_socket && chmod 777 /var/run/dbus/system_bus_socket; #>>pulse: conn dbus err. + # pulseaudio --exit-idle-time=-1 & + port=$(expr 4700 + $offsetLimitIndex) #4713 + mkdir -p /tmp/.headless; pa="/tmp/.headless/pulse-$port.pa" + cat /etc/pulse/default.pa > $pa; sed -i "s/4700/$port/g" $pa + pulseaudio --exit-idle-time=-1 -nF $pa & -# XRDP################################################## -#chansrv -export DISPLAY=:$offsetLimitIndex #:2 -/usr/local/xrdp/sbin/xrdp-chansrv & + # XRDP################################################## + #chansrv + export DISPLAY=:$offsetLimitIndex #:2 + /usr/local/xrdp/sbin/xrdp-chansrv & -# default: Xvnc :99 -BlacklistThreshold=5 -BlacklistTimeout=10 -exec Xvnc -ac $DISPLAY -listen tcp -rfbauth=/etc/xrdp/vnc_pass -depth 16 -BlacklistThreshold=3 -BlacklistTimeout=1 + # default: Xvnc :99 -BlacklistThreshold=5 -BlacklistTimeout=10 + exec Xvnc -ac $DISPLAY -listen tcp -rfbauth=/etc/xrdp/vnc_pass -depth 16 -BlacklistThreshold=3 -BlacklistTimeout=1 +} + +case "$1" in +xvnc) + startXvnc + ;; +xrec) + # go:recordmp3> go:record+lame > just parec+lame + url="localhost:$BCS_PORT/$offsetLimitIndex-$indexName.mp3?stream=true&advertise=true" + exec parec --format=s16le -d xrdp-sink.monitor |lame -r -ab 52 - - \ + | curl -k -H "Transfer-Encoding: chunked" -X POST -T - "$url" + ;; +*) + echo "please call with: xvnc.sh xvnc/xrec xx" + ;; +esac