FS#45194 - [bitcoin-daemon] Various PKGBUILD improvements
Attached to Project:
Community Packages
Opened by Johannes Ernst (jernst) - Wednesday, 03 June 2015, 21:14 GMT
Last edited by Eli Schwartz (eschwartz) - Thursday, 11 January 2018, 03:09 GMT
Opened by Johannes Ernst (jernst) - Wednesday, 03 June 2015, 21:14 GMT
Last edited by Eli Schwartz (eschwartz) - Thursday, 11 January 2018, 03:09 GMT
|
Details
Here's a patch that automates a few more of the steps for
users to get the daemon running:
* it creates the bitcoin user/group, with home directory /var/lib/bitcoin * it installs the systemd service file from the Wiki * it installs the config file in /etc/bitcoin/ and symlinks from .bitcoin I picked uid=gid=197 (not taken yet per https://wiki.archlinux.org/index.php/DeveloperWiki:UID_/_GID_Database ). If you accept my patch, we need to add a line to that wiki page and remove the FIXME line in the PKGBUILD. commit 98b08d1789e2f3d5dbd0b4a4c655e086557aecda Author: Johannes Ernst <jernst@indiecomputing.com> Date: Fri May 15 21:03:58 2015 +0000 Create bitcoin user/group, add system service file, conf file in /etc diff --git a/PKGBUILD b/PKGBUILD index ece1f57..17892e7 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,15 +1,19 @@ # $Id$ # Maintainer: Timothy Redaelli <timothy.redaelli@gmail.com> # Contributor: shahid <helllamer@gmail.com> +# Contributor: Johannes Ernst <johannes.ernst@gmail.com> + +# FIXME: claim uid=gid=197 on https://wiki.archlinux.org/index.php/DeveloperWiki:UID_/_GID_Database pkgbase=bitcoin pkgname=('bitcoin-daemon' 'bitcoin-cli' 'bitcoin-qt') pkgver=0.10.1 -pkgrel=1 +pkgrel=2 arch=('i686' 'x86_64') url="http://www.bitcoin.org/" makedepends=('boost' 'automoc4' 'qrencode' 'miniupnpc' 'protobuf') license=('MIT') +backup=('/etc/bitcoin/bitcoin.conf') source=(http://bitcoin.org/bin/bitcoin-core-$pkgver/bitcoin-$pkgver.tar.gz https://raw.github.com/bitcoin/bitcoin/v$pkgver/contrib/debian/bitcoin-qt.desktop https://raw.github.com/bitcoin/bitcoin/v$pkgver/share/pixmaps/bitcoin128.png @@ -58,9 +62,12 @@ package_bitcoin-qt() { package_bitcoin-daemon() { pkgdesc="Bitcoin is a peer-to-peer network based digital currency - daemon" depends=(boost-libs miniupnpc openssl) + install=bitcoin-daemon.install cd "$pkgbase-$pkgver" install -Dm755 src/bitcoind "$pkgdir"/usr/bin/bitcoind + mkdir -p -m750 "$pkgdir/var/lib/bitcoin/.bitcoin" + chown 197:197 "$pkgdir/var/lib/bitcoin/.bitcoin" install -Dm644 "$srcdir"/bitcoin.conf \ "$pkgdir/usr/share/doc/$pkgname/examples/bitcoin.conf" install -Dm644 "$srcdir"/bitcoind.1 \ @@ -68,6 +75,12 @@ package_bitcoin-daemon() { install -Dm644 "$srcdir"/bitcoin.conf.5 \ "$pkgdir"/usr/share/man/man5/bitcoin.conf.5 install -Dm644 COPYING "$pkgdir/usr/share/licenses/$pkgname/COPYING" + install -Dm644 "$startdir"/bitcoind.service \ + "$pkgdir"/usr/lib/systemd/system/bitcoind.service + mkdir -p -m755 "$pkgdir/etc/bitcoin/" + install -m640 "$srcdir"/bitcoin.conf \ + "$pkgdir/etc/bitcoin/bitcoin.conf" + ln -s /etc/bitcoin/bitcoin.conf "$pkgdir/var/lib/bitcoin/.bitcoin/bitcoin.conf" } package_bitcoin-cli() { diff --git a/bitcoin-daemon.install b/bitcoin-daemon.install new file mode 100644 index 0000000..1092524 --- /dev/null +++ b/bitcoin-daemon.install @@ -0,0 +1,15 @@ +post_install() { + getent group bitcoin &>/dev/null || groupadd -r -g 197 bitcoin >/dev/null + getent passwd bitcoin &>/dev/null || useradd -r -u 197 -g bitcoin -d /var/lib/bitcoin -s /bin/false -c bitcoin bitcoin >/dev/null + chown -R bitcoin:bitcoin /var/lib/bitcoin + echo Before starting bitcoind.service, you must edit /etc/bitcoin/bitcoin.conf + echo and set 'rpcuser' and a hard-to-guess 'rpcpassword'. + true +} + +post_remove() { + getent passwd bitcoin &>/dev/null && userdel bitcoin >/dev/null + getent group bitcoin &>/dev/null && groupdel bitcoin >/dev/null + true +} + diff --git a/bitcoind.service b/bitcoind.service new file mode 100644 index 0000000..92701e0 --- /dev/null +++ b/bitcoind.service @@ -0,0 +1,11 @@ +[Unit] +Description=Bitcoin daemon service +After=network.target + +[Service] +Type=simple +User=bitcoin +ExecStart=/usr/bin/bitcoind + +[Install] +WantedBy=multi-user.target |
This task depends upon
Closed by Eli Schwartz (eschwartz)
Thursday, 11 January 2018, 03:09 GMT
Reason for closing: Fixed
Additional comments about closing: bitcoin 0.15.1-4
Thursday, 11 January 2018, 03:09 GMT
Reason for closing: Fixed
Additional comments about closing: bitcoin 0.15.1-4
I'll consider to rework it and add it on next version bump
@jernst, the best thing to do would be to create the user/group and home directory via sysusers.d(5) and tmpfiles.d(5)
See e.g. https://www.archlinux.org/todo/pacman-hooks-systemd-sysuserstmpfiles/
Question: Is it absolutely necessary for a hardcoded uid/gid or was that just a workaround for packaging /var/lib/bitcoin in the package (which should now be done via tmpfiles.d)?
Aside: please submit patches as attachments rather than inline text, the bugtracker mangles whitespace when displaying comments. :D
Courtesy of
FS#52325The fact that it included an implementation patch as a a suggestion, should not be taken to mean that we should close the feature request as soon as the patch is stale. This discourages people from offering to help implement changes... -_-
As per the original request, it would be nice if the package provided:
1) The contrib service file.
2) A basic conf file.
3) A sysusers/tmpfiles description of the daemon user.
Currently, none of those things are true. Please either implement them, or reject them as something you feel the package *should* not do.