~nova/benchwarmer

62c41c0ec39a758da67534dfe07dce12c33263c7 — Nova Devereaux 5 months ago 0f28d71
Fix TZ quoting and allow regex for location key
1 files changed, 3 insertions(+), 3 deletions(-)

M build.sh
M build.sh => build.sh +3 -3
@@ 4,7 4,7 @@ EVENT_LOCATION_KEY=$2
AWS_WS_NAME=$3

function tzdateparse() {
	dos2unix | perl -ne 'chomp; if (/Z$/) { /(....)(..)(..)T(..)(..)(..)Z$/; print "$1-$2-$3 $4:$5:$6 UTC\n"; } else { /=(.*?):(....)(..)(..)T(..)(..)(..)$/; print "TZ=$1 $2-$3-$4 $5:$6:$7\n"; }' | TZ=America/Los_Angeles xargs -I {} -n 1 date -Iseconds -d {}
	dos2unix | perl -ne 'chomp; if (/Z$/) { /(....)(..)(..)T(..)(..)(..)Z$/; print "$1-$2-$3 $4:$5:$6 UTC\n"; } else { /=(.*?):(....)(..)(..)T(..)(..)(..)$/; print "TZ=\\\"$1\\\" $2-$3-$4 $5:$6:$7\n"; }' | TZ=America/Los_Angeles xargs -I {} -n 1 date -Iseconds -d {}
}
function upcominghour() {
	TZ=America/Los_Angeles date -Iseconds | perl -ne 'my @F = (/^(.*T)(\d\d).*(-.*?)$/); $F[1]++; print "$F[0]$F[1]:00:00$F[2]"'


@@ 14,6 14,6 @@ function awswormworkspace() {
	aws workspaces start-workspaces --start-workspace-requests WorkspaceId=$( aws workspaces describe-workspaces | jq '.Workspaces[] | select(.UserName=="'$AWS_WS_NAME'") | select(.State=="Available" or .State=="STOPPED") | .WorkspaceId' -r )
}

curl -so calendar.ics $CALENDAR_URI
curl -o calendar.ics $CALENDAR_URI

cat calendar.ics | grep -P '^(?:LOCATION:|DTSTART[:;])' | fgrep $EVENT_LOCATION_KEY -B 1 | fgrep DTSTART | tzdateparse | fgrep -x $UPCOMING_HOUR -q && awswormworkspace
cat calendar.ics | grep -P '^(?:LOCATION:|DTSTART[:;])' | grep -P "$EVENT_LOCATION_KEY" -B 1 | fgrep DTSTART | tzdateparse | fgrep -x $UPCOMING_HOUR -q && awswormworkspace