Skip to content

Instantly share code, notes, and snippets.

@sentient06
Created December 3, 2024 10:11
Show Gist options
  • Save sentient06/5ee11499cbf157d5ab6973f313c95078 to your computer and use it in GitHub Desktop.
Save sentient06/5ee11499cbf157d5ab6973f313c95078 to your computer and use it in GitHub Desktop.
Classic Macintosh Projects - Script for building and mounting image on QEMU
#!/bin/bash
if [ $# -ne 2 ] ; then
echo "Syntax: $0 [project_name] [should_build = 0 | 1]"
exit 1
fi
if [ ! -d "$1" ]; then
echo 'The specified project folder does not exist'
exit 1
fi
PRNAME=${1%/}
SBUILD=${2%}
if [ "$SBUILD" = "1" ]; then
rm -rf "$PRNAME/build"
./build.sh "$PRNAME"
fi
OUTFILE="$PRNAME/build/$PRNAME.bin"
IMGFILE="./R68Discs/$PRNAME.img"
if [ -f $OUTFILE ]; then
rm -rf $IMGFILE
./create_hfs_disk.sh "$OUTFILE"
if [ -f $IMGFILE ]; then
# QEMU runs on sudo because of the network settings.
# Add root password to Keychain:
# security add-generic-password -s "admin" -a "" -w "password"
if echo `security find-generic-password -s "Terminal" -a "root" -w` | sudo -kS ./check-qemu.sh; then
echo "VM is running, proceeding to mount CD-ROM..."
echo `security find-generic-password -s "Terminal" -a "root" -w` | sudo -kS ./attach-cdrom.sh "$(pwd)/R68Discs/$PRNAME.img"
else
echo "VM is not running, please start it first"
fi
fi
else
echo "Build failed: $OUTFILE not found!"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment