original.sh 691 B

123456789101112131415161718192021222324252627
  1. #!/bin/bash
  2. file_path="$HOME/.scripts/buskill"
  3. failed_path="$file_path/.failed"
  4. countdown_path="$file_path/countdown.template"
  5. last_status_path="$file_path/.last_status"
  6. days_missed=$(<"$failed_path")
  7. if [ "$days_missed" = "" ]; then
  8. days_missed=0
  9. fi
  10. echo "Days Missed: $days_missed"
  11. if [ "$days_missed" -gt 0 ]; then
  12. status_content="$(sed "s/%days%/$days_missed/" < "$countdown_path")"
  13. toot_output="$(toot post "$status_content")"
  14. status_id="$(echo "$toot_output" | awk -F '/' '{print $6}')"
  15. let days_missed++
  16. echo "$days_missed" > "$failed_path"
  17. echo "$status_id" > "$last_status_path"
  18. else
  19. echo 1 > "$failed_path"
  20. echo > "$last_status_path"
  21. fi