1
0
mirror of synced 2026-01-27 12:52:06 +00:00
Files
Interlisp.medley/scripts/loadup-setup.sh
Frank Halasz 58f8fbdc53 Restore REM.CM to be separate file from greet file; Enable chaining of medley runs using REM.CM file (#2027)
- Fixed INTERPRET.REM.CM so that it no longer tries to load the file pointed to by LDEINIT and instead loads the file pointed to by LDEREMCM. 
 LDEINIT remains the file used by greet. 
- Adjusted the medley script to have a new argument -cm (or --rem.cm) which sets LDEREMCM as appropriate before launching lde.  
- Updated the loadup scripts as required to use this new -cm argument when calling medley. 
 Finally, added a new feature to the medley script -cc (or --repeat) whereby which when medley finishes it checks for a nonzero file given as the argument to -cc.  If that file exists, medley is run again (i.e., repeated) with LDEREMCM set to that file.  This repeats until this file no longer exists or is zero-length.  The file can be found as the vale of LDEREPEATCM so that each invocation of medley can modify (or delete) this file so as to change the subsequent run of medley.
2025-02-26 09:52:01 -08:00

179 lines
4.1 KiB
Bash

#!to_be_sourced_only
# shellcheck shell=sh
MEDLEYDIR=$(cd "${LOADUP_SCRIPTDIR}/.."; pwd)
export MEDLEYDIR
if [ -z "${LOADUP_WORKDIR}" ]
then
LOADUP_WORKDIR=/tmp/loadups-$$
export LOADUP_WORKDIR
fi
if [ -z "${LOADUP_SOURCEDIR}" ]
then
LOADUP_SOURCEDIR="${MEDLEYDIR}/internal/loadups"
export LOADUP_SOURCEDIR
fi
if [ -z "${LOADUP_OUTDIR}" ]
then
LOADUP_OUTDIR="${MEDLEYDIR}/loadups"
export LOADUP_OUTDIR
fi
if [ -z "${LOADUP_LOGINDIR}" ]
then
LOADUP_LOGINDIR="${LOADUP_WORKDIR}/logindir"
export LOADUP_LOGINDIR
fi
if [ ! -d "${LOADUP_OUTDIR}" ];
then
if [ ! -e "${LOADUP_OUTDIR}" ];
then
mkdir -p "${LOADUP_OUTDIR}"
else
echo "Error: ${LOADUP_OUTDIR} exists but is not a directory. Exiting."
exit 1
fi
fi
if [ ! -d "${LOADUP_WORKDIR}" ];
then
if [ ! -e "${LOADUP_WORKDIR}" ];
then
mkdir -p "${LOADUP_WORKDIR}"
else
echo "Error: ${LOADUP_WORKDIR} exists but is not a directory. Exiting."
exit 1
fi
fi
HAS_GIT= [ -f $(which git) ] && [ -x $(which git) ]
export HAS_GIT
git_commit_ID () {
if ${HAS_GIT};
then
# This does NOT indicate if there are any modified files!
COMMIT_ID=$(git -C "$1" rev-parse --short HEAD)
fi
}
git_commit_ID "${LOADUP_SOURCEDIR}"
LOADUP_COMMIT_ID="${COMMIT_ID}"
export LOADUP_COMMIT_ID
scr="-sc 1024x768 -g 1042x790"
geometry=1024x768
touch "${LOADUP_WORKDIR}"/loadup.timestamp
script_name=$(basename "$0" ".sh")
cmfile="${LOADUP_WORKDIR}/${script_name}.cm"
initfile="${LOADUP_WORKDIR}/${script_name}.init"
# look thru args looking to see if oldschool was specified in args
j=1
jmax=$#
while [ "$j" -le "$jmax" ]
do
if [ "$(eval "printf %s \${${j}}")" = "-os" ] || [ "$(eval "printf %s \${${j}}")" = "--oldschool" ]
then
LOADUP_OLDSCHOOL=true
export LOADUP_OLDSCHOOL
break
else
j=$(( j + 1 ))
fi
done
######################################################################
loadup_start () {
echo ">>>>> START ${script_name}"
if [ -d "${MEDLEYDIR}/tmp" ];
then
TMP_PRE_EXISTS="true"
if [ -d "${MEDLEYDIR}/tmp/logindir" ];
then
LOGINDIR_PRE_EXISTS="true"
else
LOGINDIR_PRE_EXISTS="false"
fi
else
LOGINDIR_PRE_EXISTS="false"
TMP_PRE_EXISTS="false"
fi
}
loadup_finish () {
rm -f "${cmfile}"
# 2024-05-05 FGH
# Can't use exit code for now since on MacOS exit codes appear to be inverted
# Will restore once MacOS exit code are figured out
# if [ "${exit_code}" -ne 0 ] || [ ! -f "${LOADUP_WORKDIR}/$1" ]
if [ ! -f "${LOADUP_WORKDIR}/$1" ]
then
echo "----- FAILURE -----"
exit_code=1
else
echo "+++++ SUCCESS +++++"
exit_code=0
fi
echo "..... files created ....."
if [ -f "${LOADUP_WORKDIR}/$1" ]
then
shift;
for f in "$@"
do
# shellcheck disable=SC2045,SC2086
for ff in $(ls -1 "${LOADUP_WORKDIR}"/$f);
do
# shellcheck disable=SC2010
ls -l "${ff}" 2>/dev/null | grep -v "^.*~[0-9]\+~$"
done
done
fi
if [ "${TMP_PRE_EXISTS}" = "false" ];
then
rm -rf "${MEDLEYDIR}/tmp"
else
if [ "${LOGINDIR_PRE_EXISTS}" = "false" ];
then
rm -rf "${MEDLEYDIR}/tmp/logindir"
fi
fi
echo "<<<<< END ${script_name}"
echo ""
exit ${exit_code}
}
run_medley () {
if [ ! "${LOADUP_OLDSCHOOL}" = true ]
then
/bin/sh "${MEDLEYDIR}/scripts/medley/medley.command" \
--config - \
--id loadup_+ \
--geometry "${geometry}" \
--noscroll \
--logindir "${LOADUP_LOGINDIR}" \
--rem.cm "${cmfile}" \
--greet "${initfile}" \
--sysout "$1" \
"$2" "$3" "$4" "$5" "$6" "$7" ;
exit_code=$?
else
# shellcheck disable=SC2086
"${MEDLEYDIR}/run-medley" ${scr} $2 $3 $4 $5 $6 $7 -loadup "${cmfile}" "$1"
exit_code=$?
fi
}
######################################################################