mirror of
https://github.com/YunoHost-Apps/cjdns_ynh.git
synced 2024-09-03 18:16:29 +02:00
add peers
This commit is contained in:
parent
f55dc6d385
commit
47f8bdc8b2
3 changed files with 37 additions and 7 deletions
|
@ -1,6 +0,0 @@
|
|||
Security
|
||||
|
||||
Upgrading
|
||||
|
||||
Other
|
||||
...
|
|
@ -1 +0,0 @@
|
|||
What you need to know before installing cjdns...
|
|
@ -34,6 +34,43 @@ $install_dir/cjdroute --genconf | $install_dir/cjdroute --cleanconf > $install_d
|
|||
jq '.security[0].setuser = 0' $install_dir/cjdroute.conf > $install_dir/cjdroute.conf.tmp && mv $install_dir/cjdroute.conf.tmp $install_dir/cjdroute.conf
|
||||
jq '.noBackground = 1' $install_dir/cjdroute.conf > $install_dir/cjdroute.conf.tmp && mv $install_dir/cjdroute.conf.tmp $install_dir/cjdroute.conf
|
||||
|
||||
#=================================================
|
||||
# UPGRADE PEERS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Getting cjdns peers..." --weight=1
|
||||
# Fetch the JSON data
|
||||
json=$(curl -s https://vpn.anode.co/api/0.3/vpn/cjdns/peeringlines/)
|
||||
echo "Got peering lines"
|
||||
|
||||
config=$(cat $install_dir/cjdroute.conf | jq .)
|
||||
|
||||
length=$(echo $json | jq '. | length')
|
||||
ynh_script_progression --message="Adding $length cjdns peers..." --weight=1
|
||||
for (( i=0; i<$length; i++ ))
|
||||
do
|
||||
# Parse the JSON data
|
||||
ip=$(echo $json | jq -r --argjson i $i '.[$i].ip')
|
||||
port=$(echo $json | jq -r --argjson i $i '.[$i].port')
|
||||
login=$(echo $json | jq -r --argjson i $i '.[$i].login')
|
||||
password=$(echo $json | jq -r --argjson i $i '.[$i].password')
|
||||
publicKey=$(echo $json | jq -r --argjson i $i '.[$i].publicKey')
|
||||
#echo "Read peer $ip:$port $login $password $publicKey"
|
||||
#read -p "Enter to continue"
|
||||
# Prepare the peer to be inserted
|
||||
peer=$(jq -n \
|
||||
--arg ip_port "$ip:$port" \
|
||||
--arg login "$login" \
|
||||
--arg password "$password" \
|
||||
--arg publicKey "$publicKey" \
|
||||
'{($ip_port): {"login": $login, "password": $password, "publicKey": $publicKey}}')
|
||||
#echo "Prepared peer $peer"
|
||||
# Insert the peer into the cjdroute.conf file
|
||||
|
||||
config=$(echo $config | jq --argjson peer "$peer" '(.interfaces.UDPInterface[] | select(.beaconPort == 64512) .connectTo) |= . + $peer')
|
||||
done
|
||||
|
||||
echo $config > $install_dir/cjdroute.conf
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue