Skip to content
Snippets Groups Projects
Commit 782b0141 authored by Peter Gerwinski's avatar Peter Gerwinski
Browse files

made the upload module more robust; yesVNC init script

parent 83bd261d
Branches
No related tags found
No related merge requests found
#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"
#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"
[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
......@@ -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,9 +150,10 @@ 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/[-+].*$//')
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)
......@@ -165,6 +168,7 @@ position_min_module ()
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
}
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
......
send_command ()
{
echo "$module_name" $* | nc localhost "$pultd_port"
}
report_status ()
{
echo "$module_name status $*" | nc localhost "$pultd_port"
send_command "status" $*
}
......@@ -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
......
......@@ -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
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
......
......@@ -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
......
......@@ -40,6 +40,7 @@ echo "Installing PULT ..."
for file in \
novnc \
yesvnc \
vncrepeater \
vncserver \
cvh-camera \
......
#!/bin/sh
channel="$1"
websocket_port="$((5530 + channel))"
vnc_port="$((5500 + channel))"
websockify "$websocket_port" "localhost:$vnc_port"
......@@ -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> )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment