Quilibrium/Quilibrium.sh

74 lines
1.8 KiB
Bash
Raw Normal View History

2024-03-01 11:26:44 +00:00
#!/bin/bash
# 检查是否为root用户执行脚本
if [ "$(id -u)" != "0" ]; then
echo "该脚本必须以root权限运行" 1>&2
exit 1
fi
# 向 /etc/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"
# 重新加载sysctl配置以应用更改
sysctl -p
echo "sysctl 配置已重新加载"
# Update and Upgrade Ubuntu Packages without any prompts
sudo apt update && sudo apt -y upgrade
# Install wget, screen, and git without any prompts
2024-03-02 03:27:27 +00:00
sudo apt install git ufw bison screen binutils gcc make -y
2024-03-01 11:26:44 +00:00
# Install 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
# Clone the repository
git clone https://github.com/quilibriumnetwork/ceremonyclient
# Navigate to ceremonyclient/node directory
cd ceremonyclient/node
2024-03-02 06:26:42 +00:00
# 写入脚本
cat > auto.sh <<EOF
#!/bin/bash
while true; do
# 检查node进程是否存在
2024-03-02 06:31:55 +00:00
ps -ef | grep "node" | grep -v "grep"
if [ "$?" -eq 1 ]; then
2024-03-02 06:26:42 +00:00
# 如果node进程不存在输出信息并启动node
echo "Node进程未运行正在尝试重新启动..."
GOEXPERIMENT=arenas go run ./...
echo "Node进程已启动。"
else
# 如果node进程正在运行输出信息
echo "Node进程已经在运行中。"
fi
# 每次检查后休眠10秒
sleep 10
done
EOF
# 赋予权限
chmod +x auto.sh
2024-03-01 11:26:44 +00:00
# Create a screen session and run the command
2024-03-02 06:26:42 +00:00
screen -dmS Quili bash -c './auto.sh'