[Pkg-bitcoin-devel] Bug#824117: bfgminer: daemon mode

Raphaël Halimi raphael.halimi at gmail.com
Thu May 12 13:04:43 UTC 2016


Package: bfgminer
Version: 5.4.2+dfsg-1
Severity: wishlist
Tags: patch

Hi,

Here's a patch to allow bfgminer to be started as a daemon at boot time.
The only missing thing is a systemd unit file, but since systemd can use
sysv init files, it can be implemented later.

Basically, it creates a user named "bfgminer" (and adds it to the video
group to access mining hardware) and starts bfgminer as that user, in a
subdirectory located in /run. I couldn't make it work with bfgminer's
chroot-dir/setuid options, so it relies on start-stop-daemon's
chdir/chuid options (it's not a real chroot though, just a running
directory writable by bfgminer user to contain generated binaries).

The running directory is created every time before start, since /run is
most often a in a tmpfs these days; also, any previously generated
binary is removed before starting, to avoid problems caused by
OpenCL/SDK upgrades (mentioned in upstream README files).

Options are configurable from both /etc/default/bfgminer and/or
/etc/bfgminer.conf. By default, it doesn't start if it's not explicitly
enabled in /etc/default/bfgminer, so for people who prefer to run
bfgminer manually, the whole patch should be completely transparent
(minus the new configuration files and logs directory).

I intentionally left a home directory (/var/lib/bfgminer) in addition to
the running directory, for possible further tweaking (configuration
snippets, bitcoin-cli credentials, etc).

The default configuration file is almost empty (it contains brackets
with nothing in between) because bfgminer chokes on a completely empty
file; additionally, the init script checks for the presence of this
file, since bfgminer also chokes if the configuration file doesn't
exist. It *could* also check if it's readable, but such a check would be
complicated to implement in the init script since it's run by root,
whereas the binary will finally be run by another user; since
/etc/bfgminer.conf permissions are set by the postinst script, IMHO such
a test is not necessary, as it would break only if a user manually
changes these permissions.

It also contains a small patch against upstream sources to make the log
file readable by group, as it's customary in Debian that members of
"adm" group should be able to read logs (/var/log/bfgminer is installed
with group "adm" and setuid group).

I think I covered most questions, but of course, if you have any, feel
free to ask.

Regards,

-- 
Raphaël Halimi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bfgminer-daemon-mode.patch
Type: text/x-diff
Size: 7955 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-bitcoin-devel/attachments/20160512/2dc73734/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 949 bytes
Desc: OpenPGP digital signature
URL: <http://lists.alioth.debian.org/pipermail/pkg-bitcoin-devel/attachments/20160512/2dc73734/attachment.sig>


More information about the Pkg-bitcoin-devel mailing list