astroport/g1sms/sms_SETUNIT.sh

48 lines
1.2 KiB
Bash
Raw Permalink Normal View History

2020-05-01 15:19:51 +02:00
#!/bin/bash
################################################################################
# Author: Fred (support@qo-op.com)
2020-05-07 02:27:11 +02:00
# Version: 1.0
2020-05-01 15:19:51 +02:00
# 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 "X sms_SETUNIT.sh ($1=phone, $2=unit)"
phone="$1"
unit="$2"
2020-05-21 02:34:16 +02:00
UNITFILE="/home/$YOU/.zen/g1sms/$phone/_unit"
2020-05-01 15:19:51 +02:00
# 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"
mess="[G1sms+]
Unité de votre portefeuille: $unit"
sms_SEND "$phone" "$mess"
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-01 15:19:51 +02:00
log "END sms_SETUNIT.sh"
log "~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
exit