-
Notifications
You must be signed in to change notification settings - Fork 312
/
install.sh
executable file
·155 lines (122 loc) · 3.7 KB
/
install.sh
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/usr/bin/env bash
shopt -s extglob
set -e
set -o errtrace
set -o errexit
set -o pipefail
export DEBIAN_FRONTEND="noninteractive"
# Install latest release of myst for debian/ubuntu/raspbian
#
# Variables:
# - SNAPSHOT (default: false) - set to "true" to install development snapshot
#
if [[ "$SNAPSHOT" == "true" ]]; then
PPA="ppa:mysteriumnetwork/node-dev"
PPA_URL="http://ppa.launchpad.net/mysteriumnetwork/node-dev/ubuntu"
PPA_FINGER="ECCB6A56B22C536D"
elif [[ "$NETWORK" == "testnet3" ]]; then
PPA="ppa:mysteriumnetwork/node-testnet3"
PPA_URL="http://ppa.launchpad.net/mysteriumnetwork/node-testnet3/ubuntu"
PPA_FINGER="ECCB6A56B22C536D"
else
PPA="ppa:mysteriumnetwork/node"
PPA_URL="http://ppa.launchpad.net/mysteriumnetwork/node/ubuntu"
PPA_FINGER="ECCB6A56B22C536D"
fi
get_os() {
local __resultvar=$1
local result
result=$(uname | tr '[:upper:]' '[:lower:]')
eval $__resultvar="'$result'"
}
get_linux_distribution() {
local __resultvar=$1
local result
if [[ -f "/etc/os-release" ]]; then
local id=$(awk -F= '$1=="ID" { print $2 ;}' /etc/os-release)
if [[ -z "$id" ]]; then
id=$(awk -F= '$1=="ID_LIKE" { print $2 ;}' /etc/os-release)
fi
if [[ "$id" == "debian" ]]; then
if [[ "$(uname -a | grep -c raspberry)" == "1" ]]; then
id="raspbian"
fi
fi
result="$id"
else
result="unknown"
fi
eval $__resultvar="'$result'"
}
get_version_codename() {
local __resultvar=$1
local result
if [[ -f "/etc/os-release" ]]; then
local id=$(awk -F= '$1=="VERSION_CODENAME" { print $2 ;}' /etc/os-release)
result="$id"
else
result="unknown"
fi
eval $__resultvar="'$result'"
}
install_ubuntu() {
apt update
# add-apt-repository may not be available in Ubuntu server out of the box
apt install -y software-properties-common
if [[ "$container" != "docker" ]]; then
apt install -y "linux-headers-$(uname -r)"
fi
# myst
add-apt-repository -y "$PPA"
apt update
apt install -y myst
}
install_debian() {
# Wireguard
prepare_sources_list
if [[ "$container" != "docker" ]]; then
apt update
if [[ "$DISTRO" == "raspbian" ]]; then
apt install -y raspberrypi-kernel-headers
else
apt install -y "linux-headers-$(uname -r)"
fi
fi
# myst
echo "deb $PPA_URL focal main" > /etc/apt/sources.list.d/mysterium.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys "$PPA_FINGER"
apt update
apt install -y wireguard myst
}
prepare_sources_list() {
if [[ "$VERSION_CODENAME" == "buster" ]]; then
echo "deb http://deb.debian.org/debian ${VERSION_CODENAME}-backports main" > /etc/apt/sources.list.d/backports.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 04EE7237B7D453EC
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 648ACFD622F3D138
else
echo "deb http://deb.debian.org/debian/ unstable main" > /etc/apt/sources.list.d/unstable.list
echo -e "Package: *\nPin: release a=unstable\nPin-Priority: 90" > /etc/apt/preferences.d/limit-unstable
fi
}
install() {
case "$DISTRO" in
ubuntu)
install_ubuntu
;;
*)
install_debian
esac
}
echo "### Detecting platform"
get_os OS
get_linux_distribution DISTRO
get_version_codename VERSION_CODENAME
echo "System info:
OS: $OS
Distribution: $DISTRO
Version codename: $VERSION_CODENAME"
echo "### Detecting platform - done"
echo "### Installing myst & dependencies"
install
echo "### Installing myst & dependencies - done"
echo "### Installation complete!"