Created
May 5, 2025 09:05
-
-
Save Tommy19960621/6a418c32be9e1ab4af71a6c4df049778 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "🟡 Aztec Node 自動セットアップを開始します..." | |
# スクリプトを中断する条件(エラー検出) | |
set -e | |
# 1. 必要なパッケージをインストール | |
echo "🔧 パッケージをインストール中..." | |
sudo apt update -y | |
sudo apt install -y git curl jq docker.io docker-compose | |
# 2. Aztec-Node リポジトリを取得 | |
echo "📦 Aztec-Node リポジトリを取得中..." | |
cd ~ | |
rm -rf Aztec-Node | |
git clone https://github.com/airdropinsiders/Aztec-Node.git | |
cd Aztec-Node | |
# 3. スクリプト権限設定 | |
chmod +x aztec.sh | |
sed -i 's/\r$//' aztec.sh | |
# 4. RPCと秘密鍵の入力を対話形式で取得 | |
echo "🔑 Alchemy (Sepolia) RPC URL を入力してください:" | |
read -r ALCHEMY_RPC | |
echo "🔑 dRPC RPC URL を入力してください:" | |
read -r DRPC_RPC | |
echo "🔐 ウォレットの秘密鍵を入力してください(0xなし):" | |
read -r PRIVATE_KEY | |
# 5. .env ファイル生成 | |
cat <<EOF > .env | |
SEPOLIA_RPC_URL=$ALCHEMY_RPC | |
DRPC_RPC_URL=$DRPC_RPC | |
PRIVATE_KEY=$PRIVATE_KEY | |
EOF | |
# 6. Aztecノード構築開始 | |
echo "🚀 Aztecノードの構築を開始します。10分ほどかかります..." | |
sudo ./aztec.sh | |
# 7. docker-compose の実行パスを確認 | |
DC_PATH=$(which docker-compose) | |
# 8. systemd サービス設定 | |
echo "🛠️ 自動起動設定(systemd)を作成中..." | |
sudo tee /etc/systemd/system/aztec-node.service > /dev/null <<EOF | |
[Unit] | |
Description=Aztec Node (via docker-compose) | |
After=network.target docker.service | |
Requires=docker.service | |
[Service] | |
Type=oneshot | |
WorkingDirectory=/root/Aztec-Node | |
ExecStart=$DC_PATH up -d | |
ExecStop=$DC_PATH down | |
RemainAfterExit=true | |
TimeoutStartSec=0 | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
# 9. systemd 反映と起動 | |
sudo systemctl daemon-reload | |
sudo systemctl enable aztec-node.service | |
sudo systemctl start aztec-node.service | |
# 10. 動作確認 | |
echo "✅ 動作確認(docker ps):" | |
docker ps | |
echo "✅ systemd ステータス確認:" | |
systemctl status aztec-node.service --no-pager | |
# 11. 完了メッセージ | |
echo "🎉 Aztecノード構築&自動起動設定が完了しました!" | |
echo "📦 ノードデータ: /root/Aztec-Node/data" | |
echo "🔁 VPS再起動後も自動起動します" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment