professional rework
parent
3f89f2a86f
commit
6f1ae79122
83
remind.sh
83
remind.sh
|
@ -1,49 +1,48 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
TODAY=$(date +"%B %d") #month day
|
DATES_FILE="/home/meftimes/scripts/dates.txt"
|
||||||
CURRENTYEAR=$(date +%Y)
|
NTFY_TOKEN="token_goes_here"
|
||||||
|
|
||||||
if grep -q "$TODAY" /home/$USER/scripts/dates.txt; then
|
TODAY=$(date +"%B %d") #works
|
||||||
NAME=$(grep "$TODAY" /home/meftimes/scripts/dates.txt | awk '{$1=$2=$3=$4=""; print $0}')
|
|
||||||
BIRTHYEAR=$(grep "$TODAY" /home/meftimes/scripts/dates.txt | awk '{print $4}')
|
|
||||||
AGE=$(expr $CURRENTYEAR - $BIRTHYEAR)
|
|
||||||
CATEGORY=$(grep "$TODAY" /home/meftimes/scripts/dates.txt | awk '{print $1}')
|
|
||||||
REMINDER=$(grep "$TODAY" /home/meftimes/scripts/dates.txt | awk '{$1=$2=$3=""; print $0}')
|
|
||||||
|
|
||||||
case $CATEGORY in
|
grep "$TODAY" $DATES_FILE | while read -r LINE; do
|
||||||
"BIRTHDAY" )
|
CATEGORY=$(echo "$LINE" | awk '{print $1}')
|
||||||
curl \
|
|
||||||
-u :ntfy_token_goes_here \
|
case $CATEGORY in
|
||||||
-H "Priority: urgent" \
|
"BIRTHDAY" )
|
||||||
-H "Tags: birthday" \
|
CURRENTYEAR=$(date +%Y)
|
||||||
-H "Title: Birthday" \
|
NAME=$(echo "$LINE" | awk '{$1=$2=$3=$4=""; print $0}' )
|
||||||
-d "$NAME is $AGE years old today!" \
|
BIRTHYEAR=$(echo "$LINE" | awk '{print $4}')
|
||||||
https://ntfy_url_goes_here
|
AGE=$(( CURRENTYEAR - BIRTHYEAR ))
|
||||||
;;
|
|
||||||
|
|
||||||
"RENT" )
|
TAGS="birthday"
|
||||||
curl \
|
TITLE="Birthday"
|
||||||
-u :ntfy_token_goes_here \
|
CONTENT="$NAME is $AGE years old today!"
|
||||||
-H "Priority: urgent" \
|
;;
|
||||||
-H "Tags: money_with_wings" \
|
|
||||||
-H "Title: Rent Reminder" \
|
|
||||||
-d "Payment due!" \
|
|
||||||
https://ntfy_url_goes_here
|
|
||||||
;;
|
|
||||||
|
|
||||||
"REMINDER" )
|
"RENT" )
|
||||||
curl \
|
TAGS="money_with_wings"
|
||||||
-u :ntfy_token_goes_here \
|
TITLE="Rent Reminder"
|
||||||
-H "Priority: urgent" \
|
CONTENT="Payment due!"
|
||||||
-H "Tags: reminder_ribbon" \
|
;;
|
||||||
-H "Title: Reminder" \
|
|
||||||
-d "$REMINDER" \
|
|
||||||
https://ntfy_url_goes_here
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
else
|
"REMINDER" )
|
||||||
echo true #do nothing
|
REMINDER=$(echo "$LINE" | awk '{$1=$2=$3=""; print $0}')
|
||||||
fi
|
TAGS="reminder_ribbon"
|
||||||
|
TITLE="Reminder"
|
||||||
#absolute path required in script for cronjob to work
|
CONTENT="$REMINDER"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
TAGS=""
|
||||||
|
TITLE="Unknown category"
|
||||||
|
CONTENT="..."
|
||||||
|
esac
|
||||||
|
|
||||||
|
curl \
|
||||||
|
-u :$NTFY_TOKEN \
|
||||||
|
-H "Priority: urgent" \
|
||||||
|
-H "Tags: $TAGS" \
|
||||||
|
-H "Title: $TITLE" \
|
||||||
|
-d "$CONTENT" \
|
||||||
|
https://ntfy.meftimes.com/alerts
|
||||||
|
done
|
||||||
|
|
Loading…
Reference in New Issue