summarylogtreecommitdiffstats
path: root/bitcoin.install
diff options
context:
space:
mode:
authorquest2020-02-26 23:10:42 -0800
committerquest2020-02-26 23:10:42 -0800
commit65799a23ba52ed662e9217cb0f10d4bf8c328234 (patch)
treefa0311e62e17bba563723ab484eb848e291666e5 /bitcoin.install
downloadaur-65799a23ba52ed662e9217cb0f10d4bf8c328234.tar.gz
Add initial Bitcoin Cash Node
Diffstat (limited to 'bitcoin.install')
-rw-r--r--bitcoin.install60
1 files changed, 60 insertions, 0 deletions
diff --git a/bitcoin.install b/bitcoin.install
new file mode 100644
index 000000000000..56a21035ca5f
--- /dev/null
+++ b/bitcoin.install
@@ -0,0 +1,60 @@
+_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 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'
+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