forked from broxus/everscale-monitoring
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·89 lines (74 loc) · 2.57 KB
/
setup.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
#!/usr/bin/env bash
set -eE
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)
REPO_DIR=$(cd "${SCRIPT_DIR}/../" && pwd -P)
function print_help() {
echo 'Usage: setup.sh'
echo ''
echo 'Options:'
echo ' -h,--help Print this help message and exit'
}
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-h|--help)
print_help
exit 0
;;
*) # unknown option
echo 'ERROR: Unknown option'
echo ''
print_help
exit 1
;;
esac
done
service_path="/etc/systemd/system/everscale-monitoring.service"
geoip_service_path="/etc/systemd/system/geoip.service"
config_path="/etc/everscale-monitoring/config.yaml"
echo 'INFO: Running native installation'
echo 'INFO: installing and updating dependencies'
sudo apt update && sudo apt upgrade
sudo apt install build-essential llvm clang pkg-config libssl-dev
echo 'INFO: installing Rust'
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source "$HOME/.cargo/env"
echo 'INFO: building everscale-monitoring'
cd "$REPO_DIR"
RUSTFLAGS="-C target_cpu=native" cargo build --release
sudo cp "$REPO_DIR/target/release/everscale-monitoring" /usr/local/bin/everscale-monitoring
echo 'INFO: building geoip-resolver'
cd "$REPO_DIR"
RUSTFLAGS="-C target_cpu=native" cargo build --release -p geoip-resolver
sudo cp "$REPO_DIR/target/release/geoip-resolver" /usr/local/bin/geoip-resolver
echo 'INFO: creating systemd service'
if [[ -f "$service_path" ]]; then
echo "WARN: $service_path already exists"
else
sudo cp "$REPO_DIR/contrib/everscale-monitoring.native.service" "$service_path"
fi
if [[ -f "$geoip_service_path" ]]; then
echo "WARN: $geoip_service_path already exists"
else
sudo cp "$REPO_DIR/contrib/geoip.native.service" "$geoip_service_path"
fi
echo "INFO: preparing environment"
sudo mkdir -p /etc/everscale-monitoring
sudo mkdir -p /var/db/everscale-monitoring
sudo mkdir -p /var/db/geoip
if [[ -f "$config_path" ]]; then
echo "WARN: $config_path already exists"
else
sudo cp -n "$REPO_DIR/contrib/config.yaml" "$config_path"
fi
sudo wget -O /etc/everscale-monitoring/ton-global.config.json \
https://raw.githubusercontent.com/tonlabs/main.ton.dev/master/configs/ton-global.config.json
echo 'INFO: restarting timesyncd'
sudo systemctl restart systemd-timesyncd.service
echo 'INFO: done'
echo ''
echo 'INFO: Systemd service: everscale-monitoring'
echo ' Systemd geoip service: geoip-service'
echo ' Keys and configs: /etc/everscale-monitoring'
echo ' Node DB and stuff: /var/db/everscale-monitoring'
echo ' Geoip resolver DB: /var/db/geoip'