Skip to content

Instantly share code, notes, and snippets.

@nothingismagick
Last active March 29, 2018 00:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nothingismagick/ff86da0af3434844b21867a54deba5f5 to your computer and use it in GitHub Desktop.
Save nothingismagick/ff86da0af3434844b21867a54deba5f5 to your computer and use it in GitHub Desktop.
ipfs setup

maybe helpful to run this as sudo... some resources found here: https://gist.github.com/claus/1287f47b5fbaaea338ac8a04d02bf258

#!/usr/bin/env bash

apt-get update
apt-get install tar wget


# ~/.ipfs/ipfs-cluster-setup.sh
# ubuntu 16.4 go-ipfs setup geschizzle

wget https://storage.googleapis.com/golang/go1.10.linux-amd64.tar.gz
sudo tar -C /usr/local -xvf go1.10.linux-amd64.tar.gz

export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
export PATH="/usr/local/go/bin:$PATH"

go get -u -d github.com/ipfs/go-ipfs
cd $GOPATH/src/github.com/ipfs/go-ipfs && make install
mkdir ~/.ipfs/
cp misc/completion/ipfs-completion.bash ~/.ipfs/
source ~/.ipfs/ipfs-completion.bash

go get -u -d github.com/ipfs/ipfs-cluster
cd $GOPATH/src/github.com/ipfs/ipfs-cluster
make install


# would prefer to go get this, but its broken on my test machine. :(
# go get -u -d github.com/ipfs/ipfs-pack
cd
wget https://dist.ipfs.io/ipfs-pack/v0.6.0/ipfs-pack_v0.6.0_linux-amd64.tar.gz
tar xzf ipfs-pack_v0.6.0_linux-amd64.tar.gz
mv ipfs-pack/ipfs-pack go/bin/ipfs-pack
rm ipfs-pack_v0.6.0_linux-amd64.tar.gz
rm -r ipfs-pack

echo 'source ~/.ipfs/ipfs-completion.bash' >> ~/.bash_completion
echo 'export GOPATH=$HOME/go' >> ~/.bashrc
echo 'export PATH=$PATH:$GOROOT/bin:$GOPATH/bin' >> ~/.bashrc
echo 'export PATH="/usr/local/go/bin:$PATH"' >> ~/.bashrc

go get -u github.com/ipfs/ipfs-update
ipfs update install latest
ipfs init --profile=server

bash ~/.ipfs/ipfs-cluster-startup.sh & disown
exit 0

This is what I use to start up the daemon & bootstrap its cluster (with nohup and writing the PID to command line and to a /tmp file

#!/usr/bin/env bash

# ~/.ipfs/ipfs-cluster-startup.sh
# (do not bootstrap the bootstrapper!)
# chmod a+x this script!

cluster_secret=$1
bootstrap=$2
nohup ipfs daemon &> /dev/null & disown
pid=$!
echo $pid > /tmp/ipfs.pid
echo "ipfs daemon started\n/tmp/ipfs.pid ${pid}"
if [ ! -f ~/.ipfs-cluster/service.json ]; then
    # doing it this way cuz apparently without ipfs running cluster can't init, 
    # but the docs aren't clear on this. Would prefer to have it in the setup script
    ipfs-cluster-service init -s ${cluster_secret}
fi
nohup ipfs-cluster-service --bootstrap "${bootstrap}" -f &> /dev/null & disown
pid=$!
echo $pid > /tmp/ipfs-cluster.pid
echo "ipfs-cluster started\n/tmp/ipfs-cluster.pid ${pid}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment