Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
josselinchevalay | 36e3803182 |
218
install.sh
218
install.sh
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
########################################################################
|
||||
################################################################################
|
||||
# Authors:
|
||||
# [@cel](@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519)
|
||||
# [@Fred](@9BbJwPDjcyIqrOUPNn0nJZBduWdIrpMk3Cjz5MP361s=.ed25519)
|
||||
|
@ -7,142 +7,92 @@
|
|||
# [@poka]()
|
||||
# Version: 1.0.1
|
||||
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||
########################################################################
|
||||
########################################################################
|
||||
MY_PATH="`dirname \"$0\"`" # relative
|
||||
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||
ME="${0##*/}"
|
||||
echo '
|
||||
########################################################################
|
||||
# \\///
|
||||
# qo-op
|
||||
############# '$MY_PATH/$ME'
|
||||
########################################################################
|
||||
# SSB-G1-TX :: INSTALL G1 + SSB for sending G1 Tip on SSB likes
|
||||
########################################################################
|
||||
'
|
||||
###########################################################################################
|
||||
# ADD G1 Layer 10 LOVE to message writer you like !
|
||||
# INSTALL silkaj sbotc
|
||||
# PREVENT DOUBLE PAYEMENT
|
||||
############################################################################################
|
||||
|
||||
# INSTALL requirements
|
||||
[[ ! $(which base58) ]] && sudo apt install build-essential base58 -y
|
||||
|
||||
# INSTALL Silkaj, CLI for Duniter
|
||||
if [[ ! $(which silkaj) ]]; then
|
||||
echo '**************************************************************
|
||||
__ ___
|
||||
(_ | | |/ /\ |
|
||||
__) _|_ |_ |\ /--\ \_|
|
||||
|
||||
#Libre Money Layer
|
||||
'
|
||||
mkdir -p ~/.zen
|
||||
echo "INSTALL silkaj"
|
||||
sudo apt update || true
|
||||
sudo apt install build-essential -y
|
||||
sudo pip3 install base58
|
||||
sudo apt install python3-pip python3-setuptools python3-wheel -y
|
||||
pip3 install silkaj --user
|
||||
sudo apt install python3-pip python3-setuptools python3-wheel -y && pip3 install silkaj --user
|
||||
echo 'PATH=$PATH:.local/bin' >> ~/.bashrc && source ~/.bashrc
|
||||
fi
|
||||
|
||||
|
||||
# Install ScuttleButt
|
||||
echo '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
__ _ ___ ___ _ _ ___ ___
|
||||
(_ / | | | | | |_ |_) | | | |
|
||||
__) \_ |_| | | |_ |_ |_) |_| | |
|
||||
|
||||
#Libre Social Layer
|
||||
|
||||
Is it a 24/24 Pub?
|
||||
Yes/No: y? (Default No)'
|
||||
read ssb_yes
|
||||
|
||||
nodename=$(cat /etc/hostname)
|
||||
extension=$(echo $nodename | cut -d '.' -f 2)
|
||||
[[ $extension == $nodename ]] && nodename=$nodename.local
|
||||
|
||||
if [[ ! $(which sbot) && "$ssb_yes" == "y" ]]; then
|
||||
if [[ ! $(which sbot) ]]; then
|
||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
|
||||
source ~/.bashrc
|
||||
|
||||
export NVM_DIR="$HOME/.nvm"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
|
||||
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
|
||||
nvm install --lts
|
||||
|
||||
sudo apt install libtool autoconf -y
|
||||
npm install sodium-native ssb-backlinks ssb-ws ssb-links ssb-query ssb-secret-blob ssb-private
|
||||
npm install sodium-native ssb-backlinks
|
||||
npm install -g ssb-server
|
||||
|
||||
nodename=$(cat /etc/hostname).local
|
||||
echo "SSB Node Hostname (default $nodename)?"
|
||||
read EXTERNAL
|
||||
[[ $EXTERNAL == "" ]] && EXTERNAL=$nodename
|
||||
|
||||
# LOCAL
|
||||
####### BACKUP .ssb to ~/.ssb_$USER && CREATE ~/.ssb_astroport
|
||||
# If exists backup ~/.ssb to ~/.ssb_$USER SSB (one time only !)
|
||||
[[ -d ~/.ssb_$USER ]] && echo "BACKUP already existing... ~/.ssb_$USER !!! Manual check please..." && exit 1
|
||||
[[ -d ~/.ssb ]] && [[ ! -d ~/.ssb_$USER ]] && mv ~/.ssb ~/.ssb_$USER
|
||||
# CREATE ~/.ssb_astroport
|
||||
[[ ! -d ~/.ssb_astroport ]] && mkdir -p ~/.ssb_astroport
|
||||
# if exists, keep ~/.ssb_$USER/secret*
|
||||
[[ ! -f ~/.ssb_astroport/secret ]] && [[ -f ~/.ssb_$USER/secret ]] && cp -f ~/.ssb_$USER/secret* ~/.ssb_astroport/
|
||||
|
||||
# Symlink ~/.ssb -> ~/.ssb_astroport
|
||||
[[ -L ~/.ssb ]] && rm ~/.ssb
|
||||
[[ -d ~/.ssb_astroport ]] && ln -s ~/.ssb_astroport ~/.ssb
|
||||
|
||||
mkdir -p ~/.ssb
|
||||
cat > ~/.ssb/config <<EOF
|
||||
{
|
||||
"connections": {
|
||||
"incoming": {
|
||||
"net": [
|
||||
{ "scope": "public", "host": "0.0.0.0", "external": ["$nodename"], "transform": "shs", "port": 8008 }
|
||||
],
|
||||
"ws": [
|
||||
{ "scope": ["public", "local", "device"], "host": "0.0.0.0", "port": 8989, "transform": "shs", "http": true }
|
||||
{
|
||||
"scope": "public", "external": ["$EXTERNAL"], "transform": "shs", "port": 8008
|
||||
},
|
||||
{ "scope": "private", "transform": "shs", "port": 8008, "host": "127.0.0.1" }
|
||||
]
|
||||
},
|
||||
"outgoing": {
|
||||
"net": [{ "transform": "shs" }]
|
||||
"net": [
|
||||
{
|
||||
"transform": "shs"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
cat > ~/.zen/run-ssb_server.sh <<EOF
|
||||
|
||||
cat > ~/run-ssb-PUB_$EXTERNAL.sh <<EOF
|
||||
#!/bin/bash
|
||||
echo _$ > ~/.zen/ssb.pid.bash
|
||||
while true; do
|
||||
ssb-server start
|
||||
echo _! > ~/.zen/ssb.pid
|
||||
ssb-server start --host $EXTERNAL
|
||||
done
|
||||
EOF
|
||||
|
||||
# REPLACE _ with $
|
||||
sed -i s/_/\$/g ~/.zen/run-ssb_server.sh
|
||||
chmod 755 ~/.zen/run-ssb_server.sh
|
||||
|
||||
# INSTALL sbotc for CLI API
|
||||
if [[ ! $(which sbotc) ]]; then
|
||||
sudo apt install libsodium-dev jq -y
|
||||
git clone https://git.scuttlebot.io/%25133ulDgs%2FoC1DXjoK04vDFy6DgVBB%2FZok15YJmuhD5Q%3D.sha256 sbotc
|
||||
cd sbotc
|
||||
make
|
||||
sudo make install
|
||||
fi
|
||||
|
||||
chmod 755 ~/run-ssb-PUB_$EXTERNAL.sh
|
||||
~/run-ssb-PUB_$EXTERNAL.sh &
|
||||
fi
|
||||
|
||||
# LOCAL NODE
|
||||
if [[ $extension == $nodename ]] ; then
|
||||
|
||||
echo '
|
||||
_ ___ _ _ _
|
||||
|_) /\ | / |_| \ / / \ |_) |/
|
||||
| /--\ | \_ | | \/\/ \_/ | \ |\
|
||||
|
||||
Install Patchwork...
|
||||
'
|
||||
|
||||
wget -s https://github.com/ssbc/patchwork/releases/download/v3.17.6/ssb-patchwork_3.17.6_amd64.deb > /tmp/
|
||||
sudo dpkg -i /tmp/ssb-patchwork_3.17.6_amd64.deb
|
||||
|
||||
# INSTALL sbotc
|
||||
if [[ ! $(which sbotc) ]]; then
|
||||
sudo apt install libsodium-dev jq -y
|
||||
git clone https://git.scuttlebot.io/%25133ulDgs%2FoC1DXjoK04vDFy6DgVBB%2FZok15YJmuhD5Q%3D.sha256 sbotc
|
||||
cd sbotc
|
||||
make
|
||||
sudo make install
|
||||
fi
|
||||
|
||||
|
||||
###########################################################################################
|
||||
####################### G1 SSB ACCOUNT MANAGER ############################################
|
||||
###########################################################################################
|
||||
|
||||
|
||||
|
||||
# If user already has an SSB account, we generate Duniter secret key from SSB secret key
|
||||
if [[ -f ~/.ssb/secret ]]; then
|
||||
|
||||
|
@ -165,62 +115,48 @@ else
|
|||
|
||||
mkdir -p ~/.ssb
|
||||
echo "WELCOME CREATING YOUR G1 SSB ACCOUNT !!!"
|
||||
echo "
|
||||
__ __ __ _
|
||||
/__ /| (_ (_ |_)
|
||||
\_| | __) __) |_)
|
||||
|
||||
CHOOSE YOU LOGIN or LEAVE BLANK & HIT ENTER FOR AUTO GENERATION"
|
||||
echo "CHOOSE YOU LOGIN or LEAVE BLANK & HIT ENTER FOR AUTO GENERATION"
|
||||
read salt
|
||||
[[ $salt != "" ]] && echo "PASSWORD?" && read pepper && [[ $pepper == "" ]] && exit 1
|
||||
[[ $salt != "" ]] && echo "PASSWORD?" && read pepper && [[ $pepper == "" ]] && exit
|
||||
|
||||
if [[ "$salt" == "" && "$pepper" == "" ]]; then
|
||||
echo '
|
||||
._ _ ._ _ ._ _ _ ._ o _
|
||||
| | | | | (/_ | | | (_) | | | (_
|
||||
|
||||
passphrase generator...'
|
||||
|
||||
# INSTALL Cargo
|
||||
if [[ ! $(which cargo) ]]; then
|
||||
curl https://sh.rustup.rs -sSf | sh
|
||||
PATH=$PATH:~/.cargo/env
|
||||
source $HOME/.cargo/env
|
||||
fi
|
||||
|
||||
# Install DUP-Mnemonic
|
||||
|
||||
if [[ ! $(which dup-mnemonic) ]]; then
|
||||
cd /tmp
|
||||
git clone https://git.duniter.org/tools/dup-mnemonic-rs
|
||||
cd dup-mnemonic-rs
|
||||
cargo build --release
|
||||
sudo cp target/release/dup-mnemonic /usr/local/bin
|
||||
fi
|
||||
|
||||
# GENERATE MNEMONIC KEY: 9 MOTS
|
||||
if [[ $salt == "" ]]; then
|
||||
declare -a makeyarray
|
||||
makeyarray=($(dup-mnemonic -l $lang))
|
||||
# LOGIN (=SALT) 6 WORDS
|
||||
salt="${makeyarray[0]} ${makeyarray[1]} ${makeyarray[2]} ${makeyarray[3]} ${makeyarray[4]} ${makeyarray[5]}"
|
||||
# PASS (=PEPPER) 3 WORDS
|
||||
pepper="${makeyarray[6]} ${makeyarray[7]} ${makeyarray[8]}"
|
||||
fi
|
||||
echo "........."
|
||||
echo "REMEMBER YOUR CREDENTIALS: $salt / $pepper"
|
||||
# INSTALL Cargo
|
||||
if [[ ! $(which cargo) ]]; then
|
||||
curl https://sh.rustup.rs -sSf | sh
|
||||
PATH=$PATH:~/.cargo/env
|
||||
source $HOME/.cargo/env
|
||||
fi
|
||||
|
||||
# Install DUP-Mnemonic
|
||||
|
||||
if [[ ! $(which dup-mnemonic) ]]; then
|
||||
cd /tmp
|
||||
git clone https://git.duniter.org/tools/dup-mnemonic-rs
|
||||
cd dup-mnemonic-rs
|
||||
cargo build --release
|
||||
sudo cp target/release/dup-mnemonic /usr/local/bin
|
||||
fi
|
||||
|
||||
# GENERATE MNEMONIC KEY: 9 MOTS
|
||||
if [[ $salt == "" ]]; then
|
||||
declare -a makeyarray
|
||||
makeyarray=($(dup-mnemonic -l $lang))
|
||||
# LOGIN (=SALT) 6 MOTS
|
||||
salt="${makeyarray[0]} ${makeyarray[1]} ${makeyarray[2]} ${makeyarray[3]} ${makeyarray[4]} ${makeyarray[5]}"
|
||||
# PASS (=PEPPER) 3 MOTS
|
||||
pepper="${makeyarray[6]} ${makeyarray[7]} ${makeyarray[8]}"
|
||||
fi
|
||||
echo "........."
|
||||
echo "REMEMBER YOUR CREDENTIALS: $salt / $pepper"
|
||||
|
||||
# CREATE ~/.ssb/secret.dunikey
|
||||
python3 $MY_PATH/key_create_dunikey.py "$salt" "$pepper"
|
||||
mv $MY_PATH/.secret.dunikey ~/.ssb/secret.dunikey
|
||||
python3 ./key_create_dunikey.py "$salt" "$pepper"
|
||||
mv ./.secret.dunikey ~/.ssb/secret.dunikey
|
||||
|
||||
# CREATE SSB secret
|
||||
pub=$(cat ~/.ssb/secret.dunikey | grep "pub" | cut -d ' ' -f 2)
|
||||
priv=$(cat ~/.ssb/secret.dunikey | grep "sec" | cut -d ' ' -f 2)
|
||||
ssbpub=$(echo $pub | base58 -d | base64)
|
||||
ssbpriv=$(echo $priv | base58 -d | base64)
|
||||
|
||||
cat > ~/.ssb/secret <<EOF
|
||||
# This secret is related to your G1Wallet - https://cesium.app
|
||||
# silkaj balance $pub
|
||||
|
|
|
@ -111,8 +111,7 @@ SSB_PATH=~/.ssb/ docker-compose build
|
|||
create your dunikey
|
||||
|
||||
```
|
||||
SSB_PATH=~/your-copy-ssb/ docker-compose up -d tip # only you need to run tiping part
|
||||
SSB_PATH=~/your-copy-ssb/ docker-compose up -d # if you need to run all platform
|
||||
SSB_PATH=~/.ssb/ docker-compose up -d tip # only you need to run tiping part
|
||||
```
|
||||
|
||||
run main tip script
|
||||
|
|
35
tip.sh
35
tip.sh
|
@ -26,7 +26,7 @@ debugMsgMode=0
|
|||
# If you don't want to wait
|
||||
readable=1
|
||||
|
||||
minimumAmountPerLikeInLOVE="10"
|
||||
minimumAmountPerLikeInUD="0.1"
|
||||
|
||||
############################################################################################
|
||||
|
||||
|
@ -129,7 +129,7 @@ else
|
|||
exit 1
|
||||
fi
|
||||
|
||||
printf "You have ${bold}%s LOVE${normal} on your Duniter Ğ1 wallet.\n\n" "$((balance * 100))"
|
||||
printf "You have ${bold}%s UDĞ1${normal} on your Duniter Ğ1 wallet.\n\n" "$balance"
|
||||
if [[ $readable -eq 1 ]]; then sleep 2; fi
|
||||
printf "Want to show your appreciation of your fellow butts' posts while helping spreading awareness about libre currencies?\n\n"
|
||||
if [[ $readable -eq 1 ]]; then sleep 3; fi
|
||||
|
@ -274,22 +274,22 @@ tx_are_possible=0
|
|||
while [[ $tx_are_possible -eq 0 ]]
|
||||
do
|
||||
|
||||
printf "How many LOVE do you want to send per each like you gave? (minimum is ${bold}%s LOVE${normal}) " "$((minimumAmountPerLikeInLOVE))"
|
||||
printf "How many UDĞ1 do you want to send per each like you gave? (minimum is ${bold}%s UDĞ1${normal}) " "$minimumAmountPerLikeInUD"
|
||||
read a
|
||||
printf "\n"
|
||||
|
||||
if [[ -z $a ]]
|
||||
then
|
||||
amountPerLikeInUD=$(bc -l <<< "scale=2; $minimumAmountPerLikeInLOVE / 100")
|
||||
amountPerLikeInUD=$minimumAmountPerLikeInUD
|
||||
else
|
||||
amountPerLikeInUD=$(bc -l <<< "scale=2; $a / 100")
|
||||
fi
|
||||
amountPerLikeInUD=$a
|
||||
fi
|
||||
|
||||
amountGiven=$(echo "$totalLikesGiven * $amountPerLikeInUD" | bc -l)
|
||||
|
||||
|
||||
has_enough_money=$(( $(echo "$amountGiven <= $balance" | bc -l) ))
|
||||
amountPerLike_is_enough=$(( $(echo "$amountPerLikeInUD >= $minimumAmountPerLikeInLOVE" | bc -l) ))
|
||||
amountPerLike_is_enough=$(( $(echo "$amountPerLikeInUD >= $minimumAmountPerLikeInUD" | bc -l) ))
|
||||
tx_are_possible=$(( $has_enough_money && $amountPerLike_is_enough ))
|
||||
|
||||
if [[ $readable -eq 1 ]]; then sleep 1; fi
|
||||
|
@ -298,13 +298,13 @@ do
|
|||
|
||||
if [[ $has_enough_money -eq 0 ]] ; then
|
||||
|
||||
printf "You don't have enough LOVE to send all transactions.\n\n"
|
||||
printf "You don't have enough UDĞ1 to send all transactions.\n\n"
|
||||
if [[ $readable -eq 1 ]]; then sleep 1; fi
|
||||
printf "${bold}%s LOVE${normal} are needed.\n\n" "$((amountGiven * 100))"
|
||||
printf "${bold}%s UDĞ1${normal} are needed.\n\n" "$amountGiven"
|
||||
if [[ $readable -eq 1 ]]; then sleep 1; fi
|
||||
elif [[ $amountPerLike_is_enough -eq 0 ]] ; then
|
||||
|
||||
printf "Minimum amount per like is %s LOVE.\n\n" $minimumAmountPerLikeInLOVE
|
||||
printf "Minimum amount per like is %s UDĞ1.\n\n" $minimumAmountPerLikeInUD
|
||||
if [[ $readable -eq 1 ]]; then sleep 1; fi
|
||||
|
||||
fi
|
||||
|
@ -312,13 +312,13 @@ do
|
|||
printf "Try again with a different amount per like.\n\n"
|
||||
maxAmountPerLike=$(awk -vp=$balance -vq=$totalLikesGiven 'BEGIN{printf "%.2f" ,p / q}')
|
||||
if [[ $readable -eq 1 ]]; then sleep 1; fi
|
||||
printf "Maximum amount per like possible: ${bold}%s LOVE${normal}\n\n" "$((maxAmountPerLike * 100))"
|
||||
printf "Maximum amount per like possible: ${bold}%s UDĞ1${normal}\n\n" "$maxAmountPerLike"
|
||||
if [[ $readable -eq 1 ]]; then sleep 1; fi
|
||||
else
|
||||
newBalance=$(echo "$balance - $amountGiven" | bc -l)
|
||||
printf "${bold}%s LOVE${normal} will be given.\n\n" "$((amountGiven * 100))"
|
||||
printf "${bold}%s UDĞ1${normal} will be given.\n\n" "$amountGiven"
|
||||
if [[ $readable -eq 1 ]]; then sleep 1; fi
|
||||
printf "After sending transactions, your new balance will be ${bold}%s LOVE${normal}\n\n" "$((newBalance * 100))"
|
||||
printf "After sending transactions, your new balance will be ${bold}%s UDĞ1${normal}\n\n" "$newBalance"
|
||||
if [[ $readable -eq 1 ]]; then sleep 1; fi
|
||||
printf "Press ENTER to continue: " && read
|
||||
printf "\n"
|
||||
|
@ -410,7 +410,7 @@ do
|
|||
|
||||
done
|
||||
|
||||
newLine+=$(printf "| %s LOVE " "$((tipAmount * 100))")
|
||||
newLine+=$(printf "| %s UDĞ1 " "$tipAmount")
|
||||
|
||||
newLine+="|\n"
|
||||
|
||||
|
@ -451,7 +451,7 @@ do
|
|||
#printf '%s\n' "silkaj -af --file ~/.ssb/secret.dunikey tx --output $g1_author --amountUD $tipAmount --comment "Thx for your cool posts on ScuttleButt"
|
||||
silkaj -p "$duniter_server" -af --file ~/.ssb/secret.dunikey tx --output $g1_author --amountUD $tipAmount --comment "Thx for your cool posts on ScuttleButt" -y 2>/dev/null
|
||||
|
||||
printf "\n${bold}%s LOVE${normal} sent to %s!\n\n" "$((tipAmount * 100))" "$author_name"
|
||||
printf "\n${bold}%s UDĞ1${normal} sent to %s!\n\n" "$tipAmount" "$author_name"
|
||||
fi
|
||||
|
||||
(( authorNum++ ))
|
||||
|
@ -473,7 +473,7 @@ then
|
|||
fi
|
||||
fi
|
||||
|
||||
printf "\n%s LOVE sent to %s butts!\n\n" "$((amountGiven * 100))" "${#likesNbPerAuthor[@]}"
|
||||
printf "\n%s UDĞ1 sent to %s butts!\n\n" "$amountGiven" "${#likesNbPerAuthor[@]}"
|
||||
|
||||
# Let's publicly thank everyone!
|
||||
#echo -e "${tyPosts[$n]}"
|
||||
|
@ -512,9 +512,6 @@ then
|
|||
printf "It's a file.\n\n"
|
||||
if [[ $readable -eq 1 ]]; then sleep 2; fi
|
||||
printf "It's called $msg_filename.md\n\n"
|
||||
# Open file with xed
|
||||
[[ $(which xed) ]] && xed ~/$msg_filename.md &
|
||||
|
||||
else
|
||||
printf "It's %s files.\n\n" "${#tyPosts[@]}"
|
||||
if [[ $readable -eq 1 ]]; then sleep 2; fi
|
||||
|
|
Loading…
Reference in New Issue