finishing script to add stats

master
Adriel Sand 2021-10-01 13:01:02 +03:00
parent 10ef216171
commit 0dc57b2e6b
1 changed files with 14 additions and 9 deletions

View File

@ -68,7 +68,7 @@ do
fi fi
if [[ $line = $lines ]] if [[ $line = $lines ]]
then then
time_decimal=$(echo $(date -d "$total_time" +'%H').$(($(date -d "$total_time" +'%M') * 100 / 60))) time_decimal=$(echo $(date -d "$total_time" +'%H' | bc).$(($(date -d "$total_time" +'%M' | bc) * 100 / 60)))
echo "$current_date,$time_decimal" >> days.csv echo "$current_date,$time_decimal" >> days.csv
fi fi
fi fi
@ -83,17 +83,22 @@ while read in
do do
hours=$(echo $in | cut -d, -f2) hours=$(echo $in | cut -d, -f2)
line=$(( $line + 1 )) line=$(( $line + 1 ))
date_var=$(echo $in | cut -d, -f1)
if [[ $line > $line_start ]] if [[ $line > $line_start ]]
then then
day_num=$(( $day_num + 1 )) day_num=$(( $day_num + 1 ))
if [[ $day_num = 1 ]]; then day_1=$(echo $hours | sed "s/0//"); fi if [[ $day_num = 1 ]]; then day_1=$(echo $hours | sed "s/0//"); day_date_1=$(echo $date_var | sed 's/\//\\\//g'); fi
if [[ $day_num = 2 ]]; then day_2=$(echo $hours | sed "s/0//"); fi if [[ $day_num = 2 ]]; then day_2=$(echo $hours | sed "s/0//"); day_date_2=$(echo $date_var | sed 's/\//\\\//g'); fi
if [[ $day_num = 3 ]]; then day_3=$(echo $hours | sed "s/0//"); fi if [[ $day_num = 3 ]]; then day_3=$(echo $hours | sed "s/0//"); day_date_3=$(echo $date_var | sed 's/\//\\\//g'); fi
if [[ $day_num = 4 ]]; then day_4=$(echo $hours | sed "s/0//"); fi if [[ $day_num = 4 ]]; then day_4=$(echo $hours | sed "s/0//"); day_date_4=$(echo $date_var | sed 's/\//\\\//g'); fi
if [[ $day_num = 5 ]]; then day_5=$(echo $hours | sed "s/0//"); fi if [[ $day_num = 5 ]]; then day_5=$(echo $hours | sed "s/0//"); day_date_5=$(echo $date_var | sed 's/\//\\\//g'); fi
if [[ $day_num = 6 ]]; then day_6=$(echo $hours | sed "s/0//"); fi if [[ $day_num = 6 ]]; then day_6=$(echo $hours | sed "s/0//"); day_date_6=$(echo $date_var | sed 's/\//\\\//g'); fi
if [[ $day_num = 7 ]]; then day_7=$(echo $hours | sed "s/0//"); fi if [[ $day_num = 7 ]]; then day_7=$(echo $hours | sed "s/0//"); day_date_7=$(echo $date_var | sed 's/\//\\\//g'); fi
fi fi
done < days.csv done < days.csv
cat stats.html | sed "s/offtime_1/$day_1/" | sed "s/offtime_2/$day_2/"| sed "s/offtime_3/$day_3/" | sed "s/offtime_4/$day_4/" | sed "s/offtime_5/$day_5/" | sed "s/offtime_6/$day_6/" | sed "s/offtime_7/$day_7/" > stats/index.html hours_so_far=$(($(TZ='Asia/Beirut' date +'%H') - $(echo $day_7. | cut -d. -f1)))
cat stats.html | sed "s/offtime_1/$day_1/" | sed "s/offtime_2/$day_2/"| sed "s/offtime_3/$day_3/" | sed "s/offtime_4/$day_4/" | sed "s/offtime_5/$day_5/" | sed "s/offtime_6/$day_6/" | sed "s/offtime_7/$day_7/" | sed "s/hours_so_far_day/$hours_so_far/" | sed "s/day_date_1/$day_date_1/" | sed "s/day_date_2/$day_date_2/" | sed "s/day_date_3/$day_date_3/" | sed "s/day_date_4/$day_date_4/" | sed "s/day_date_5/$day_date_5/" | sed "s/day_date_6/$day_date_6/" | sed "s/day_date_7/$day_date_7/" > /usr/local/apache2/htdocs/stats/index.html
chown daemon:daemon /usr/local/apache2/htdocs/stats/index.html