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.

Revisions

  1. sentient06 created this gist Dec 3, 2024.
    43 changes: 43 additions & 0 deletions build_and_run.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    #!/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