diff --git a/etc/pult/pult-2.conf b/etc/pult/pult-2.conf new file mode 100644 index 0000000000000000000000000000000000000000..f1498e496d0345a6daf391ca5da7594945a79a2f --- /dev/null +++ b/etc/pult/pult-2.conf @@ -0,0 +1,33 @@ +#start_text="starten" +#stop_text="stoppen" +#hide_text="verbergen" +#show_text="zeigen" +#min_text="minimieren" +#max_text="maximieren" + +bbb_url="https://bbb.cvh-server.de/b/pet-jxk-dch" +bbb_invitation="follow <a target=\"_blank\" href=\"$bbb_url\">this link</a> to $bbb_url" +jm_url="https://meet.cvh-server.de/VNC2" +jm_invitation="follow <a target=\"_blank\" href=\"$jm_url\">this link</a> to $jm_url" +janus_receiver_url="https://streaming.cvh-server.de/cvh-camera/camera-receiver.html?room=1002" +janus_receiver_url_redundant="https://streaming.cvh-server.de/cvh-camera/camera-receiver.html?room=1005" +janus_sender_url="https://streaming.cvh-server.de/cvh-camera/camera-sender.html?room=1002" +janus_sender_url_redundant="https://streaming.cvh-server.de/cvh-camera/camera-sender.html?room=1005" +janus_invitation="follow <a target=\"_blank\" href=\"$janus_sender_url\">this link</a> to $janus_sender_url" +janus_invitation_redundant="follow <a target=\"_blank\" href=\"$janus_sender_url_redundant\">this link</a> to $janus_sender_url_redundant" +om_url="https://openmeetings.cvh-server.de:5443/openmeetings/#room/24" +om_invitation="follow <a target=\"_blank\" href=\"$om_url\">this link</a> to $om_url" +upload_sender_url="https://streaming.cvh-server.de/cgi-bin/pult-upload-2.cgi" +upload_invitation="follow <a target="_blank" href=\"$upload_sender_url\">this link</a> to $upload_sender_url" + +module vnc vnc module_name="VNC" listen=22 invitation="connect through SSH tunnel to port 5522" +module vnc-gast vnc module_name="VNC Gast" invitation="connect to streaming.cvh-server.de:2" +module bbb bbb-camera module_name="BBB-Kamera" url="$bbb_url" invitation="$bbb_invitation" +module jm jm-camera module_name="JM-Kamera" url="$jm_url" invitation="$jm_invitation" +camera_default_max_resolution="1024x768" +module janus cvh-camera module_name="CVH-Kamera 2" url="$janus_receiver_url" persistent_invitation="$janus_invitation" +module janus-r cvh-camera module_name="CVH-Kamera 5" camera_room="1005" url="$janus_receiver_url_redundant" persistent_invitation="$janus_invitation_redundant" min_geometry="480x360-0-360" +module janus-d cvh-camera module_name="CVH-Kamera D" browser="false" direct="true" persistent_invitation="$janus_invitation" +module om om-board module_name="OM-Tafel" url="$om_url" persistent_invitation="$om_invitation" +module bbbb bbb-board module_name="BBB-Tafel" url="$bbb_url" persistent_invitation="$bbb_invitation" min_geometry="1440x810+0+0" +module upload upload module_name="Upload" persistent_invitation="$upload_invitation" diff --git a/etc/pult/pult-3.conf b/etc/pult/pult-3.conf new file mode 100644 index 0000000000000000000000000000000000000000..7e98276366c983529144a955ee2ad232467f6aef --- /dev/null +++ b/etc/pult/pult-3.conf @@ -0,0 +1,33 @@ +#start_text="starten" +#stop_text="stoppen" +#hide_text="verbergen" +#show_text="zeigen" +#min_text="minimieren" +#max_text="maximieren" + +bbb_url="https://bbb.cvh-server.de/b/pet-jxk-dch" +bbb_invitation="follow <a target=\"_blank\" href=\"$bbb_url\">this link</a> to $bbb_url" +jm_url="https://meet.cvh-server.de/VNC3" +jm_invitation="follow <a target=\"_blank\" href=\"$jm_url\">this link</a> to $jm_url" +janus_receiver_url="https://streaming.cvh-server.de/cvh-camera/camera-receiver.html?room=1003" +janus_receiver_url_redundant="https://streaming.cvh-server.de/cvh-camera/camera-receiver.html?room=1005" +janus_sender_url="https://streaming.cvh-server.de/cvh-camera/camera-sender.html?room=1003" +janus_sender_url_redundant="https://streaming.cvh-server.de/cvh-camera/camera-sender.html?room=1005" +janus_invitation="follow <a target=\"_blank\" href=\"$janus_sender_url\">this link</a> to $janus_sender_url" +janus_invitation_redundant="follow <a target=\"_blank\" href=\"$janus_sender_url_redundant\">this link</a> to $janus_sender_url_redundant" +om_url="https://openmeetings.cvh-server.de:5443/openmeetings/#room/24" +om_invitation="follow <a target=\"_blank\" href=\"$om_url\">this link</a> to $om_url" +upload_sender_url="https://streaming.cvh-server.de/cgi-bin/pult-upload-3.cgi" +upload_invitation="follow <a target="_blank" href=\"$upload_sender_url\">this link</a> to $upload_sender_url" + +module vnc vnc module_name="VNC" listen=22 invitation="connect through SSH tunnel to port 5523" +module vnc-gast vnc module_name="VNC Gast" invitation="connect to streaming.cvh-server.de:3" +module bbb bbb-camera module_name="BBB-Kamera" url="$bbb_url" invitation="$bbb_invitation" +module jm jm-camera module_name="JM-Kamera" url="$jm_url" invitation="$jm_invitation" +camera_default_max_resolution="1024x768" +module janus cvh-camera module_name="CVH-Kamera 3" url="$janus_receiver_url" persistent_invitation="$janus_invitation" +module janus-r cvh-camera module_name="CVH-Kamera 5" camera_room="1005" url="$janus_receiver_url_redundant" persistent_invitation="$janus_invitation_redundant" min_geometry="480x360-0-360" +module janus-d cvh-camera module_name="CVH-Kamera D" browser="false" direct="true" persistent_invitation="$janus_invitation" +module om om-board module_name="OM-Tafel" url="$om_url" persistent_invitation="$om_invitation" +module bbbb bbb-board module_name="BBB-Tafel" url="$bbb_url" persistent_invitation="$bbb_invitation" min_geometry="1440x810+0+0" +module upload upload module_name="Upload" persistent_invitation="$upload_invitation" diff --git a/etc/systemd/system/yesvnc@.service b/etc/systemd/system/yesvnc@.service new file mode 100644 index 0000000000000000000000000000000000000000..6b49bf610e8e622f010560aed91341dce1694e78 --- /dev/null +++ b/etc/systemd/system/yesvnc@.service @@ -0,0 +1,11 @@ +[Unit] +Description = yesVNC WebSocket %i +After=syslog.target network.target + +[Service] +Type = simple +User = novnc +ExecStart = /usr/local/sbin/yesvnc %i + +[Install] +WantedBy = multi-user.target diff --git a/lib/pult/pult.daemon b/lib/pult/pult.daemon index a06b23d7791138c518baf784dc9f87c0bf797e5b..c0d56f474a79189b1ecb2467d632684ba6782a4d 100755 --- a/lib/pult/pult.daemon +++ b/lib/pult/pult.daemon @@ -93,6 +93,7 @@ module () switch_to_resolution () { + $debug && echo "switch_to_resolution: $*" 1>&2 local resolution if echo "$1" | grep -q "x"; then resolution="$1" @@ -103,8 +104,8 @@ switch_to_resolution () screen_height="$2" resolution="${screen_width}x${screen_height}" fi - $debug && echo "switch_to_resolution: $resolution" 1>&2 - if xrandr | grep -q "$resolution"; then + $debug && echo "switch_to_resolution: resolution = $resolution" 1>&2 + if xrandr | grep -wq "$resolution"; then $debug && echo "standard mode: $resolution" 1>&2 else local timing=$( @@ -119,6 +120,7 @@ switch_to_resolution () xrandr --output VNC-0 --newmode "$resolution" $timing xrandr --addmode VNC-0 "$resolution" fi + $debug && echo xrandr --output VNC-0 --mode "$resolution" 1>&2 xrandr --output VNC-0 --mode "$resolution" 2>&1 xdotool mousemove $((screen_width - 1)) $((screen_height / 2)) } @@ -148,23 +150,25 @@ position_min_module () if [ -z "$geometry" ]; then geometry="480x360-0-0" fi - $debug && echo "geometry[$m] = $geometry" 1>&2 + $debug && echo "position_min_module: geometry[$mm] = $geometry" 1>&2 local min_width=$(echo "$geometry" | cut -d "x" -f 1) local min_height=$(echo "$geometry" | cut -d "x" -f 2 | sed -e 's/[-+].*$//') - local new_pos=$(echo "$geometry" | sed -e 's/^[0-9x]*//') - local new_pos_x=$(echo "$new_pos" | egrep -o '^[-+]+[0-9]+') - local new_pos_x_sign=$(echo "$new_pos_x" | cut -b 1) - new_pos_x=$(echo "$new_pos_x" | cut -b 2-) - if [ "$new_pos_x_sign" = "-" ]; then - new_pos_x=$((screen_width - min_width - new_pos_x)) - fi - local new_pos_y=$(echo "$new_pos" | egrep -o '[-+]+[0-9]+$') - local new_pos_y_sign=$(echo "$new_pos_y" | cut -b 1) - new_pos_y=$(echo "$new_pos_y" | cut -b 2-) - if [ "$new_pos_y_sign" = "-" ]; then - new_pos_y=$((screen_height - min_height - new_pos_y)) + if ((screen_width >= 2 * min_width)) || ((screen_height >= 2 * min_height)); then + local new_pos=$(echo "$geometry" | sed -e 's/^[0-9x]*//') + local new_pos_x=$(echo "$new_pos" | egrep -o '^[-+]+[0-9]+') + local new_pos_x_sign=$(echo "$new_pos_x" | cut -b 1) + new_pos_x=$(echo "$new_pos_x" | cut -b 2-) + if [ "$new_pos_x_sign" = "-" ]; then + new_pos_x=$((screen_width - min_width - new_pos_x)) + fi + local new_pos_y=$(echo "$new_pos" | egrep -o '[-+]+[0-9]+$') + local new_pos_y_sign=$(echo "$new_pos_y" | cut -b 1) + new_pos_y=$(echo "$new_pos_y" | cut -b 2-) + if [ "$new_pos_y_sign" = "-" ]; then + new_pos_y=$((screen_height - min_height - new_pos_y)) + fi + switch_to_geometry "$mm" "$wid" "$min_width" "$min_height" "$new_pos_x" "$new_pos_y" fi - switch_to_geometry "$mm" "$wid" "$min_width" "$min_height" "$new_pos_x" "$new_pos_y" } position_all_min_modules_except () @@ -238,6 +242,8 @@ shopt -s lastpipe update_pult_status background_wid=$(xwininfo -root -children | grep "$background_pattern" | awk '{ print $1; }') +rm -rf "$lock_file" + while true; do nc.openbsd -q 0 -l "$pultd_port" | \ while read -ra cmd; do diff --git a/lib/pult/pult.functions b/lib/pult/pult.functions index 0edb5b22ec827aa4f9b8dc041f0893b299944069..c0c8d61cfff45c1a214c1a946b353f7c3343a3c2 100644 --- a/lib/pult/pult.functions +++ b/lib/pult/pult.functions @@ -1,4 +1,9 @@ +send_command () +{ + echo "$module_name" $* | nc localhost "$pultd_port" +} + report_status () { - echo "$module_name status $*" | nc localhost "$pultd_port" + send_command "status" $* } diff --git a/lib/pult/upload.daemon b/lib/pult/upload.daemon index 007e53f08cbe3c6b1d8a5492ec2317c7437f20f9..6e34ccd2b708cc77b3cc67c2f08cb0eb52ae3060 100755 --- a/lib/pult/upload.daemon +++ b/lib/pult/upload.daemon @@ -58,8 +58,9 @@ nc.openbsd -l "$module_daemon_port" | \ echo "... done." fi elif [ "$cmd" = "screenshot" ]; then + send_command "reset" echo "Receiving screenshot data $b64_filename ..." - rm -rf "$b64_filename" + rm -rf "$b64_filename" "$upload_filename" touch "$lock_filename" read line while [ -n "$line" ]; do diff --git a/lib/pult/upload.module b/lib/pult/upload.module index d48621b6caff12524b86c954f95becee7fa05a62..0c55f0a3f193b624c8a0747a048765c65d6d0156 100755 --- a/lib/pult/upload.module +++ b/lib/pult/upload.module @@ -31,7 +31,11 @@ img_title="$module_name Image Viewer" cmd="$1" case "$cmd" in start) - rm -rf "$pid_file" "$config_file" "$upload_dir/$filename" "$upload_dir/$error_filename" "$upload_dir/$lock_filename" "$www_dir$download_dir/$filename" + if [ -f "$pid_file" ]; then + kill $(cat "$pid_file") || true + rm -rf "$pid_file" + fi + rm -rf "$config_file" "$upload_dir/$filename" "$upload_dir/$error_filename" "$upload_dir/$lock_filename" "$www_dir$download_dir/$filename" touch "$config_file" echo -e "\$pultd_port = $pultd_port;" >> "$config_file" echo -e "\$module_name = \"$module_name\";" >> "$config_file" @@ -61,11 +65,13 @@ case "$cmd" in "$upload_dir/$filename" & websockify_pid="$!" echo "$websockify_pid" >> "$pid_file" - while [ -z "$(ps -o pid,ppid -ax | grep $websockify_pid\$)" ]; do + while ps -p "$websockify_pid" > /dev/null && [ -z "$(ps -o pid,ppid -ax | grep $websockify_pid\$)" ]; do sleep 0.1 done - ps -o pid,ppid -ax | grep "$websockify_pid\$" | cut -d " " -f 1 >> "$pid_file" - (sleep 0.1; report_status "listening") & + if ps -p "$websockify_pid" > /dev/null; then + ps -o pid,ppid -ax | grep "$websockify_pid\$" | cut -d " " -f 1 >> "$pid_file" + (sleep 0.1; report_status "listening") & + fi ;; stop) if [ -f "$pid_file" ]; then diff --git a/lib/pult/vnc.daemon b/lib/pult/vnc.daemon index a033d3e2e0eb41209143ab33825c67ef05c6e5c2..e72f95b0bec0a2c644b66f066f59e8a26e42756f 100755 --- a/lib/pult/vnc.daemon +++ b/lib/pult/vnc.daemon @@ -49,17 +49,23 @@ while true; do resolution=$(echo "$line" | grep "created.*image" \ | grep -o " *[0-9x]* *$") if [ -n "$resolution" ]; then - $debug && echo -e "$0[$channel]: line = \"$line\"" - width=$(echo "$resolution" | cut -d "x" -f 1) - height=$(echo "$resolution" | cut -d "x" -f 2) + $debug && echo -e "$0[$channel]: line = \"$line\"" 1>&2 + $debug && echo -e "$0[$channel]: resolution = \"$resolution\"" 1>&2 + width=$(echo $resolution | cut -d "x" -f 1) + height=$(echo $resolution | cut -d "x" -f 2) + $debug && echo "$0[$channel]: width = $width, height = $height" 1>&2 # if [ "$width" -gt "$((2 * height))" ]; then # width=$((height * 16 / 9 + 4)) # height=$((height + 24)) # fi - line=$(xwininfo -root -children | grep "ssvnc") + line=$(xwininfo -root -children | grep "SSVNC") + $debug && echo -e "$0[$channel]: line = \"$line\"" 1>&2 windowid=$(echo "$line" | awk '{ print $1; }') + $debug && echo -e "$0[$channel]: windowid = \"$windowid\"" 1>&2 xdotool set_window --name "Controlled by PULT" "$windowid" report_status "running" "$windowid" "$width" "$height" + elif echo "$line" | grep -q "VNC server closed connection"; then + report_status "listening" fi done sleep 1 diff --git a/pult-install b/pult-install index 9c0f23016ee35b4ba073ea81bd344163308a42a9..3bf80e361b7ef8eaeaf485c5046f138bfb4a0169 100755 --- a/pult-install +++ b/pult-install @@ -40,6 +40,7 @@ echo "Installing PULT ..." for file in \ novnc \ + yesvnc \ vncrepeater \ vncserver \ cvh-camera \ diff --git a/sbin/yesvnc b/sbin/yesvnc new file mode 100755 index 0000000000000000000000000000000000000000..8e22c3308846cfe68abdedb0eeff256da0acf831 --- /dev/null +++ b/sbin/yesvnc @@ -0,0 +1,8 @@ +#!/bin/sh + +channel="$1" + +websocket_port="$((5530 + channel))" +vnc_port="$((5500 + channel))" + +websockify "$websocket_port" "localhost:$vnc_port" diff --git a/www/cgi-bin/pult-upload.cgi b/www/cgi-bin/pult-upload.cgi index f57dc08b3530026b507581eb22f04634c9127a4e..bd72c03a3671aa9361836bca2b72293e604e4428 100755 --- a/www/cgi-bin/pult-upload.cgi +++ b/www/cgi-bin/pult-upload.cgi @@ -44,6 +44,8 @@ if ( open CONFIG, "$config_file" ) if ( $channel >= 1 && $channel <= 6 && $upload_filehandle ) { + system ( "echo $module_name reset | nc localhost $pultd_port >/dev/null" ); + usleep ( 1000000 ); open ( UPLOADFILE, ">$upload_dir/$filename" ) or die "$!"; binmode UPLOADFILE; while ( <$upload_filehandle> )