#!/bin/bash
echo "检查是否以root用户执行脚本"
if [ "$(id -u)" != "0" ]; then
echo "该脚本必须以root权限运行" 1>&2
exit 1
fi
echo "更新并升级Ubuntu软件包"
sudo apt update && sudo apt -y upgrade
echo "增加swap空间"
sudo mkdir /swap
sudo fallocate -l 24G /swap/swapfile
sudo chmod 600 /swap/swapfile
sudo mkswap /swap/swapfile
sudo swapon /swap/swapfile
echo '/swap/swapfile swap swap defaults 0 0' >> /etc/fstab
echo "sysctl.conf文件追加内容"
echo -e "\n# 自定义最大接收和发送缓冲区大小" >> /etc/sysctl.conf
echo "net.core.rmem_max=600000000" >> /etc/sysctl.conf
echo "net.core.wmem_max=600000000" >> /etc/sysctl.conf
echo "配置已添加到/etc/sysctl.conf"
echo "重新加载sysctl配置以应用更改"
sysctl -p
echo "sysctl配置已重新加载"
echo "安装wget、screen和git等组件"
sudo apt install git ufw bison screen binutils gcc make bsdmainutils -y
echo "安装GVM"
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
source /root/.gvm/scripts/gvm
gvm install go1.4 -B
gvm use go1.4
export GOROOT_BOOTSTRAP=$GOROOT
gvm install go1.17.13
gvm use go1.17.13
export GOROOT_BOOTSTRAP=$GOROOT
gvm install go1.20.2
gvm use go1.20.2
echo "克隆仓库"
git clone https://github.com/quilibriumnetwork/ceremonyclient
echo "进入ceremonyclient/node目录"
cd ceremonyclient/node
# 构建服务
GOEXPERIMENT=arenas go install ./...
# 写入服务
sudo tee /lib/systemd/system/ceremonyclient.service > /dev/null <<EOF
[Unit]
Description=Ceremony Client GO App Service
[Service]
Type=simple
Restart=always
RestartSec=5S
WorkingDirectory=/root/ceremonyclient/node
Environment=GOEXPERIMENT=arenas
ExecStart=/root/.gvm/pkgsets/go1.20.2/global/bin/node ./...
[Install]
WantedBy=multi-user.target
EOF
# 重新加载 systemd 并启用并启动服务
sudo systemctl daemon-reload
sudo systemctl enable ceremonyclient
sudo systemctl start ceremonyclient
日志查询:sudo journalctl -f -u ceremonyclient.service