Update Waku.sh
This commit is contained in:
parent
e1b7f42363
commit
bcd07fe1f5
63
Waku.sh
63
Waku.sh
@ -13,8 +13,7 @@ function main_menu() {
|
||||
echo "请选择要执行的操作:"
|
||||
echo "1. 安装节点"
|
||||
echo "2. 修复错误"
|
||||
echo "3. 编辑 .env 文件"
|
||||
echo "4. 退出"
|
||||
echo "3. 退出"
|
||||
read -rp "请输入操作选项:" choice
|
||||
|
||||
case $choice in
|
||||
@ -25,9 +24,6 @@ function main_menu() {
|
||||
fix_errors
|
||||
;;
|
||||
3)
|
||||
edit_env_file
|
||||
;;
|
||||
4)
|
||||
echo "退出脚本,谢谢使用!"
|
||||
exit 0
|
||||
;;
|
||||
@ -50,7 +46,7 @@ function install_node() {
|
||||
# 检测Docker安装是否成功
|
||||
if ! command -v docker &> /dev/null; then
|
||||
echo "安装 Docker ..."
|
||||
sudo apt install -y docker.io
|
||||
sudo apt install -y docker.io
|
||||
if ! command -v docker &> /dev/null; then
|
||||
echo "安装 Docker 失败,请检查错误信息。"
|
||||
exit 1
|
||||
@ -74,17 +70,19 @@ function install_node() {
|
||||
cd nwaku-compose || { echo "切换目录失败,请检查目录结构和权限。"; exit 1; }
|
||||
cp .env.example .env
|
||||
|
||||
# 编辑 .env 文件
|
||||
edit_env_file
|
||||
|
||||
echo "请编辑 .env 文件并填写所需的信息:"
|
||||
echo "nano .env"
|
||||
# 提示用户输入 ETH_CLIENT_ADDRESS
|
||||
read -rp "请输入 ETH_CLIENT_ADDRESS(如 https://sepolia.infura.io/v3/<key>):" RLN_RELAY_ETH_CLIENT_ADDRESS
|
||||
|
||||
# 注册节点
|
||||
./register_rln.sh || { echo "注册节点失败,请检查错误信息。"; exit 1; }
|
||||
# 提示用户输入 ETH_TESTNET_KEY
|
||||
read -rp "请输入 ETH_TESTNET_KEY:" ETH_TESTNET_KEY
|
||||
|
||||
# 启动 Docker Compose
|
||||
docker-compose up -d || { echo "启动 Docker Compose 失败,请检查错误信息。"; exit 1; }
|
||||
# 提示用户输入 RLN_RELAY_CRED_PASSWORD
|
||||
read -rp "请输入 RLN_RELAY_CRED_PASSWORD:" RLN_RELAY_CRED_PASSWORD
|
||||
|
||||
# 将用户输入写入 .env 文件
|
||||
echo "RLN_RELAY_ETH_CLIENT_ADDRESS=$RLN_RELAY_ETH_CLIENT_ADDRESS" >> .env
|
||||
echo "ETH_TESTNET_KEY=$ETH_TESTNET_KEY" >> .env
|
||||
echo "RLN_RELAY_CRED_PASSWORD=\"$RLN_RELAY_CRED_PASSWORD\"" >> .env
|
||||
|
||||
echo "Waku安装完成,并已注册节点并启动。"
|
||||
read -rp "按 Enter 返回菜单。"
|
||||
@ -108,9 +106,6 @@ function fix_errors() {
|
||||
# 编辑 .env 文件
|
||||
nano .env # 请修改 ETH_CLIENT_ADDRESS 为 RLN_RELAY_ETH_CLIENT_ADDRESS
|
||||
|
||||
# 注册节点
|
||||
./register_rln.sh || { echo "注册节点失败,请检查错误信息。"; exit 1; }
|
||||
|
||||
# 启动 Docker Compose
|
||||
docker-compose up -d || { echo "启动 Docker Compose 失败,请检查错误信息。"; exit 1; }
|
||||
|
||||
@ -118,37 +113,5 @@ function fix_errors() {
|
||||
read -rp "按 Enter 返回菜单。"
|
||||
}
|
||||
|
||||
# 编辑 .env 文件函数
|
||||
function edit_env_file() {
|
||||
clear
|
||||
echo "正在编辑 /root/nwaku-compose/.env 文件 ..."
|
||||
|
||||
# 进入 nwaku-compose 目录
|
||||
cd /root/nwaku-compose || { echo "进入目录失败,请检查目录结构和权限。"; exit 1; }
|
||||
|
||||
# 显示提示信息
|
||||
echo "# 请填写以下内容,并按需修改:"
|
||||
echo "# ETH_CLIENT_ADDRESS=https://sepolia.infura.io/v3/<key> # Sepolia ETH 的 RPC 地址"
|
||||
echo "# ETH_TESTNET_KEY=<YOUR_TESTNET_PRIVATE_KEY_HERE> # 有测试网 ETH 的私钥(最好创建新钱包)"
|
||||
echo "# RLN_RELAY_CRED_PASSWORD=\"my_secure_keystore_password\" # 设置密码"
|
||||
|
||||
# 打开编辑器编辑文件
|
||||
nano .env
|
||||
|
||||
# 提示用户按 Enter 返回菜单
|
||||
read -rp "按 Enter 返回菜单。"
|
||||
|
||||
# 替换 ETH_CLIENT_ADDRESS 为 RLN_RELAY_ETH_CLIENT_ADDRESS
|
||||
RLN_RELAY_ETH_CLIENT_ADDRESS=$(grep '^ETH_CLIENT_ADDRESS=' .env | cut -d '=' -f 2-)
|
||||
sed -i "s|ETH_CLIENT_ADDRESS=.*|RLN_RELAY_ETH_CLIENT_ADDRESS=$RLN_RELAY_ETH_CLIENT_ADDRESS|" .env
|
||||
|
||||
echo "已将 ETH_CLIENT_ADDRESS 替换为 RLN_RELAY_ETH_CLIENT_ADDRESS。"
|
||||
read -rp "按 Enter 返回菜单。"
|
||||
|
||||
# 返回到脚本所在目录
|
||||
cd - >/dev/null || { echo "返回目录失败,请检查目录结构和权限。"; exit 1; }
|
||||
}
|
||||
|
||||
|
||||
# 主程序开始
|
||||
main_menu
|
||||
|
Loading…
Reference in New Issue
Block a user