2018-03-14 21:51:31 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Licence GPL 3
|
|
|
|
|
|
|
|
#####################
|
|
|
|
## S e t t i n g s ##
|
|
|
|
#####################
|
|
|
|
|
2019-09-18 21:50:31 +00:00
|
|
|
VERSION=0.4.22
|
2018-03-14 21:51:31 +00:00
|
|
|
AIM=/usr/local/bin/ipfs
|
|
|
|
DATA_DIR=/var/spool/ipfs/
|
|
|
|
USER=ipfs
|
|
|
|
|
|
|
|
####### ENDE #######
|
|
|
|
|
|
|
|
[ "`id -u`" != "0" ] && { echo run as root; exit 1; }
|
|
|
|
|
|
|
|
#################
|
|
|
|
## daemon user ##
|
|
|
|
#################
|
|
|
|
|
|
|
|
adduser $USER --disabled-password --disabled-login --home $DATA_DIR --system
|
|
|
|
|
|
|
|
|
|
|
|
##################
|
|
|
|
## 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
|
|
|
|
|
|
|
|
#download ...
|
2019-03-10 21:40:43 +00:00
|
|
|
wget "https://github.com/ipfs/go-ipfs/releases/download/v${VERSION}/go-ipfs_v${VERSION}_linux-${ARCH}.tar.gz"
|
2018-03-14 21:51:31 +00:00
|
|
|
|
|
|
|
#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 $USER $AIM
|
|
|
|
|
|
|
|
## init ipfs
|
|
|
|
export "IPFS_PATH=$DATA_DIR"
|
|
|
|
export "HOME=$DATA_DIR"
|
|
|
|
sudo -E -u ipfs ipfs init --profile=server
|
|
|
|
#If you're not running ipfs in a hosted environment, use ipfs init"
|
|
|
|
sed -i 's/127.0.0.1/0.0.0.0/g' $DATA_DIR/config
|
|
|
|
|
|
|
|
#go back and delete temp
|
|
|
|
cd -
|
|
|
|
rm -r `cd -`
|
2018-04-14 18:02:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
#################
|
|
|
|
## init skript ##
|
|
|
|
#################
|
|
|
|
|
|
|
|
cp ipfs.initd /etc/init.d/ipfs
|
|
|
|
sed -i "s/#GID#/`id -g $USER`/g" /etc/init.d/ipfs
|
|
|
|
sed -i "s/#UID#/`id -u $USER`/g" /etc/init.d/ipfs
|
|
|
|
sed -i 's|#DATA#|'${DATA_DIR}'|g' /etc/init.d/ipfs
|
|
|
|
sed -i 's|#AIM#|'${AIM}'|g' /etc/init.d/ipfs
|
|
|
|
chmod +x /etc/init.d/ipfs
|
|
|
|
update-rc.d ipfs defaults
|