ironfish自动化部署

本次仅完成自动创建钱包,通过MD5完成自动随机生成用户,

方便完成三期报名注册,请先使用一个测试。程序以及相关命令会由官方改变而改变

注册地址:https://testnet.ironfish.network/signup

[hide]
该10位随机字符为注册graffiti 填写的数值,请妥善保管数据
#!/bin/bash
[[ $EUID != 0 ]] && echo -e " 当前非ROOT账号,无法继续操作,请使用 sudo su。" && exit 1
programs=("curl" "tar" "wget" "clang" "pkg-config" "libssl-dev" "jq" "build-essential" "git" "make" "ncdu" "expect")
for program in "${programs[@]}"; do
 if ! command -v "$program" > /dev/null; then
    apt-get update
    apt-get install -y "$program"
  fi
done
echo "docker 安装"
    curl -fsSL https://get.docker.com | bash -s docker
    sudo systemctl daemon-reload
    sudo systemctl restart docker
    echo "docker 安装完成"
#name=$(openssl rand -base64 3 | md5sum | cut -c1-8)
name=$(cat /dev/urandom | head -n 10 | md5sum | head -c 10)
echo "你的节点名字是 $name"
    docker pull ghcr.io/iron-fish/ironfish:latest
    docker run -itd --name node --net host --volume /root/.node:/root/.ironfish ghcr.io/iron-fish/ironfish:latest start
    sleep 10
    docker exec -it node bash -c "ironfish config:set blockGraffiti ${name}"
    docker exec -it node bash -c "ironfish config:set enableTelemetry true"
    echo "启动成功!"

    echo "请检查状态"
    docker exec -it node bash -c "ironfish config:show" | grep blockGraffiti 
    docker exec -it node bash -c "ironfish config:show" | grep enableTelemetry
    docker exec -it node bash -c "ironfish status"

echo "创建随机钱包"
/usr/bin/expect  << EOF
spawn docker exec -it node bash -c "ironfish accounts:create"
expect {
  "*account*" {
     send "$name\n"
     exp_continue
   }
}
EOF
bash -c "cat > ironfish_update.sh" <<EOF
#!/bin/bash
echo "升级镜像,请等待"
docker pull ghcr.io/iron-fish/ironfish:latest
docker stop node
docker rm node
rm -rf /root/.node
echo "重新配置数据"
echo "你的节点名字是 $name"
docker run -itd --name node --net host --volume /root/.node:/root/.ironfish ghcr.io/iron-fish/ironfish:latest start
sleep 10
docker exec -it node bash -c "ironfish config:set blockGraffiti ${name}"
docker exec -it node bash -c "ironfish config:set enableTelemetry true"
echo "启动成功!升级完成"
EOF
sleep 10
echo "你的节点名字是 $name"
docker exec -it node bash -c "ironfish accounts:list"
docker exec -it node bash -c "ironfish accounts:export ${name}"
docker exec -it node bash -c "ironfish accounts:use ${name}"
echo "升级节点命令 bash ironfish_update.sh"
sleep 10
[/hide]
# 查看钱包
docker exec -it node bash -c "ironfish accounts:list"
# 创建新钱包
docker exec -it node bash -c "ironfish accounts:create"
# 设置为默认钱包
docker exec -it node bash -c "ironfish accounts:use 钱包名称"
# 导出钱包密钥
docker exec -it node bash -c "ironfish accounts:export 钱包名称"
# 导入钱包密钥
docker exec -it node bash -c "ironfish accounts:import"
#升级镜像,该脚本自动生成。请勿修改name变量。
bash ironfish_update.sh

nodejs安装常用命令