Created
August 13, 2019 08:41
-
-
Save bafu/dc7487929268050ca48a0fd7a8a98b72 to your computer and use it in GitHub Desktop.
Installs a Textile cafe node on Linux
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
#!/usr/bin/env bash | |
# | |
# Textile Cafe node installation script. | |
# | |
# This script helps install and run a Cafe node on Amazon EC2 instance. | |
# | |
# You also need to enable these inbound TCP ports in the security group | |
# of the instance: | |
# | |
# 4001 - Swarm TCP; should be exposed to the public | |
# 5050 - Web (IPFS) Gateway | |
# 6060 - Profiling API | |
# 8081 - Swarm Websockets; must be exposed publicly when the node | |
# is listening using the websocket transport | |
# (/ipX/.../tcp/8081/ws). | |
# 40600 - Daemon API; must not be exposed publicly but to | |
# client services under you control | |
# 40601 - Cafe REST API | |
# | |
# Usage example: | |
# ec2 $ ./cafe_install.sh -r v0.6.9 -u https://mycafe.com | |
set -e | |
while getopts r:u:p: option | |
do | |
case "${option}" | |
in | |
r) RELEASE=${OPTARG};; | |
u) URL=${OPTARG};; | |
#p) IP=${OPTARG};; | |
esac | |
done | |
[[ -z "$RELEASE" ]] && { echo "Please specify a release tag, e.g., -r v1.0.0" ; exit 1; } | |
[[ -z "$URL" ]] && { echo "Please specify a public host URL, e.g., -u https://mycafe.com" ; exit 1; } | |
#[[ -z "$IP" ]] && { echo "Please specify a public host IP address, e.g., -p 18.144.12.134" ; exit 1; } | |
# install | |
wget https://github.com/textileio/go-textile/releases/download/"$RELEASE"/go-textile_"$RELEASE"_linux-amd64.tar.gz | |
tar xvfz go-textile_"$RELEASE"_linux-amd64.tar.gz | |
rm go-textile_"$RELEASE"_linux-amd64.tar.gz | |
sudo ./install | |
# init | |
textile init --server --cafe-open --cafe-url="$URL" --api-bind-addr=0.0.0.0:40600 --cafe-bind-addr=0.0.0.0:40601 --gateway-bind-addr=0.0.0.0:5050 --swarm-ports=4001 $(textile wallet init | tail -n1) | |
# textile systemctl service | |
sudo bash -c 'cat >/lib/systemd/system/textile.service <<EOL | |
[Unit] | |
Description=textile | |
[Service] | |
ExecStart=/usr/local/bin/textile daemon | |
Restart=always | |
User=ubuntu | |
Group=ubuntu | |
[Install] | |
WantedBy=multi-user.target | |
EOL' | |
# enable the new services | |
sudo systemctl daemon-reload | |
sudo systemctl enable textile.service | |
sudo systemctl start textile | |
# echo new node info | |
sleep 5 | |
echo "version:" $(textile version) | |
#echo "peer: " $(textile peer) | |
echo "address:" $(textile account address) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script is based on the upstream's version