$YOU is ipfs user
This commit is contained in:
parent
af7fbf154f
commit
8c1571c246
|
@ -12,14 +12,14 @@ MY_PATH="`dirname \"$0\"`" # relative
|
|||
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||
|
||||
## Récupère les données du profile
|
||||
source ~/.zen/secret.astroport.key
|
||||
source /home/$YOU/.zen/secret.astroport.key
|
||||
|
||||
function sms_SEND () {
|
||||
# sms_SEND ($1=phone, $2=message)
|
||||
local dest="$1"
|
||||
local mess="$2"
|
||||
if [[ ${#dest} -eq 10 || ${#dest} -eq 12 ]]; then
|
||||
if [[ -d ~/.zen/g1sms_wallets/$dest ]]; then
|
||||
if [[ -d /home/$YOU/.zen/g1sms_wallets/$dest ]]; then
|
||||
# TEST IF $dest IS ON CURRENT NODE
|
||||
sudo gammu-smsd-inject TEXT "$dest" -text "$mess" 1>&2
|
||||
else
|
||||
|
@ -107,11 +107,11 @@ function ipfs_node_wallets_add (){
|
|||
##########################
|
||||
log "TODO ipfs_node_wallets_add"
|
||||
##########################
|
||||
# IWALLETS=$(su $YOU -c "ipfs add -rHq '~/.zen/g1sms_wallets' | tail -n 1")
|
||||
# IWALLETS=$(su $YOU -c "ipfs add -rHq '/home/$YOU/.zen/g1sms_wallets' | tail -n 1")
|
||||
|
||||
# CHAIN STATE FOR $IPFSNODEID
|
||||
# echo $IWALLETS > ~/.zen/ipfs/.$IPFSNODEID.wallets.chain
|
||||
# log "__SUB:ipfs_node_wallets_add: NEW '~/.zen/g1sms_wallets' HASH ipfs ls $IWALLETS"
|
||||
# echo $IWALLETS > /home/$YOU/.zen/ipfs/.$IPFSNODEID.wallets.chain
|
||||
# log "__SUB:ipfs_node_wallets_add: NEW '/home/$YOU/.zen/g1sms_wallets' HASH ipfs ls $IWALLETS"
|
||||
|
||||
# PUBLISH IPNS NODE WALLETS
|
||||
# NODEWALLETS=$(su $YOU -c "ipfs name publish --quieter /ipfs/$IWALLETS")
|
||||
|
@ -124,9 +124,9 @@ function ipfs_node_wallets_add (){
|
|||
#################################################################################################################################
|
||||
function sms_uid2key (){
|
||||
# sms_uid2key "$MEMBERUID" "$PHONE" "$PIN"
|
||||
RIBFILE="~/.zen/g1sms_wallets/$PHONE/_uidrib"
|
||||
NAMEFILE="~/.zen/g1sms_wallets/$PHONE/_uidname"
|
||||
UIDNAFILE="~/.zen/g1sms_wallets/$PHONE/_uidna"
|
||||
RIBFILE="/home/$YOU/.zen/g1sms_wallets/$PHONE/_uidrib"
|
||||
NAMEFILE="/home/$YOU/.zen/g1sms_wallets/$PHONE/_uidname"
|
||||
UIDNAFILE="/home/$YOU/.zen/g1sms_wallets/$PHONE/_uidna"
|
||||
# New related wallet asked
|
||||
ASKWALLET="$1"
|
||||
#For micro payement
|
||||
|
@ -152,7 +152,7 @@ function sms_uid2key (){
|
|||
fi
|
||||
|
||||
# Search fo duplicate
|
||||
DUP=$(grep -Rwl "$ASKWALLET" ~/.zen/g1sms_wallets/*/_uidname | cut -f 6 -d '/')
|
||||
DUP=$(grep -Rwl "$ASKWALLET" /home/$YOU/.zen/g1sms_wallets/*/_uidname | cut -f 6 -d '/')
|
||||
if [[ "$DUP" != "" && "$DUP" != "$PHONE" ]]; then
|
||||
sms_SEND "$ADMINPHONE" "ADMIN! INFO: $PHONE prend le même $ASKWALLET, que $DUP"
|
||||
sms_SEND "$DUP" "Vous devez savoir que $ASKWALLET est associé à un autre téléphone que le votre également!"
|
||||
|
@ -162,22 +162,22 @@ function sms_uid2key (){
|
|||
# FIND ASKWALLET into wallets, wallest_swarm OR duniter (silkaj)
|
||||
DESTMEM="$VIRDEST"
|
||||
# SEARCH IN WALLETS
|
||||
LOCAL=$(grep -Rwl "$ASKWALLET" ~/.zen/g1sms_wallets/*/_uidna | cut -f 6 -d '/')
|
||||
LOCAL=$(grep -Rwl "$ASKWALLET" /home/$YOU/.zen/g1sms_wallets/*/_uidna | cut -f 6 -d '/')
|
||||
if [[ "$LOCAL" != "" ]]; then
|
||||
# LOCAL G1sms account
|
||||
DESTRIB=$(cat ~/.zen/g1sms_wallets/$LOCAL/_pub)
|
||||
DESTRIB=$(cat /home/$YOU/.zen/g1sms_wallets/$LOCAL/_pub)
|
||||
DESTPHONE=$LOCAL
|
||||
log "__SUB:sms_uid2key: FOUND LOCAL ($MASTERPHONE) G1sms+ wallet: $DESTRIB ($LOCAL)"
|
||||
else
|
||||
|
||||
##################### REWRITE TODO
|
||||
# SEARCH IN WALLETS SWARM
|
||||
# INSWARM=$(grep -Rwl "$ASKWALLET" ~/.zen/ipfs_swarm/*/_uidna | cut -f 6 -d '/' )
|
||||
# INSWARM=$(grep -Rwl "$ASKWALLET" /home/$YOU/.zen/ipfs_swarm/*/_uidna | cut -f 6 -d '/' )
|
||||
# MYCHAN=$( echo $INSWARM | cut -f 6 -d '/' )
|
||||
# MYHASH=$( echo $MYCHAN | cut -f 1 -d '@' )
|
||||
# if [[ "$INSWARM" != "" ]]; then
|
||||
# REMOTENODE=$(cat ~/.zen/ipfs_swarm/$MYIPFS/MASTERPHONE.sms)
|
||||
# DESTRIB=$(cat ~/.zen/ipfs_swarm/$MYHASH/_pub)
|
||||
# REMOTENODE=$(cat /home/$YOU/.zen/ipfs_swarm/$MYIPFS/MASTERPHONE.sms)
|
||||
# DESTRIB=$(cat /home/$YOU/.zen/ipfs_swarm/$MYHASH/_pub)
|
||||
# DESTPHONE=$INSWARM
|
||||
# log "__SUB:sms_uid2key: FOUND SWARM ($REMOTENODE) G1sms+ wallet: $DESTRIB ($INSWARM)"
|
||||
# else
|
||||
|
@ -187,9 +187,9 @@ function sms_uid2key (){
|
|||
DESTRIB=$(silkaj id "$ASKWALLET" | grep -w "$ASKWALLET" | awk '{print $2}' | tail -n 1)
|
||||
log "__SUB:sms_uid2key: OUT OFF SWARM MEMBER wallet: $DESTRIB"
|
||||
# GET CESIUM+ geoPoint DATA (TODO: cron for GCHANGE SMS Alert)
|
||||
curl -s ${CESIUM}/user/profile/${DESTRIB} | jq '._source.geoPoint' > "~/.zen/g1sms_wallets/$PHONE/_uidgeo.json"
|
||||
log "__SUB:sms_uid2key: GET CESIUM+ geoPoint and AVATAR : $(cat ~/.zen/g1sms_wallets/$PHONE/_uidgeo.json)"
|
||||
curl -s ${CESIUM}/user/profile/${DESTRIB} | jq '._source.avatar._content' | sed 's/\"//g' | base64 -d > "~/.zen/g1sms_wallets/$PHONE/_avatar.png"
|
||||
curl -s ${CESIUM}/user/profile/${DESTRIB} | jq '._source.geoPoint' > "/home/$YOU/.zen/g1sms_wallets/$PHONE/_uidgeo.json"
|
||||
log "__SUB:sms_uid2key: GET CESIUM+ geoPoint and AVATAR : $(cat /home/$YOU/.zen/g1sms_wallets/$PHONE/_uidgeo.json)"
|
||||
curl -s ${CESIUM}/user/profile/${DESTRIB} | jq '._source.avatar._content' | sed 's/\"//g' | base64 -d > "/home/$YOU/.zen/g1sms_wallets/$PHONE/_avatar.png"
|
||||
fi
|
||||
|
||||
if [ "$DESTRIB" != "" ]; then
|
||||
|
@ -197,7 +197,7 @@ function sms_uid2key (){
|
|||
echo "$ASKWALLET" > "$NAMEFILE"
|
||||
log "__SUB:sms_uid2key: NEW EXTERNAL RELATED $DESTRIB / FOR MEMBER OR WALLET = $ASKWALLET - INIT 0.1 TX"
|
||||
duniter_server=$(./tools/duniter_getnode.sh)
|
||||
INIT=$(silkaj -p "$duniter_server" -af --file ~/.zen/g1sms_wallets/$PHONE/secret.dunikey tx --output $DESTRIB --amount 1 --comment "[G1sms+] Porte Monnaie $(cat $UIDNAFILE) -> $(cat $NAMEFILE)" -y)
|
||||
INIT=$(silkaj -p "$duniter_server" -af --file /home/$YOU/.zen/g1sms_wallets/$PHONE/secret.dunikey tx --output $DESTRIB --amount 1 --comment "[G1sms+] Porte Monnaie $(cat $UIDNAFILE) -> $(cat $NAMEFILE)" -y)
|
||||
|
||||
log "__SUB:sms_uid2key: INIT = $INIT | Create Connection with related Wallet."
|
||||
log_history "$PHONE" "MEMBER, $ASKWALLET"
|
||||
|
@ -218,54 +218,55 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
|
|||
UNKNOWN=0
|
||||
# TODO Optimize GLOBAL/local variables use, use more function array output ?!
|
||||
# Initiate PHONE settings files and values
|
||||
IPFSNODEIDFILE="~/.zen/g1sms_wallets/$PHONE/MASTERPHONE.ipfsid" # Contains G1sms+ NODE IPFS id
|
||||
SMSNODE="~/.zen/g1sms_wallets/$PHONE/MASTERPHONE.sms" # Contains G1sms+ SMS phone number
|
||||
PINFILE="~/.zen/g1sms_wallets/$PHONE/_pin" # Contains phone wallet diceware password
|
||||
GPGPINFILE="~/.zen/g1sms_wallets/$PHONE/_pin.gpg" # Contains g1smsnode cypher phone wallet diceware password
|
||||
AUTHCRYPTFILE="~/.zen/g1sms_wallets/$PHONE/_authfile.crypt" # Crypt with $NODE_G1PUBKEY
|
||||
PUBKEYFILE="~/.zen/g1sms_wallets/$PHONE/_pub" # Contains phone wallet public key (RIB)
|
||||
UNITFILE="~/.zen/g1sms_wallets/$PHONE/_unit" # Contains phone wallet prefered unit (LOVE,G1,DU)
|
||||
IPFSNODEIDFILE="/home/$YOU/.zen/g1sms_wallets/$PHONE/MASTERPHONE.ipfsid" # Contains G1sms+ NODE IPFS id
|
||||
SMSNODE="/home/$YOU/.zen/g1sms_wallets/$PHONE/MASTERPHONE.sms" # Contains G1sms+ SMS phone number
|
||||
PINFILE="/home/$YOU/.zen/g1sms_wallets/$PHONE/_pin" # Contains phone wallet diceware password
|
||||
GPGPINFILE="/home/$YOU/.zen/g1sms_wallets/$PHONE/_pin.gpg" # Contains g1smsnode cypher phone wallet diceware password
|
||||
AUTHCRYPTFILE="/home/$YOU/.zen/g1sms_wallets/$PHONE/_authfile.crypt" # Crypt with $NODE_G1PUBKEY
|
||||
PUBKEYFILE="/home/$YOU/.zen/g1sms_wallets/$PHONE/_pub" # Contains phone wallet public key (RIB)
|
||||
UNITFILE="/home/$YOU/.zen/g1sms_wallets/$PHONE/_unit" # Contains phone wallet prefered unit (LOVE,G1,DU)
|
||||
|
||||
RIBFILE="~/.zen/g1sms_wallets/$PHONE/_uidrib" # Contains phone wallet related UID Pubkey
|
||||
NAMEFILE="~/.zen/g1sms_wallets/$PHONE/_uidname" # Contains the member UID related to wallet
|
||||
MAILFILE="~/.zen/g1sms_wallets/$PHONE/_email" # Contains the member EMAIL (Send BILLET)
|
||||
GPGMAILFILE="~/.zen/g1sms_wallets/$PHONE/_email.gpg" # Contains the member EMAIL (Send BILLET)
|
||||
UIDNAFILE="~/.zen/g1sms_wallets/$PHONE/_uidna" # Contains the G1sms+ UID Name for recursive VIR
|
||||
GEOFILE="~/.zen/g1sms_wallets/$PHONE/_uidgeo.json" # Contains the member GeoPoint from member Cesium+ related to wallet
|
||||
RIBFILE="/home/$YOU/.zen/g1sms_wallets/$PHONE/_uidrib" # Contains phone wallet related UID Pubkey
|
||||
NAMEFILE="/home/$YOU/.zen/g1sms_wallets/$PHONE/_uidname" # Contains the member UID related to wallet
|
||||
MAILFILE="/home/$YOU/.zen/g1sms_wallets/$PHONE/_email" # Contains the member EMAIL (Send BILLET)
|
||||
GPGMAILFILE="/home/$YOU/.zen/g1sms_wallets/$PHONE/_email.gpg" # Contains the member EMAIL (Send BILLET)
|
||||
UIDNAFILE="/home/$YOU/.zen/g1sms_wallets/$PHONE/_uidna" # Contains the G1sms+ UID Name for recursive VIR
|
||||
GEOFILE="/home/$YOU/.zen/g1sms_wallets/$PHONE/_uidgeo.json" # Contains the member GeoPoint from member Cesium+ related to wallet
|
||||
|
||||
RECFILE="~/.zen/g1sms_wallets/$PHONE/VIREMENTS" # File showing recurrent payements are left to be done with this G1sms Wallet
|
||||
GPGRECFILE="~/.zen/g1sms_wallets/$PHONE/VIREMENTS.gpg" # Cypher file with IPFSPrivKey (Node .Identity.PrivKey)
|
||||
RECFILE="/home/$YOU/.zen/g1sms_wallets/$PHONE/VIREMENTS" # File showing recurrent payements are left to be done with this G1sms Wallet
|
||||
GPGRECFILE="/home/$YOU/.zen/g1sms_wallets/$PHONE/VIREMENTS.gpg" # Cypher file with IPFSPrivKey (Node .Identity.PrivKey)
|
||||
|
||||
DABUIDF="~/.zen/g1sms_wallets/$PHONE/uidna.G1TAGNODE" # Contains G1Dab Name
|
||||
DABUIDF="/home/$YOU/.zen/g1sms_wallets/$PHONE/uidna.G1TAGNODE" # Contains G1Dab Name
|
||||
# GET CURRENT NODE UIDNA (default DABUID)
|
||||
NODEUIDNA=$(cat ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_uidna)
|
||||
NODEUIDNA=$(cat /home/$YOU/.zen/ipfs/.$IPFSNODEID/G1SSB/_uidna)
|
||||
######################################################################
|
||||
# (NO PIN) = FIRST ACCOUNT: Create wallet
|
||||
if [ ! -f "$PINFILE" ]; then
|
||||
# NOSMS mode?
|
||||
if [[ $2 == "NOSMS" ]]; then UNKNOWN="unknown"; return; fi
|
||||
|
||||
mkdir -p /home/$YOU/.zen/g1sms_wallets/$PHONE/
|
||||
|
||||
#######################
|
||||
# GIVE NAME TO WALLET
|
||||
#######################
|
||||
# 4 derniers chiffres du numéro de téléphone
|
||||
TAIL=${PHONE:8:4}
|
||||
TAIL=${PHONE:6:6}
|
||||
# No UIDNA yet. Create new
|
||||
UIDNA=$(~/.zen/astroport/zen/tools/diceware.sh 1 | xargs)
|
||||
UIDNA=$(/home/$YOU/.zen/astroport/zen/tools/diceware.sh 1 | xargs)
|
||||
# Check if already existing among all swarm wallets
|
||||
while [[ $(grep -Rwl "$UIDNA$TAIL" ~/.zen/ipfs_swarm/.*/G1*/_uidna) ]]; do UIDNA=$(~/.zen/astroport/zen/tools/diceware.sh 1 | xargs); done
|
||||
while [[ $(grep -Rwl "$UIDNA$TAIL" /home/$YOU/.zen/ipfs_swarm/.*/G1SMS/_uidna 2>/dev/null) ]]; do UIDNA=$(/home/$YOU/.zen/astroport/zen/tools/diceware.sh 1 | xargs); done
|
||||
UIDNA="$UIDNA$TAIL"
|
||||
echo "$UIDNA" > "$UIDNAFILE"
|
||||
|
||||
#######################
|
||||
# Create Account Files
|
||||
#######################
|
||||
mkdir -p "~/.zen/g1sms_wallets/$PHONE/"
|
||||
PIN=$(~/.zen/astroport/zen/tools/diceware.sh | xargs)
|
||||
|
||||
PIN=$(/home/$YOU/.zen/astroport/zen/tools/diceware.sh | xargs)
|
||||
|
||||
python3 ./tools/key_create_dunikey.py "$UIDNA" "$PIN" ## Copy PubSec file to /tmp/secret.dunikey
|
||||
mv /tmp/secret.dunikey ~/.zen/g1sms_wallets/$PHONE/
|
||||
PUBKEY=$(cat ~/.zen/g1sms_wallets/$PHONE/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
|
||||
mv /tmp/secret.dunikey /home/$YOU/.zen/g1sms_wallets/$PHONE/
|
||||
PUBKEY=$(cat /home/$YOU/.zen/g1sms_wallets/$PHONE/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
|
||||
log "__SUB:sms_INIT_ACCOUNT: !! G1 Wallet CREATED: $PHONE = $UIDNA $PIN : $PUBKEY"
|
||||
|
||||
|
||||
|
@ -278,7 +279,7 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
|
|||
log "__SUB:sms_INIT_ACCOUNT: G1 Wallet TX IN: $TX_IN"
|
||||
sleep 2
|
||||
|
||||
TX_OUT=$(silkaj -p "$duniter_server" -af --file ~/.zen/g1sms_wallets/$PHONE/secret.dunikey tx --output $NODE_G1PUBKEY --amount 0.1 --comment "[G1sms+] $UIDNA$TAIL 3RD:$NODE_G1PUBKEY:ACK" -y)
|
||||
TX_OUT=$(silkaj -p "$duniter_server" -af --file /home/$YOU/.zen/g1sms_wallets/$PHONE/secret.dunikey tx --output $NODE_G1PUBKEY --amount 0.1 --comment "[G1sms+] $UIDNA$TAIL 3RD:$NODE_G1PUBKEY:ACK" -y)
|
||||
log "__SUB:sms_INIT_ACCOUNT: G1 Wallet TX OUT: $TX_OUT"
|
||||
|
||||
################
|
||||
|
|
Loading…
Reference in New Issue