Just put together a quick bash script I call to email me when my pogo server comes online.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | #!/bin/bash ### ### ff0000scripts ### notify-boot ### 20150419 ### ###set defaults #set host #$(hostname) for computer name #HOST=myComputerID HOST=$( hostname ) #set user to mail to.... or email address #MAILTO=me #MAILTO=$(id -un) #generated email address user@machine: MAILTO="$(id -un)@$(hostname -f)" MAILTO=$( id -un) #input options/arguments while getopts :h:m:c:s: option; do case "${option}" in h) HOST=${OPTARG} ;; m) MAILTO=${OPTARG} ;; c) CONTENTS=${OPTARG} ;; s) SUBJECT=${OPTARG} ;; \?) echo "Invalid option: -${OPTARG}" >&2 echo " -h: hostname" echo " -m: mailto" echo " -s: subject" echo " -c: message contents" echo " -?: help" exit 1 ;; :) echo "Option -${OPTARG} requires an argument." >&2 exit 1 ;; esac done #set subject if not specified by -s if [ -z "${SUBJECT}" ]; then SUBJECT= "${HOST} rebooted" ; fi #set message contents if not specified by -c if [ -z "${CONTENTS}" ]; then CONTENTS= "${HOST} rebooted" ; fi echo "${CONTENTS}" | mail -s "${SUBJECT}" ${MAILTO} |
Leave a Reply