Last active
November 3, 2020 04:56
-
-
Save YasunoriMATSUOKA/df58e9e82d255fa2e5d20c36a20776ff to your computer and use it in GitHub Desktop.
Symbolのノード構築用スタートアップスクリプトです。動作は未検証です。
This file contains 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 | |
# symbol-bootstrap-0.2.0 | |
# initial startup script | |
# reference 1: https://nemlog.nem.social/blog/49345 | |
# reference 2: https://github.com/44uk/symbol-testnet-node-running-hands-on/blob/master/hands-on/index.md | |
# Execute as root | |
sudo su | |
# Create Swap | |
fallocate -l 8G /swapfile | |
chmod 600 /swapfile | |
mkswap /swapfile | |
swapon /swapfile | |
# Install Node.js and npm | |
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - | |
apt-get install -y nodejs | |
npm install -g npm@latest | |
# Install Symbol Bootstrap v0.2.0 | |
npm install -g symbol-bootstrap@0.2.0 | |
# Update packages | |
apt-get update -y && apt-get upgrade -y | |
# Install Docker | |
apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - | |
apt-key fingerprint 0EBFCD88 | |
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
apt-get update -y && apt-get install -y docker-ce docker-ce-cli containerd.io | |
# Install Docker Compose | |
curl -L https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose | |
chmod +x /usr/local/bin/docker-compose | |
# Docker Container Log File | |
echo '{"log-driver":"journald","log-opts":{"tag":"docker/{{.ImageName}}/{{.Name}}"}}' > /etc/docker/daemon.json | |
systemctl restart docker | |
# Create working directory | |
mkdir -p /opt/symbol-bootstrap | |
cd /opt/symbol-bootstrap | |
# Create custom setting yml file | |
cat << _EOS_ >> my-preset.yml | |
nodes: | |
- | |
host: __YOUR_IP_ADDRESS_OR_DOMAIN_NAME__ | |
friendlyName: __YOUR_FRIENDLY_NAME__ | |
gateways: | |
- | |
throttlingBurst: 80 | |
throttlingRate: 40 | |
_EOS_ | |
# Create setting files from custom setting yml file | |
symbol-bootstrap config -p testnet -a dual -c my-preset.yml -r | |
# Create docker-compose.yml | |
symbol-bootstrap compose -r | |
# Modify Bug | |
sed -i.bak '/set -e/d' target/docker/mongo/mongors.sh | |
# Start Symbol Bootstrap | |
symbol-bootstrap run -d | |
# Sleep 5 minutes | |
sleep 5m | |
# Stop Symbol Bootstrap | |
symbol-bootstrap stop | |
# Add Service | |
cat << _EOS_ >> /etc/systemd/system/symbol-platform.service | |
[Unit] | |
Description=Symbol Platform Node Daemon | |
After=docker.service | |
[Service] | |
Type=simple | |
WorkingDirectory=/opt/symbol-bootstrap | |
ExecStartPre=/usr/bin/symbol-bootstrap stop | |
ExecStartPre=-/bin/rm target/nodes/api-node/data/server.lock | |
ExecStartPre=-/bin/rm target/nodes/api-node/data/broker.lock | |
ExecStart=/usr/bin/symbol-bootstrap run | |
ExecStop=/usr/bin/symbol-bootstrap stop | |
TimeoutStartSec=180 | |
TimeoutStopSec=120 | |
Restart=on-failure | |
RestartSec=60 | |
PrivateTmp=true | |
[Install] | |
WantedBy=default.target | |
_EOS_ | |
systemctl daemon-reload | |
systemctl enable symbol-platform |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
以下の情報を参考にさせて頂きました。この場を借りて感謝申し上げます。
https://nemlog.nem.social/blog/49345
https://github.com/44uk/symbol-testnet-node-running-hands-on/blob/master/hands-on/index.md