professional rework
parent
3f89f2a86f
commit
6f1ae79122
81
remind.sh
81
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 \
|
|
||||||
-H "Priority: urgent" \
|
|
||||||
-H "Tags: birthday" \
|
|
||||||
-H "Title: Birthday" \
|
|
||||||
-d "$NAME is $AGE years old today!" \
|
|
||||||
https://ntfy_url_goes_here
|
|
||||||
;;
|
|
||||||
|
|
||||||
"RENT" )
|
case $CATEGORY in
|
||||||
curl \
|
"BIRTHDAY" )
|
||||||
-u :ntfy_token_goes_here \
|
CURRENTYEAR=$(date +%Y)
|
||||||
-H "Priority: urgent" \
|
NAME=$(echo "$LINE" | awk '{$1=$2=$3=$4=""; print $0}' )
|
||||||
-H "Tags: money_with_wings" \
|
BIRTHYEAR=$(echo "$LINE" | awk '{print $4}')
|
||||||
-H "Title: Rent Reminder" \
|
AGE=$(( CURRENTYEAR - BIRTHYEAR ))
|
||||||
-d "Payment due!" \
|
|
||||||
https://ntfy_url_goes_here
|
|
||||||
;;
|
|
||||||
|
|
||||||
"REMINDER" )
|
TAGS="birthday"
|
||||||
curl \
|
TITLE="Birthday"
|
||||||
-u :ntfy_token_goes_here \
|
CONTENT="$NAME is $AGE years old today!"
|
||||||
-H "Priority: urgent" \
|
;;
|
||||||
-H "Tags: reminder_ribbon" \
|
|
||||||
-H "Title: Reminder" \
|
|
||||||
-d "$REMINDER" \
|
|
||||||
https://ntfy_url_goes_here
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
else
|
"RENT" )
|
||||||
echo true #do nothing
|
TAGS="money_with_wings"
|
||||||
fi
|
TITLE="Rent Reminder"
|
||||||
|
CONTENT="Payment due!"
|
||||||
|
;;
|
||||||
|
|
||||||
#absolute path required in script for cronjob to work
|
"REMINDER" )
|
||||||
|
REMINDER=$(echo "$LINE" | awk '{$1=$2=$3=""; print $0}')
|
||||||
|
TAGS="reminder_ribbon"
|
||||||
|
TITLE="Reminder"
|
||||||
|
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