G1sms/shell/sms_SETUNIT.sh

45 lines
1.1 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/)
################################################################################
source ./shell/init.sh
source ./shell/functions.sh
log "X sms_SETUNIT.sh ($1=phone, $2=unit)"
phone="$1"
unit="$2"
UNITFILE="./wallets/$phone/$phone.unit"
# Initialise PHONE, PIN, PUBKEY, UNIT, HIST
sms_INIT_ACCOUNT "$phone" "NOSMS"
if [[ $UNKNOWN == "unknown" ]]; then
sms_ERROR "$phone" "Porte-monnaie inconnu. Envoyez N (suivi de votre Pseudo membre) pour le créer."
exit
fi
# No unit received
if [[ $unit == "U" || $unit == "" ]]; then
if [[ -f "$UNITFILE" ]]; then
unit=$(cat "$UNITFILE")
else
unit="$COIN";
fi
fi
echo "$unit" > "$UNITFILE"
log "G1sms wallet new $unit... IPFS SWARM publishing..."
ipfs_node_wallets_add
mess="[G1sms+]
Unité de votre portefeuille: $unit"
sms_SEND "$phone" "$mess"
log "END sms_SETUNIT.sh"
log "~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
exit