meilleure gestion des erreurs
This commit is contained in:
parent
75f3524e9b
commit
55a1fea0dc
|
@ -14,37 +14,66 @@ G1PUB=$(cat /home/${YOU}/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
|
||||||
## STOP GAMMU-SMSD
|
## STOP GAMMU-SMSD
|
||||||
sudo service gammu-smsd stop
|
sudo service gammu-smsd stop
|
||||||
|
|
||||||
|
########################################################################
|
||||||
echo "SEARCHING FOR SMS TO SEND TO USERS"
|
echo "SEARCHING FOR SMS TO SEND TO USERS"
|
||||||
for tosend in /home/${YOU}/.zen/SMS/PHONE/*/*.tosend.sh; do
|
for tosend in /home/${YOU}/.zen/SMS/PHONE/*/*.tosend.sh; do
|
||||||
phonehash=$(echo "$tosend" | cut -d '/' -f 7) && [[ $phonehash == "*" ]] && continue
|
phonehash=$(echo "${tosend}" | cut -d '/' -f 7) && [[ $phonehash == "*" ]] && continue
|
||||||
xzuid=$(cat "/home/${YOU}/.zen/SMS/PHONE/${phonehash}/xzuid.txt")
|
xzuid=$(cat "/home/${YOU}/.zen/SMS/PHONE/${phonehash}/xzuid.txt")
|
||||||
[[ ! $xzuid ]] && echo "ERROR $tosend" && continue
|
[[ ! $xzuid ]] && echo "ERROR $tosend" && continue
|
||||||
|
|
||||||
./sms/natools.py decrypt -f pubsec -k "/home/${YOU}/.zen/secret.dunikey" -i "/home/${YOU}/.zen/SMS/PHONE/${phonehash}/passwd.encrypt" -o "/tmp/${phonehash}.phone"
|
./sms/natools.py decrypt -f pubsec -k "/home/${YOU}/.zen/secret.dunikey" -i "/home/${YOU}/.zen/SMS/PHONE/${phonehash}/passwd.encrypt" -o "/tmp/${phonehash}.phone"
|
||||||
phone=$(cat /tmp/${phonehash}.phone)
|
phone=$(cat /tmp/${phonehash}.phone)
|
||||||
echo "${phone}"
|
echo "${phone}"
|
||||||
|
## PREPARE SMS
|
||||||
cat "${tosend}" | sed "s/_PHONE_/${phone}/g" | sed "s/_ID_/${xzuid}/g" > /tmp/tosend.sh && chmod +x /tmp/tosend.sh
|
cat "${tosend}" | sed "s/_PHONE_/${phone}/g" | sed "s/_ID_/${xzuid}/g" > /tmp/tosend.sh && chmod +x /tmp/tosend.sh
|
||||||
bash -x /tmp/tosend.sh && mv ${tosend} ${tosend}.txt && rm /tmp/tosend.sh || mv ${tosend} ${tosend}.error.txt
|
## SEND SMS & ARCHIVE SMS IN /SMS/PHONE/${phonehash}/ (.txt OR .error.txt)
|
||||||
|
bash -x /tmp/tosend.sh && mv ${tosend} ${tosend}.txt || mv ${tosend} ${tosend}.error.txt
|
||||||
|
rm /tmp/tosend.sh
|
||||||
sleep 3
|
sleep 3
|
||||||
done
|
done
|
||||||
|
|
||||||
|
########################################################################
|
||||||
echo "SEARCHING FOR GUIDE SMS TO SEND TO GUILDE USERS"
|
echo "SEARCHING FOR GUIDE SMS TO SEND TO GUILDE USERS"
|
||||||
for guidesend in /home/${YOU}/.zen/SMS/GUILDES/*/OUTPUT/*.tosend.sh; do
|
for guidesend in /home/${YOU}/.zen/SMS/GUILDES/*/OUTPUT/*.tosend.sh; do
|
||||||
guilde=$(echo "$guidesend" | cut -d '/' -f 7) && [[ $guilde == "*" ]] && continue
|
guilde=$(echo "$guidesend" | cut -d '/' -f 7) && [[ $guilde == "*" ]] && continue
|
||||||
[[ ! -d /home/${YOU}/.zen/SMS/GUILDES/${guilde} ]] && continue
|
[[ ! -d /home/${YOU}/.zen/SMS/GUILDES/${guilde} ]] && continue
|
||||||
|
|
||||||
|
smsfile=$(echo "$guidesend" | cut -d '/' -f 9)
|
||||||
|
|
||||||
for phonelink in /home/${YOU}/.zen/SMS/GUILDES/${guilde}/MEMBERS/*; do
|
for phonelink in /home/${YOU}/.zen/SMS/GUILDES/${guilde}/MEMBERS/*; do
|
||||||
[[ ! -L $phonelink ]] && continue
|
[[ ! -L $phonelink ]] && continue
|
||||||
phone=$(echo "$phonelink" | cut -d '/' -f 9)
|
phone=$(echo "$phonelink" | cut -d '/' -f 9)
|
||||||
|
phonehash=$(echo $phone | sha256sum | cut -d ' ' -f1)
|
||||||
|
xzuid=$(cat "/home/${YOU}/.zen/SMS/PHONE/${phonehash}/xzuid.txt")
|
||||||
|
[[ ! $xzuid ]] && echo "ERROR $tosend" && continue
|
||||||
|
## PREPARE SMS
|
||||||
cat "${guidesend}" | sed "s/_PHONE_/${phone}/g" | sed "s/_ID_/${xzuid}/g" > /tmp/guidesend.sh && chmod +x /tmp/guidesend.sh
|
cat "${guidesend}" | sed "s/_PHONE_/${phone}/g" | sed "s/_ID_/${xzuid}/g" > /tmp/guidesend.sh && chmod +x /tmp/guidesend.sh
|
||||||
bash -x /tmp/guidesend.sh
|
## SEND SMS & ARCHIVE SMS IN /SMS/PHONE/${phonehash}/ (.txt OR .error.txt)
|
||||||
|
bash -x /tmp/guidesend.sh && cp ${guidesend} /home/${YOU}/.zen/SMS/PHONE/${phonehash}/${smsfile}_${guilde}.txt || mv ${guidesend} /home/${YOU}/.zen/SMS/PHONE/${phonehash}/${smsfile}_${guilde}.error.txt
|
||||||
|
rm /tmp/guidesend.sh
|
||||||
sleep 3
|
sleep 3
|
||||||
done
|
done
|
||||||
mv ${guidesend} ${guidesend}.txt && rm /tmp/guidesend.sh || mv ${guidesend} ${guidesend}.error.txt
|
## REMOVING ${guidesend} from guilde SMS QUEUE
|
||||||
|
mv ${guidesend} ${guidesend}.txt
|
||||||
done
|
done
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
########################################################################
|
||||||
|
echo "RETRY ERROR MESSAGE"
|
||||||
|
for tosend in /home/${YOU}/.zen/SMS/PHONE/*/*.tosend.sh.error.txt; do
|
||||||
|
phonehash=$(echo "${tosend}" | cut -d '/' -f 7) && [[ $phonehash == "*" ]] && continue
|
||||||
|
xzuid=$(cat "/home/${YOU}/.zen/SMS/PHONE/${phonehash}/xzuid.txt")
|
||||||
|
[[ ! $xzuid ]] && echo "ERROR $tosend" && continue
|
||||||
|
|
||||||
|
./sms/natools.py decrypt -f pubsec -k "/home/${YOU}/.zen/secret.dunikey" -i "/home/${YOU}/.zen/SMS/PHONE/${phonehash}/passwd.encrypt" -o "/tmp/${phonehash}.phone"
|
||||||
|
phone=$(cat /tmp/${phonehash}.phone)
|
||||||
|
echo "SENDING ${phone}"
|
||||||
|
## PREPARE SMS
|
||||||
|
cat "${tosend}" | sed "s/_PHONE_/${phone}/g" | sed "s/_ID_/${xzuid}/g" > /tmp/tosend.sh && chmod +x /tmp/tosend.sh
|
||||||
|
## SEND SMS & ARCHIVE RESULT (error?)
|
||||||
|
bash -x /tmp/tosend.sh && mv ${tosend} ${tosend}.txt && rm /tmp/tosend.sh || mv ${tosend} ${tosend}.error.txt
|
||||||
|
sleep 3
|
||||||
|
done
|
||||||
|
|
||||||
## REINIT gammu-smsd spool
|
## REINIT gammu-smsd spool
|
||||||
sudo rm /var/spool/gammu/inbox/* 2>/dev/null
|
sudo rm /var/spool/gammu/inbox/* 2>/dev/null
|
||||||
|
|
Loading…
Reference in New Issue