2020-05-01 15:19:51 +02:00
|
|
|
#!/bin/bash
|
|
|
|
################################################################################
|
|
|
|
# Author: Fred (support@qo-op.com)
|
|
|
|
# Version: 0.1
|
|
|
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
|
|
|
################################################################################
|
2020-05-12 23:25:52 +02:00
|
|
|
MY_PATH="`dirname \"$0\"`" # relative
|
|
|
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
|
|
|
source $MY_PATH/init.sh
|
|
|
|
source $MY_PATH/functions.sh
|
|
|
|
|
2020-05-01 15:19:51 +02:00
|
|
|
log "${c_yellow}X sms_NEW.sh ($1=phone, $2=uid)$c_"
|
|
|
|
|
|
|
|
PHONE="$1"
|
|
|
|
MEMBERUID="$2"
|
|
|
|
|
|
|
|
# Initialise PHONE, PIN, PUBKEY, UNIT
|
|
|
|
sms_INIT_ACCOUNT "$PHONE"
|
2020-05-12 23:25:52 +02:00
|
|
|
|
2020-05-01 15:19:51 +02:00
|
|
|
if [[ "$MEMBERUID" != "" && "$MEMBERUID" != "N" && "$MEMBERUID" != "D" && "$MEMBERUID" != "NOUV" ]]; then
|
2020-05-12 02:48:45 +02:00
|
|
|
log "# UID RECEIVED in SMS searching for $MEMBERUID"
|
2020-05-01 15:19:51 +02:00
|
|
|
VIRDEST=$MEMBERUID
|
|
|
|
MEMRIB=$(sms_uid2key "$MEMBERUID" "$PHONE" "$PIN")
|
2020-05-12 02:48:45 +02:00
|
|
|
log "# MEMRIB: $MEMRIB"
|
2020-06-12 16:54:03 +02:00
|
|
|
[[ $MEMRIB == "" ]] && sms_SEND "$PHONE" "Nous rencontrons un problème pour trouver $MEMBERUID... Rééssayer dans 5 mn" && exit 1
|
2020-05-01 15:19:51 +02:00
|
|
|
MEMBER="$MEMBERUID"
|
|
|
|
fi
|
|
|
|
|
|
|
|
sms_INIT_ACCOUNT "$PHONE" "NOSMS"
|
|
|
|
# Check account amount
|
|
|
|
countvalues=($(check_account))
|
|
|
|
log "$(declare -p countvalues)"
|
|
|
|
AMOUNTG1=${countvalues[0]}
|
|
|
|
AMOUNT=${countvalues[1]}
|
|
|
|
UNIT=${countvalues[2]}
|
|
|
|
|
2020-05-12 23:25:52 +02:00
|
|
|
# ONLY USED BY sms_NEW.sh !!! To send back PIN
|
2020-05-27 17:44:38 +02:00
|
|
|
[[ -f "${PINFILE}.crypt" ]] && /home/$YOU/.zen/astroport/zen/tools/natools.py decrypt -f pubsec -k "$NODE_PUBSECFILE" -i "${PINFILE}.crypt" -o "$PINFILE" && PIN=$(cat "$PINFILE");
|
2020-05-12 23:25:52 +02:00
|
|
|
[[ "$PIN" != "" ]] && echo "" > "$PINFILE" || PIN="PIN EMPTY !!! Contacter $ADMINPHONE SVP"
|
|
|
|
|
2020-06-06 14:08:49 +02:00
|
|
|
mess="Votre Clef
|
2020-05-28 21:04:29 +02:00
|
|
|
$UIDNA
|
2020-05-07 02:27:11 +02:00
|
|
|
$PIN
|
|
|
|
|
2020-05-01 15:19:51 +02:00
|
|
|
Solde: $AMOUNT $UNIT
|
2020-05-28 21:00:16 +02:00
|
|
|
https://cesium.app
|
2020-05-07 02:27:11 +02:00
|
|
|
"
|
2020-05-12 23:25:52 +02:00
|
|
|
|
2020-05-01 15:19:51 +02:00
|
|
|
sms_SEND "$PHONE" "$mess"
|
|
|
|
sleep 2
|
2020-05-12 23:25:52 +02:00
|
|
|
|
2020-05-01 15:19:51 +02:00
|
|
|
sms_SEND "$PHONE" "$PUBKEY"
|
2020-05-12 23:25:52 +02:00
|
|
|
|
2020-05-12 11:01:52 +02:00
|
|
|
[[ $MEMRIB != "" ]] && sms_SEND "$PHONE" "Compte Atttaché: $MEMBER $SMSEMAIL
|
2020-05-01 15:19:51 +02:00
|
|
|
$MEMRIB"
|
|
|
|
|
2020-05-21 02:34:16 +02:00
|
|
|
[[ -d /home/$YOU/.zen/g1sms/$PHONE ]] && [[ $(whoami) == "root" ]] && chown -R $YOU /home/$YOU/.zen/g1sms/$PHONE
|
2020-05-12 17:21:02 +02:00
|
|
|
|
2020-05-12 23:25:52 +02:00
|
|
|
# Add contact to database (TODO REFRESH Member Name in SQL)
|
2020-05-01 15:19:51 +02:00
|
|
|
add_contact $PHONE $MEMBERUID && log "${c_green}Contact has been added to database$c_" || log "${c_red}Contact can't be added to database$c_"
|
|
|
|
|
|
|
|
log "${c_yellow}END sms_NEW.sh$c_"
|
|
|
|
log "~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
|
|
|
|
2020-05-12 23:25:52 +02:00
|
|
|
exit 0
|