119 lines
5.1 KiB
Bash
Executable File
119 lines
5.1 KiB
Bash
Executable File
#!/bin/bash
|
|
## eFile is older than "nn min ago"
|
|
if [[ $(date +%s -r /tmp/index.html) -lt $(date +%s --date="1440 min ago") ]]; then
|
|
cd /tmp; rm -f index.html; rm -f /tmp/buffer
|
|
wget https://www.bio-dynamie.org/jardinage/demarrer/
|
|
fi
|
|
## EXTRACT SEMAINES
|
|
# Semaine du 26 avril au 2 mai 2021
|
|
SEM1=$(cat /tmp/index.html | awk '/Semaine/{s=x}{s=s$0"\n"}/Semaine/{print s}' | html2text -utf8 | head -n 1)
|
|
A=$(echo "$SEM1" | awk -F 'du ' '{print $2}' | cut -d ' ' -f 1)
|
|
B=$(echo "$SEM1" | awk -F 'au ' '{print $2}' | cut -d ' ' -f 1)
|
|
|
|
# Semaine du 3 au 9 mai 2021
|
|
SEM2=$(cat /tmp/index.html | awk '/Semaine/{s=x}{s=s$0"\n"}/Semaine/{print s}' | html2text -utf8 | tail -n 1)
|
|
C=$(echo "$SEM2" | awk -F 'du ' '{print $2}' | cut -d ' ' -f 1)
|
|
D=$(echo "$SEM2" | awk -F 'au ' '{print $2}' | cut -d ' ' -f 1)
|
|
|
|
echo "SEMAINES: (1) $A - $B / (2) $C - $D"
|
|
|
|
DAY=$(date +%A | awk '{ print toupper( substr( $0, 1, 1 ) ) substr( $0, 2 ); }')
|
|
DOM=$(date +%-d) && TOM=$(($DOM + 1)) && ND=$(($DOM + 7)) # remove leading 0?
|
|
MONTH=$(date +%m)
|
|
YEAR=$(date +%y)
|
|
|
|
[[ $DAY == "Monday" ]] && DAY="Lundi" && DAYE="Mardi"
|
|
[[ $DAY == "Tuesday" ]] && DAY="Mardi" && DAYE="Mercredi"
|
|
[[ $DAY == "Wednesday" ]] && DAY="Mercredi" && DAYE="Jeudi"
|
|
[[ $DAY == "Thursday" ]] && DAY="Jeudi" && DAYE="Vendredi"
|
|
[[ $DAY == "Friday" ]] && DAY="Vendredi" && DAYE="Samedi"
|
|
[[ $DAY == "Saturday" ]] && DAY="Samedi" && DAYE="Dimanche"
|
|
[[ $DAY == "Sunday" ]] && DAY="Dimanche" && DAYE="Mardi"
|
|
|
|
# CHECK WEEK INTERVAL
|
|
[[ $DOM -ge $A && $DOM -le $B ]] && S=1
|
|
[[ $DOM -ge $C && $DOM -le $D ]] && S=2
|
|
|
|
echo "##################################################################"
|
|
echo "Nous sommes $DAY $DOM/$MONTH/$YEAR (SEMAINE $S)"
|
|
echo "##################################################################"
|
|
|
|
# BROKEN cat /tmp/index.html | awk "/$DOM\/$MONTH\/$YEAR/{s=x}{s=s$0\"\n\"}/$TOM\/$MONTH\/$YEAR/{print s}" | html2text -utf8
|
|
|
|
#read
|
|
if [[ "$DAY" == "Lundi" ]]; then
|
|
echo "LUNDI"
|
|
LUNDI=$(cat /tmp/index.html | awk '/Lundi/{s=x}{s=s$0"\n"}/Mardi/{print s}' | html2text -utf8 | awk -F "$TOM/" '{print $1}')
|
|
echo "$LUNDI" > /tmp/buffer
|
|
[[ $S == "1" ]] && tr '\n' ' ' < /tmp/buffer | awk -F "$ND" '{print $1}' > /tmp/sms
|
|
[[ $S == "2" ]] && tr '\n' ' ' < /tmp/buffer | awk -F "$ND" '{print $2}' > /tmp/sms
|
|
fi
|
|
|
|
#read
|
|
if [[ "$DAY" == "Mardi" ]]; then
|
|
echo "MARDI"
|
|
MARDI=$(cat /tmp/index.html | awk '/Mardi/{s=x}{s=s$0"\n"}/Mercredi/{print s}' | html2text -utf8 | awk -F "$TOM/" '{print $1}')
|
|
echo "$MARDI" > /tmp/buffer
|
|
[[ $S == "1" ]] && tr '\n' ' ' < /tmp/buffer | awk -F "$ND" '{print $1}' > /tmp/sms
|
|
[[ $S == "2" ]] && tr '\n' ' ' < /tmp/buffer | awk -F "$ND" '{print $2}' > /tmp/sms
|
|
fi
|
|
|
|
#read
|
|
if [[ "$DAY" == "Mercredi" ]]; then
|
|
echo "MERCREDI"
|
|
MERCREDI=$(cat /tmp/index.html | awk '/Mercredi/{s=x}{s=s$0"\n"}/Jeudi/{print s}' | html2text -utf8 | awk -F "$TOM/" '{print $1}')
|
|
echo "$MERCREDI" > /tmp/buffer
|
|
[[ $S == "1" ]] && tr '\n' ' ' < /tmp/buffer | awk -F "$ND" '{print $1}' > /tmp/sms
|
|
[[ $S == "2" ]] && tr '\n' ' ' < /tmp/buffer | awk -F "$ND" '{print $2}' > /tmp/sms
|
|
fi
|
|
|
|
#read
|
|
if [[ "$DAY" == "Jeudi" ]]; then
|
|
echo "JEUDI"
|
|
JEUDI=$(cat /tmp/index.html | awk '/Jeudi/{s=x}{s=s$0"\n"}/Vendredi/{print s}' | html2text -utf8 | awk -F "$TOM/" '{print $1}')
|
|
echo "$JEUDI" > /tmp/buffer
|
|
[[ $S == "1" ]] && tr '\n' ' ' < /tmp/buffer | awk -F "$ND" '{print $1}' > /tmp/sms
|
|
[[ $S == "2" ]] && tr '\n' ' ' < /tmp/buffer | awk -F "$ND" '{print $2}' > /tmp/sms
|
|
fi
|
|
|
|
#read
|
|
if [[ "$DAY" == "Vendredi" ]]; then
|
|
echo "VENDREDI"
|
|
VENDREDI=$(cat /tmp/index.html | awk '/ Vendredi/{s=x}{s=s$0"\n"}/ Samedi/{print s}' | html2text -utf8 | awk -F "$TOM/" '{print $1}')
|
|
echo "$VENDREDI" > /tmp/buffer
|
|
[[ $S == "1" ]] && tr '\n' ' ' < /tmp/buffer | awk -F "$ND" '{print $1}' > /tmp/sms
|
|
[[ $S == "2" ]] && tr '\n' ' ' < /tmp/buffer | awk -F "$ND" '{print $2}' > /tmp/sms
|
|
fi
|
|
|
|
#read
|
|
if [[ "$DAY" == "Samedi" ]]; then
|
|
echo "SAMEDI"
|
|
SAMEDI=$(cat /tmp/index.html | awk '/Samedi/{s=x}{s=s$0"\n"}/Dimanche/{print s}' | html2text -utf8 | awk -F "$TOM/" '{print $1}')
|
|
echo "$SAMEDI" > /tmp/buffer
|
|
[[ $S == "1" ]] && tr '\n' ' ' < /tmp/buffer | awk -F "$ND" '{print $1}' > /tmp/sms
|
|
[[ $S == "2" ]] && tr '\n' ' ' < /tmp/buffer | awk -F "$ND" '{print $2}' > /tmp/sms
|
|
fi
|
|
|
|
#read
|
|
if [[ "$DAY" == "Dimanche" ]]; then
|
|
echo "DIMANCHE"
|
|
DIMANCHE=$(cat /tmp/index.html | awk '/Dimanche/{s=x}{s=s$0"\n"}/#Lune/{print s}' | html2text -utf8 | awk -F "$TOM/" '{print $1}')
|
|
echo "$DIMANCHE" > /tmp/buffer
|
|
[[ $S == "1" ]] && tr '\n' ' ' < /tmp/buffer | awk -F '#' '{print $1}' > /tmp/sms
|
|
[[ $S == "2" ]] && tr '\n' ' ' < /tmp/buffer | awk -F '#' '{print $2}' > /tmp/sms
|
|
fi
|
|
|
|
if [[ "$DAY" == "Lundi" ]]; then
|
|
echo "__________LUNE__________"
|
|
LUNE=$(cat /tmp/index.html | awk '/#Lune/{s=x}{s=s$0"\n"}/\.#/{print s}' | html2text -utf8 | awk -F 'Lundi' '{print $1}')
|
|
echo "$LUNE" >> /tmp/buffer
|
|
[[ $S == "1" ]] && tr '\n' ' ' < /tmp/buffer | awk -F '#Lune' '{print $2}' >> /tmp/sms
|
|
[[ $S == "2" ]] && tr '\n' ' ' < /tmp/buffer | awk -F '#Lune' '{print $3}' >> /tmp/sms
|
|
fi
|
|
|
|
echo "##################################################################"
|
|
echo "SMS"
|
|
echo "##################################################################"
|
|
cat /tmp/sms
|
|
echo "##################################################################"
|