Skip to content

Commit 35eb9d6

Browse files
committed
Merge #12769: Add systemd service to bitcoind in debian package
2a87b1b Add systemd service for bitcoind (ctp-tsteenholdt) 9085532 Sync contrib/debian from Matt Corallo's PPA (ctp-tsteenholdt) Pull request description: On suggestion from @TheBlueMatt I have updated `contrib/debian` files to include a systemd service in the `bitcoind` build. Tested and working on Ubuntu 16.04 and 17.10. This fixes Issue #12758 Tree-SHA512: b6137fafee940c7410df1242c8716a87f47c5bc60eb8df3ad0184a50c2d67ef3f2728761c742670a0ad546ab6e7ad60472a721350cd6280b3bcbdc582e50ee07
2 parents c5f7efe + 2a87b1b commit 35eb9d6

File tree

10 files changed

+235
-9
lines changed

10 files changed

+235
-9
lines changed

contrib/debian/bitcoin-qt.desktop

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[Desktop Entry]
2-
Version=1.0
2+
Encoding=UTF-8
33
Name=Bitcoin Core
44
Comment=Connect to the Bitcoin P2P Network
55
Comment[de]=Verbinde mit dem Bitcoin peer-to-peer Netzwerk
@@ -11,4 +11,3 @@ Type=Application
1111
Icon=bitcoin128
1212
MimeType=x-scheme-handler/bitcoin;
1313
Categories=Office;Finance;P2P;Network;Qt;
14-
StartupWMClass=Bitcoin-qt

contrib/debian/bitcoind.install

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
usr/local/bin/bitcoind usr/bin
22
usr/local/bin/bitcoin-cli usr/bin
3+
debian/examples/bitcoin.conf etc/bitcoin

contrib/debian/bitcoind.postinst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/sh
2+
3+
# setup bitcoin account, homedir etc
4+
5+
set -e
6+
7+
BCUSER="bitcoin"
8+
BCHOME="/var/lib/bitcoin"
9+
10+
if [ "$1" = "configure" ]; then
11+
12+
# Add bitcoin user/group - this will gracefully abort if the user already exists.
13+
# A homedir is never created.
14+
adduser --system --home "${BCHOME}" --no-create-home --group "${BCUSER}"
15+
16+
# If the homedir does not already exist, create it with proper
17+
# ownership and permissions.
18+
if [ ! -d "${BCHOME}" ]; then
19+
mkdir -m 0750 -p "${BCHOME}"
20+
chown "${BCUSER}:${BCUSER}" "${BCHOME}"
21+
fi
22+
23+
fi
24+
25+
#DEBHELPER#
26+
27+
exit 0

contrib/debian/bitcoind.postrm

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/sh
2+
3+
# setup bitcoin account, homedir etc
4+
5+
set -e
6+
7+
BCUSER="bitcoin"
8+
BCHOME="/var/lib/bitcoin"
9+
10+
if [ "$1" = "purge" ]; then
11+
12+
# The bitcoin user is left in place for now - This is to ensure that a new user
13+
# will not inherit the users UID/GID and inadvertently gain access to wallets etc
14+
15+
# The homedir is also left intact to ensure that we don't accidentally delete a
16+
# wallet or something equally important
17+
18+
echo
19+
echo "#"
20+
echo "# The bitcoin user (${BCUSER}) and data dir (${BCHOME})"
21+
echo "# were left intact."
22+
echo "#"
23+
echo "# Make sure to check \"${BCHOME}\" for wallets and other"
24+
echo "# important bits."
25+
echo "#"
26+
echo "# After backing up all vital data, cleanup can be completed"
27+
echo "# by running: sudo userdel -r ${BCUSER}"
28+
echo "#"
29+
echo
30+
31+
fi
32+
33+
#DEBHELPER#
34+
35+
exit 0

contrib/debian/bitcoind.service

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# It is not recommended to modify this file in-place, because it will
2+
# be overwritten during package upgrades. If you want to add further
3+
# options or overwrite existing ones then use
4+
# $ systemctl edit bitcoind.service
5+
# See "man systemd.service" for details.
6+
7+
# Note that almost all daemon options could be specified in
8+
# /etc/bitcoin/bitcoin.conf
9+
10+
[Unit]
11+
Description=Bitcoin daemon
12+
After=network.target
13+
14+
[Service]
15+
ExecStart=/usr/bin/bitcoind -daemon -datadir=/var/lib/bitcoin -conf=/etc/bitcoin/bitcoin.conf -pid=/run/bitcoind/bitcoind.pid
16+
# Creates /run/bitcoind owned by bitcoin
17+
RuntimeDirectory=bitcoind
18+
User=bitcoin
19+
Type=forking
20+
PIDFile=/run/bitcoind/bitcoind.pid
21+
Restart=on-failure
22+
23+
# Hardening measures
24+
####################
25+
26+
# Provide a private /tmp and /var/tmp.
27+
PrivateTmp=true
28+
29+
# Mount /usr, /boot/ and /etc read-only for the process.
30+
ProtectSystem=full
31+
32+
# Disallow the process and all of its children to gain
33+
# new privileges through execve().
34+
NoNewPrivileges=true
35+
36+
# Use a new /dev namespace only populated with API pseudo devices
37+
# such as /dev/null, /dev/zero and /dev/random.
38+
PrivateDevices=true
39+
40+
# Deny the creation of writable and executable memory mappings.
41+
# Commented out as it's not supported on Debian 8 or Ubuntu 16.04 LTS
42+
#MemoryDenyWriteExecute=true
43+
44+
[Install]
45+
WantedBy=multi-user.target

contrib/debian/changelog

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,95 @@
1+
bitcoin (0.16.0-trusty2) trusty; urgency=medium
2+
3+
* Add systemd service to bitcoind
4+
5+
-- Thomas M Steenholdt <[email protected]> Wed, 18 Apr 2018 16:40:00 -0200
6+
7+
bitcoin (0.16.0-xenial1) xenial; urgency=medium
8+
9+
* Mark for xenial.
10+
11+
-- Matt Corallo (BlueMatt) <[email protected]> Mon, 05 Mar 2018 11:20:00 -0500
12+
13+
bitcoin (0.16.0-trusty1) trusty; urgency=medium
14+
15+
* New upstream release.
16+
17+
-- Matt Corallo (BlueMatt) <[email protected]> Mon, 05 Mar 2018 11:18:00 -0500
18+
19+
bitcoin (0.15.1-trusty1) trusty; urgency=medium
20+
21+
* New upstream release.
22+
* Remove backported patches (which are now upstream).
23+
24+
-- Matt Corallo (BlueMatt) <[email protected]> Sat, 11 Nov 2017 16:51:00 -0500
25+
26+
bitcoin (0.15.0-artful9) artful; urgency=medium
27+
28+
* Mark for artful.
29+
30+
-- Matt Corallo (BlueMatt) <[email protected]> Sat, 21 Oct 2017 20:56:00 -0400
31+
32+
bitcoin (0.15.0-trusty9) trusty; urgency=medium
33+
34+
* Add missing xvfb dep.
35+
36+
-- Matt Corallo (BlueMatt) <[email protected]> Thu, 14 Sep 2017 22:47:00 -0400
37+
38+
bitcoin (0.15.0-trusty8) trusty; urgency=medium
39+
40+
* Backport #11332 to fix Qt settings upgrade segfault.
41+
* Use qt5 on arm to fix Qt test segfault.
42+
43+
-- Matt Corallo (BlueMatt) <[email protected]> Thu, 14 Sep 2017 22:03:00 -0400
44+
45+
bitcoin (0.15.0-trusty7) trusty; urgency=medium
46+
47+
* Backport #11210 to fix build inside launchpad.
48+
49+
-- Matt Corallo (BlueMatt) <[email protected]> Tue, 12 Sep 2017 16:13:00 -0400
50+
51+
bitcoin (0.15.0-trusty6) trusty; urgency=medium
52+
53+
* Make launchpad print more debug information.
54+
55+
-- Matt Corallo (BlueMatt) <[email protected]> Tue, 12 Sep 2017 12:50:00 -0400
56+
57+
bitcoin (0.15.0-trusty5) trusty; urgency=medium
58+
59+
* Use proper makefile comparison to fix Xvfb start.
60+
61+
-- Matt Corallo (BlueMatt) <[email protected]> Tue, 12 Sep 2017 12:49:00 -0400
62+
63+
bitcoin (0.15.0-trusty4) trusty; urgency=medium
64+
65+
* Use full path for start-stop-daemon to fix Xvfb start.
66+
67+
-- Matt Corallo (BlueMatt) <[email protected]> Tue, 12 Sep 2017 11:44:00 -0400
68+
69+
bitcoin (0.15.0-trusty3) trusty; urgency=medium
70+
71+
* Fix DISPLAY setting when using xvfb.
72+
73+
-- Matt Corallo (BlueMatt) <[email protected]> Mon, 11 Sep 2017 20:06:00 -0400
74+
75+
bitcoin (0.15.0-trusty2) trusty; urgency=medium
76+
77+
* Use xvfb to run qt4 tests.
78+
79+
-- Matt Corallo (BlueMatt) <[email protected]> Mon, 11 Sep 2017 17:31:00 -0400
80+
81+
bitcoin (0.15.0-trusty1) trusty; urgency=medium
82+
83+
* New upstream release.
84+
85+
-- Matt Corallo (BlueMatt) <[email protected]> Mon, 11 Sep 2017 16:17:00 -0400
86+
87+
bitcoin (0.14.2-trusty1) trusty; urgency=medium
88+
89+
* New upstream release.
90+
91+
-- Matt Corallo (BlueMatt) <[email protected]> Fri, 23 Jun 2017 18:21:00 -0400
92+
193
bitcoin (0.14.1-trusty4) trusty; urgency=medium
294

395
* Re-enable UPnP support.

contrib/debian/control

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,21 @@ Build-Depends: debhelper,
2020
libboost-chrono1.48-dev | libboost-chrono-dev (>> 1.47),
2121
libminiupnpc8-dev | libminiupnpc-dev,
2222
qt4-qmake, libqt4-dev,
23+
xvfb,
2324
qttools5-dev-tools, qttools5-dev,
2425
libqrencode-dev,
2526
libprotobuf-dev, protobuf-compiler,
2627
python,
27-
libzmq3-dev
28+
libzmq3-dev,
29+
dh-systemd
2830
Standards-Version: 3.9.2
2931
Homepage: https://bitcoincore.org/
3032
Vcs-Git: git://github.com/bitcoin/bitcoin.git
3133
Vcs-Browser: https://github.com/bitcoin/bitcoin
3234

3335
Package: bitcoind
3436
Architecture: any
35-
Depends: ${shlibs:Depends}, ${misc:Depends}
37+
Depends: ${shlibs:Depends}, ${misc:Depends}, adduser
3638
Description: peer-to-peer network based digital currency - daemon
3739
Bitcoin is a free open source peer-to-peer electronic cash system that
3840
is completely decentralized, without the need for a central server or

contrib/debian/examples/bitcoin.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@
7676
#rpcuser=Ulysseys
7777
#rpcpassword=YourSuperGreatPasswordNumber_DO_NOT_USE_THIS_OR_YOU_WILL_GET_ROBBED_385593
7878
#
79-
# The second method `rpcauth` can be added to server startup argument. It is set at initialization time
80-
# using the output from the script in share/rpcauth/rpcauth.py after providing a username:
79+
# The second method `rpcauth` can be added to server startup argument. It is set at intialization time
80+
# using the output from the script in share/rpcuser/rpcuser.py after providing a username:
8181
#
82-
# ./share/rpcauth/rpcauth.py alice
82+
# ./share/rpcuser/rpcuser.py alice
8383
# String to be appended to bitcoin.conf:
8484
# rpcauth=alice:f7efda5c189b999524f151318c0c86$d5b51b3beffbc02b724e5d095828e0bc8b2456e9ac8757ae3211a5d9b16a22ae
8585
# Your password:

contrib/debian/patches/series

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-

contrib/debian/rules

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,44 @@
66
# $(if $(filter nocheck,$(DEB_BUILD_OPTIONS)),,src/test_bitcoin)
77

88
%:
9-
dh --with bash-completion $@
9+
dh --with bash-completion --with systemd $@
1010

1111
override_dh_auto_clean:
1212
if [ -f Makefile ]; then $(MAKE) distclean; fi
1313
rm -rf Makefile.in aclocal.m4 configure src/Makefile.in src/bitcoin-config.h.in src/build-aux src/qt/Makefile.in src/qt/test/Makefile.in src/test/Makefile.in
1414

1515
QT=$(shell dpkg-vendor --derives-from Ubuntu && echo qt4 || echo qt5)
16+
# qt4 is very broken on arm
17+
ifeq ($(findstring arm,$(shell uname -m)),arm)
18+
QT=qt5
19+
endif
20+
ifeq ($(findstring aarch64,$(shell uname -m)),aarch64)
21+
QT=qt5
22+
endif
1623

1724
# Yea, autogen should be run on the source archive, but I like doing git archive
1825
override_dh_auto_configure:
1926
./autogen.sh
2027
./configure --with-gui=$(QT)
2128

2229
override_dh_auto_test:
30+
ifeq ($(QT), qt4)
31+
xvfb-run -n 99 -l make check
32+
else
2333
make check
34+
endif
35+
36+
# No SysV or Upstart init scripts included
37+
override_dh_installinit:
38+
dh_installinit \
39+
--noscripts
40+
41+
# Don’t enable service by default
42+
override_dh_systemd_enable:
43+
dh_systemd_enable \
44+
--no-enable
45+
46+
# Restart after upgrade
47+
override_dh_systemd_start:
48+
dh_systemd_start \
49+
--restart-after-upgrade

0 commit comments

Comments
 (0)