1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

initial commit

This commit is contained in:
initial commit 2019-09-07 14:03:22 +04:00 committed by vvaltman
commit c2da007f40
1610 changed files with 398047 additions and 0 deletions

View file

@ -0,0 +1,148 @@
#!/bin/bash
binary="../../ton-build/generate-random-id"
die() {
echo "$@" 1>&2 ;
exit 1;
}
run_help() {
echo "generates config for ton"
echo " server-list - list of core DHT servers"
echo " server-list.local - list of additional servers"
echo " also expects generate-random-id binary to be accessible by path '$binary'"
die
}
get_line() {
x=`grep -h -e "^$1 " server-list server-list.local`
echo $x
}
get_ip_block() {
echo $1 | cut -f $2 -d"."
}
get_ip() {
ip=`echo $1 | cut -f 2 -d" "`
a=$(get_ip_block $ip 1)
b=$(get_ip_block $ip 2)
c=$(get_ip_block $ip 3)
d=$(get_ip_block $ip 4)
ip=$(( $a * 256 * 256 * 256 + $b * 256 * 256 + $c * 256 + $d ))
if [ "$ip" -gt "2147483647" ] ; then
ip=$((256*256*256*256 - $ip))
ip="-$ip"
fi
echo $ip
}
get_port() {
echo $1 | cut -f 3 -d" "
}
get_pk() {
#echo \'$1\' | cut -f 4 -d" "
echo $1 | cut -f 4 -d" "
}
get_addr_list() {
line=$1
ip=$(get_ip "$line")
port=$(get_port "$line")
addr_list="{\"@type\":\"adnl.addressList\",\"version\":0,\"addrs\":[{\"ip\":$ip,\"port\":$port,\"@type\":\"adnl.address.udp\"}]}"
echo $addr_list
}
get_node() {
line=$1
addr_list=$(get_addr_list "$line")
pk=$(get_pk "$line")
res=`$binary -k $pk -a $addr_list | tail -1`
echo $res
}
get_id_short() {
pk=$(get_pk "$1")
res=`$binary -k $pk | tail -1`
echo $res
}
action=$1
if [ "$action" == "global" ] ; then
[ -f "$binary" ] || die "can not file '$binary'"
[ -f "server-list" ] || die "can not file 'server-list'"
[ -f "server-list.local" ] || die "can not file 'server-list.local'"
if [ "x$2" == "x" ] ; then
config_filename="ton-global.config.json"
else
config_filename=$2
fi
list=`cat server-list | awk '{ print $1}'`
config='{"@type":"config.global","dht":{"@type":"dht.config.global","k":10,"a":3,"static_nodes":{"@type":"adnl.nodes","nodes":'
cnt=0
for name in $list ; do
if [ $cnt -eq 0 ] ; then
config="$config["
else
config="$config,"
fi
cnt=$(($cnt + 1))
line=$(get_line $name)
node=$(get_node "$line")
config="$config$node"
done
config="$config]}}}"
#name=$1
#line=$(get_line $name)
#echo $line
#res=$(get_node "$line")
#echo $res
echo $config > $config_filename
elif [ "$action" == "local" ] ; then
[ -f "$binary" ] || die "can not file '$binary'"
[ -f "server-list" ] || die "can not file 'server-list'"
[ -f "server-list.local" ] || die "can not file 'server-list.local'"
name=$2
if [ "x$3" == "x" ] ; then
config_filename="ton-local.config.$name.json"
else
config_filename=$3
fi
line=$(get_line $name)
config='{"@type":"config.local","local_ids":['
id=$(get_pk "$line")
id_short=$(get_id_short "$line")
addr_list=$(get_addr_list "$line")
config="$config{\"@type\":\"id.config.local\",\"id\":$id,\"addr_list\":$addr_list}]"
config="$config,\"net\":$addr_list"
config="$config,\"dht\":[{\"@type\":\"dht.config.local\",\"id\":$id_short}]"
config="$config,\"dht_random\":{\"@type\":\"config.dht.random\",\"cnt\":0,\"addr_list\":$addr_list}"
config="$config,\"public_overlays\":[{\"@type\":\"overlay.config.local\",\"name\":\"testoverlay\",\"id\":$id_short}]"
config="$config,\"public_overlays_random\":{\"@type\":\"overlay.config.random\",\"cnt\":0,\"name\":\"testoverlay\",\"addr_list\":$addr_list}"
config="$config}"
echo $config > $config_filename
elif [ "$action" == "-h" ] ; then
run_help
elif [ "$action" == "--help" ] ; then
run_help
fi

View file

@ -0,0 +1,2 @@
|1|ZHWS4UqZvNaFSyJtpsIjaxt81x0=|EcIbvL5PRC309C1xvWmahWmxS+0= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/VqLat/MaB33pZy0y3rJZtnqwR2qOOvbwKZYKiEO1O6VqNEBxKvJJelCq0dTXWT5pbO2gDXC6h6QDXCaHo6pOHGPUy+YBaGQRGuSusMEASYiWunYN0vCAI8QaXnWMXNMdFP3jHAJH0eDsoiGnLPBlBp4TNm6rYI74nMzgz3B9IikW4WVK+dc8KZJZWYjAuORU3jc1c/NPskD2ASinf8v3xnfXeukU0sJ5N6m5E8VLjObPEO+mN2t/FZTMZLiFqPWc/ALSqnMnnhwrNi2rbfg/rd/IpL8Le3pSBne8+seeFVBoGqzHM9yXw==
|1|J3+q3mgMPZ5MP5OhvjE5owUKTUk=|tH2DPyqGRjXkrRy2rZBOm/F34vs= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/VqLat/MaB33pZy0y3rJZtnqwR2qOOvbwKZYKiEO1O6VqNEBxKvJJelCq0dTXWT5pbO2gDXC6h6QDXCaHo6pOHGPUy+YBaGQRGuSusMEASYiWunYN0vCAI8QaXnWMXNMdFP3jHAJH0eDsoiGnLPBlBp4TNm6rYI74nMzgz3B9IikW4WVK+dc8KZJZWYjAuORU3jc1c/NPskD2ASinf8v3xnfXeukU0sJ5N6m5E8VLjObPEO+mN2t/FZTMZLiFqPWc/ALSqnMnnhwrNi2rbfg/rd/IpL8Le3pSBne8+seeFVBoGqzHM9yXw==

41
install-scripts/prepare.sh Executable file
View file

@ -0,0 +1,41 @@
#!/bin/bash
host=$1
user="root"
ssh=$user@$host
die() {
echo "$@" 1>&2 ;
exit 1;
}
run_help() {
echo "tries to initialize new server"
echo "uses these files: "
echo " tonkey - RSA key that allows to access git repository"
echo " server-list - list of core DHT servers"
echo " server-list.local - list of additional servers"
die
}
if [ "$1" == "-h" ] ; then
run_help
fi
if [ "$1" == "--help" ] ; then
run_help
fi
scp tonkey $ssh:.ssh/id_rsa || die "cannot copy id_rsa"
ssh $ssh chmod 0600 .ssh/id_rsa || die "cannot chmod id_rsa"
scp known_hosts $ssh:.ssh/known_hosts || die "cannot copy known_hosts"
ssh $ssh "apt-get update && apt-get -y install git libssl-dev cmake g++ gperf libz-dev" || die "cannot install packets"
ssh $ssh "git clone git@bitbucket.org:toin/ton.git ; cd ton && git submodule init ; git submodule update && cd third-party/libraptorq && git submodule init && git submodule update" || die "cannot clone git"
ssh $ssh "cd ton && git submodule update" || die "can not init submodules"
ssh $ssh "if [ ! -d ton-build ]; then mkdir ton-build ; fi"
ssh $ssh "cd ton-build && cmake ../ton" || die "cannot prepare for build"
ssh $ssh "cd ton-build && make -j 8 test-node" || die "cannot build"
sh generate-config.sh global ton-global.config.json || die "cannot create global config"
sh generate-config.sh local $host ton-local.config.json || die "cannot create local config"
scp ton-global.config.json ton-local.config.json $ssh: