forked from axiom-team/astroport
65 lines
2.2 KiB
Bash
Executable File
65 lines
2.2 KiB
Bash
Executable File
#!/bin/bash
|
|
################################################################################
|
|
# Author: Fred (support@qo-op.com)
|
|
# Version: 0.1
|
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
|
################################################################################
|
|
MY_PATH="`dirname \"$0\"`" # relative
|
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
|
source $MY_PATH/init.sh
|
|
source $MY_PATH/functions.sh
|
|
|
|
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"
|
|
|
|
if [[ "$MEMBERUID" != "" && "$MEMBERUID" != "N" && "$MEMBERUID" != "D" && "$MEMBERUID" != "NOUV" ]]; then
|
|
log "# UID RECEIVED in SMS searching for $MEMBERUID"
|
|
VIRDEST=$MEMBERUID
|
|
MEMRIB=$(sms_uid2key "$MEMBERUID" "$PHONE" "$PIN")
|
|
log "# MEMRIB: $MEMRIB"
|
|
[[ $MEMRIB != "" ]] && MEMBER="$MEMBERUID" && MEMBERUID=""
|
|
[[ $MEMRIB == "" ]] && sms_SEND "$PHONE" "Aucun membre: $MEMBERUID... Création simple portefeuille pour $MEMBERUID" && MEMBER=""
|
|
fi
|
|
|
|
sms_INIT_ACCOUNT "$PHONE" "NOSMS" "$MEMBERUID"
|
|
# Check account amount
|
|
countvalues=($(check_account))
|
|
log "$(declare -p countvalues)"
|
|
AMOUNTG1=${countvalues[0]}
|
|
AMOUNT=${countvalues[1]}
|
|
UNIT=${countvalues[2]}
|
|
|
|
# ONLY USED BY sms_NEW.sh !!! To send back PIN
|
|
[[ -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");
|
|
[[ "$PIN" != "" ]] && echo "" > "$PINFILE" || PIN="PIN EMPTY !!! Contacter $ADMINPHONE SVP"
|
|
|
|
mess="CLEFS : $UIDNA
|
|
$PIN
|
|
|
|
Solde = $AMOUNT $UNIT
|
|
Utilisez https://cesium.app et https://gchange.fr !
|
|
"
|
|
|
|
sms_SEND "$PHONE" "$mess"
|
|
sleep 2
|
|
|
|
sms_SEND "$PHONE" "$PUBKEY"
|
|
|
|
[[ $MEMRIB != "" ]] && sms_SEND "$PHONE" "Compte Atttaché: $MEMBER $SMSEMAIL
|
|
$MEMRIB"
|
|
|
|
[[ -d /home/$YOU/.zen/g1sms/$PHONE ]] && [[ $(whoami) == "root" ]] && chown -R $YOU /home/$YOU/.zen/g1sms/$PHONE
|
|
|
|
# Add contact to database (TODO REFRESH Member Name in SQL)
|
|
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 "~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
|
|
|
exit 0
|