dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit 37aa008a0621aad9bf9328143ab5cb47e2886914
parent 280c573cc90c68469521fae547c913ae7ebcbfd2
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Sun, 29 Apr 2018 20:20:21 -0400

Set secret environment variables in separate file, add text script

Diffstat:
Mlinks/.bash_profile | 2++
Alinks/bin/text.sh | 38++++++++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/links/.bash_profile b/links/.bash_profile @@ -3,6 +3,8 @@ export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8 +[ -f $HOME/.secret_env_vars ] && source $HOME/.secret_env_vars + #### PATH AND MACHINE SPECIFIC CONFIGS diff --git a/links/bin/text.sh b/links/bin/text.sh @@ -0,0 +1,38 @@ +#!/bin/bash -e + +my_number='+18582473666' + +if [ "$1" == "susan" ]; then + number='+18582478946' +elif [ "$1" == "anders" ]; then + number='+18582478944' +elif [ "$1" == "christian" ]; then + number='+4530246587' +else + echo "recipient '$1' not recognized" + exit 1 +fi + +if [ -z "$TWILIO_AUTH_TOKEN" ]; then + echo "error: TWILIO_AUTH_TOKEN not set" + exit 1 +fi + +twilio_account_sid=AC4f71fe53fd07f12da0cea8295b078548 +twilio_auth_token=$TWILIO_AUTH_TOKEN + +message="$2" + +# Send a text message +response=$(curl -X POST --fail --show-error --silent\ + "https://api.twilio.com/2010-04-01/Accounts/$twilio_account_sid/Messages.xml"\ + --data-urlencode "From=$my_number" \ + --data-urlencode "To=$number" \ + --data-urlencode "Body=$message" \ + -u "$twilio_account_sid:$twilio_auth_token" ) + +# Log errors +if [ $? -gt 0 ]; then + echo "Failed to send SMS: $response" + exit 1 +fi