astroport/g1sms/init.sh

115 lines
4.2 KiB
Bash
Raw Permalink Normal View History

2020-05-05 01:34:37 +02:00
#!/bin/bash
##################################################################
# Author: Fred (support@qo-op.com)
2020-05-05 04:41:17 +02:00
# Version: 0.2
2020-05-05 01:34:37 +02:00
# License: GPL (http://www.google.com/search?q=GPL)
##################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
2020-05-12 01:17:16 +02:00
export YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1);
[[ $YOU == "" ]] && echo "Please run ipfs daemon" && exit 1
if [[ $(whoami) == "root" ]]; then
2020-05-16 14:30:19 +02:00
export IPFSNODEID=$(su $YOU -c "ipfs id -f='<id>\n'") #TODO G1SMS gammu is running root, a group problem?
else
export IPFSNODEID=$(ipfs id -f='<id>\n')
fi
2020-05-11 08:17:26 +02:00
[[ $IPFSNODEID == "" ]] && echo "PROBLEM GETTING IPFSNODEID" && exit 1
2020-05-27 17:44:38 +02:00
2020-05-11 00:57:26 +02:00
[[ ! -f /tmp/g1sms.log ]] && echo "ASTROPORT G1SMS ACTIVITY" > /tmp/g1sms.log && chmod 777 /tmp/g1sms.log
2020-05-11 01:19:09 +02:00
2020-05-05 01:34:37 +02:00
function log () {
2020-05-11 00:57:26 +02:00
[[ "$DOLOG" == "YES" ]] && echo "$PHONE:$1" >> /tmp/g1sms.log;
2020-05-05 01:34:37 +02:00
}
2020-05-12 22:47:43 +02:00
log "¯\_༼<O͡〰o>༽_/¯"
2020-05-12 22:45:29 +02:00
log "$PHONE: >>> $(date)"
2020-05-05 01:34:37 +02:00
###################################################################################################################################
fn_exists() {
# appended double quote is an ugly trick to make sure we do get a string -- if $1 is not a known command, type does not output anything
[ `type -t $1`"" == 'file' ]
}
2020-05-05 04:41:17 +02:00
2020-05-05 01:34:37 +02:00
# ATOMATIC gammu-smsd-inject desactivation if no gammu is installed on system
2020-05-28 17:01:11 +02:00
if [[ ! $(which gammu-smsd-inject) ]]; then
2020-05-11 02:03:10 +02:00
echo ":p) DESACTIVATION ENVOI DE SMS .............."
2020-05-05 04:41:17 +02:00
function gammu-smsd-inject () {
log "$PHONE: >>> SENDING SMS $4 TO $2 "
}
2020-05-05 01:34:37 +02:00
else
2020-05-05 04:41:17 +02:00
export G1SMS="YES"
2020-05-05 01:34:37 +02:00
fi
2020-05-28 20:22:16 +02:00
echo "
2020-05-11 01:16:16 +02:00
_ _ __
(_)___ (_) /_
/ / __ \/ / __/
/ / / / / / /_
/_/_/ /_/_/\__/
g1sms $G1SMS
2020-05-28 20:56:31 +02:00
" > /dev/null
2020-05-05 01:34:37 +02:00
2020-05-11 01:16:16 +02:00
export YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1);
2020-05-13 20:37:04 +02:00
# TODO (make and use ./zen/config )
2020-05-11 01:16:16 +02:00
##################################################################
# Activate logging to /tmp/g1sms.log (YES/NO)
export DOLOG="YES"
export CPERROR="NOYES"
##################################################################
# Country Node Phone international prefix (TODO Worldwide)
export COUNTRY="+33"
##################################################################
# Choose Default Unit: G1, DU, LOVE (DU cents), ZEN (G1 cents)
export COIN="G1"
##################################################################
# Limit and commission values
export LIMIT=2 # Solde minimum = 2 G1
# FIXED COMMISSION SYSTEM
export COMMISSION=1 # transaction commission amount (G1)
export BILLCOM=20
##################################################################
# COMMISSION PARTS FROM TX FOR NODE & G1SMS NETWORK
# PART COMMISSION SYSTEM
export SWARMCOMM=10
# TODO: NODE G1sms Wallet can receive rewards from SWARM or WALLETS/FILES
export NODECOMM=10
##################################################################
# SMS SIM Card Phone Number
export MASTERPHONE="+33695196729"
2020-05-11 08:07:00 +02:00
export ADRESSE="G1FabLab Toulouse"
export G1DAB="YES"
2020-05-11 01:16:16 +02:00
##################################################################
# ADMIN COMMAND PHONE ORIGIN
export ADMINPHONE="+33647683646"
export ADMINPSEUDO="Fred"
##################################################################
# DUNITER/CESIUM+ DEFAULT SERVERS
2020-05-21 02:34:16 +02:00
export DUNITER="https://duniter-g1.p2p.legal"
2020-05-11 01:16:16 +02:00
export CESIUM="https://g1.data.le-sou.org"
##################################################################
# DU has a G1 value changed every 6 month!
2020-05-11 06:53:41 +02:00
# "/home/$YOU/.zen/_DU" removed every 6 month for refresh
if [[ -f /home/$YOU/.zen/_DU ]]; then
export DUFACTOR=$(bc <<< "scale=2; $(cat /home/$YOU/.zen/_DU) / 100")
2020-05-11 01:16:16 +02:00
else
LASTDU=$(curl -s ${DUNITER}/blockchain/with/ud | jq '.result.blocks[]' | tail -n 1) || exit 1
2020-05-11 06:53:41 +02:00
[[ $LASTDU != "" ]] && curl -s ${DUNITER}/blockchain/block/${LASTDU} | jq -r '.dividend' > /home/$YOU/.zen/_DU || exit 1
export DUFACTOR=$(bc <<< "scale=2; $(cat /home/$YOU/.zen/_DU) / 100")
2020-05-11 01:16:16 +02:00
fi
2020-05-11 08:07:00 +02:00
# INIT KEYS
2020-05-28 20:22:16 +02:00
echo 'init
2020-05-28 16:59:53 +02:00
__
/ /_____ __ _______
/ //_/ _ \/ / / / ___/
/ ,< / __/ /_/ (__ )
/_/|_|\___/\__, /____/
2020-05-28 20:22:16 +02:00
/____/ ' > /dev/null
2020-05-11 01:16:16 +02:00
source $MY_PATH/init_keys.sh
2020-05-05 01:34:37 +02:00