脚本自动生成随机ITN标识,导出进行注册既可以。配合镜像配置文件和必要的密码文件,密码文件可以下载或者直接用cat生成写入。可自行修改。
[hide]
一键部署脚本代码
#!/bin/bash
[[ $EUID != 0 ]] && echo -e " 当前非ROOT账号,无法继续操作,请使用 sudo su。" && exit 1
echo "docker 安装"
# 定义需要安装的程序列表
programs=("git" "docker" "docker-compose" "npm")
# 遍历程序列表
for program in "${programs[@]}"; do
# 判断程序是否已安装
if ! command -v "$program" > /dev/null; then
# 程序未安装,执行安装操作
apt-get update
apt-get install -y "$program"
fi
done
echo "克隆仓库"
if [ -d "testnet-public-tools" ]; then
cd testnet-public-tools/testnet-validator
else
git clone https://gitlab.com/q-dev/testnet-public-tools
cd testnet-public-tools/testnet-validator
fi
echo "下载配置文件"
if [ -d "keystore" ]; then
wget -O /root/testnet-public-tools/testnet-validator/keystore/pwd.txt https://web.danny.fund/pwd.txt
wget -O /root/testnet-public-tools/testnet-validator/docker-compose.yaml https://web.danny.fund/docker-compose.yaml
else
mkdir keystore
wget -O /root/testnet-public-tools/testnet-validator/keystore/pwd.txt https://web.danny.fund/pwd.txt
wget -O /root/testnet-public-tools/testnet-validator/docker-compose.yaml https://web.danny.fund/docker-compose.yaml
fi
echo "创建秘钥"
docker-compose run --rm --entrypoint "geth account new --datadir=/data --password=/data/keystore/pwd.txt" testnet-validator-node > /root/address.log
cat /root/address.log | grep Public | awk '{print $6}' > /root/address.txt
echo "读取地址配置启动"
ip=$(curl ifconfig.me)
zfc=$(openssl rand -base64 3 | md5sum | cut -c1-6)
add=$(cat /root/address.txt)
address=$zfc-$add
echo "这里可以只使用$zfc,不使用$add"
echo "Identifier:$address" > Identifier.txt
bash -c "cat > /root/testnet-public-tools/testnet-validator/.env" <<EOF
# docker image for q client
QCLIENT_IMAGE=qblockchain/q-client:latest
# your q address here (without leading 0x)
ADDRESS=$add
# your public IP address here
IP=$ip
# the port you want to use for p2p communication (default is 30313)
EXT_PORT=30313
# extra bootnode you want to use
BOOTNODE1_ADDR=enode://c610793186e4f719c1ace0983459c6ec7984d676e4a323681a1cbc8a67f506d1eccc4e164e53c2929019ed0e5cfc1bc800662d6fb47c36e978ab94c417031ac8@79.125.97.227:30304
BOOTNODE2_ADDR=enode://8eff01a7e5a66c5630cbd22149e069bbf8a8a22370cef61b232179e21ba8c7b74d40e8ee5aa62c54d145f7fc671b851e5ccbfe124fce75944cf1b06e29c55c80@79.125.97.227:30305
BOOTNODE3_ADDR=enode://7a8ade64b79961a7752daedc4104ca4b79f1a67a10ea5c9721e7115d820dbe7599fe9e03c9c315081ccf6a2afb0b6652ee4965e38f066fe5bf129abd6d26df58@79.125.97.227:30306
EOF
bash -c "cat > /root/testnet-public-tools/testnet-validator/config.json" <<EOF
{
"address": "$add",
"password": "888888",
"keystoreDirectory": "/data",
"rpc": "https://rpc.qtestnet.org"
}
EOF
sed -i "s/danny-address/$address/g" /root/testnet-public-tools/testnet-validator/docker-compose.yaml
sed -i "s/\r//g" /root/testnet-public-tools/testnet-validator/docker-compose.yaml
echo "启动"
docker-compose up -d
echo "导出私钥"
cd /root
wget https://web.danny.fund/js-tools.tar.gz && tar -zxvf js-tools.tar.gz && cd /root/js-tools
npm install
bash -c "cat > /root/js-tools/key.sh" <<EOF
#!/bin/bash
node extract-geth-private-key $add /root/testnet-public-tools/testnet-validator/ 888888
EOF
chmod 777 /root/js-tools/key.sh
sed -i "s/\r//g" /root/js-tools/key.sh
./key.sh
addkey=$(cat /root/js-tools/PK*)
echo -e "本脚本搭建启动成功"
echo -e "Validators Contract地址:https://hq.qtestnet.org/" >> q.txt
echo -e "水龙头地址:https://faucet.qtestnet.org/" >> q.txt
echo -e "日志查看命令:cd /root/testnet-public-tools/testnet-validator/ && docker-compose logs -f --tail "100"" >> q.txt
echo -e "如需技术支持联系:Danny"
echo -e "当前服务器IP:$ip" >> q.txt
echo -e "你的钱包地址是:$add" >> q.txt
echo -e "你的钱包私钥是:$addkey" >> q.txt
echo -e "你的标识符是:$address" >> q.txt
echo "你的所有信息如下:"
cat q.txt
echo "您可以前往https://itn.qdev.li/注册认证了"
[/hide]