summarylogtreecommitdiffstats
path: root/bitcoin.install
blob: e8a2fa7b4abd9e79a94950af4d166ca5c23f4f7c (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
  printf "%b\n" "$bitcoin"
}

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

post_remove() {
  _rmuser
  rm -rf /srv/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 ABC
___________

To start bitcoin-abc:

$ systemctl start bitcoin

To communicate with bitcoin-abc as a normal user:

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

$ bitcoin-cli getmininginfo

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