-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·119 lines (89 loc) · 3.29 KB
/
install
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/env bash
case "$OSTYPE" in
darwin*) x="OSX" ;;
linux*) x="LINUX" ;;
msys*) x="WINDOWS" ;;
*) x="unknown: $OSTYPE" ;;
esac
echo $x
set -o pipefail
source ./lib/functions.sh
mode="install"
if [ -x "$(command -v ipfs)" ]; then
ask ">>> IPFS already installed. Should it be updated?" || exit 0
mode="update"
fi
if [ "$x" == "WINDOWS" ]; then
echo ">>> Starting installation on Linux device compatible with $x"
# Download and install IPFS
echo ">>> Installing IPFS version $ipfs_version"
echo ">>> Starting IPFS"
echo ">>> All done."
elif [ "$x" == "LINUX" ]; then
echo ">>> Starting installation on Linux device compatible with $x"
# Download and install IPFS
ipfs_arch=${2-"linux-amd64"}
ipfs_version=$(curl -s https://dist.ipfs.io/go-ipfs/versions | tail -1)
ipfs_version=${1-$ipfs_version}
ipfs_version="v${ipfs_version#v}"
echo ">>> Installing IPFS version $ipfs_version"
tar_gz_destination=/tmp/go-ipfs_${ipfs_version}_${ipfs_arch}.tar.gz
wget "https://dist.ipfs.io/go-ipfs/${ipfs_version}/go-ipfs_${ipfs_version}_${ipfs_arch}.tar.gz" \
-q --show-progress \
-O $tar_gz_destination
if [ ! -f $tar_gz_destination ]; then
echo ">>> Failed to download IPFS"
exit 1
fi
ipfs_destination=/usr/local/bin/ipfs
tar xzf $tar_gz_destination -C /tmp
sudo install /tmp/go-ipfs/ipfs $ipfs_destination
echo ">>> Starting IPFS"
# Maybe initialize IPFS
[ ! -d ~/.ipfs ] && ipfs init
# Install and enable bring-up configurations for IPFS daemon
init_system=$(get_init_system)
ipfs_path=$HOME/.ipfs
ipfs_user=$(whoami)
ipfs_group=$(id -gn)
if [ $init_system == "systemd" ]; then
cat ./lib/ipfs-daemon.service.tpl | \
sed "s|{{ipfs_path}}|${ipfs_path}|g" | \
sed "s|{{ipfs_user}}|${ipfs_user}|g" | \
sed "s|{{ipfs_group}}|${ipfs_group}|g" | \
sudo tee /lib/systemd/system/ipfs-daemon.service > /dev/null
sudo systemctl daemon-reload
if [ "$mode" == "install" ]; then
sudo systemctl enable --now ipfs-daemon
elif [ "$mode" == "update" ]; then
sudo systemctl restart ipfs-daemon
fi
elif [ $init_system == "upstart" ]; then
cat ./lib/ipfs-daemon.conf.tpl | \
sed "s|{{ipfs_path}}|${ipfs_path}|g" | \
sed "s|{{ipfs_user}}|${ipfs_user}|g" | \
sudo tee /etc/init/ipfs-daemon.conf > /dev/null
sudo initctl reload-configuration
if [ "$mode" == "install" ]; then
sudo service ipfs-daemon start
elif [ "$mode" == "update" ]; then
sudo service ipfs-daemon stop
sudo service ipfs-daemon start
fi
else
echo ">>> Unable to detect init system - you don't seem to be using systemd or upstart. The IPFS daemon will have to be controlled manually."
fi
rm $tar_gz_destination
#Install node
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
apt-get install -y nodejs
#Install yarn
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
apt-get update && sudo apt-get install yarn
#install all packages
yarn
echo ">>> All done."
fi
## ssh root@45.63.14.97
## 1Wf@WQJ?Jy(qPGNq