Install your own IPFS docker node in on line
curl -sL https://gist.github.com/DrI-T/882ae8a852ab2bc58a333e3c6f279d03/raw/one-liner-install.sh | sh -e
-- gist:882ae8a852ab2bc58a333e3c6f279d03
# | |
echo "--- # ${0##*/}" | |
if echo -n "\e" | grep -q -e 'e'; then | |
e="-e" # bash needs a -e ! | |
fi | |
red=$(echo -n $e "\e[31m") | |
green=$(echo -n $e "\e[1;32m") | |
nc=$(echo -n $e "\e[0m") | |
if ! which sudo > /dev/null; then | |
apt-get update | |
apt-get -y install sudo | |
fi | |
if ! which lsb_release > /dev/null; then | |
sudo apt-get install lsb-release | |
fi | |
linux=$(lsb_release -i | cut -d: -f 2) | |
echo linux: $linux | |
if ! which docker > /dev/null; then | |
# uninstall old | |
sudo apt-get remove docker docker-engine docker.io containerd runc 2>/dev/null | |
sudo apt-get update | |
if [ "x$linux" == 'xDebian' ]; then | |
# install prerequisites | |
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common | |
# add GPG key | |
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - | |
sudo apt-key fingerprint 9DC858229FC7DD38854AE2D88D81803C0EBFCD88 | |
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | |
fi | |
if [ "x$linux" != 'xUbuntu' ]; then | |
sudo apt-get install apt-transport-https ca-certificates curl gnupg | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg | |
echo \ | |
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ | |
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | |
fi | |
# install docker | |
sudo apt-get update | |
sudo apt-get install docker-ce docker-ce-cli containerd.io | |
service docker start | |
if sudo docker run --rm hello-world | grep -q "working correctly."; then | |
echo "docker: ${green}provided${nc}" | |
else | |
echo "${red}ERROR: docker failed to install!${nc}" | |
exit 251 | |
fi | |
if ! id -nG | grep -q -w docker; then | |
sudo groupadd docker | |
sudo usermod -aG docker $USER | |
fi | |
fi |
Run the following commands in a bash shell; this will install a docker instance of IPFS and run the IPFS daemon within this docker.
sudo apt-get curl # you need to have <code>curl</code> installed
curl -sL https://gist.github.com/DrI-T/882ae8a852ab2bc58a333e3c6f279d03/raw/one-liner-install.sh | sh -
cloning command:
git clone https://gist.github.com/882ae8a852ab2bc58a333e3c6f279d03.git
# | |
export IPFS_CONTAINER=${IPFS_CONTAINER:-ipfs-node} | |
# dockerized ipfs is _ipfs | |
_ipfs() { | |
docker exec $IPFS_CONTAINER ipfs $@ | |
} | |
dockerip=$(docker exec $IPFS_CONTAINER ifconfig eth0 | grep inet | sed -n -e 's/inet addr:/inet /' -e 's/^ *inet \([^ ]*\).*/\1/p;') | |
echo dockerip: $dockerip | |
gateway=$(_ipfs config Addresses.Gateway) | |
gw_port=$(echo $gateway | cut -d/ -f 5) | |
echo gw_port: $gw_port | |
api=$(_ipfs config Addresses.API) | |
api_port=$(echo $api | cut -d/ -f 5) | |
echo api_port: $api_port | |
docker exec -i -t $IPFS_CONTAINER sh | |
#_ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin |
# | |
echo "--- # ${0##*/}" | |
if echo -n "\e" | grep -q -e 'e'; then | |
e="-e" # bash needs a -e ! | |
fi | |
# colors : [see also](https://en.wikipedia.org/wiki/ANSI_escape_code) | |
default=$(echo -n $e "\e[39m") | |
red=$(echo -n $e "\e[31m") | |
green=$(echo -n $e "\e[1;32m") | |
yellow=$(echo -n $e "\e[1;33m") | |
cyan=$(echo -n $e "\e[2;36m") | |
grey=$(echo -n $e "\e[0;90m") | |
nc=$(echo -n $e "\e[0m") | |
export IPFS_CONTAINER=${IPFS_CONTAINER:-ipfs-node} | |
dockerip=$(docker exec $IPFS_CONTAINER ifconfig eth0 | grep inet | sed -n -e 's/inet addr:/inet /' -e 's/^ *inet \([^ ]*\).*/\1/p;') | |
# dockerized ipfs is _ipfs | |
_ipfs() { | |
docker exec $IPFS_CONTAINER ipfs "$@" | |
} | |
IPFS_PATH=$(_ipfs repo stat | grep RepoPath: | sed -e 's/ */ /g' | cut -d' ' -f 2) | |
echo "IPFS_PATH: ${yellow}$IPFS_PATH${grey} on $dockerip${nc}" | |
peerid=$(_ipfs config Identity.PeerID) && echo "peerid: ${green}$peerid${nc}" | |
echo dockerip: $dockerip | |
echo "repo: |-" | |
_ipfs repo stat | sed -e 's/^/ /' | |
api=$(_ipfs config Addresses.API) | |
echo "api: $api" | |
gateway=$(_ipfs config Addresses.Gateway) | |
gw_port=$(echo $gateway | cut -d/ -f 5) | |
api_port=$(echo $api | cut -d/ -f 5) | |
swarm_port=$(_ipfs config Addresses.Swarm | grep -e /tcp | head -1 | cut -d/ -f5 | sed -e 's/".*//') | |
echo gw_port: ${cyan}$gw_port${nc} | |
echo api_port: ${cyan}$api_port${nc} | |
echo swarm: $swarm_port | |
gw_url="http://$dockerip:$gw_port" | |
api_url="http://$dockerip:$api_port/api/v0/" | |
# adding CORS parameters | |
allowed_origins="[ | |
'http://$dockerip:$gw_port', | |
'http://$dockerip:$api_port', | |
'http://localhost', | |
'http://127.0.0.1:8080', | |
'http://127.0.0.1:5001', | |
'http://127.0.0.1:48084', | |
'https://ipfs.blockringtm.ml', | |
'http://list.fairnet.ml.ipns.localhost:8080', | |
'https://playcode.io', | |
'https://js.do', | |
'https://cdpn.io', | |
'https://fiddle.jshell.net', | |
'https://replit.com', | |
'http://bl.ocks.org', | |
'https://bl.ocks.org', | |
'https://gateway.pinata.cloud', | |
'https://gateway.ipfs.io', | |
'https://webui.ipfs.io']" | |
allowed_origins=$(echo $allowed_origins | sed -e 's,'"'"',",g') | |
if ! _ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin | grep -q blockringtm.ml; then | |
_ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin "$allowed_origins" | |
_ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "POST"]' | |
else | |
echo "Allowed-Origins: |-" | |
_ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin | sed -e 's/^/ /' | |
fi | |
# adding bootstraps | |
# "/ip4/212.129.2.151/tcp/24001/ws/p2p/Qmd2iHMauVknbzZ7HFer7yNfStR4gLY1DSiih8kjquPzWV" | |
bootstraps='[ | |
"/ip4/212.129.2.151/tcp/24001/ws/p2p/Qmd2iHMauVknbzZ7HFer7yNfStR4gLY1DSiih8kjquPzWV", | |
"/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN", | |
"/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa", | |
"/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb", | |
"/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt", | |
"/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", | |
"/ip4/104.131.131.82/udp/4001/quic/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", | |
"/ip4/104.236.179.241/tcp/4001/p2p/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM", | |
"/ip4/104.236.179.241/udp/4001/quic/p2p/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM", | |
"/ip4/128.199.219.111/tcp/4001/p2p/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", | |
"/ip4/128.199.219.111/udp/4001/quic/p2p/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", | |
"/ip4/104.236.76.40/tcp/4001/p2p/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", | |
"/ip4/104.236.76.40/udp/4001/quic/p2p/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", | |
"/ip4/178.62.158.247/tcp/4001/p2p/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd", | |
"/ip4/178.62.158.247/udp/4001/quic/p2p/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd", | |
"/ip6/2604:a880:1:20::203:d001/tcp/4001/p2p/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM", | |
"/ip6/2400:6180:0:d0::151:6001/tcp/4001/p2p/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", | |
"/ip6/2604:a880:800:10::4a:5001/tcp/4001/p2p/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", | |
"/ip6/2a03:b0c0:0:1010::23:1001/tcp/4001/p2p/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd" | |
]' | |
_ipfs config --json Bootstrap "$(echo "$bootstraps" | tr -d '\n' )" | |
# adding OVH peer | |
peers='[{"Addrs":["/ip4/212.129.2.151/tcp/24001/ws"],"ID":"Qmd2iHMauVknbzZ7HFer7yNfStR4gLY1DSiih8kjquPzWV"}]' | |
# ipfs dht findpeer 12D3KooWHpj1ercuLscv78Ezz4TADdwSgNkmNmd4qH8dfCCcwZHX | |
_ipfs config --json Peering.Peers "$peers" | |
#curl -s -D - -X POST "http://$dockerip:$api_port/api/v0/id" | |
if curl -s -D - -X POST "${api_url}add?file=test&pin=true&raw-leaves=true&hash=sha3-224&cid-base=base58btc" -F "file=fairTeam" | grep -q z6CfPs4KMZEFsrvodUfZTtYjMWpxAbPsdZGzv3o1wtYj; then | |
echo "info: POST test ${green}successful${nc}; welcome to fairTeam" | |
else | |
echo "info: POST test ${red}failed${nc}" | |
echo "please: |-" | |
echo " reboot your IPFS node" | |
echo " by running:" | |
echo " ${cyan}sh ipfs-reboot.sh${nc}" | |
exit 251 | |
fi | |
keylist=12D3KooWJEgKKeZuawJLDu7TP5qCwmq8RSA5fkdHxREVLoavaPmt | |
qmlist=$(_ipfs name resolve $keylist | sed -e 's,/ipfs/,,') | |
echo "Important-Info: |-" | |
sed -e 's/^/ /' <<EOT | |
your docker ip address is ${yellow}$dockerip${nc} | |
your gateway is running on port $gw_port | |
your api_url is "${yellow}$api_url${nc}" | |
your webui_url is "${yellow}$gw_url${grey}/ipfs/Qmb3cY3zFJ5isjJ5H9cP47Vfqa6pqNwypbuo2TiBGjUmLd/${nc}#/welcome | |
please open your webui_urli in your browser, | |
and if you have a "${red}Could not connect to the IPFS API${nc}" message | |
enter ${green}/ip4/$dockerip/tcp/$api_port${nc} in point (3.) of the page. | |
our application is running at | |
xdg-open ${green}http://$dockerip:$gw_port/ipns/$keylist/list/node_list_create_n_rank.html${nc} | |
EOT | |
if [ "x$qmlist" != 'x' ]; then | |
echo " or" | |
echo " xdg-open ${green}http://$dockerip:$gw_port/ipfs/$qmlist/list/node_list_create_n_rank.html${nc}" | |
fi | |
echo '' | |
echo "${cyan}Happy fairJourney !${nc}" | |
echo . |
# | |
# ------------------------------------------------------------------------------------ | |
echo "--- # ${0##*/}" | |
export IPFS_IMAGE=${IPFS_IMAGE:-ipfs/go-ipfs} | |
export IPFS_CONTAINER=${IPFS_CONTAINER:-ipfs-node} | |
if [ "?$IPFS_PATH" != '?' ]; then | |
echo IPFS_PATH: $IPFS_PATH | |
fi | |
IPFS_PATH=${IPFS_PATH:-$HOME/.ipfs} | |
if echo -n "\e" | grep -q -e 'e'; then | |
e="-e" # bash needs a -e ! | |
fi | |
red=$(echo -n $e "\e[31m") | |
green=$(echo -n $e "\e[1;32m") | |
yellow=$(echo -n $e "\e[1;33m") | |
nc=$(echo -n $e "\e[0m") | |
# ------------------------------------------------------------------------------------ | |
uid=$(id -u) | |
gid=$(id -g) | |
# 1. start docker | |
if ! docker ps -f name=$IPFS_CONTAINER | grep -q -w $IPFS_CONTAINER; then | |
# remove pre-existing container | |
if docker ps -a -f name=$IPFS_CONTAINER | grep -q -w $IPFS_CONTAINER; then | |
echo "docker: rm $IPFS_CONTAINER" | |
docker rm $IPFS_CONTAINER | |
fi | |
# run a new one | |
docker run -d --name $IPFS_CONTAINER --user $uid:$gid \ | |
-p 127.0.0.1:8080:8080 -p 127.0.0.1:5001:5001 \ | |
-v $IPFS_PATH:/data/ipfs -w /export $IPFS_IMAGE daemon | |
sleep 7 | |
docker logs $IPFS_CONTAINER | |
else | |
echo "docker: ${green}$IPFS_CONTAINER is running${nc}" | |
echo " ${yellow}you might want to stop this $IPFS_CONTAINER w/ sh ipfs-stop.sh${nc}" | |
was_running=1 | |
fi | |
# 2. check is container is indeed running | |
if ! docker ps -f name=$IPFS_CONTAINER | grep -q -w $IPFS_CONTAINER; then | |
echo "${red}Error: $IPFS_CONTAINER docker didn't run${nc}" | |
echo " ${yellow}you might have an other ipfs daemon locking the repository, you might want to do a 'ipfs shutdown'${nc}" | |
exit 251 | |
else | |
dockerip=$(docker exec $IPFS_CONTAINER ifconfig eth0 | grep inet | sed -n -e 's/inet addr:/inet /' -e 's/^ *inet \([^ ]*\).*/\1/p;') | |
if [ "x$was_running" = 'x' ]; then | |
echo "docker: ${green}$IPFS_CONTAINER is running on $dockerip${nc}" | |
echo "info: ${0##*/} ${green}successful${nc}" | |
fi | |
fi | |
# wait until daemon is ready | |
while true; do | |
if docker logs --tail 3 $IPFS_CONTAINER | grep -q -w 'Daemon is ready'; then | |
break | |
fi | |
done | |
# ------------------------------------------------------------------------------------ |
# | |
IPFS_CONTAINER=${IPFS_CONTAINER:-ipfs-node} | |
docker exec $IPFS_CONTAINER ipfs shutdown | |
sleep 3 | |
docker logs --tail 3 $IPFS_CONTAINER | |
sleep 2 | |
docker start $IPFS_CONTAINER | |
sleep 7 | |
docker logs --tail 3 $IPFS_CONTAINER | |
# | |
# | |
IPFS_CONTAINER=${IPFS_CONTAINER:-ipfs-node} | |
docker start $IPFS_CONTAINER | |
sleep 7 | |
docker logs --tail 3 $IPFS_CONTAINER | |
sleep 3 | |
peerid=$(docker exec $IPFS_CONTAINER ipfs config Identity.PeerID) | |
echo peerid: $peerid | |
docker exec $IPFS_CONTAINER ipfs swarm addrs local |
# | |
IPFS_CONTAINER=${IPFS_CONTAINER:-ipfs-node} | |
docker exec $IPFS_CONTAINER ipfs shutdown | |
sleep 4 | |
docker logs --tail 3 $IPFS_CONTAINER |
# | |
export IPFS_CONTAINER=${IPFS_CONTAINER:-ipfs-node} | |
# dockerized ipfs is _ipfs | |
_ipfs() { | |
docker exec $IPFS_CONTAINER ipfs "$@" | |
} | |
api=$(_ipfs config Addresses.API) | |
gateway=$(_ipfs config Addresses.Gateway) | |
echo "api: $api" | |
echo "gateway: $gateway" | |
gw_port=$(echo $gateway | cut -d/ -f 5) | |
api_port=$(echo $api | cut -d/ -f 5) | |
# | |
# run this script with the following command: | |
curl all/one-liner-install.sh | sh - | |
set -e | |
if ! which git 1>/dev/null; then | |
if ! which sudo > /dev/null; then | |
echo apt-get update | |
apt-get update | |
echo apt-get install sudo | |
apt-get -y install sudo | |
fi | |
echo sudo apt-get install git | |
sudo apt-get -y install git | |
fi | |
echo git clone | |
gist=27ce2878f50aaee5b9ab0ac1975adb4c | |
git clone https://gist.github.com/DrI-T/$gist.git | |
cd $gist | |
sh docker-install.sh | |
sh ipfs-install.sh | |
sh ipfs-init.sh | |
sh ipfs-reboot.sh | |
sleep 3 | |
xdg-open index.html | |
exit $? | |
true |