From: Don Armstrong Date: Tue, 29 Jan 2019 01:44:55 +0000 (-0800) Subject: add upload_ics script X-Git-Url: https://git.donarmstrong.com/?p=bin.git;a=commitdiff_plain;h=799dd7bdd11086efbaf7e6c5e0c9abf37fa39267 add upload_ics script --- diff --git a/upload_ics b/upload_ics new file mode 100644 index 0000000..559d442 --- /dev/null +++ b/upload_ics @@ -0,0 +1,38 @@ +#!/bin/bash + +set -e + +. ~/.cadaver_cals + +tempdir=$(mktemp -d) +tempdir=$(readlink -f "$tempdir") +trap "/bin/rm -f \"$tempdir\"/*.ics; rmdir \"$tempdir\"" QUIT INT EXIT + +for ics in "$@"; do + bevents=($(grep -n BEGIN:VEVENT "$file" | cut -d: -f1)) + eevents=($(grep -n END:VEVENT "$file" | cut -d: -f1)) + + ehead=${bevents[0]} + let "ehead -= 1" + + bfoot=$(wc -l < $file) + let "bfoot -= ${eevents[-1]}" + + for (( i=0; i < ${#bevents[@]}; i++)); do + head -n $ehead "$file" > "$file"-$i.ics + sed -n ${bevents[$i]},${eevents[$i]}p "$file" >> "$file"-$i.ics + tail -n $bfoot "$file" >> "$file"-$i.ics + done +done + +(cd "$tempdir"; +cadaver $CADAVER_CAL << EOC + mput *.ics + exit +EOC +rm *.ics; +) +rmdir $tempdir; +trap - QUIT INT EXIT + +