summarylogtreecommitdiffstats
path: root/bitcoind.install
blob: d239c2de4b3ce741ab307de5efbabbdb82b7317e (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
post_install() {
  printf "\n%b\n" "$info"

  # Persist an existing blockchain in the old datadir by symlinking it
  if [ -f /srv/bitcoin/peers.dat ] && [ ! -d /var/lib/bitcoind ]; then
    ln -s /srv/bitcoin /var/lib/bitcoind
    printf "  Blockchain:    /srv/bitcoin\n\n"
  else
    # New installation: create data directory
    mkdir -p -m 755 /var/lib/bitcoind
    printf "  Blockchain:    /var/lib/bitcoind\n\n"
  fi

  # Warn if previous settings are present
  [ -f /etc/bitcoin/bitcoin.conf.pacsave ] && note "before starting bitcoind you may have to merge /etc/bitcoin/bitcoin.conf.pacsave\n          into /etc/bitcoin/bitcoin.conf in order to keep your previous configuration.\n"
}

post_upgrade() {
  post_install 
}

note() {
  printf "${blue}==>${yellow} NOTE:${bold} $1${all_off}\n"
}

all_off="$(tput sgr0)"
bold="${all_off}$(tput bold)"
blue="${bold}$(tput setaf 4)"
yellow="${bold}$(tput setaf 3)"

read -d '' info <<'EOF'
  Bitcoin Core
  ____________

  To start bitcoin-core:

      # systemctl start bitcoind

      [ to reindex: systemctl start bitcoind-reindex ]

  To communicate with bitcoin-core as a normal user:

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

      $ bitcoin-cli getmininginfo

  Documentation: /usr/share/doc/bitcoin
  Config:        /etc/bitcoin/bitcoin.conf
EOF