summarylogtreecommitdiffstats
path: root/bitcoin.install
blob: 5f48f0a902f62bf0a3648afec7df38b494f90c50 (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
54
55
56
57
58
59
_bc_user=bitcoin
_bc_group=bitcoin

post_install() {
  _mkuser
  chown -R $_bc_user:$_bc_group /etc/bitcoin /srv/bitcoin /run/bitcoin
  printf "%b\n" "$bitcoin"
}

post_upgrade() {
  _mkuser
  chown -R $_bc_user:$_bc_group /etc/bitcoin /srv/bitcoin /run/bitcoin
  printf "%b\n" "$bitcoin"
}

post_remove() {
  _rmuser
  rm -rf /srv/bitcoin /run/bitcoin
}

_mkuser() {
  getent passwd $_bc_user &>/dev/null || {
    echo -n "Creating bitcoin user... "
    grep -E "^$_bc_group:" /etc/group >/dev/null || groupadd $_bc_group
    useradd -m -d /etc/bitcoin -g $_bc_group -s /usr/bin/nologin $_bc_user 2>/dev/null
    echo "done"
  }
}

_rmuser() {
  echo -n "Removing bitcoin user... "
  userdel -rf $_bc_user 2>/dev/null
  echo "done"
}

read -d '' bitcoin <<'EOI'

Bitcoin Cash Node
_________________

To start bitcoin-cash-node:

$ systemctl start bitcoin

To communicate with bitcoin-cash-node as a normal user:

$ mkdir -p ~/.bitcoin
$ cat > ~/.bitcoin/bitcoin.conf <<'EOF'
rpcport=8332
rpcuser=bitcoin
rpcpassword=secret
EOF

$ bitcoin-cli getmininginfo

Config:        /etc/bitcoin/bitcoin.conf
Blockchain:    /srv/bitcoin
Documentation: /usr/share/doc/bitcoin
EOI