2

I have installed gerrit on a remote ubuntu server. Now I would like it to automatically start when the server reboots. I am trying to follow this:

http://gerrit-documentation.googlecode.com/svn/Documentation/2.3/install.html#rc_d

which is a two-liner:

sudo ln -snf `pwd`/home/gerrit2/gerrit_application/bin/gerrit.sh /etc/init.d/gerrit.sh
sudo ln -snf ../init.d/gerrit.sh /etc/rc3.d/S90gerrit

I have verified that both files are created. But when I reboot the application its not started. I still have to manually start it with:

root@mm11:/home/gerrit2/gerrit_application/bin# ./gerrit.sh start

How do I debug/fix this?

I have also tried with:

sudo ln -snf /home/gerrit2/gerrit_application/bin/gerrit.sh /etc/init.d/gerrit
sudo update-rc.d gerrit defaults

Which gives:

root@mm11:/home/gerrit2# update-rc.d gerrit defaults
 Adding system startup for /etc/init.d/gerrit ...
   /etc/rc0.d/K20gerrit -> ../init.d/gerrit
   /etc/rc1.d/K20gerrit -> ../init.d/gerrit
   /etc/rc6.d/K20gerrit -> ../init.d/gerrit
   /etc/rc2.d/S20gerrit -> ../init.d/gerrit
   /etc/rc3.d/S20gerrit -> ../init.d/gerrit
   /etc/rc4.d/S20gerrit -> ../init.d/gerrit
   /etc/rc5.d/S20gerrit -> ../init.d/gerrit

3 Answers 3

1

At first you should copy your script in pool of scripts:

/etc/init.d/

linux have a set of dircetory that contain a set of link to this pool, at various runlevels:

/etc/rc0.d # for runlevel 0 for trun off system in all of dirstos
/etc/rc1.d # runlevel 1, for single user in all distros
/etc/rc2.d # runlevel 2 , default runlevel for debian-base dirstros
/etc/rc3.d # runlevel 3, in redhat-base systems, using for everything without graphical mode
/etc/rc4.d # runlevel 4,reserved by system
/etc/rc5.d  #runlevel 5 , in  Redhat base , defualt runlevel
/etc/rc6.d  # for runlevel 6 for reboot system in all of distros

you should run :

ln -s /etc/init.d/YOUR_SCRIPT /etc/rcNUMBER.d/{S OR K}NUMYOUR_SCRIPT

such as:

ln -s /etc/init.d/apache2 /etc/rc2.d/S99apache2

S OR K : S statrt, K: Kill
NUM before script: priority of run, if you have two scrip such S10squid amd S99apache, At first squid will be run then apache. 

update-rc.d vs chkconfig :

update-rc.d works in Debian-base systems and chkconfig works in redhat-base systems.

1
  • Se my edited post. It now gets installed in rc0, ..., rc6. But it still does not startup when the machine reboots.
    – u123
    Sep 19, 2013 at 18:46
0

You're linking to the script in the rc3.d directory, which is the directory for services started in runlevel 3. The default runlevel in Ubuntu is 2 IIRC. So you may want to change your second line to:

sudo ln -snf ../init.d/gerrit.sh /etc/rc2.d/S90gerrit

Of course it's possible that the server has been configured to start in another runlevel. Find out the current runlevel with

who -r
1
  • See edited post, its installed in at all run-levels.
    – u123
    Sep 19, 2013 at 18:54
0

first of all, try running your script manually as root (no need to reboot the system):

 /etc/init.d/gerrit start

if this works and ther service still does not start at boot time, the problem might be that when trying to execute your script, the PATH variable might not be what you expect. try setting PATH to sane defaults within your script (gerrit.sh)

e.g.

#!/bin/bash
PATH=/sbin:/usr/sbin:/bin:/usr/bin

#...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .