summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Weidenbaum2015-06-09 11:41:58 -0700
committerAndy Weidenbaum2015-06-09 11:41:58 -0700
commite678c90e4c295cdfcbb232664f0c47326e845978 (patch)
treec8dcf8e695f4df500093d02f97b5b61f63a7b631
downloadaur-e678c90e4c295cdfcbb232664f0c47326e845978.tar.gz
Initial import
-rw-r--r--.SRCINFO42
-rw-r--r--PKGBUILD106
-rw-r--r--bs.install99
-rw-r--r--bs.logrotate10
-rw-r--r--bs.service14
-rw-r--r--bsinit.service12
6 files changed, 283 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 00000000000..2228676ab87
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,42 @@
+pkgbase = libbitcoin-server-git
+ pkgdesc = Bitcoin Full Node and Query Server
+ pkgver = 20150519
+ pkgrel = 2
+ url = https://github.com/libbitcoin/libbitcoin-server
+ install = bs.install
+ arch = i686
+ arch = x86_64
+ groups = libbitcoin
+ license = AGPL3
+ makedepends = autoconf
+ makedepends = automake
+ makedepends = gcc
+ makedepends = git
+ makedepends = libconfig
+ makedepends = libtool
+ makedepends = make
+ makedepends = pkg-config
+ depends = boost
+ depends = boost-libs
+ depends = czmq-git
+ depends = czmqpp-git
+ depends = libbitcoin-node-git
+ depends = libsodium
+ depends = secp256k1-git
+ depends = zeromq
+ optdepends = libbitcoin-explorer: CurveZMQ client/server authentication
+ provides = libbitcoin-server
+ conflicts = libbitcoin-server
+ source = git+https://github.com/libbitcoin/libbitcoin-server
+ source = git+https://github.com/libbitcoin/libbitcoin-server.wiki
+ source = bs.logrotate
+ source = bs.service
+ source = bsinit.service
+ sha256sums = SKIP
+ sha256sums = SKIP
+ sha256sums = 09ea3d2bf7cb87a0760c2a73893d62d1868d232c9e925cabf6140b1b031efee3
+ sha256sums = 564112d0860f1523049bd89779e1b1bfc189a3d143d2cc808441981ed793658a
+ sha256sums = 2bcf3615cd8e5ba6d4c78429b018b9bf756d5fad6ab879963a13f19e47315c7d
+
+pkgname = libbitcoin-server-git
+
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 00000000000..1befa366325
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,106 @@
+# Maintainer: Andy Weidenbaum <archbaum@gmail.com>
+
+pkgname=libbitcoin-server-git
+pkgver=20150519
+pkgrel=2
+pkgdesc="Bitcoin Full Node and Query Server"
+arch=('i686' 'x86_64')
+depends=('boost'
+ 'boost-libs'
+ 'czmq-git'
+ 'czmqpp-git'
+ 'libbitcoin-node-git'
+ 'libsodium'
+ 'secp256k1-git'
+ 'zeromq')
+makedepends=('autoconf'
+ 'automake'
+ 'gcc'
+ 'git'
+ 'libconfig'
+ 'libtool'
+ 'make'
+ 'pkg-config')
+optdepends=('libbitcoin-explorer: CurveZMQ client/server authentication')
+groups=('libbitcoin')
+url="https://github.com/libbitcoin/libbitcoin-server"
+license=('AGPL3')
+source=(git+https://github.com/libbitcoin/libbitcoin-server
+ git+https://github.com/libbitcoin/libbitcoin-server.wiki
+ bs.logrotate
+ bs.service
+ bsinit.service)
+sha256sums=('SKIP'
+ 'SKIP'
+ '09ea3d2bf7cb87a0760c2a73893d62d1868d232c9e925cabf6140b1b031efee3'
+ '564112d0860f1523049bd89779e1b1bfc189a3d143d2cc808441981ed793658a'
+ '2bcf3615cd8e5ba6d4c78429b018b9bf756d5fad6ab879963a13f19e47315c7d')
+provides=('libbitcoin-server')
+conflicts=('libbitcoin-server')
+install=bs.install
+
+pkgver() {
+ cd ${pkgname%-git}
+ git log -1 --format="%cd" --date=short | sed "s|-||g"
+}
+
+prepare() {
+ cd ${pkgname%-git}
+
+ msg2 'Configuring...'
+ cp -dpr --no-preserve=ownership data/bs.cfg data/bs.cfg.in
+ sed -i 's@^blockchain_path.*@blockchain_path = /srv/bs/blockchain@' data/bs.cfg.in
+ sed -i 's@^debug_file.*@debug_file = /var/log/bs/debug.log@' data/bs.cfg.in
+ sed -i 's@^error_file.*@error_file = /var/log/bs/error.log@' data/bs.cfg.in
+ sed -i 's@^hosts_file.*@hosts_file = /etc/bs/hosts@' data/bs.cfg.in
+}
+
+build() {
+ cd ${pkgname%-git}
+
+ msg2 'Building...'
+ ./autogen.sh
+ ./configure \
+ --prefix=/usr \
+ --sbindir=/usr/bin \
+ --libexecdir=/usr/lib/libbitcoin-server \
+ --sysconfdir=/etc \
+ --sharedstatedir=/usr/share/libbitcoin-server \
+ --localstatedir=/var/lib/libbitcoin-server \
+ --with-bash-completiondir=/usr/share/bash-completion/completions \
+ --with-gnu-ld
+ make
+}
+
+package() {
+ cd ${pkgname%-git}
+
+ msg2 'Installing license...'
+ install -Dm 644 COPYING "$pkgdir/usr/share/licenses/libbitcoin-server/COPYING"
+
+ msg2 'Installing...'
+ install -dm 700 "$pkgdir/etc/bs"
+ install -dm 700 "$pkgdir/srv/bs"
+ make DESTDIR="$pkgdir" install
+
+ msg2 'Installing documentation...'
+ cp -dpr --no-preserve=ownership "$srcdir/libbitcoin-server.wiki" \
+ "$pkgdir/usr/share/doc/libbitcoin-server/wiki"
+
+ msg2 'Installing conf...'
+ install -Dm 600 data/bs.cfg.in "$pkgdir/etc/bs/bs.cfg"
+
+ msg2 'Installing systemd service files...'
+ install -Dm 644 "$srcdir/bs.service" \
+ "$pkgdir/usr/lib/systemd/system/bs.service"
+ install -Dm 644 "$srcdir/bsinit.service" \
+ "$pkgdir/usr/lib/systemd/system/bsinit.service"
+
+ msg2 'Installing logrotate conf...'
+ install -dm 700 "$pkgdir/var/log/bs"
+ install -Dm 644 "$srcdir/bs.logrotate" "$pkgdir/etc/logrotate.d/bs"
+
+ msg2 'Cleaning up pkgdir...'
+ find "$pkgdir" -type d -name .git -exec rm -r '{}' +
+ find "$pkgdir" -type f -name .gitignore -exec rm -r '{}' +
+}
diff --git a/bs.install b/bs.install
new file mode 100644
index 00000000000..8ba8f146cce
--- /dev/null
+++ b/bs.install
@@ -0,0 +1,99 @@
+_bs_user=bs
+_bs_group=bs
+
+post_install() {
+ _mkuser
+ _disable_cow
+ chown -R $_bs_user:$_bs_group /etc/bs /srv/bs /var/log/bs
+ printf "%b\n" "$xx"
+}
+
+post_remove() {
+ _rmuser
+ rm -rf /etc/bs /srv/bs /var/log/bs
+}
+
+
+# ------------------------------------------------------------------------------
+# helper functions for creating libbitcoin-server user / group
+# ------------------------------------------------------------------------------
+
+_mkuser() {
+ getent passwd $_bs_user &>/dev/null || {
+ echo -n "Creating libbitcoin-server user... "
+ grep -E "^$_bs_group:" /etc/group >/dev/null || groupadd $_bs_group
+ useradd -m -d /etc/bs -g $_bs_group -s /usr/bin/nologin $_bs_user
+ echo "done"
+ }
+}
+
+_rmuser() {
+ echo -n "Removing libbitcoin-server user... "
+ userdel -rf $_bs_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 [[ $(df -TP "$1" | tail -n 1 | awk '{print $2}') == '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 mainintaining 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
+}
+
+# if blockchain or log dir has btrfs filesystem, disable CoW:
+_disable_cow() {
+ for _dir in /srv/bs /var/log/bs; do
+ _is_btrfs "$_dir" && _chattrify "$_dir" "700" "$_bs_user" "$_bs_group"
+ done
+}
+
+read -d '' xx <<'EOF'
+libbitcoin-server
+=================
+
+To run normally:
+
+ $ bs --initchain /path/to/bs/config/file
+ $ bs /path/to/bs/config/file
+
+To run as a service:
+
+ $ sudo systemctl start bsinit # wait several mins for blockchain dir to init
+ $ sudo systemctl start bs
+EOF
diff --git a/bs.logrotate b/bs.logrotate
new file mode 100644
index 00000000000..ff5f541eb65
--- /dev/null
+++ b/bs.logrotate
@@ -0,0 +1,10 @@
+/var/log/bs/*.log {
+ size 5M
+ missingok
+ rotate 7
+ compress
+ delaycompress
+ notifempty
+ create 644 bs bs
+ sharedscripts
+}
diff --git a/bs.service b/bs.service
new file mode 100644
index 00000000000..2ba2ad5d05e
--- /dev/null
+++ b/bs.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Libbitcoin server: a full Bitcoin node in the global peer-to-peer network
+Conflicts=bsinit.service
+
+[Service]
+Type=simple
+User=bs
+Group=bs
+ExecStart=/usr/bin/bs /etc/bs/bs.cfg
+ExecReload=/usr/bin/kill -s SIGHUP $MAINPID
+ExecStop=/usr/bin/kill -s SIGINT $MAINPID
+
+[Install]
+WantedBy=multi-user.target
diff --git a/bsinit.service b/bsinit.service
new file mode 100644
index 00000000000..6b6acfd9b1a
--- /dev/null
+++ b/bsinit.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Libbitcoin server: initialize database in the configured directory
+Conflicts=bs.service
+
+[Service]
+Type=oneshot
+User=bs
+Group=bs
+ExecStart=/usr/bin/bs -i /etc/bs/bs.cfg
+
+[Install]
+WantedBy=multi-user.target