sms_SETUNIT.sh 917 Bytes
Newer Older
zicmama's avatar
zicmama committed
1 2 3 4
#!/bin/bash
################################################################################
# Author: Fred (support@qo-op.com)
# Version: 0.1
5
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
zicmama's avatar
zicmama committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
################################################################################
source /root/G1SMS/shell/init.sh
source /root/G1SMS/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 pour le créer."
	exit
fi

# No unit received
if [[ $unit == "U" ]]; then
	if [[ -f "$UNITFILE" ]]; then
		unit=$(cat "$UNITFILE")
	else
		unit="LOVE";
28
	fi
zicmama's avatar
zicmama committed
29 30 31 32 33 34 35 36 37 38
fi

echo "$unit" > "$UNITFILE"

mess="[G1SMS]
Unité de votre porte-monnaie Libre: $unit"

sms_SEND "$phone" "$mess"

exit