professional rework

main
meftimes 2024-11-03 20:24:16 -05:00
parent 3f89f2a86f
commit 6f1ae79122
1 changed files with 41 additions and 42 deletions

View File

@ -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}') grep "$TODAY" $DATES_FILE | while read -r LINE; do
AGE=$(expr $CURRENTYEAR - $BIRTHYEAR) CATEGORY=$(echo "$LINE" | awk '{print $1}')
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 case $CATEGORY in
"BIRTHDAY" ) "BIRTHDAY" )
curl \ CURRENTYEAR=$(date +%Y)
-u :ntfy_token_goes_here \ NAME=$(echo "$LINE" | awk '{$1=$2=$3=$4=""; print $0}' )
-H "Priority: urgent" \ BIRTHYEAR=$(echo "$LINE" | awk '{print $4}')
-H "Tags: birthday" \ AGE=$(( CURRENTYEAR - BIRTHYEAR ))
-H "Title: Birthday" \
-d "$NAME is $AGE years old today!" \ TAGS="birthday"
https://ntfy_url_goes_here TITLE="Birthday"
CONTENT="$NAME is $AGE years old today!"
;; ;;
"RENT" ) "RENT" )
curl \ TAGS="money_with_wings"
-u :ntfy_token_goes_here \ TITLE="Rent Reminder"
-H "Priority: urgent" \ CONTENT="Payment due!"
-H "Tags: money_with_wings" \
-H "Title: Rent Reminder" \
-d "Payment due!" \
https://ntfy_url_goes_here
;; ;;
"REMINDER" ) "REMINDER" )
curl \ REMINDER=$(echo "$LINE" | awk '{$1=$2=$3=""; print $0}')
-u :ntfy_token_goes_here \ TAGS="reminder_ribbon"
-H "Priority: urgent" \ TITLE="Reminder"
-H "Tags: reminder_ribbon" \ CONTENT="$REMINDER"
-H "Title: Reminder" \
-d "$REMINDER" \
https://ntfy_url_goes_here
;; ;;
*)
TAGS=""
TITLE="Unknown category"
CONTENT="..."
esac esac
else curl \
echo true #do nothing -u :$NTFY_TOKEN \
fi -H "Priority: urgent" \
-H "Tags: $TAGS" \
#absolute path required in script for cronjob to work -H "Title: $TITLE" \
-d "$CONTENT" \
https://ntfy.meftimes.com/alerts
done