aboutsummaryrefslogtreecommitdiff
path: root/ipfs-check-install-setup-init-update
blob: c15981b5e75e778152d7900002c8ce279033a701 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
logthis(){
	echo "IPFS TOOL:  $1" >> $WORKDIR/logs
}
install(){
	logthis "ipfs-check-install-setup-init"
	IPFS_VERSION="$(curl https://github.com/ipfs/go-ipfs/releases/latest | sed -e 's/.*releases//g' | sed -e 's/".*//' | sed -e 's/\/tag\///')"
	SWARMSHA512SUM="7001e37412758c43d372a969e977ca11511e034c8c1e233a58dc3ce1c6f3c1aa7d2da8cba9944a5eabaa8885742bfe6cc6794224c146b7129da8f633b53b9cfc"
	IPFS_TARGET_FILE="go-ipfs_"$IPFS_VERSION"_linux-amd64.tar.gz"
	AKBIN="$WORKDIR/bin"
	mkdir $AKBIN
	AKAR="$ARCHIVESDIR"
	mkdir $AKAR
	if [ ! -d $AKAR ]; then
		mkdir $AKAR
		if [ $? != 0 ]; then
			logthis "Problem creating directory"
			exit 1;
		fi
	fi
	logthis "Downloading ipfs $IPFS_VERSION"
	if [ ! -f $AKAR/$IPFS_TARGET_FILE ]; then
		wget -O $AKAR/$IPFS_TARGET_FILE https://dist.ipfs.io/go-ipfs/$IPFS_VERSION/$IPFS_TARGET_FILE ;
	fi
	logthis "Making temp files"
	TIMESTAMP="$(date -u +%s)"
	TEMPASSIN="/tmp/aktmp_$TIMESTAMP"
	if [ ! -d $TEMPASSIN ]; then
		mkdir $TEMPASSIN
		cd $TEMPASSIN
		tar xf $AKAR/$IPFS_TARGET_FILE
		cp go-ipfs/ipfs $AKBIN/ipfs
	fi
	logthis "ipfs installed on $AKBIN"
	if [ ! -d $HOME/.ipfs ]; then
		mkdir $HOME/.ipfs
		$AKBIN/ipfs init ;
	fi
	if [ ! -f $HOME/.ipfs/swarm.key ]; then
		wget -O $HOME/.ipfs/swarm.key https://arching-kaos.net/files/swarm.key ;
	elif [ "$(sha512sum $HOME/.ipfs/swarm.key | awk '{ print $1 }')" == "$SWARMSHA512SUM" ]; then
		logthis "Congrats! You are already in our swarm" ;
	else
		logthis "Error: Found swarm.key but not ours"
		logthis "Visit https\:\/\/arching-kaos.net\/files\/swarm.key and copy it to your ipfs folder" ;
	fi
}
which ipfs > /dev/null 2>&1
if [ $? != 0 ]; then
	install
	ipfs init
else logthis "Found IPFS"
fi