#!/bin/bash git_push() { git add -f percentage.txt git commit -m "YearProgressBot: logfile: Current Percentage: ${PERCENTAGE}%" echo ${GIT_NAME_AND_REPONAME} git remote -v git push --quiet -f https://${GITHUB_USERNAME}:${GIT_TOKEN}@github.com/${GIT_NAME_AND_REPONAME} } get_percentage() { source config.txt CURRENT_YEAR=$(date +%Y) if [ $((CURRENT_YEAR % 400)) -eq 0 ]; then TOTAL_DAYS=366 elif [ $((CURRENT_YEAR % 100)) -eq 0 ]; then TOTAL_DAYS=365 elif [ $((CURRENT_YEAR % 4)) -eq 0 ]; then TOTAL_DAYS=366 else TOTAL_DAYS=365 fi CURRENT_DAY=$(echo "$(date +%j) + 0" | bc) echo $((CURRENT_DAY*100/TOTAL_DAYS)) } display() { PERCENTAGE=$(get_percentage) if [ -f "percentage.txt" ]; then echo "percentage.txt present!" ; else echo "percentage.txt not found, generating it!" && touch percentage.txt ; fi if [ "${LENGTH}" = "" ]; then LENGTH=20 ; fi FILLED=$((LENGTH*PERCENTAGE/100)); BLANK=$((LENGTH-FILLED)) for ((i=0;i> percentage.txt git_push && telegram_message elif [[ "$(tail -1 percentage.txt)" -ge "99" ]] && [[ "${PERCENTAGE}" -le "1" ]]; then echo ${PERCENTAGE} >> percentage.txt git_push && telegram_message elif [[ "$(tail -1 percentage.txt)" = "${PERCENTAGE}" ]]; then echo "Percentage Same, Exiting...." exit 0 else echo bruh fi telegram_message } display main