cshelswell (OP)
|
|
October 10, 2013, 08:28:15 PM |
|
Hi I've got bitcoind installed on a headless ubuntu server to run an application. I'm just trying to get it to start on a reboot. I've had a really good search and can't find anything that I think is applicable to me. I found this: https://bitcointalk.org/?topic=965.0 but I installed bitcoin from the PPA's and there's nothing in the /etc/init.d folder. Can i just go ahead and create this script anyway? Any advice on how to get ubuntu to load bitcoind at startup would be great - thanks
|
|
|
|
dserrano5
Legendary
Offline
Activity: 1974
Merit: 1029
|
|
October 10, 2013, 08:42:03 PM |
|
Not the most professional in the world but this is what I have: $ grep bitcoin /etc/crontab @reboot btc /usr/bin/nice /home/btc/bin/bitcoind
|
|
|
|
redtwitz
|
|
October 10, 2013, 08:59:31 PM |
|
Hi I've got bitcoind installed on a headless ubuntu server to run an application. I'm just trying to get it to start on a reboot. I've had a really good search and can't find anything that I think is applicable to me. I found this: https://bitcointalk.org/?topic=965.0 but I installed bitcoin from the PPA's and there's nothing in the /etc/init.d folder. Can i just go ahead and create this script anyway? Init scripts will work, no matter where the executables came from. However, they are a hassle. Throw bitcoind in your /etc/rc.local.
If you do, be careful to execute the daemon as the proper user. On Ubuntu, the file exists by default, so adding the line su cshelswell -c bitcoind anywhere before the exit command should do the job.
|
|
|
|
cshelswell (OP)
|
|
October 10, 2013, 09:18:22 PM |
|
hey guys - thanks for your help. I think i might be missing something though as I'm not getting it working. So i've edited /etc/rc.local and added the line: rebooted but a bitcoind getinfo get's "couldn't connect to server"? I'm guessing I'm missing a step somewhere? Thanks for you help
|
|
|
|
redtwitz
|
|
October 10, 2013, 09:23:55 PM |
|
As long as myuser is a login account and bitcoind is in myuser's path, that should work (although I forgot the ampersand at the end). It should be Check that /etc/rc.local is executable. If it is and it still doesn't work, could you post its entire contents?
|
|
|
|
cshelswell (OP)
|
|
October 10, 2013, 09:34:14 PM |
|
hmm still not working. I'm assuming that bitcoind is in the path since all i have to do to start it is type "bitcoind"
thanks
|
|
|
|
redtwitz
|
|
October 10, 2013, 09:36:38 PM |
|
What else does /etc/rc.local contain? Is it executable? What haapens if you execute sudo /etc/rc.local from a terminal?
|
|
|
|
cshelswell (OP)
|
|
October 10, 2013, 09:51:28 PM |
|
hey so /etc/rc.local contains: test -e /etc/ssh/ssh_host_dsa_key || dpkg-reconfigure openssh-server myuser -c bitcoind & exit 0
if i run it as root it just does nothing. Doesn't load bitcoind which i'm assuming it should?
|
|
|
|
dserrano5
Legendary
Offline
Activity: 1974
Merit: 1029
|
|
October 10, 2013, 10:05:46 PM |
|
Specify the full path. The environment on rc.local doesn't necessarily matches the one on that user's shell. That includes $PATH.
And "su" is missing there.
|
|
|
|
redtwitz
|
|
October 10, 2013, 10:06:38 PM |
|
I see no shebang. The first line should say something like this: If "sh -e" is indeed being used, the second command won't be executed if the first one fails. To avoid this, change the first command to test -e /etc/ssh/ssh_host_dsa_key || dpkg-reconfigure openssh-server || : or the shebang to Also, the second command seems to be missing the "su" at the beginning. Specify the full path. The environment on rc.local doesn't necessarily matches the one on that user's shell. That includes $PATH.
Right. Without the "-l" switch, root's path would be used. But if "sudo /etc/rc.local" doesn't complain about a missing executable, so something else is (also) wrong.
|
|
|
|
cshelswell (OP)
|
|
October 10, 2013, 10:12:20 PM |
|
sorry the whole file is: #!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing.
test -e /etc/ssh/ssh_host_dsa_key || dpkg-reconfigure openssh-server su myuser -c bitcoind & exit 0
though if i run it now i just get: mkdir: cannot create directory ‘/home/myuser/.bitcoin’: No such file or directory I installed bitcoind as root could that be the issue? thanks for all your help!
|
|
|
|
redtwitz
|
|
October 10, 2013, 11:35:04 PM |
|
Does the directory /home/myuser exist? What happens if you login as myuser and execute bitcoind?
|
|
|
|
cshelswell (OP)
|
|
October 11, 2013, 12:40:15 AM |
|
yeah that doesn't work. Is there no way to run /etc/rc.local as root and have: test -e /etc/ssh/ssh_host_dsa_key || dpkg-reconfigure openssh-server root -c bitcoind & exit 0
Cheers
|
|
|
|
redtwitz
|
|
October 11, 2013, 02:08:21 AM |
|
Of course you can run bitcoind as root, although by the principle of least privilege, you shouldn't. In this case, the command would be just since rc.local gets executed by root anyway (the "-daemon" switch seems more natural than the ampersand). However, it looks like myuser doesn't have a hoe directory. This would be the case if you, e.g., created it with If you have already configured bitcoind as root (created a configuration file, downloaded the blockchain, etc.), do the following as root: mkdir /home/myuser mv /root/.bitcoin /home/myuser chown -R myuser:myuser /home/myuser
If not, do the following as root: mkdir -p /home/myuser/.bitcoin echo -n rpcpassword= > /home/myuser/.bitcoin/bitcoin.conf head -c 16 /dev/random | md5sum | cut -b 1-32 >> /home/myuser/.bitcoin/bitcoin.conf echo daemon=1 >> /home/myuser/.bitcoin/bitcoin.conf chown -R myuser:myuser /home/myuser chmod 600 /home/myuser/.bitcoin/bitcoin.conf
The setting "daemon=1" makes the ampersand obsolete.
|
|
|
|
|
redtwitz
|
|
October 11, 2013, 11:50:47 AM |
|
Glad you got it working.
|
|
|
|
vindimy
|
|
October 13, 2013, 05:59:56 AM |
|
If you guys want a really easy and fast way to install and manage bitcoind (or any other altcoin) and keep it up to date, consider the Opscode Chef crypto-coin cookbook. I use it for my "altcointip bot" project. It provides automated, zero-config install of any coin by compiling specific release from source. It uses upstart to control the coin service: : ~$ cat /etc/init/bitcoind.conf description bitcoind
start on runlevel [2345] stop on runlevel [016]
setuid bitcoin setgid altcointip
respawn respawn limit 10 60 # 10 times in 60 seconds
exec /opt/altcointip/coins/bitcoin/bitcoind -datadir=/opt/altcointip/coins/bitcoin/data -conf=/opt/altcointip/coins/bitcoin/bitcoin.conf Here's what final result looks like: :~$ ps aux|grep coin litecoin 664 0.4 9.3 1667632 190036 ? SLsl Oct07 37:50 /opt/altcointip/coins/litecoin/litecoind -datadir=/opt/altcointip/coins/litecoin/data -conf=/opt/altcointip/coins/litecoin/litecoin.conf ppcoin 668 0.3 3.0 867176 62248 ? Ssl Oct07 26:14 /opt/altcointip/coins/ppcoin/ppcoind -datadir=/opt/altcointip/coins/ppcoin/data -conf=/opt/altcointip/coins/ppcoin/ppcoin.conf 2007 673 0.4 4.5 1447688 93268 ? SLsl Oct07 35:19 /opt/altcointip/coins/primecoin/primecoind -datadir=/opt/altcointip/coins/primecoin/data -conf=/opt/altcointip/coins/primecoin/primecoin.conf bitcoin 676 0.7 17.1 1812184 350156 ? SLsl Oct07 65:57 /opt/altcointip/coins/bitcoin/bitcoind -datadir=/opt/altcointip/coins/bitcoin/data -conf=/opt/altcointip/coins/bitcoin/bitcoin.conf namecoin 680 0.2 10.9 834768 223228 ? Ssl Oct07 25:06 /opt/altcointip/coins/namecoin/namecoind -datadir=/opt/altcointip/coins/namecoin/data -conf=/opt/altcointip/coins/namecoin/namecoin.conf 2009 3526 0.6 4.4 917764 90960 ? Ssl Oct07 47:59 /opt/altcointip/coins/feathercoin/feathercoind -datadir=/opt/altcointip/coins/feathercoin/data -conf=/opt/altcointip/coins/feathercoin/feathercoin.conf
:~$ bitcoind getinfo { "version" : 80500, "protocolversion" : 70001, "walletversion" : 60000, "balance" : 0.68225642, "blocks" : 263287, "timeoffset" : -10, "connections" : 10, "proxy" : "", "difficulty" : 189281249.28103292, "testnet" : false, "keypoololdest" : 1376917621, "keypoolsize" : 100, "paytxfee" : 0.00010000, "unlocked_until" : 0, "errors" : "" }
|
|
|
|
|