forked from axiom-team/astroport
78 lines
2.9 KiB
Bash
Executable File
78 lines
2.9 KiB
Bash
Executable File
#!/bin/bash
|
|
################################################################################
|
|
# Author: Fred (support@qo-op.com)
|
|
# Version: 1.0
|
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
|
################################################################################
|
|
# Accessible seulement pour ADMINPHONE.
|
|
# Permet de lancer des paquets de SMS aux membres, wallets, ...
|
|
# TODO Add OptIN/OUT options (./sms_ABO.sh) + Extand ADMIN functions...
|
|
source ./init.sh
|
|
source ./functions.sh
|
|
log "__SUB:sms_ADMIN.sh: START ($1=CMD, $2=MESSAGE)"
|
|
|
|
CMD="$1"
|
|
MESSAGE="$2"
|
|
|
|
case "$CMD" in
|
|
|
|
USR)
|
|
log "__SUB:sms_ADMIN.sh: Send message to phone Member or Wallet UIDNA"
|
|
# Get it from first MESSAGE message word...
|
|
towoo=$(echo $MESSAGE | cut -d ' ' -f 1)
|
|
|
|
SEARCH=$(grep -Rwl "$towoo" /home/$YOU/.zen/ipfs_swarm/*/_uidna* | tail -n 1 | cut -f 6 -d '/')
|
|
if [[ "$SEARCH" != "" ]]; then
|
|
REMOTENODE=$(cat /home/$YOU/.zen/ipfs_swarm/$SEARCH/MASTERPHONE.sms)
|
|
DESTRIB=$(cat /home/$YOU/.zen/ipfs_swarm/$SEARCH/_pub)
|
|
DESTPHONE=$SEARCH
|
|
log "__SUB:sms_ADMIN.sh: FOUND $towoo on NODE ($REMOTENODE) G1sms+ wallet: $DESTRIB : $DESTPHONE)"
|
|
|
|
if [[ "$DESTPHONE" == "$ADMINPHONE" || "$DESTPHONE" == "$MASTERPHONE" ]]; then continue; fi
|
|
sms_SEND "$DESTPHONE" "$MESSAGE"
|
|
sms_SEND "$ADMINPHONE" "ADMIN OK!! Message: $MESSAGE envoyé à $towoo: $DESTPHONE"
|
|
fi
|
|
;;
|
|
|
|
|
|
MEM)
|
|
log "__SUB:sms_ADMIN.sh: Send $MESSAGE message to All NODE members"
|
|
for f in /home/$YOU/.zen/g1sms_wallets/*/_uidname; do
|
|
uid=$(cat $f);
|
|
num=$(echo $f | cut -d '/' -f 6);
|
|
if [[ "$num" == "$ADMINPHONE" || "$num" == "$MASTERPHONE" ]]; then continue; fi
|
|
log "__SUB:sms_ADMIN.sh: Send SMS to $num: $uid"
|
|
sms_SEND "$num" "$uid, $MESSAGE"
|
|
sleep 5
|
|
done
|
|
sms_SEND "$ADMINPHONE" "ADMIN! Message envoyé aux $(cat /home/$YOU/.zen/g1sms_wallets/*/*.uidname | wc -l) membres de ce NODE"
|
|
;;
|
|
|
|
ALL)
|
|
log "__SUB:sms_ADMIN.sh: Send $MESSAGE message to All NODE G1sms wallets"
|
|
for f in /home/$YOU/.zen/g1sms_wallets/*; do
|
|
num=$(echo $f | cut -d '/' -f 6);
|
|
if [[ "$num" == "$ADMINPHONE" || "$num" == "$MASTERPHONE" ]]; then continue; fi
|
|
log "__SUB:sms_ADMIN.sh: Send SMS to $num"
|
|
sms_SEND "$num" "$MESSAGE"
|
|
sleep 5
|
|
done
|
|
sms_SEND "$ADMINPHONE" "ADMIN! Message envoyé aux $(ls /home/$YOU/.zen/g1sms_wallets/ | cut -d '/' -f3 | wc -l) possesseur de G1sms Wallets de ce NODE"
|
|
;;
|
|
|
|
*)
|
|
log "__SUB:sms_ADMIN.sh: Send back ERRORs message to Admin"
|
|
if [ -f "/tmp/ERROR.CRON" ]; then
|
|
text=$(cat "/tmp/ERROR.CRON")
|
|
rm -f "/tmp/ERROR.CRON"
|
|
fi
|
|
sms_SEND "$ADMINPHONE" "USR / MEM / ALL / SWARM
|
|
$text"
|
|
;;
|
|
esac
|
|
|
|
sms_SEND "$ADMINPHONE" "ADMIN! JOB FINISHED"
|
|
|
|
log "__SUB:sms_ADMIN.sh: END ~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
|
exit
|