Last active
May 3, 2020 07:21
-
-
Save oe-trader/f558e33b4d30d671c2b6be68fbc2bd5a to your computer and use it in GitHub Desktop.
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 TestNet Chikujo(BuildUp) Script for Ubuntu 18.04 | |
# *********************************************** | |
# Quote source | |
# [general] https://nemlog.nem.social/blog/36829 | |
# [https] https://nemlog.nem.social/blog/31033 | |
# ------- SETTING START ------ | |
# user name | |
USER_NAME=nember | |
# password | |
PASSWORD= | |
# friendly name | |
FRIENDLY_NAME= | |
# get the host name automatically? (no:0 yes:1) | |
HOST_AUTOSETTING=0 | |
# setting the host name manually | |
NODE_HOST= | |
# use https? (no:0 yes:1) | |
ENABLE_HTTPS=1 | |
# Check for the existence of the new version. | |
# https://github.com/nemfoundation/symbol-testnet-bootstrap/releases | |
BOOTSTRAP_TAG=0.9.4.1-beta3 | |
# ------- SETTING END ------ | |
SSHD_PORT=50022 | |
DOCKER_COMPOSE_VER=1.25.4 | |
apt-get update -y && apt-get upgrade -y | |
/bin/sed -i -e "s/^#Port 22$/Port $SSHD_PORT/" /etc/ssh/sshd_config | |
/bin/sed -i -e "s/^#PermitRootLogin yes$/PermitRootLogin no/" /etc/ssh/sshd_config | |
/bin/sed -i -e "s/^PermitRootLogin yes$/PermitRootLogin no/" /etc/ssh/sshd_config | |
systemctl restart sshd | |
pkgs='ufw' | |
if ! dpkg -s $pkgs >/dev/null 2>&1; then | |
apt-get install -y $pkgs | |
fi | |
yes | ufw enable | |
# ufw allow $SSHD_PORT | |
ufw allow 3000 # API HTTP | |
ufw allow 7900 | |
ufw allow 7902 | |
ufw reload | |
# create user | |
adduser --disabled-password --gecos "" "$USER_NAME" | |
echo "$USER_NAME:$PASSWORD" | chpasswd | |
gpasswd -a "$USER_NAME" sudo | |
# docker install and start service | |
apt-get install -y apt-transport-https ca-certificates curl software-properties-common | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - | |
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-compose install | |
curl -L https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_VER/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose | |
chmod +x /usr/local/bin/docker-compose | |
# create service | |
cat << __EOD__ > /etc/systemd/system/symbol.service | |
[Unit] | |
Description=Symbol Node Daemon | |
After=docker.service | |
[Service] | |
Type=simple | |
User=root | |
WorkingDirectory=/home/$USER_NAME/symbol-testnet-bootstrap-$BOOTSTRAP_TAG/api-harvest-assembly | |
Environment=COMPOSE_FILE=/home/$USER_NAME/symbol-testnet-bootstrap-$BOOTSTRAP_TAG/api-harvest-assembly/docker-compose.yaml | |
ExecStartPre=/usr/local/bin/docker-compose -f \$COMPOSE_FILE down | |
ExecStartPre=/usr/local/bin/docker-compose -f \$COMPOSE_FILE rm -f | |
ExecStart=/usr/local/bin/docker-compose -f \$COMPOSE_FILE up --build | |
ExecStop=/usr/local/bin/docker-compose -f \$COMPOSE_FILE stop | |
ExecStopPost=/usr/local/bin/docker-compose -f \$COMPOSE_FILE down | |
ExecStopPost=/usr/local/bin/docker-compose -f \$COMPOSE_FILE rm -f | |
ExecReload=/usr/local/bin/docker-compose -f \$COMPOSE_FILE restart | |
Restart=always | |
RestartSec=60s | |
[Install] | |
WantedBy=multi-user.target | |
__EOD__ | |
cd /home/$USER_NAME | |
# DL symbol bootstrap | |
curl -L https://github.com/nemfoundation/symbol-testnet-bootstrap/archive/$BOOTSTRAP_TAG.tar.gz | tar zx | |
chown -R $USER_NAME: symbol-testnet-bootstrap-$BOOTSTRAP_TAG | |
cd symbol-testnet-bootstrap-$BOOTSTRAP_TAG/api-harvest-assembly | |
# DNS reverse lookup | |
pkgs='host' | |
if ! dpkg -s $pkgs >/dev/null 2>&1; then | |
apt-get install -y $pkgs | |
fi | |
if [ $HOST_AUTOSETTING = 1 ]; then | |
host -t TXT $(curl inet-ip.info) > host.txt | |
NODE_HOST=$(cat host.txt | sed -e 's/^.*domain name pointer //' -e 's/\.$//' host.txt) | |
rm host.txt | |
fi | |
# enable https | |
if [ $ENABLE_HTTPS = 1 ]; then | |
echo " https-portal:" >> docker-compose.yaml | |
echo " image: steveltn/https-portal:1" >> docker-compose.yaml | |
echo " ports:" >> docker-compose.yaml | |
echo " - \"80:80\"" >> docker-compose.yaml | |
echo " - \"3001:443\"" >> docker-compose.yaml | |
echo " restart: always" >> docker-compose.yaml | |
echo " environment:" >> docker-compose.yaml | |
echo " DOMAINS: '$NODE_HOST -> http://rest-gateway:3000'" >> docker-compose.yaml | |
echo " STAGE: production" >> docker-compose.yaml | |
echo " volumes:" >> docker-compose.yaml | |
echo " - ./ssl-certs:/var/lib/https-portal:rw" >> docker-compose.yaml | |
echo " depends_on:" >> docker-compose.yaml | |
echo " - rest-gateway" >> docker-compose.yaml | |
ufw allow 80 # Let's Encrypt | |
ufw allow 3001 # API HTTPS | |
ufw reload | |
fi | |
# create config files | |
docker-compose up --build --detach | |
# set friendly name | |
if [ -n "$FRIENDLY_NAME" ]; then | |
sed -i.bak "/friendly_name/ s/[0-9A-Z]\{8\}/$FRIENDLY_NAME/" api-node/config-input.yaml | |
docker-compose -f docker-compose.yaml up --build update_vars | |
fi | |
# set node host | |
if [ -n "$NODE_HOST" ]; then | |
mv api-node/userconfig/resources/config-node.properties.template{,.bk} | |
tr -d \\r < api-node/userconfig/resources/config-node.properties.template.bk | sed "/^host/ s/$/$NODE_HOST/" > api-node/userconfig/resources/config-node.properties.template | |
fi | |
chown -R $USER_NAME: api-node/userconfig | |
# fix | |
docker-compose down | |
sh reset-to-nemesis.sh | |
docker-compose up --build --detach | |
# start service | |
systemctl daemon-reload | |
systemctl enable symbol && systemctl start symbol | |
# cleanup | |
apt-get clean -y && apt-get autoremove -y | |
dpkg -l 'linux-image-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge | |
update-grub |
curl -L https://github.com/nemfoundation/symbol-testnet-bootstrap/archive/0.9.3.2-beta1.tar.gz | tar zx
もっと要約すっと
今回のは こうっすな
tar.gzのリンクをコピペですな
その前に"curl -L " その後に" | tar zx"を付ける
これですな!
curl -L https://github.com/nemfoundation/symbol-testnet-bootstrap/archive/0.9.3.2-beta1.tar.gz | tar zx
もっと要約すっと
今回のは こうっすなtar.gzのリンクをコピペですな
その前に"curl -L " その後に" | tar zx"を付ける
これですな!
そうですw
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
なるほどこれがベータ版のダウンロード方法なのね
BOOTSTRAP_TAG=0.9.3.2-beta1 ←ココに名前コピペ
curl -L https://github.com/nemfoundation/symbol-testnet-bootstrap/archive/$BOOTSTRAP_TAG.tar.gz | tar zx
頂きますた