Commit aab6b79d authored by Fred's avatar Fred

Delete functions.sh~

parent a14e06be
#!/bin/bash
# G1SMS COMMUN FUNCTIONS
# !!!!!!!!!!! COMMENT / UNCOMMENT to activate/desactivate real SMS
#function gammu-smsd-inject () { ###
# echo ">>> sending SMS $4 TO $2 " >> /tmp/g1sms.log ###
#} ###
function security () {
if [ -d "/root/G1SMS" ]
then
cd "/root/G1SMS"
else
echo "G1SMS MUST BE INSTALLED IN HOME ROOT DIRECTORY. SET YOUR WALLET KEYS! chmod 700 ./wallets"
exit
fi
chown -R root:root ./wallets
chmod 700 ./wallets
}
function log () {
# log ($1=text)
if [ "$DOLOG" == "YES" ]
then
echo "$1" >> /tmp/g1sms.log
fi
}
function sms_SEND () {
# sms_SEND ($1=phone, $2=message)
local dest="$1"
local mess="$2"
gammu-smsd-inject TEXT "$dest" -text "$mess"
}
function sms_ERROR () {
# sms_ERROR ($1=phone, $2=message)
local dest="$1"
local mess="[G1SMS] Erreur
$2
Envoyez A pour de l'Aide."
gammu-smsd-inject TEXT "$dest" -text "$mess"
}
function log_history () {
log "history ($1=phone, $2=message)"
PHONE="$1"
HISTFILE="./wallets/$PHONE/$PHONE.hist"
echo "$(date +%Y%m%d-%H:%M:$S)_$2" >> "$HISTFILE"
}
#######################################"
function sms_INIT_ACCOUNT () {
log "sms_INIT_ACCOUNT ($1=phone, $2=NOSMS)"
PHONE="$1"
UNKNOWN=0
PINFILE="./wallets/$PHONE/$PHONE.pin"
PUBKEYFILE="./wallets/$PHONE/$PHONE.pub"
UNITFILE="./wallets/$PHONE/$PHONE.unit"
HISTFILE="./wallets/$PHONE/$PHONE.hist"
# (NO PIN) FirstAccount Create wallet
if [ ! -f "$PINFILE" ]; then
if [[ $2 == "NOSMS" ]]; then UNKNOWN="unknown"; return; fi
mkdir "./wallets/$PHONE/"
# Create Account Files (Get back old beta account)
if [ -f "./keys/$PHONE.pin" ]; then ###
mv "./keys/$PHONE.pin" "$PINFILE"; ###
else ###
PIN=$(./shell/diceware.sh | xargs)
PUBKEY=$(./silkaj/silkaj generate_auth_file --auth-scrypt -salt="$PHONE" -password="$PIN")
# Send first G1SMS transaction to activate account (THIRD_PARTY_MANAGER no member wallet)
# log "$MASTERKEYFILE $PUBKEY THIRD_PARTY_MANAGER:$MASTERPUB"
INIT=$(./silkaj/silkaj transaction --auth-file -file="$MASTERKEYFILE" --amount=2 --output=$PUBKEY --comment="THIRD_PARTY_MANAGER:$MASTERPUB" -y)
#log "Transaction1 $INIT"
DOUBLE=$(./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount=1 --output=$MASTERPUB --comment="THIRD_PARTY_MANAGER:$MASTERPUB:ACK" -y)
#log "Transaction2 $DOUBLE"
echo "$PIN" > "$PINFILE"
fi ###
if [ -f "./keys/$PHONE.pub" ]; then ###
mv "./keys/$PHONE.pub" "$PUBKEYFILE"; ###
else ###
echo "$PUBKEY" > "$PUBKEYFILE"
fi ###
echo "LOVE" > "$UNITFILE"
echo "$(date +%Y%m%d-%H:%M): OUVERTURE" >> "$HISTFILE"
fi
# Init caller : GLOBAL VAR SET
PIN=$(cat "$PINFILE" | xargs)
PUBKEY=$(cat "$PUBKEYFILE" | xargs)
UNIT=$(cat "$UNITFILE" | xargs)
HIST=$(tail -n3 "$HISTFILE")
# LOG
log "PHONE: $PHONE"
log "PIN: $PIN"
log "KEY: $PUBKEY"
log "UNIT: $UNIT"
log "HIST: $HIST"
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment