#!/bin/sh # Author: Robert Harder # Date: September 2010 # License: Public Domain # For use with notifo.com # Provide your username and API key here # Example NOTIFO_USER=johndoe NOTIFO_API_KEY=baf06f567ee7e30bc5ab5760b48ab748e7e30bcd3 # Default values LABEL=$(hostname) TITLE=$(whoami) MSG= URI= function USAGE(){ echo "Usage: $0 [-l label] [-t title] [-u url] [message]" echo " -l label The application sending the message" echo " -t title The title of the message" echo " -u url The URL to take the user for more information" echo " message The message to display to the user or STDIN if not supplied" echo " -h/-? This help message" echo "Example: $0 -l Log -t "Access Granted" A user has logged into your system." } # Process command line arguments while [ "$1" ] do if [ "$1" = "-l" ]; then LABEL="$2" shift 2 elif [ "$1" = "-t" ]; then TITLE="$2" shift 2 elif [ "$1" = "-u" ]; then URI="$2" shift 2 elif [ "$1" = "-h" ]; then USAGE exit 0 elif [ "$1" = "-?" ]; then USAGE exit 0 else MSG="$@" shift $# fi done # Change command line to curl depending on whether the # message is coming from command line arguments or from STDIN. if [ -n "$MSG" ]; then MSGCOMPONENT="msg=${MSG}" else MSGCOMPONENT="msg@-" fi #echo \ curl -s -k \ -u ${NOTIFO_USER}:${NOTIFO_API_KEY} \ --data-urlencode "label=${LABEL}" \ --data-urlencode "title=${TITLE}" \ --data-urlencode "uri=${URI}" \ --data-urlencode "${MSGCOMPONENT}" \ https://api.notifo.com/v1/send_notification echo