From 59c92430cc927a155057042395507ad7eae86bcb Mon Sep 17 00:00:00 2001 From: gandalf Date: Mon, 30 May 2022 22:36:25 +0200 Subject: [PATCH] Already almost done with the caldav-project. Some template-adjustment has to be done still, but it'll do. --- .env | 1 - .gitignore | 2 + add_alarm.sh | 42 +++++ add_date.sh | 71 ++++++--- templates/alarm_frist_jura_e.ics | 5 + templates/alarm_frist_jura_t.ics | 27 ++++ templates/alarm_frist_personal_t.ics | 5 + templates/alarm_termin_jura_e.ics | 12 ++ templates/alarm_termin_personal_e.ics | 5 + templates/alarm_wv_t.ics | 21 +++ templates/template_alarm.ics | 144 ++++++++++++++++++ templates/template_frist.ics | 55 +++++++ templates/template_readable.ics | 35 +++++ template.ics => templates/template_termin.ics | 17 ++- templates/template_wv.ics | 37 +++++ 15 files changed, 453 insertions(+), 26 deletions(-) delete mode 100644 .env create mode 100755 add_alarm.sh mode change 100644 => 100755 add_date.sh create mode 100644 templates/alarm_frist_jura_e.ics create mode 100644 templates/alarm_frist_jura_t.ics create mode 100644 templates/alarm_frist_personal_t.ics create mode 100644 templates/alarm_termin_jura_e.ics create mode 100644 templates/alarm_termin_personal_e.ics create mode 100644 templates/alarm_wv_t.ics create mode 100644 templates/template_alarm.ics create mode 100644 templates/template_frist.ics create mode 100644 templates/template_readable.ics rename template.ics => templates/template_termin.ics (68%) create mode 100644 templates/template_wv.ics diff --git a/.env b/.env deleted file mode 100644 index 2995361..0000000 --- a/.env +++ /dev/null @@ -1 +0,0 @@ -FINDPATH=$HOME/Dokumente diff --git a/.gitignore b/.gitignore index 69141d7..43ca3a1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ # Custom entries .erinnermich.csv .erinneralle.csv +.env +*-*.ics # ---> Linux diff --git a/add_alarm.sh b/add_alarm.sh new file mode 100755 index 0000000..e6929ca --- /dev/null +++ b/add_alarm.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +### This shell script is used to subscribe alarms to events/todos that are to be uploaded into caldav on the owncloud server by add_date.sh + +# Usage output string. $0 is filename. +usage="$0 (t|e) categories date" + +# print usage string if improper options, or if requested. +if [ "$#" -ne 3 ] || [ "$1" == "-h" ] || [ "$1" == "--help" ]; then + echo "$usage" + exit 1 +else + +# read login credentials and config +BASEPATH=$(dirname $(realpath $0)) +. $BASEPATH/.env + +# find relevant categories and decide for a template + main_cat=$(echo $2 | cut -d, -f1 | tr 'A-Z' 'a-z') + sec_cat=$(echo $2 | cut -d, -f2 | tr 'A-Z' 'a-z') + if [ $main_cat != wv ]; then + main_cat=${main_cat}_${sec_cat} + fi + +# invoke template or exit, if template does not exist. add_date will then expect no output of this script. + template=$BASEPATH/templates/alarm_${main_cat}_$1.ics + aux=alarm.aux + if [ -e $template ]; then + cp $template $aux + else + exit 1; + fi + +# adjust the template + sed -i "s|20160225|$3|g" $aux + sed -i "s|20160224|$(($3-1))|g" $aux + sed -i "s|20160223|$(($3-2))|g" $aux + sed -i "s|replacememail|${mails[$sec_cat]}|g" $aux + +# output the stuff for add_date to read + cat $aux +fi diff --git a/add_date.sh b/add_date.sh old mode 100644 new mode 100755 index 9506cb7..d35c5b1 --- a/add_date.sh +++ b/add_date.sh @@ -1,43 +1,78 @@ #!/bin/bash -### This shell script is used to create new events in caldav on our owncloud server after a machine booking on our grr server +### This shell script is used to create new events in caldav on the owncloud server +### Copied from https://gist.github.com/remyd1/a353b07219884c5878cc27d04aab9d96 and modified to fit my needs. +# Usage output string. $0 is filename. +usage="$0 categories date description [dtstart] [dtend] +where categories is a comma separated list that MUST start with FRIST, WF or TERMIN +and the second item in this list denotes the required alarm set." -usage="$0 machineNumber user starttime endtime" - -if [ "$#" -ne 4 ] || [ "$1" == "-h" ] || [ "$1" == "--help" ];then - echo $usage +# print usage string if improper options, or if requested. +if [ "$#" -lt 3 ] || [ "$1" == "-h" ] || [ "$1" == "--help" ]; then + echo "$usage" exit 1 else +# read login credentials and config +BASEPATH=$(dirname $(realpath $0)) +. $BASEPATH/.env + +# generate random UID starting here random1=`