* Update docker file build to use new deb linux installers; move Dockefile to .github/workflows since its really only useable from the buildDocker.yml workflow * Fix typo in dockerfile location * remove extraneous " in >>GITHUB_ENV statements * Fix handling of TARGETPLATFORM in Dockerfile * Trying with just one platform * Fix issues with missing man-db in docker build workflow; added man-db to depends in deb builds for linux * Sicthed docker from tightvnc to tigervnc to match oio. This getting the apt package name right. * Going back to single platform to debug this thing * Trying with just arm64 * Removing arm/v7 from docker images. Takes too long to build and just wastes our github actions minutes. This is assuming its a never used feature since docker is not big on raspberry pis and their ilk. * Fix typo in control-linux; update build_deb so that files in /usr/local installed by deb are owned by root; add ubuntu user and nano in docker file for dbebugging; when in draft only create for x86_64 platform * Fix typo in buildDocker.yml * Add sudo to docker image; in docker image ensure that all /usr/local/interlisp files are owned by root * Add securityTypes none to docker entrypoint * Updated docker base to Ubuntu 22.10 to get fixed xrdp; add xrdp to the docker image; updated user permission in docker image; * In Dockerfile make xrdp install noninteractive * Update medley.sh scripts to handle docker case * Fix a couple of typos * BuildDcoker: added pulling latest draft release (if any) when this is a draft docker build; removed checkout of medley code cause its not used * BuildDocker: added medley checkout backin - turns pout its needed by a bunch of actions even though I dont really think they use it * BuildDocker: moved download assets to use gh instaed of a marketplace action becauase that action could not handle draft releases. * Tweaking medley.sh and associated tweaks to work Windows via wsl medley and docker * adding first pass at powershell script for windows docker and wsl * Tuning how Xvnc, medley, and vncviewer handle the various ways of exiting - eg logout vs closing viewer window. * Tuning vncviewer launch to make sure that tty works as expected when medley.sh runs in background * Minor typo fixes and added extra check to use of /run/shm in medley_vnc.sh * Added SSH_KEY secret to buildReleaseIncDocker workflow * Gertting the add SSH_KEY secret into orkflows right this time, hopefully * Adding TERM env variable and setting USER to medley in docker image * Debugging medley.ps1 and adding a couple of arguments * Typo in Dockerfile medley * Synchronizing flag processing and usage for medley.ps1 and medley.sh; refactored medley_args.sh and medley_usage.sh code. * Adding first pass at windows installer * Adding first pass an inno setup script for Windows installation * Update buildLoadup workflow and downloads page for windows installer * Fix typo in buildLoadup * BuildLoadup make sure windows runner uses powershell * Another typo in buildLoadup * Another typo in buildLoadup; damn those double quotes * Updating handling of windows installer in buildLoadup, added vncviewer to medley.iss install * Unknown syntax error in buildLoadup * Another damn typo from double quotes * buildLoadup: fixed loadup job outputs * buidLoadup: fixed bug with COMBINED_RELEASE_TAG; fixed Upload script in windows job to be compatible with actions.script v6. * buidLoadup: upload win installer adapted to find draft releases as well as full releases * BuildLoadup: fixing up javascript in actions in windows job to use / instead of \ in pathname * BuildLoadup: changing win installer update to same action used for other release assets * Fix windows installer file name; in BuildLoadup move update downl;oad page to the Windows runner because uploading the window-installer changes the release download url, so updating the downloads page must be done after the windows installer upload.; General buildLoadup cleanup * Run md2html to update downloads page * Fix typo in build_deb.sh * Removing some leftover crud in medley_usage.sh * Fixing up windows installer a bit, mostly cosmetic * Adding support for WSL1; mostly forcing --vnc and changing how to find open ports and displays since WSL1 networking is different tha WSL2 * Update manual page for new Windows Medley script * First pass done for man page that incorporates new Windows medley script. Add Xvnc wait before calling run-medley in case of docker to prevent occasonal missing X windows server error. * Change buildLoadup to update man page to a draft if this is a draft run.
251 lines
7.2 KiB
Bash
Executable File
251 lines
7.2 KiB
Bash
Executable File
###############################################################################
|
||
#
|
||
# medley_vnc.sh - script for running Medley Interlisp on WSL using Xvnc
|
||
# on the Linux side and a vncviewer on the Windows side.
|
||
# This script run under Linux will start the right apps
|
||
# on both the Linux and Windows sides.
|
||
#
|
||
# !!!! This script is meant to be SOURCEd from the scripts/medley.sh script.
|
||
# !!!! It should not be run as a standlone script.
|
||
#
|
||
# 2023-01-12 Frank Halasz
|
||
#
|
||
# Copyright 2023 Interlisp.org
|
||
#
|
||
###############################################################################
|
||
|
||
ip_addr() {
|
||
ip -4 -br address show dev eth0 | awk '{print $3}' | sed 's-/.*$--'
|
||
}
|
||
|
||
find_open_display() {
|
||
local ctr=1
|
||
local result=-1
|
||
local locked_pid=0
|
||
while [ ${ctr} -lt 64 ];
|
||
do
|
||
if [ ! -e /tmp/.X${ctr}-lock ];
|
||
then
|
||
result=${ctr}
|
||
break
|
||
else
|
||
locked_pid=$(cat /tmp/.X${ctr}-lock)
|
||
ps lax | awk '{print $3}' | grep --quiet ${locked_pid} >/dev/null
|
||
if [ $? -eq 1 ];
|
||
then
|
||
result=${ctr}
|
||
break
|
||
else
|
||
(( ctr++ ))
|
||
fi
|
||
fi
|
||
done
|
||
echo ${result}
|
||
}
|
||
|
||
find_open_port() {
|
||
local ctr=5900
|
||
local result=-1
|
||
while [ ${ctr} -lt 6000 ];
|
||
do
|
||
if [[ ${wsl} = true && ${wsl_ver} -eq 1 ]];
|
||
then
|
||
netstat.exe -a -n | awk '{ print $2 }' | grep -q ":${ctr}\$"
|
||
else
|
||
ss -a | grep -q "LISTEN.*:${ctr}[^0-9]"
|
||
fi
|
||
if [ $? -eq 1 ];
|
||
then
|
||
result=${ctr}
|
||
break
|
||
else
|
||
(( ctr++ ))
|
||
fi
|
||
done
|
||
echo ${result}
|
||
}
|
||
|
||
#
|
||
# Make sure prequisites for vnc support in wsl are in place
|
||
#
|
||
if [ "${use_vnc}" = "true" ];
|
||
then
|
||
win_userprofile="$(cmd.exe /c "<nul set /p=%UserProfile%" 2>/dev/null)"
|
||
vnc_dir="$(wslpath ${win_userprofile})/AppData/Local/Interlisp"
|
||
vnc_exe="vncviewer64-1.12.0.exe"
|
||
if [[ $(which Xvnc) = "" || $(Xvnc -version |& grep -iq tigervnc; echo $?) -eq 1 ]];
|
||
then
|
||
echo "Error: The -v or --vnc flag was set."
|
||
echo "But it appears that that TigerVNC \(Xvnc\) has not been installed."
|
||
echo "Please install TigerVNC using \"sudo apt install tigervnc-standalone-server tigervnc-xorg-extension\""
|
||
echo "Exiting."
|
||
exit 4
|
||
elif [ ! -e "${vnc_dir}/${vnc_exe}" ];
|
||
then
|
||
if [ -e "${IL_DIR}/wsl/${vnc_exe}" ];
|
||
then
|
||
# make sure TigerVNC viewer is in a Windows (not Linux) directory. If its in a Linux directory
|
||
# there will be a long delay when it starts up
|
||
mkdir -p ${vnc_dir}
|
||
cp -p "${IL_DIR}/wsl/${vnc_exe}" "${vnc_dir}/${vnc_exe}"
|
||
else
|
||
echo "TigerVnc viewer is required by the -vnc option but is not installed."
|
||
echo -n "Ok to download from SourceForge? [y, Y, n or N, default n] "
|
||
read resp
|
||
if [ -z ${resp} ]; then resp=n; else resp=${resp:0:1}; fi
|
||
if [[ ${resp} = 'n' || ${resp} = 'N' ]];
|
||
then
|
||
echo "Ok. You can download the Tiger VNC viewer \(v1.12.0\) .exe yourself and "
|
||
echo "place it in ${vnc_dir}/${vnc_exe}. Then retry."
|
||
echo "Exiting."
|
||
exit 5
|
||
else
|
||
pushd "${vnc_dir}" >/dev/null
|
||
wget https://sourceforge.net/projects/tigervnc/files/stable/1.12.0/vncviewer64-1.12.0.exe
|
||
popd >/dev/null
|
||
fi
|
||
fi
|
||
fi
|
||
fi
|
||
#
|
||
# Start the log file so we can trace any issues with vnc, etc
|
||
#
|
||
LOG=${LOGINDIR}/logs/medley_${run_id}.log
|
||
mkdir -p $(dirname -- ${LOG})
|
||
echo "START" >${LOG}
|
||
#
|
||
# If we're running under docker:
|
||
# set the VNC_PORT to the value of the --port flag (or its default value)
|
||
# set DISPLAY to :0
|
||
#
|
||
#set -x
|
||
if [ "${docker}" = "true" ];
|
||
then
|
||
export VNC_PORT=5900
|
||
export DISPLAY=:0
|
||
else
|
||
# are we running in background - used for pretty-fying the echos
|
||
case $(ps -o stat= -p $$) in
|
||
*+*) bg=false ;;
|
||
*) bg=true ;;
|
||
esac
|
||
# For not docker (i.e., for wsl/vnc)
|
||
# find an unused display and an available port
|
||
#
|
||
#set -x
|
||
OPEN_DISPLAY=`find_open_display`
|
||
if [ ${OPEN_DISPLAY} -eq -1 ];
|
||
then
|
||
echo "Error: cannot find an unused DISPLAY between 1 and 63"
|
||
echo "Exiting"
|
||
exit 33
|
||
else
|
||
if [ ${bg} = true ]; then echo; fi
|
||
echo "Using DISPLAY=:${OPEN_DISPLAY}"
|
||
fi
|
||
export DISPLAY=":${OPEN_DISPLAY}"
|
||
export VNC_PORT=`find_open_port`
|
||
if [ ${VNC_PORT} -eq -1 ];
|
||
then
|
||
echo "Error: cannot find an unused port between 5900 and 5999"
|
||
echo "Exiting"
|
||
exit 33
|
||
else
|
||
echo "Using VNC_PORT=${VNC_PORT}"
|
||
fi
|
||
fi
|
||
#
|
||
# Start the Xvnc server
|
||
#
|
||
mkdir -p ${LOGINDIR}/logs
|
||
/usr/bin/Xvnc "${DISPLAY}" \
|
||
-rfbport ${VNC_PORT} \
|
||
-geometry "${geometry#-g }" \
|
||
-SecurityTypes None \
|
||
-NeverShared \
|
||
-DisconnectClients=0 \
|
||
--MaxDisconnectionTime=10 \
|
||
>> ${LOG} 2>&1 &
|
||
|
||
# Leaving pid wait for all but docker,
|
||
# which seems to need it. For all others
|
||
# it seems like its not needed but we'll have
|
||
# to see how it runs on slower/faster machines
|
||
# FGH 2023-02-16
|
||
if [ ${docker} = true ];
|
||
then
|
||
xvnc_pid=""
|
||
end_time=$(expr $(date +%s) + 10)
|
||
while [ -z "${xvnc_pid}" ];
|
||
do
|
||
if [ $(date +%s) -gt $end_time ];
|
||
then
|
||
echo "Xvnc server failed to start."
|
||
echo "See log file at ${LOG}"
|
||
echo "Exiting"
|
||
exit 3
|
||
fi
|
||
sleep .125
|
||
xvnc_pid=$(pgrep -f "Xvnc ${DISPLAY}")
|
||
done
|
||
# echo "XVNC_PID is ${xvnc_pid}"
|
||
fi
|
||
#
|
||
# Run Medley in foreground if docker, else in background
|
||
#
|
||
tmp_dir=$(if [[ -d /run/shm && ! -h /run/shm ]]; then echo "/run/shm"; else echo "/tmp"; fi)
|
||
medley_run=$(mktemp --tmpdir=${tmp_dir} medley-XXXXX)
|
||
cat > ${medley_run} <<..EOF
|
||
#!/bin/bash
|
||
${MEDLEYDIR}/run-medley -id '${run_id}' ${geometry} ${screensize} ${run_args[@]} \
|
||
2>&1 | tee -a ${LOG} | grep -v "broken (explicit kill"
|
||
if [ -n "\$(pgrep -f "${vnc_exe}.*:${VNC_PORT}")" ]; then vncconfig -disconnect; fi
|
||
..EOF
|
||
#cat ${medley_run}
|
||
chmod +x ${medley_run}
|
||
if [ "${docker}" = "true" ];
|
||
then
|
||
${medley_run}; rm ${medley_run}
|
||
else
|
||
(${medley_run}; rm ${medley_run}) &
|
||
#
|
||
# If not docker (i.e., if wsl/vnc), start the vncviewer on the windows side
|
||
#
|
||
|
||
# First give medley time to startup
|
||
# sleep .25
|
||
# SLeep appears not to be needed, but faster/slower machines ????
|
||
# FGH 2023-02-08
|
||
|
||
# Then start vnc viewer on Windows side
|
||
start_time=$(date +%s)
|
||
${vnc_dir}/${vnc_exe} \
|
||
-geometry "+50+50" \
|
||
-ReconnectOnError=off \
|
||
−AlertOnFatalError=off \
|
||
$(ip_addr):${VNC_PORT} \
|
||
>>${LOG} 2>&1 &
|
||
wait $!
|
||
if [ $( expr $(date +%s) - ${start_time} ) -lt 5 ];
|
||
then
|
||
if [ -z "$(pgrep -f "Xvnc ${DISPLAY}")" ];
|
||
then
|
||
echo "Xvnc server failed to start."
|
||
echo "See log file at ${LOG}"
|
||
echo "Exiting"
|
||
exit 3
|
||
else
|
||
echo "VNC viewer failed to start.";
|
||
echo "See log file at ${LOG}";
|
||
echo "Exiting" ;
|
||
exit 4;
|
||
fi
|
||
fi
|
||
fi
|
||
#
|
||
# Done, "Go back" to medley.sh
|
||
#
|
||
true
|
||
|
||
#######################################
|