diff --git a/.env b/.env index 88848a5..f64dbc2 100644 --- a/.env +++ b/.env @@ -1,3 +1,50 @@ ### Variables d'environnement LOG_FILE="/tmp/g1sms.log" + +export YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1) +export CHEMIN="/home/$YOU/G1sms+" +cd $CHEMIN +################################################################## +# Activate logging to /tmp/g1sms.log (YES/NO) +export DOLOG="YES" +export CPERROR="NOYES" +################################################################## +# Country Node Phone international prefix (TODO Worldwide) +export COUNTRY="+33" +################################################################## +# DU has a G1 value changed every 6 month! +# ./_DU Updated by cron_CODE.backup.sh +if [[ -f "./_DU" ]]; then export DUFACTOR=$(bc <<< "scale=2; $(cat "./_DU") / 100"); else log "__SUB:init.sh: FAILING TO FIND ./_DU EXIT!!!"; exit; fi +################################################################## +# 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="+33660780131" +export ADRESSE="au G1FabLab de Toulouse" +export G1DAB="NO" +################################################################## +# ADMIN COMMAND PHONE ORIGIN +export ADMINPHONE="+33647683646" +export ADMINPSEUDO="Fred" +################################################################## +# DUNITER/CESIUM+ DEFAULT SERVERS +export DUNITER="https://g1.duniter.org" +export CESIUM="https://g1.data.le-sou.org" + +# TODO Use latest Silkaj from "sudo pip3 install silkaj" +# export SILKAJ="/usr/local/bin/silkaj" +source $CHEMIN/shell/init_keys.sh diff --git a/shell/g1_gen_pubkey.py b/shell/g1_gen_pubkey.py index 0a543f5..c6e210b 100755 --- a/shell/g1_gen_pubkey.py +++ b/shell/g1_gen_pubkey.py @@ -2,7 +2,6 @@ import sys from duniterpy.key import SigningKey - def generate_public_key(salt: str, password: str) -> str: """ Return public key from credentials @@ -39,4 +38,3 @@ if __name__ == '__main__': # exit with status code ok exit(0) - diff --git a/shell/init.sh.template b/shell/init.sh.template index ffdbf46..9ee433f 100755 --- a/shell/init.sh.template +++ b/shell/init.sh.template @@ -9,12 +9,13 @@ function log () { # log ($1=text) if [ "$DOLOG" == "YES" ] then - echo "$PHONE:$1" >> /tmp/g1sms.log + echo "$PHONE:$1" >> $LOG_FILE fi } +### Déclaration de l'environnement +source .env -################################################################################################################################### 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' ] @@ -28,49 +29,3 @@ function gammu-smsd-inject () { else export G1SMS="YES" fi - export YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1) - export CHEMIN="/home/$YOU/G1sms+" - cd $CHEMIN - ################################################################## - # Activate logging to /tmp/g1sms.log (YES/NO) - export DOLOG="YES" - export CPERROR="NOYES" - ################################################################## - # Country Node Phone international prefix (TODO Worldwide) - export COUNTRY="+33" - ################################################################## - # DU has a G1 value changed every 6 month! - # ./_DU Updated by cron_CODE.backup.sh - if [[ -f "./_DU" ]]; then export DUFACTOR=$(bc <<< "scale=2; $(cat "./_DU") / 100"); else log "__SUB:init.sh: FAILING TO FIND ./_DU EXIT!!!"; exit; fi - ################################################################## - # 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="+33660780131" - export ADRESSE="au G1FabLab de Toulouse" - export G1DAB="NO" - ################################################################## - # ADMIN COMMAND PHONE ORIGIN - export ADMINPHONE="+33647683646" - export ADMINPSEUDO="Fred" - ################################################################## - # DUNITER/CESIUM+ DEFAULT SERVERS - export DUNITER="https://g1.duniter.org" - export CESIUM="https://g1.data.le-sou.org" - - # TODO Use latest Silkaj from "sudo pip3 install silkaj" - # export SILKAJ="/usr/local/bin/silkaj" - source $CHEMIN/shell/init_keys.sh diff --git a/sms_received.sh b/sms_received.sh index c9b4032..a4e3599 100755 --- a/sms_received.sh +++ b/sms_received.sh @@ -6,7 +6,7 @@ # # G1sms+ est totalement décentralisé! Il peut être fait de multiples SWARM de Services dont les codes évoluent de façon décentralisé. # Puis se mettent à jour autour des $ADMINPHONE par consensus d'utilisateurs ;) -# +# # Log => tail -f /tmp/g1sms.log -n 200 # gammu => tail -f /tmp/smsd.log -n 200 # @@ -16,10 +16,10 @@ # # Utiliser la commande ./search fournie pour fouiller dans le code, mais tout est ordonnancé d'ici, donc vous êtes au bon endroit pour commencer à farfouiller. ############################################################################### -# EN FAISANT PARTIE DU SWARM G1sms+ VOUS VOUS ENGAGEZ A ASSURER LA SECURITE +# EN FAISANT PARTIE DU SWARM G1sms+ VOUS VOUS ENGAGEZ A ASSURER LA SECURITE # PHYSIQUE ET INFORMATIQUE DE VOTRE NOEUD ET NE PAS INTRODUIRE DE CODE MALVEILLANT # DANS LE GROUPE SI VOUS ETES AMENES A EN PROPOSER UNE MISE A JOUR. -# UNE COMMISSION EST PERCU SUR CERTAINS TRANSFERTS. +# UNE COMMISSION EST PERCU SUR CERTAINS TRANSFERTS. # ELLE EST PROVISION EN CAS DE FRAUDE ET SA REATRIBUTION POURRA EVOLUER... # # Author: Fred (support@qo-op.com) @@ -55,7 +55,7 @@ log "#############################################" security ################################################################## -# Refresh All peers SWARM Wallets. +# Refresh All peers SWARM Wallets. ################################################################## ipfs_swarm_wallets_refresh @@ -106,9 +106,9 @@ case "$CMD" in else ./shell/sms_ERROR.sh "$PHONE" "ex:: VIR 100 mot5678 = Envoyer 100 $UNIT au portefeuille G1sms+ 'mot5678' (On peut aussi utiliser le pseudo d'un Membre)" & fi - ;; + ;; REC) - # ex: "REC 2000 John J 12" (Virer 2000 UNIT au G1sms+ wallet de John pour les 12 prochains jours) + # ex: "REC 2000 John J 12" (Virer 2000 UNIT au G1sms+ wallet de John pour les 12 prochains jours) AMOUNT=$(echo "$TEXT" | awk '{print $2}' | grep -E "^\-?[0-9]+$") VIRDEST=$(echo "$TEXT" | awk '{print $3}' | grep -E "([A-Za-z0-9\-\_]+$)") PERIOD=$(echo "$TEXT" | awk '{print toupper($4)}' | grep -E "([A-Za-z0-9\-\_]+$)") @@ -116,7 +116,7 @@ case "$CMD" in if [[ "$VIRDEST" != "" && "$AMOUNT" != "" && "$PERIOD" != "" && "$TIME" != "" ]]; then ./shell/sms_REC.sh "$PHONE" "$VIRDEST" "$AMOUNT" "$PERIOD" "$TIME" & else - ./shell/sms_ERROR.sh "$PHONE" "ex:: REC 20 Fred M 12 => Virer 20 $UNIT au portefeuille G1sms+ de Fred pendant 12 Mois (Choisir la période: J,S,M,A)." & + ./shell/sms_ERROR.sh "$PHONE" "ex:: REC 20 Fred M 12 => Virer 20 $UNIT au portefeuille G1sms+ de Fred pendant 12 Mois (Choisir la période: J,S,M,A)." & fi ;; C|S|SOLDE) @@ -162,7 +162,7 @@ case "$CMD" in if [[ "$VAL" != "" ]]; then ./shell/sms_G1TAG.sh "$PHONE" "$VAL" "$NUM" & else - ./shell/sms_ERROR.sh "$PHONE" "ex:: TAG 2 12 => Créer 12 G1Tag de 2 G1" & + ./shell/sms_ERROR.sh "$PHONE" "ex:: TAG 2 12 => Créer 12 G1Tag de 2 G1" & fi ;; U|UNIT) @@ -186,7 +186,7 @@ case "$CMD" in exit ;; ADMIN) - # If Phone is ADMIN + # If Phone is ADMIN if [[ "$PHONE" == "$ADMINPHONE" ]]; then CMD=$(echo "$TEXT" | awk '{print toupper($2)}') PARAM=$(echo "$TEXT" | awk '{print substr($0,index($0,$3))}') @@ -206,4 +206,3 @@ if [[ "$PHONE" != "$ADMINPHONE" && "$CPERROR" == "YES" ]]; then sms_SEND "$ADMIN echo $PUBKEY exit -