ipfs_daemon/setup-ipfs-daemon

76 lines
1.4 KiB
Plaintext
Raw Normal View History

2018-02-20 22:33:30 +00:00
#!/bin/bash
# Licence GPL 3
2018-02-20 20:32:38 +00:00
2018-02-20 22:33:30 +00:00
#####################
## S e t t i n g s ##
#####################
2018-02-20 20:32:38 +00:00
2018-02-20 22:33:30 +00:00
VERSION=0.4.13
AIM=/usr/local/bin/ipfs
2018-02-25 15:23:17 +00:00
DATA_DIR=/var/spool/ipfs/
2018-02-20 20:32:38 +00:00
2018-02-20 22:33:30 +00:00
####### ENDE #######
2018-02-20 20:32:38 +00:00
2018-02-20 22:33:30 +00:00
[ "`id -u`" != "0" ] && { echo run as root; exit 1; }
#################
## daemon user ##
#################
2018-02-25 15:23:17 +00:00
adduser ipfs --disabled-password --disabled-login --home $DATA_DIR --system
2018-02-20 22:33:30 +00:00
#################
## init skript ##
#################
2018-02-20 20:32:38 +00:00
cp ipfs.initd /etc/init.d/ipfs
2018-02-20 22:33:30 +00:00
sed -i "s/#GID#/`id -g ipfs`/g" /etc/init.d/ipfs
sed -i "s/#UID#/`id -u ipfs`/g" /etc/init.d/ipfs
2018-02-25 15:23:17 +00:00
sed -i "s/#DATA#/$DATA_DIR/g" /etc/init.d/ipfs
2018-02-20 22:33:30 +00:00
chmod +x /etc/init.d/ipfs
2018-02-20 20:32:38 +00:00
update-rc.d ipfs defaults
2018-02-20 22:33:30 +00:00
##################
## install ipfs ##
##################
# creat tmp and enter it
cd `mktemp -d`
# select CPU architecture
ARCH=`uname -m`
case "$ARCH" in
i?86) ARCH=386 ;;
x86_64) ARCH="amd64" ;;
*arm*) ARCH="arm" ;;
*) echo ipfs for $arch not available; exit 1 ;;
esac
2018-02-20 20:32:38 +00:00
2018-02-20 22:33:30 +00:00
#download ...
wget "https://dist.ipfs.io/go-ipfs/v"$VERSION"/go-ipfs_v"$VERSION"_linux-"$ARCH".tar.gz"
#extract
tar xzf go-ipfs_*
#delete old one if exit
[ -f $AIM ] && rm $AIM
# install new
cp go-ipfs/ipfs $AIM
#set permissions
chmod 770 $AIM
chown ipfs:ipfs $AIM
2018-02-20 20:32:38 +00:00
## init ipfs
2018-02-25 15:23:17 +00:00
export "HOME=$DATA_DIR"
su ipfs -c "ipfs init --profile=server"
#If you're not running ipfs in a hosted environment, use ipfs init"
2018-02-20 22:33:30 +00:00
sed -i 's/127.0.0.1/0.0.0.0/g' /var/spool/ipfs/.ipfs/config
2018-02-20 20:32:38 +00:00
2018-02-20 22:33:30 +00:00
#go back and delete temp
cd -
rm -r `cd -`