1
0
mirror of synced 2026-01-12 00:42:56 +00:00
Interlisp.medley/scripts/loadup-setup.sh
Frank Halasz 415a698df5
Overhaul of loadup scripts (#1699)
* Make medley.sh and its associated scripts POSIX compliant - i.e., debashify them

* Added config file for medley script, medley now reads from config file and prepends arguemnts from file to the copmmand line arguments

* WIP. Updates to medley.sh scripts.

* WIP.  More on medley.sh and friends update.

* WIP. Medley redo

* WIP.  Debugging new medley scripts

* Renamed medley.sh/medley.command to be medley_main.sh.  Added code to compile single medley.sh/medley.command script by inlining all of the source'd medley_*.sh files.

* Add temp fix for cygwin Issue #1685

* Minor fixup to medley_utils.sh; take debug code out out of run_medley

* Add README to medley directory to explain how to compile medley.sh (medley.command).

* Ooops. This time really adding the README file to the medley directory explaining how to compile medley.sh (medley.command)

* Update loadup- scripts to use updated medley scripts rather than run-medley

* Fix default setting of $config_file in medley_configfile.sh

* Redo medley compile to pick up last commikt

* Fixing how maiko exe is found and sysout argument error processing - both issues discovered testing on MAcOS

* In medley_configfile, replace echo with printf %s because echo - does not work in zsh

* Supress config file on loadups calls to Medley

* Add oldschool support (use original run-medley) to loadup scripts; improve FAILURE detection so loadup-all won't proceed once one of the components fails

* Add in medley_args.sh add -prog as synonym to --maikoprog to aid in loadup scripts; in medley_run.sh script try to get a good exit code for call to maiko, especially useful for loadup scripts

* Run loadup scripts thru shellcheck and update as necessary to make Posix compliant

* Get rid of -nt comparisons in loadup-setup.sh because they are not posix-complaint.  They were not really needed anyway.

* Removing (for now) use of lde exit codes to decide FAILURE case in loadup-setup.sh since exit codes from lde apperar to be inverted on MacOS.

* Update medley man page.  Add - functionality to more args is medley_args.sh

* Compile medley.sh with changes from last commit

* Ooops.  Left medley_args.sh changes out of last commit.  Rectifying here.

* Added support for LDEKEYBOARDTYPE to medley_run to match run-medley

* Add to medley.sh: auto numbered id's and titles with id's inserted

* Cleanup some shellcheck issues in medley_main.sh

* fix maiko args -nh-xxx.  were -nethub-xxxx. In medley_run.sh

* Overhaul handling of pass-on args to manage the quoting issues prevelant in the previous implementation

* Cleanup minor shellcheck issues in medley_*.sh scripts

* Add underscore as character allowed in ids - makes things clearer when id used with +

* Add a self-numbering id to medley calls in loadup scripts

* Put workaround in medley_run.sh for Issue #1702 - issues with sysout arg processing in Maiko

* Oops.  messed up LDESRCSYSOUT in last commit.  should be LDESOURCESYSOUT

* compile medley.sh
2024-05-09 21:31:27 -07:00

164 lines
3.5 KiB
Bash

#!sh
# shellcheck shell=sh
MEDLEYDIR="$(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
scr="-sc 1024x768 -g 1042x790"
geometry=1024x768
touch "${LOADUP_WORKDIR}"/loadup.timestamp
script_name=$(basename "$0" ".sh")
cmfile="${LOADUP_WORKDIR}/${script_name}.cm"
# 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
./medley --config - \
--id loadup_+ \
--geometry "${geometry}" \
--noscroll \
--logindir "${LOADUP_LOGINDIR}" \
--greet "${cmfile}" \
--sysout "$1" \
"$2" "$3" "$4" "$5" "$6" "$7" ;
exit_code=$?
else
# shellcheck disable=SC2086
./run-medley ${scr} $2 $3 $4 $5 $6 $7 -loadup "${cmfile}" "$1"
exit_code=$?
fi
}
######################################################################