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