#!/bin/bash ################################################################################ # Author: Fred (support@qo-op.com) # Version: 0.1 # 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 (./shell/sms_ABO.sh) + Extand ADMIN functions... source ./shell/init.sh source ./shell/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" ./wallets_swarm/*/*.uidna* | tail -n 1 | cut -f 3 -d '/') if [[ "$SEARCH" != "" ]]; then REMOTENODE=$(cat ./wallets_swarm/$SEARCH/MASTERPHONE.sms) DESTRIB=$(cat ./wallets_swarm/$SEARCH/$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 ./wallets/*/*.uidname; do uid=$(cat $f); num=$(echo $f | cut -d '/' -f3); 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 ./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 ./wallets/*; do num=$(echo $f | cut -d '/' -f3); 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 ./wallets/ | cut -d '/' -f3 | wc -l) possesseur de G1sms Wallets de ce NODE" ;; SWARM) log "__SUB:sms_ADMIN.sh: Send $MESSAGE message to All SWARM G1sms wallets" for f in ./wallets_swarm/+33*; do num=$(echo $f | cut -d '/' -f3); 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: $MESSAGE envoyé aux $(ls ./wallets_swarm/ | cut -d '/' -f3 | wc -l) PHONE G1sms Wallets du SWARM" ;; *) 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