-
Notifications
You must be signed in to change notification settings - Fork 0
/
installelectrs.sh
executable file
·131 lines (100 loc) · 4.62 KB
/
installelectrs.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
#!/bin/bash
read -p "Enter futurebit RPC password. If you have not changed the RPC password, use futurebit. Note you will not see your password typing!" -s rpcPassword
echo
cd $HOME
git clone https://github.com/romanz/electrs
cd electrs
sudo apt-get update
sudo apt install -y clang cmake build-essential cargo tor prometheus
echo $'\e[1;31m'This will run for 25+ minutes!!!$'\e[0m'
cargo build --locked --release
sudo mkdir /media/nvme/electrs
sudo chmod 777 /media/nvme/electrs
sudo mkdir /var/lib/tor/electrs_hidden_service/
if grep -q "/var/lib/tor/electrs_hidden_service" "/etc/tor/torrc"; then
echo $'\e[1;33m'electrs hidden service already exists in /etc/tor/torcc! Please manually update as needed.$'\e[0m'
else
sudo bash -c 'echo "
#Electrs installed via https://github.com/apurgert/installelectrs
HiddenServiceDir /var/lib/tor/electrs_hidden_service/
HiddenServicePort 50001 127.0.0.1:50001
HiddenServiceVersion 3
" >> /etc/tor/torrc'
fi
sudo usermod -a -G debian-tor futurebit
sudo chown debian-tor:debian-tor /var/lib/tor/electrs_hidden_service
sudo chmod 700 /var/lib/tor/electrs_hidden_service
sudo systemctl restart tor
mkdir ~/.electrs
if [ -f "$HOME/.electrs/config.toml" ]; then
echo $'\e[1;33m'File $HOME/.electrs/config.toml already exists! Please manually update as needed.$'\e[0m'
else
touch ~/.electrs/config.toml
echo "
#Configured via https://github.com/apurgert/installelectrs
#DO NOT EDIT THIS FILE DIRECTLY - COPY IT FIRST!
#If You Edit This, You Will Cry A Lot During Update And Will Not Want To Live Anymore!
#This Is An EXAMPLE Of How Configuration File Should Look Like.
#Do NOT Blindly Copy This And Expect It To Work For You!
#If You Don't Know What You're Doing Consider Using Automated Setup Or Ask An Experienced Friend.
#This Example Contains Only The Most Important Settings.
#See Docs Or Electrs Man Page For Advanced Settings.
#File Where Bitcoind Stores The Cookie, Usually File .Cookie In Its Datadir
#Cookie_file = "/Var/Run/Bitcoin-Mainnet/Cookie"
#Username And Password Instead
auth = \"futurebit:$rpcPassword\"
#The Listening RPC Address Of Bitcoind, Port Is Usually 8332
daemon_rpc_addr = \"127.0.0.1:8332\"
#The Listening P2P Address Of Bitcoind, Port Is Usually 8333
daemon_p2p_addr = \"127.0.0.1:8333\"
#Directory Where The Index Should Be Stored. It Should Have At Least 70GB Of Free Space.
db_dir = \"/media/nvme/electrs\"
#Bitcoin Means Mainnet. Don't Set To Anything Else Unless You're A Developer.
network = \"bitcoin\"
#The Address On Which Electrs Should Listen. Warning: 0.0.0.0 Is Probably A Bad Idea!
#Tunneling Is The Recommended Way To Access Electrs Remotely.
electrum_rpc_addr = \"127.0.0.1:50001\"
#How Much Information About Internal Workings Should Electrs Print. Increase Before Reporting A Bug.
log_filters = \"INFO\"
" > $HOME/.electrs/config.toml
fi
if [ -f "/etc/systemd/system/electrs.service" ]; then
echo $'\e[1;33m'File /etc/systemd/system/electrs.service already exists! Please manually update as needed.$'\e[0m'
else
sudo touch /etc/systemd/system/electrs.service
echo "
[Unit]
Description=Electrs Private Electrum Server installed via https://github.com/apurgert/installelectrs
After=multi-user.target
[Service]
WorkingDirectory=/home/futurebit/electrs
ExecStart=/home/futurebit/electrs/target/release/electrs
User=futurebit
Group=futurebit
Type=simple
KillMode=process
TimeoutSec=60
Restart=always
RestartSec=60
[Install]
WantedBy=multi-user.target
" | sudo tee -a /etc/systemd/system/electrs.service >/dev/null
fi
sudo systemctl enable electrs --now
if grep -q "electrs" "/etc/prometheus/prometheus.yml"; then
echo $'\e[1;33m'electrs already exists in /etc/prometheus/prometheus.yml! Please manually update as needed.$'\e[0m'
else
echo "
- job_name: electrs
static_configs:
- targets: ['localhost:4224']
" | sudo tee -a /etc/prometheus/prometheus.yml >/dev/null
fi
sudo systemctl restart prometheus
myIP="$(ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1')"
echo "electrs version "; ./target/release/electrs --version
systemctl is-active --quiet tor && echo $'\e[1;32m'tor is running$'\e[0m' || echo $'\e[1;31m'tor is NOT running$'\e[0m'
systemctl is-active --quiet electrs && echo $'\e[1;32m'electrs is running$'\e[0m' || echo $'\e[1;31m'electrs is NOT running$'\e[0m'
systemctl is-active --quiet electrs && echo $'\e[1;32m'prometheus is running$'\e[0m' || echo $'\e[1;31m'prometheus is NOT running$'\e[0m'
echo "Script finished. View sync progress via http://$myIP:9090/graph?g0.range_input=1h&g0.expr=index_height&g0.tab=0.
Your electrs onion address is"; sudo cat /var/lib/tor/electrs_hidden_service/hostname