Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 500602 - net-p2p/{bitcoind, litecoind,ppcoind,datacoin-hp,primecoind}: init script should not use pkg-config
Summary: net-p2p/{bitcoind, litecoind,ppcoind,datacoin-hp,primecoind}: init script sho...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Anthony Basile
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-07 09:20 UTC by ViliusSutkus89
Modified: 2014-02-25 18:28 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
bitcoin.initd (bitcoin.initd,747 bytes, text/plain)
2014-02-07 10:06 UTC, Lars Wendler (Polynomial-C) (RETIRED)
Details
bitcoin.initd (bitcoin.initd,747 bytes, text/plain)
2014-02-07 14:02 UTC, Lars Wendler (Polynomial-C) (RETIRED)
Details
bitcoin.initd (bitcoin.initd,761 bytes, text/plain)
2014-02-07 14:36 UTC, Lars Wendler (Polynomial-C) (RETIRED)
Details
bitcoin.initd (bitcoin.initd,831 bytes, text/plain)
2014-02-07 15:33 UTC, Lars Wendler (Polynomial-C) (RETIRED)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ViliusSutkus89 2014-02-07 09:20:41 UTC
Steps to reproduce:
1. emerge bitcoind
2. emerge --depclean --with-bdeps=y    (pkgconfig is depcleaned)
3. /etc/init.d/bitcoind start
See message in terminal:
/etc/init.d/bitcoind: line 46: pkg-config: command not found
Comment 1 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2014-02-07 10:05:20 UTC
This is one of the worst init scripts in Gentoo I've ever seen.
Comment 2 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2014-02-07 10:06:54 UTC
Created attachment 369772 [details]
bitcoin.initd

Please find attached a rewritten init script.

I haven't tested it as I don't use bitcoind but if someone else tests it and reports any possible problems here I'm happy to help sorting these problems out.
Comment 3 ViliusSutkus89 2014-02-07 11:09:20 UTC
Lars, is that the whole init script?

Not that I'm an expert on the topic, but I think it may be missing some start(), stop() functions.
Comment 4 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2014-02-07 12:45:23 UTC
(In reply to palme3000 from comment #3)
> Lars, is that the whole init script?
> 
> Not that I'm an expert on the topic, but I think it may be missing some
> start(), stop() functions.

Yes, that is the whole init script. 
Openrc adds default start()/stop() functions when the init script doesn't come with its own functions.

If you don't believe me, just have a look at /etc/init.d/rsyncd script  ;)
Comment 5 ViliusSutkus89 2014-02-07 13:38:26 UTC
It's really hard to believe it when `ps aux | grep bitcoin` gives 0 results :D

- bitcoind_user="${BITCOIND_USER:-nobody:nobody}
+ bitcoind_user="${BITCOIN_USER:-nobody:nobody}

- star_pre() {
+ start_pre() {
Comment 6 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2014-02-07 14:02:02 UTC
Created attachment 369792 [details]
bitcoin.initd

(In reply to palme3000 from comment #5)
> It's really hard to believe it when `ps aux | grep bitcoin` gives 0 results
> :D
> 
> - bitcoind_user="${BITCOIND_USER:-nobody:nobody}
> + bitcoind_user="${BITCOIN_USER:-nobody:nobody}
> 
> - star_pre() {
> + start_pre() {

Thanks for the fixes. I assume these fixes were enough to make the init script work?

Attached is an updated init script with your fixes included.
Comment 7 ViliusSutkus89 2014-02-07 14:12:24 UTC
I believe so.

One pet peeve is that if bitcoind fails to start, because for example data dir is read-only, there's not much errors displayed by openrc script.
Comment 8 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2014-02-07 14:36:58 UTC
Created attachment 369794 [details]
bitcoin.initd

(In reply to palme3000 from comment #7)
> I believe so.
> 
> One pet peeve is that if bitcoind fails to start, because for example data
> dir is read-only, there's not much errors displayed by openrc script.

That might be because I forgot to re-implement the "--wait 30000" option. Attached is (another) fixed version of the init script which might take care of that problem.
Comment 9 ViliusSutkus89 2014-02-07 14:56:14 UTC
Maybe --wait 3000 ? 30000 is really long if you have bitcoind in default runlevel.

Other than that, it's all good.
Comment 10 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2014-02-07 15:07:11 UTC
(In reply to palme3000 from comment #9)
> Maybe --wait 3000 ? 30000 is really long if you have bitcoind in default
> runlevel.
> 
> Other than that, it's all good.

30000 is the value in the old init script for stopping the daemon. If you can confirm that waiting 3000 milliseconds is enough for openrc to see bitcoind being stopped then I have no problems in reducing the wait time. If you want you can also try a wait value of 2000 milliseconds. That is the wait time for startup with openrc in the old script.
Comment 11 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2014-02-07 15:33:51 UTC
Created attachment 369802 [details]
bitcoin.initd

Okay, I just read in start-stop-daemon man page that you cannot use --wait when stopping a daemon (although this used to work once).
So here's another reworked script with --wait milliseconds for startup set to 2000.
Comment 12 Anthony Basile gentoo-dev 2014-02-16 23:54:58 UTC
(In reply to Lars Wendler (Polynomial-C) from comment #11)
> Created attachment 369802 [details]
> bitcoin.initd
> 
> Okay, I just read in start-stop-daemon man page that you cannot use --wait
> when stopping a daemon (although this used to work once).
> So here's another reworked script with --wait milliseconds for startup set
> to 2000.

Lars, is this ready to go?  I'll commit with a rev bump.
Comment 13 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2014-02-17 05:41:36 UTC
(In reply to Anthony Basile from comment #12)
> 
> Lars, is this ready to go?  I'll commit with a rev bump.

Yes, this is ready to go.
Comment 14 Anthony Basile gentoo-dev 2014-02-21 14:29:40 UTC
(In reply to Lars Wendler (Polynomial-C) from comment #13)
> (In reply to Anthony Basile from comment #12)
> > 
> > Lars, is this ready to go?  I'll commit with a rev bump.
> 
> Yes, this is ready to go.

Okay this is on the tree with bitcoind-0.8.6-r1.  Please test!

Note that I also maintain the following:

    litecoind
    ppcoind
    datacoin-hp
    primecoind

where I just copied over the original initd from the bitcoin overlay and edited it for the different names.  Once I've gotten feedback about whether the new initd works, I'll propagate the fixed initd there.  Please don't close this bug, let me do it.
Comment 15 ViliusSutkus89 2014-02-25 16:39:20 UTC
Hey.
Just tested latest bump, can confirm that it works fine.
Lars, Anthony, thanks for the updates.
Comment 16 Anthony Basile gentoo-dev 2014-02-25 18:28:42 UTC
(In reply to palme3000 from comment #15)
> Hey.
> Just tested latest bump, can confirm that it works fine.
> Lars, Anthony, thanks for the updates.

Thanks for testing.  I've now added the improved initd script to

    litecoind
    ppcoind
    datacoin-hp
    primecoind

I don't know if you're using those, but if you are, please test there too.  Reopen this bug if there's still an issue.

Thanks everyone!