Add 86Box launch script for MacOS
parent
922fb54ccf
commit
b3ee4d1d7a
@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Enable strict mode
|
||||
set -euo pipefail
|
||||
|
||||
# Attempt to create a specific directory as a crude lock
|
||||
machine_dir=$HOME/486
|
||||
lock_dir=$machine_dir/.locked
|
||||
if ! mkdir "$lock_dir" 2> /dev/null
|
||||
then
|
||||
echo "Lockout failed. The machine may already be running." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Initialize globals used by handle-trap
|
||||
signals='INT TERM'
|
||||
|
||||
# Usage: handle-trap [exit_code]
|
||||
#
|
||||
# Removes the lock upon script exit or signal
|
||||
#
|
||||
# Positional arguments:
|
||||
# exit_code Optional exit code for which to trigger a script exit
|
||||
function handle-trap
|
||||
{
|
||||
trap - EXIT $signals
|
||||
rm -r "$lock_dir"
|
||||
if [[ $# -gt 0 ]]
|
||||
then
|
||||
exit "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
# Set the trap
|
||||
trap handle-trap EXIT
|
||||
trap 'handle-trap 1' $signals
|
||||
|
||||
# Change into the machine directory and start the machine
|
||||
cd "$machine_dir"
|
||||
86Box.app/Contents/MacOS/86Box
|
Loading…
Reference in New Issue