summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomZ2016-12-22 22:01:49 +0100
committerTomZ2016-12-22 22:01:49 +0100
commit1220b923db456f8f3f36150c868ba3d3516e5e10 (patch)
tree232f52ec276498d6029a86ecf73e39d311100f2c
parent6de6b00975690b042e03d62ce7ba7b67279da4ef (diff)
downloadaur-1220b923db456f8f3f36150c868ba3d3516e5e10.tar.gz
Made the running as daemon part work properly
-rw-r--r--.SRCINFO8
-rw-r--r--PKGBUILD18
-rw-r--r--bitcoin-qt.install11
-rw-r--r--bitcoin.conf31
-rw-r--r--bitcoin.install128
5 files changed, 174 insertions, 22 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 7bbb20b414a7..a3207c014f22 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,11 +1,11 @@
# Generated by mksrcinfo v8
-# Thu Dec 22 14:27:20 UTC 2016
+# Thu Dec 22 21:01:30 UTC 2016
pkgbase = bitcoin-classic-git
pkgdesc = Bitcoin Classic versions of Bitcoind, bitcoin-cli, bitcoin-tx, and bitcoin-qt, most recent stable branch, w/GUI and wallet
- pkgver = v1.2.0.b1.r55.g95803467
+ pkgver = v1.2.0.b1.r56.gd5556713
pkgrel = 1
url = https://bitcoinclassic.com/
- install = bitcoin-qt.install
+ install = bitcoin.install
arch = i686
arch = x86_64
license = MIT
@@ -30,8 +30,10 @@ pkgbase = bitcoin-classic-git
conflicts = bitcoin-tx
source = git+https://github.com/bitcoinclassic/bitcoinclassic.git#branch=develop
source = bitcoin.logrotate
+ source = bitcoin.conf
sha256sums = SKIP
sha256sums = 7bf4bdad419c1ee30b88c7e4190707c5ff250da8b23d68d5adf14043f8e2ac73
+ sha256sums = c8787560c6423605796c8d3e080cb522ed849cea12b5c23293c22e405a015a53
pkgname = bitcoin-classic-git
diff --git a/PKGBUILD b/PKGBUILD
index e767282ac835..b312458cb99c 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,7 +1,7 @@
# Maintainer: Tom Zander
pkgname=bitcoin-classic-git
-pkgver=v1.2.0.b1
+pkgver=v1.2.0.b1.r56.gd5556713
pkgrel=1
pkgdesc='Bitcoin Classic versions of Bitcoind, bitcoin-cli, bitcoin-tx, and bitcoin-qt, most recent stable branch, w/GUI and wallet'
arch=('i686' 'x86_64')
@@ -11,11 +11,14 @@ depends=('boost-libs' 'desktop-file-utils' 'libevent' 'qt5-base' 'protobuf' 'ope
makedepends=('boost' 'qt5-tools')
provides=('bitcoin-daemon' 'bitcoin-cli' 'bitcoin-qt' 'bitcoin-tx')
conflicts=('bitcoin-daemon' 'bitcoin-cli' 'bitcoin-qt' 'bitcoin-tx')
-install=bitcoin-qt.install
+install=bitcoin.install
source=("git+https://github.com/bitcoinclassic/bitcoinclassic.git#branch=develop"
- "bitcoin.logrotate")
+ "bitcoin.logrotate"
+ "bitcoin.conf")
+
sha256sums=('SKIP'
- "7bf4bdad419c1ee30b88c7e4190707c5ff250da8b23d68d5adf14043f8e2ac73")
+ "7bf4bdad419c1ee30b88c7e4190707c5ff250da8b23d68d5adf14043f8e2ac73"
+ "c8787560c6423605796c8d3e080cb522ed849cea12b5c23293c22e405a015a53")
pkgver() {
cd "$srcdir/bitcoinclassic"
@@ -54,16 +57,15 @@ package() {
msg2 'Installing bitcoin-daemon...'
install -Dm755 "$srcdir/bitcoinclassic/src/bitcoind" "$pkgdir/usr/bin/bitcoind"
install -Dm644 "$srcdir/bitcoinclassic/contrib/debian/examples/bitcoin.conf"\
- "$pkgdir/usr/share/doc/$pkgname/examples/bitcoin.conf"
+ "$pkgdir/usr/share/doc/bitcoin/examples/bitcoin.conf"
install -Dm644 "$srcdir/bitcoinclassic/contrib/debian/manpages/bitcoind.1"\
"$pkgdir/usr/share/man/man1/bitcoind.1"
install -Dm644 "$srcdir/bitcoinclassic/contrib/debian/manpages/bitcoin.conf.5"\
"$pkgdir/usr/share/man/man5/bitcoin.conf.5"
msg2 'Installing bitcoin.conf...'
- # Install bitcoin.conf is one does not already exist
- [[ ! -e "/etc/bitcoin/bitcoin.conf" ]] && install -Dm 644 \
- "$srcdir/bitcoinclassic/contrib/debian/examples/bitcoin.conf" -t "$pkgdir/etc/bitcoin"
+ install -Dm 644 "$srcdir/bitcoin.conf" "$pkgdir/etc/bitcoin/bitcoin.conf.dist"
+ install -Dm 644 "$srcdir/bitcoinclassic/share/rpcuser/rpcuser.py" "$pkgdir/etc/bitcoin/rpcuser.py"
msg2 'Installing bitcoin.service...'
install -Dm 644 "$srcdir/bitcoinclassic/contrib/init/bitcoind.service" \
diff --git a/bitcoin-qt.install b/bitcoin-qt.install
deleted file mode 100644
index 8f20cf484d13..000000000000
--- a/bitcoin-qt.install
+++ /dev/null
@@ -1,11 +0,0 @@
-post_install() {
- update-desktop-database -q
-}
-
-post_upgrade() {
- update-desktop-database -q
-}
-
-post_remove() {
- update-desktop-database -q
-}
diff --git a/bitcoin.conf b/bitcoin.conf
new file mode 100644
index 000000000000..8d6e980515c3
--- /dev/null
+++ b/bitcoin.conf
@@ -0,0 +1,31 @@
+# See a longer example at; /usr/share/doc/bitcoin/examples/bitcoin.conf
+
+# Defaults that are also passed in by systemd
+datadir=/var/lib/bitcoind
+pid=/var/lib/bitcoind/bitcoind.pid
+disablewallet=1
+
+# make the cookie go to /etc/bitcoin
+rpccookiefile=/etc/bitcoin/.cookie
+# make sure the cookie is readable by users able to read /etc/bitcoin
+sysperms=1
+
+# --rpcauth--
+# There additionally is the config option "rpcauth" to allow
+# multiple different users to use different credentials for login.
+#
+# The config option comes in the format:
+# rpcauth=USERNAME:SALT$HASH
+#
+# Where:
+# 1-USERNAME is desired username. Name doesn't have to be unique.
+# 2-SALT is the salt for the HMAC_SHA256 function
+# 3-HASH is a hex string that is the result of the HMAC_SHA256
+# function on the user's secret password plus the SALT as the key.
+#
+# A "canonical" password generating python script has been supplied
+# at "/etc/bitcoin/rpcuser.py". From the client-side, one connects
+# using the standard -rpcuser/-rpcpassword options.
+#
+# How to create an RPC user login credential.
+# $ python2 /etc/bitcoin/rpcuser.py <username>
diff --git a/bitcoin.install b/bitcoin.install
new file mode 100644
index 000000000000..25050db1a9b1
--- /dev/null
+++ b/bitcoin.install
@@ -0,0 +1,128 @@
+_bc_user=bitcoin
+_bc_group=bitcoin
+
+post_install() {
+ _mkuser
+ # disable Copy-On-Write (btrfs directories only)
+ _dir="/var/lib/bitcoind"
+ mkdir -p "$_dir"
+ _is_btrfs "$_dir" && _disable_cow "$_dir"
+ if test ! -f /etc/bitcoin/bitcoin.conf; then
+ cp /etc/bitcoin/bitcoin.conf.dist /etc/bitcoin/bitcoin.conf
+ fi
+ chown -R $_bc_user:$_bc_group /etc/bitcoin "$_dir"
+ printf "%b\n" "$bitcoin"
+}
+
+post_upgrade() {
+ _mkuser
+ chown -R $_bc_user:$_bc_group /etc/bitcoin "/var/lib/bitcoind"
+ printf "%b\n" "$bitcoin"
+}
+
+post_remove() {
+ _rmuser
+}
+
+
+# ------------------------------------------------------------------------------
+# helper functions for creating bitcoin user / group
+# ------------------------------------------------------------------------------
+
+_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 -r $_bc_user 2>/dev/null
+ echo "done"
+}
+
+
+# ------------------------------------------------------------------------------
+# helper functions for disabling btrfs Copy-On-Write (CoW)
+# https://wiki.archlinux.org/index.php/Btrfs#Copy-On-Write_.28CoW.29
+# ------------------------------------------------------------------------------
+
+# check if dir is btrfs
+_is_btrfs() {
+ if [[ $(findmnt --target $1 --output FSTYPE --noheadings) == 'btrfs' ]]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+# disable btrfs CoW
+_chattrify() {
+ # original dir, with trailing slash stripped if it exists
+ _orig_dir=$( echo "$1" | sed 's@/$@@' )
+
+ # if original dir exists, back it up
+ [[ -d "$1" ]] && mv "$1" "${_orig_dir}"_old
+
+ # re-make original dir
+ mkdir -p "$1"
+
+ # set permissions on re-made dir
+ chmod "$2" "$1"
+
+ # disable btrfs CoW on re-made dir
+ chattr +C "$1"
+
+ # recursive copy to restore backed up dir while maintaining disabled CoW
+ [[ -d "${_orig_dir}"_old ]] \
+ && find "${_orig_dir}"_old -mindepth 1 -maxdepth 1 -exec cp -R '{}' "$1" \;
+
+ # set ownership on re-made dir
+ chown -R $3:$4 "$1"
+
+ # purge backed up dir
+ [[ -d "${_orig_dir}"_old ]] && rm -rf "${_orig_dir}"_old
+}
+
+_disable_cow() {
+ _chattrify "$1" "750" "$_bc_user" "$_bc_group"
+}
+
+
+read -d '' bitcoin <<'EOF'
+########################################################################
+########################################################################
+## ##
+## Bitcoin Classic ##
+## ____________ ##
+## ##
+## To start bitcoin-classic: ##
+## ##
+## # systemctl start bitcoin ##
+## ##
+## To communicate with bitcoin-classic as a normal user: ##
+## ##
+## $ mkdir -p ~/.bitcoin ##
+## $ echo rpccookiefile=/etc/bitcoin/.cookie \\ ##
+## > ~/.bitcoin/bitcoin.conf <<'EOF' ##
+## ##
+## $ bitcoin-cli getmininginfo ##
+## ##
+## Config: /etc/bitcoin/bitcoin.conf ##
+## Blockchain: /var/lib/bitcoind ##
+## ##
+## --rpccookiefile-- ##
+## The daemon uses a special 'cookie' file for authentication. ##
+## This file is generated with random content when the daemon ##
+## starts, and deleted when it exits. Its contents are used as ##
+## authentication token. Read access to this file controls who can ##
+## access through RPC. Users pass --rpccookiefile to their calls ##
+## of bitcoin-cli ##
+## You can find the cookie at /etc/bitcoin/.cookie ##
+## ##
+########################################################################
+########################################################################
+EOF