[
  {
    "path": ".gitignore",
    "content": ".DS_Store"
  },
  {
    "path": "README.md",
    "content": "# Raspberry PI SD Installer OS X\n\n### Shell Script for creating Raspberry PI SD card on OS X.\n\n---\n\n##### Usage:\n\n1. Simply execute the install script from Terminal and pass the image to write. (Image, not ZIP)\n\n\teg. `sudo ./install ~/Downloads/wheezyDebian.img`\n\n2. Select the disk to write the image to by selecting the disk number provided in the output.\n\n3. Wait for disk to finish writing. You can check the write progress with `Ctrl+T`.\n\n---\n\n##### CAUTION:\n\n**Make absolutely sure to select the correct disk from the list of mounted disks output by the script.\nSelecting your system drive WILL overwrite it!**\n\nIf you are unsure which disk you need to select you can remove the SD card, check the mounted disks by running `df -hl` and \nthen re-check after re-inserting the SD card.\n\nThe disk name will likely be something similar to: `/dev/disk2s1`\n\n---\n\n#### [Download SD Card Images here.](http://www.raspberrypi.org/downloads)"
  },
  {
    "path": "install",
    "content": "#!/bin/bash\n\n# Raspberry PI Install Script\n# Author: Ray Viljoen\n\n# Quit on error\nset -e\n\n_piline=\"------------------------------------------------------------------------------------\"\n\n# Display colorized information output\nfunction _info() {\n    COLOR='\\033[00;32m' # green\n    RESET='\\033[00;00m' # white\n    echo -e \"${COLOR}${@}${RESET}\"\n}\n \n# Display colorized warning output\nfunction _warn() {\n    COLOR='\\033[00;31m' # red\n    RESET='\\033[00;00m' # white\n    echo -e \"${COLOR}${@}${RESET}\"\n}\n\n_info '\n__________.___  .___                 __         .__  .__                \n\\______   \\   | |   | ____   _______/  |______  |  | |  |   ___________ \n |     ___/   | |   |/    \\ /  ___/\\   __\\__  \\ |  | |  | _/ __ \\_  __ \\\n |    |   |   | |   |   |  \\\\___ \\  |  |  / __ \\|  |_|  |_\\  ___/|  | \\/\n |____|   |___| |___|___|  /____  > |__| (____  /____/____/\\___  >__|   \n                         \\/     \\/            \\/               \\/       \n'\n\n\n# Set $1 as image path\nDISTRO=\"$1\"\n\n# Check image path is set else exit\nif [ -z \"$DISTRO\" ]; then\n    _warn $_piline\n    _warn \"ERR: No image path supplied\"\n    _warn $_piline\n    exit 0\nfi\n\n\n\n# Selected disk\n_udisk=\"\"\n\nfunction promptDisk() {\n\n    # ================================================\n    # Check connected disks and save paths to array\n    # ================================================\n\n    # Counter\n    i=0\n\n    echo $_piline\n\n    # Loop over df -lh\n    while read line; do\n\n        # Print with local mount only and add counter to select disk\n        if [ \"$i\" -gt 0 ]; then\n            echo \"$i) $line\"\n            # Asign first work (path) to array with corresponding counter\n            _mount[i]=$( echo $line | awk '{print $1;}')\n        else\n            _info \"   $line\"\n            echo $_piline\n        fi\n\n        # Increment counter\n        ((i++))\n\n    done <<< \"$(df -h)\"\n    echo -e \"$_piline\\n\"\n\n    _opts=''\n    for i in \"${!_mount[@]}\"; do\n        [ -z \"$_opts\" ] && _opts=\"${_opts}${i}\" || _opts=\"${_opts}, ${i}\"\n    done\n\n    # Ask user to select mounted disk\n    echo \"Select the disk to use by enetering the disk number.\"\n    _warn \"*** MAKE SURE YOU SELECT THE CORRECT DISK ***\"\n    _warn \"*** Refer to the Readme if uncertain ***\"\n    echo -n -e \"\\nUse disk [ $_opts ] #\"\n    read ans\n\n    # Set selected disk\n    _udisk=${_mount[$ans]}\n\n    # Test if valid disk selected\n    if [ -z \"$_udisk\" ]; then\n        _warn \"\\n ======= Invalid selection ======= \\n\"\n        promptDisk\n    fi\n}\n\n# Run prompt\npromptDisk\n\n# ===========================================================\n# Past this point a valid disk has been selected, so proceed.\n# ===========================================================\n\n# Format disk name to raw format\n_rawdisk=$( echo $_udisk | awk 'sub(\"..$\", \"\")' | sed 's/disk/rdisk/')\n\n# Unmount Disk\necho \"Unmounting Disk\"\ndiskutil unmount $_udisk\n\necho \"Writing image\"\necho \"Ctrl+T to see progress..\"\nsudo dd bs=1m if=${DISTRO} of=${_rawdisk}\n\n# Eject disk\necho \"Ejecting Disk\"\ndiskutil eject ${_rawdisk}\n\n_info \"All Done!\""
  }
]