Pages:
Author

Topic: 1 BTC for basic linux info - How to auto start namecoind and pushpoold (Read 3102 times)

hero member
Activity: 780
Merit: 510
Bitcoin - helping to end bankster enslavement.
After reading the request from the last guy I decided to figure it out myself or work around the problems.

First I found out that namecoind was not starting because it was running under a user that was not root and was looking for bitcoin.conf file in /home/user/.namecoin/ folder.

So I moved everything from the /root/.namecoin folder to the user's home folder.

Then there was a bunch of other issues such as permissions on many folders and files need to be changed for both namcoind and pushpoold

chown user folder
chmod 777 folder


Then timing issues, moved sleeps here and there and boom it all worked just not under root.

not sure if there is a way to make it run the script as root but some people say that's not a good thing to do I guess if the software has buffer over run vulnerably if the app is not running as root he can't do much damage.

Anyhow I guess I will pay myself one BTC.

sr. member
Activity: 298
Merit: 252
PM me and for 1.5 BTC I can work on it personally or have one of our techs do it since we run those services all the time on our servers and are used to them. (1.5 because of the low price of the BTC right now)

What we can also do is run a screen session so you can watch how we fix it in real-time so you know exactly what we did also.

Just would need SSH login information for the server in question and root access.
hero member
Activity: 780
Merit: 510
Bitcoin - helping to end bankster enslavement.
Why did this not work?

Code:
update-rc.d namecoin defaults;

running it again gives me this...

Code:
update-rc.d namecoin defaults
update-rc.d: warning: /etc/init.d/namecoin missing LSB information
update-rc.d: see
 System start/stop links for /etc/init.d/namecoin already exist.

Reboot gives me JAKE STINK ALL.  WTF?

running as su manually
/etc/init.d/namecoin start;
give me what I want the start up to do!


BTW pushpoold is the only thing that is running after reboot.
hero member
Activity: 780
Merit: 510
Bitcoin - helping to end bankster enslavement.
Back to the restart problem that has not been fixed yet.

Here is a copy of my script... (remember I am not a linux user in fact the last 30 days it the most I have used linux in my whole life.)

Code:
#!/bin/sh
# Starts and stops namecoin & pushpool & blkmond
#


case "$1" in
start)
        echo ""
        echo "Starting namecoind and pushpool"
        echo ""
       /home/ubuntu/namecoin/namecoind -daemon -server
        sleep 1
       /home/ubuntu/pushpool/pushpoold --config=/home/ubuntu/pushpool/server.json
        screen -dmS blkmond /home/ubuntu/pushpool/blkmond /home/ubuntu/pushpool/blkmond.conf
        $0 view

;;

stop)
   echo ""
   echo "Killing pushpoold then Stoping namecoin"

   killall pushpoold
   killall blkmond
   /home/ubuntu/namecoin/namecoind stop
;;

restart)
     $0 stop
     sleep 4
     $0 start
;;

view)
        ps -e | grep namecoind
        ps -e | grep pushpoold
        ps -e | grep blkmond
;;


*)
        echo "Usage: $0 {start|stop|restart}"
        exit 1
esac

This (/etc/init.d/namecoin start;) needs to be executed as root under ubuntu 11.04 this should be easy PLEASE help.  I have to ask since I have and major issues everywhere else and was able to resolve it but this eludes me?  WTF?

BTW the script works.
hero member
Activity: 576
Merit: 514
Some things that come to mind:
- perhaps namcoind has an option to specify the data directory (bitcoin has, I'm using that)
- symlink (ln -s) or hardlink (mount -o bind) those directories (hardlinks need to go into /etc/fstab too iirc)

hero member
Activity: 780
Merit: 510
Bitcoin - helping to end bankster enslavement.
Hm, can you post the script you use?

Did you get any output when you did the update-rc.d?
Undo the previous: update-rc.d myscriptname remove
Set runlevels manually: update-rc.d myscriptname start 13 stop 06
Look into /etc/rc3.d/ to see if there's a symlink to your /etc/init.d/myscriptname

Logs should go into /var/log/. Usually, there's messages, boot, syslog or something similar which might contain some information about why the service start fails. dmesg perhaps too.
I'm running out of ideas sadly though, since Ubuntu isn't my preferred Linux distro. Oh, and you are in runlevel 3, right? Check with "who -r".

And "/etc/init.d/myscriptname start" works just fine when you do it manually? What user are you when doing that? Root?
Thanks.
For your help if we get it going I'll pay you the BTC.
Anyhow I'm not in front of the computer right now but to test, and verify all the things you ask. However i can tell you that "/etc/init.d/myscriptname start" works just fine and I am happy about that.  But if I run it as a user and not root it fails as namcoind try's to read the data from /home/username/.namecoin instead of /root/.namecoin

Bummer. As chown to the /root/.namecoin does not work.  I guess I have to do some sort of linking of the folders. 
hero member
Activity: 576
Merit: 514
Hm, can you post the script you use?

Did you get any output when you did the update-rc.d?
Undo the previous: update-rc.d myscriptname remove
Set runlevels manually: update-rc.d myscriptname start 13 stop 06
Look into /etc/rc3.d/ to see if there's a symlink to your /etc/init.d/myscriptname

Logs should go into /var/log/. Usually, there's messages, boot, syslog or something similar which might contain some information about why the service start fails. dmesg perhaps too.
I'm running out of ideas sadly though, since Ubuntu isn't my preferred Linux distro. Oh, and you are in runlevel 3, right? Check with "who -r".

And "/etc/init.d/myscriptname start" works just fine when you do it manually? What user are you when doing that? Root?
hero member
Activity: 780
Merit: 510
Bitcoin - helping to end bankster enslavement.
Haven't used Ubuntu that often, but if I remember correctly you can have a service start automatically at boot with something like "update-rc.d myscriptname defaults" as root.
Or you can symlink to the script in init.d from rc3.d/S99myscriptname (don't forget that you probably also need to symlink rc1.d/K99myscriptname).
Don't forget to look into logs for error messages.


I did the "update-rc.d myscriptname defaults" as root rebooted and nothing started.

Just so you know I have no idea where the logs are.

hero member
Activity: 576
Merit: 514
Haven't used Ubuntu that often, but if I remember correctly you can have a service start automatically at boot with something like "update-rc.d myscriptname defaults" as root.
Or you can symlink to the script in init.d from rc3.d/S99myscriptname (don't forget that you probably also need to symlink rc1.d/K99myscriptname).
Don't forget to look into logs for error messages.
hero member
Activity: 780
Merit: 510
Bitcoin - helping to end bankster enslavement.
I have tried every single option none of them work I am missing stuff like what user run it under or whatever I'll have to figure it out.

The /etc/init.d/myscriptname was helpful as I can manually stop and start it.  Thanks!
hero member
Activity: 780
Merit: 510
Bitcoin - helping to end bankster enslavement.
Thanks for all the solutions I will try them all and give the reward to the first person that got it right.  I am 100% sure that syntax errors will cause it to fail ether by me or in your comment.

BTW I am using ubuntu server 11.04.

hero member
Activity: 566
Merit: 500
Unselfish actions pay back better

or better yet,  put it in a script that can restart it if it fails,   actually  if this is for production use, look into something like daemontools or runit  iinstead.

Some linuxes (ubuntu comes to mind) use upstart, so all you have to do is drop a properly formed script in /etc/init.  E.g.:

Code:
# bitcoind

description "Keep bitcoind in the air"

start on (filesystem
          and runlevel [2345]
          and started rsyslog
          and net-device-added INTERFACE=eth0)

stop  on (shutdown
          or runlevel [!2345])

pre-start script
  /usr/bin/logger -t upstart starting bitcoind
end script

post-start script
  /usr/bin/logger -t upstart started bitcoind
end script

env LANG=C
env LC_ALL=C
env HOME=/var/lib/bitcoin

export LANG
export LC_ALL
export HOME

chdir /var/spool/bitcoin
umask 0077
nice 10

kill timeout 45

script
  exec /usr/bin/sudo -H -u bitcoin \
       /usr/local/sbin/bitcoind -datadir=/var/spool/bitcoin -server
end script

respawn

pre-stop script
  /usr/bin/logger -t upstart stopping bitcoind
  exec /usr/local/sbin/bitcoind stop
end script

post-stop script
  /usr/bin/logger -t upstart stopped bitcoind
end script

# eof

(The script make assumptions about where to find bitcoind, what user to run as, wich network interface to use, etc.)

Cheers,
sr. member
Activity: 574
Merit: 250
So I googled
found many ways to get things started but none of them worked.

Let me show you one way that I though should be basic and work...

I opened up the file
/etc/rc.local
Looks like this...
Code:
#!/bin/sh
#
# This script is executed at the end of each multiuser runlevel.

/home/bitcoinpool/namecoin/namecoind -daemond &
/home/bitcoinpool/pushpool/pushpoold --coinfig=/home/bitcoinpool/pushpool/server.json &

Exit 0

When I reboot nothing.

Please help and get paid in full!


Linux does not define the runlevel start up scripts,  depends on the specific userland as to how that is set up. Just which init set up is being used?   What are you running specifically?

Also, the above runs everything as root,  not a great idea.   I would  run namecoid as its own user, probably in a chrooted jail.

In any case, a lot of Linux set up use vixie cron... in that case create a user
for running this ( myncduser or whatever).  Add them to cron.allow if need be.

# crontab -u myncduser  -e

then add the line

@reboot /home/bitcoinpool/namecoin/namecoind -daemond


or better yet,  put it in a script that can restart it if it fails,   actually  if this is for production use, look into something like daemontools or runit  iinstead.
hero member
Activity: 518
Merit: 500
So I googled
found many ways to get things started but none of them worked.

Let me show you one way that I though should be basic and work...

I opened up the file
/etc/rc.local
Looks like this...
Code:
#!/bin/sh
#
# This script is executed at the end of each multiuser runlevel.

/home/bitcoinpool/namecoin/namecoind -daemond &
/home/bitcoinpool/pushpool/pushpoold --coinfig=/home/bitcoinpool/pushpool/server.json &

Exit 0

When I reboot nothing.

Please help and get paid in full!


Heres what you need:
create the following script:
Quote
#!/bin/sh
# Starts and stops namecoin + pushpool
#


case "$1" in
start)
       /home/bitcoinpool/namecoin/namecoind -daemon -server
       /home/bitcoinpool/pushpool/pushpoold --config=/home/bitcoinpool/pushpool/server.json &
      
;;

stop)
   
   killall namecoind pushpoold
;;

restart)
     $0 stop
     $0 start
;;

*)
        echo "Usage: $0 {start|stop|restart}"
        exit 1
esac

save the script under /etc/init.d/somenameyoucanchooseyourself
now, make the script executable:
chmod +x /etc/init.d/somenameyoucanchooseyourself

if you use a debian like system(ie debian, ubuntu etc), you can enable this script to run at boot using:
update-rc.d somenameyoucanchooseyourself defaults
hero member
Activity: 588
Merit: 500
Also, "daemon" is misspelled.
full member
Activity: 176
Merit: 100
Using rc.local you "fire-and-forget" the daemon. UNIX style is to have an init script which you can use in order to start, stop and restart daemons. Furthermore the init process will start the daemons for you if you linked the init script to the appropriate runlevel(s) and stops them properly if you reboot/halt the server. With this knowledge you should have a look at this thread:

http://bitcointalk.org/?topic=965.0

and adapt it to your needs. It should help you doing it the "right" way. Do the same for pushpoold. If you like you can tip the original author.
hero member
Activity: 576
Merit: 514
Also...

I assume you don't mean "coinfig", but "config"
hero member
Activity: 576
Merit: 514
To capture all output (stdout+stderr), you can append ">> /var/log/bitcoinpool.log 2>&1".
Also, check your standard logs (messages, cron) for additional error messages.

In most cases such scripts fail because of relative paths. Cron has a different environment.
full member
Activity: 238
Merit: 100
One other thing to mention.  Some scripts need to run as the correct user (so that they know where their hidden data directory is).  If I were you, I would change the script to look like the example below, so that they execute as the correct user (and not as root):

Code:
#!/bin/sh
#
# This script is executed at the end of each multiuser runlevel.

su bitcoinpool -c /home/bitcoinpool/namecoin/namecoind -daemond &
su bitcoinpool -c /home/bitcoinpool/pushpool/pushpoold --coinfig=/home/bitcoinpool/pushpool/server.json &

Exit 0
full member
Activity: 238
Merit: 100
What distro are you using?  I ask because some distros use /etc/rc.d/rc.local.

Was /etc/rc.local already there and you added to it, or did you create it yourself?

You could also do some simple debugging to see if your script is ever being executed. Something simple like:

Code:
echo "Yep, it executed!" > /home/bitcoinpool/debug.txt

Then after a reboot you can see if it made the debug.txt.file
Pages:
Jump to: