Machine Box

Easily start and stop Machine Box boxes.

Image preview of Machine Box plugin.

machinebox.1m.sh

Edit
Open on GitHub
#!/bin/bash

# ----------------------------------------------------------------
# TODO: insert your MB_KEY here.
# Get your key from https://machinebox.io/account
# For more help, see https://machinebox.io/docs/setup/box-key
MB_KEY=""
# ----------------------------------------------------------------

# <xbar.title>Machine Box</xbar.title>
# <xbar.version>v1.0</xbar.version>
# <xbar.author>Machina</xbar.author>
# <xbar.author.github>machinabot</xbar.author.github>
# <xbar.desc>Easily start and stop Machine Box boxes.</xbar.desc>
# <xbar.image>http://i.imgur.com/gkOYSWH.png</xbar.image>
# <xbar.dependencies>bash,jq,docker</xbar.dependencies>
# <xbar.abouturl>https://machinebox.io/?source=bitbar</xbar.abouturl>

export PATH="$PATH:/usr/local/bin"
command -v jq >/dev/null 2>&1 || { echo >&2 "Click to install jq command... | href=https://stedolan.github.io/jq/?source=bitbar"; exit 0; }
command -v docker >/dev/null 2>&1 || { echo >&2 "Click to install Docker... | href=https://machinebox.io/out/docker/install?source=bitbar"; exit 0; }

if [ "$#" -gt 1 ]; then
    if [ "$1" = "start" ]; then
        if [ "$MB_KEY" = "" ]; then
            osascript -e 'display notification "You need to configure your MB_KEY environment variable" with title "Machine Box" subtitle "Failed to start box"' 
            exit 0
        fi
        osascript -e 'display notification "Go to http://localhost:8080/" with title "Machine Box" subtitle "Downloading and starting..."' 
        docker run -d -p 8080:8080 -e "MB_KEY=$MB_KEY" "machinebox/$2"
        open http://localhost:8080
        exit 0
    fi
    if [ "$1" = "stop" ]; then
        echo "stopping $2..."
        osascript -e 'display notification "Stopping..." with title "Machine Box"' 
        docker stop "$(docker ps -q --filter ancestor="machinebox/$2")"
        osascript -e 'display notification "Box has been stopped" with title "Machine Box" subtitle "Stopped"' 
        exit 0
    fi
fi

echo " | image=iVBORw0KGgoAAAANSUhEUgAAAC0AAAAtCAYAAAA6GuKaAAAMFWlDQ1BJQ0MgUHJvZmlsZQAASImVVwdYU8kWnltSCCSUAAJSQu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OQTZimQR9kB1h3EC78wmaVRSi6lAlWbh2JSul8mlqSQ1RMq9Qe/yyUZlFpowsLD4jwJ5+9+1WvaVNTQxHXW93nZs2Z/HC+792z1f1N996qwOA+JaLL9815BYc9vWA+T1nWSuupgiWdGMGy72r731jID7a9VLL0VX/9sX1j5R7fN/riPapxwe6kZilaBDGpuDzRkm1laLpJCHzgopEGsumaGg8RvmxcQrOrqP2GpkqemJ6XfUtgvcLy//9zubmC46Z1QfSrZ3svvX3ypDZwxj7BRwDOHgpyNO8+SSmzQrKGMVVm1Vs8ASWPzizkT20YKVtzayFodaRoQU1/lDFib5WeuK1PUIZwAjVZRTFhvdnJ/bRc4MX6Pm+c7S35z16ofMsST43pcuLaNSis1xViIKJLNk9LnZqsF2+9U+s8dtNqxpWrl4lnR7oohd379k0rmTeBADO8DUsc1CfxDSfnanp0YHBH5WFG0acVvvPkNg4YrnU/b/uaaF3Y4N6PpYU169fTytWrKAINrn8+0bk5Qi989Z+KkXIjo+OUt1n5tLylSupqqqKktjUvvTCi+zwhU7W8cxv9BV333nbrRtupzmil85XWEYqZOXBN1559aVPcnufxnQBuPH+QOeJIo/7cNfo8MJtfzxYcrPdpwZtLrEneslounU1m1Y5jfjOpxT5BmyN9r/+OmGngQCUpmXLl1M1AGvIwfn7DJL6t57eQQ2V9dQZv6zZA15hsLf3wN/96J++cuYPR44BMP9Yw0m9Rhb8AS+fxPREjQlDEOCnxY3HDh7Gw7vLpk97b8OiZbaZwZC6VzwiReMxstlkM1fmO54E2BQMBBjuLQA0jW0bz8PxeQK96fQhPM+jax+h2xY2qnuOHbY8tO2JNvR7Bw4Fn+CsAIwE/Ua5wcANBm4wcIOB/68M/B+43usvlMdsowAAAABJRU5ErkJggg=="

if ! docker ps >/dev/null 2>&1; then 
    echo "---"
    echo "Docker daemon isn't running"
    echo "---"
    echo "Learn more about running Docker... | href=https://machinebox.io/docs/setup/docker?source=bitbar"
    exit 0
fi

if [ "$MB_KEY" = "" ]; then
    echo "---"
    echo "You need to Setup MB_KEY"
    echo "by editing the machinebox.sh plugin file"
    echo "---"
    echo "Get a free MB_KEY... | href=https://machinebox.io/account?source=bitbar"
    exit 1
fi

# list running boxes at the top
RUNNING_BOXES=$(docker ps --format '{{.Image}}' | grep machinebox)

running=""
if [[ "$RUNNING_BOXES" = "" ]]; then 
    running=""
else
    running="yes"
fi

echo "---"

boxes=$(curl --silent 'https://machinebox.io/api/boxes?source=bitbar' | jq -r '.boxes[].name')

for box in $boxes; do
    if [ "$(docker ps | grep -c "machinebox/$box")" = 1 ]; then
        echo "$box"
        echo "--Open console... | href=http://localhost:8080"
        echo "--Stop $box | bash=$0 refresh=true terminal=false param1=stop param2=$box"
    else
        if [[ "$running" = "yes" ]]; then
            echo "Start $box"
        else
            echo "Start $box | bash=$0 refresh=true terminal=false param1=start param2=$box"
        fi
    fi
done

echo "---"
echo "Open machinebox.io... | href=https://machinebox.io/account?source=bitbar"