0

I have created on our Debian squeeze my own daemon from skeleton where is my application starting (+I add there some logging to my log file). I have put this file to /etc/init.d/

cp /home/ja /etc/init.d/ucloud-test -f
chown root /etc/init.d/ucloud-test
chmod 775 /etc/init.d/ucloud-test

After that I created symlinks to this daemon:

ln -sf ../init.d/ucloud-test /etc/rc0.d/K02ucloud-test
ln -sf ../init.d/ucloud-test /etc/rc1.d/K02ucloud-test
ln -sf ../init.d/ucloud-test /etc/rc6.d/K02ucloud-test
ln -sf ../init.d/ucloud-test /etc/rc2.d/S17ucloud-test
ln -sf ../init.d/ucloud-test /etc/rc3.d/S17ucloud-test
ln -sf ../init.d/ucloud-test /etc/rc4.d/S17ucloud-test
ln -sf ../init.d/ucloud-test /etc/rc5.d/S17ucloud-test

It created this symlinks:

root@id135728-2:/home/ja# cd /etc
root@id135728-2:/etc# ls -l  rc* | grep ucloud-test
lrwxrwxrwx 1 root root  21 Aug  7 13:15 K02ucloud-test -> ../init.d/ucloud-test
lrwxrwxrwx 1 root root  21 Aug  7 13:15 K02ucloud-test -> ../init.d/ucloud-test
lrwxrwxrwx 1 root root  21 Aug  7 13:15 S17ucloud-test -> ../init.d/ucloud-test
lrwxrwxrwx 1 root root  21 Aug  7 13:15 S17ucloud-test -> ../init.d/ucloud-test
lrwxrwxrwx 1 root root  21 Aug  7 13:15 S17ucloud-test -> ../init.d/ucloud-test
lrwxrwxrwx 1 root root  21 Aug  7 13:15 S17ucloud-test -> ../init.d/ucloud-test
lrwxrwxrwx 1 root root  21 Aug  7 13:15 K02ucloud-test -> ../init.d/ucloud-test

If I try to read some of those symlinks it shows code from my daemon (it should be right).

root@id135728-2:/etc# cat rc0.d/K02ucloud-test

After reboot looks like that my daemon is not executed (application is not working and there is nothing in my log file). But if I execute that daemon myself application is working and there logging in my log.

/etc/init.d/ucloud-test start

Does anyone know where can be a issue? Thanks, Roman

1
  • 2
    Frequently init scripts fail because they get executed with a very basic environment and that environment may be lacking something in the PATH and/or other variables compared to how your users environment is configured
    – HBruijn
    Aug 7, 2018 at 13:10

1 Answer 1

2

It's difficult to say what might be going on without further debugging (which would mean extensive logging from the script itself to figure out what's not as you expect it to be), but a really good place to start with this kind of issue on Squeeze is the documentation on init script comment conventions that help manage dependencies. Because, 99% of the time, if your init script 'just works' after boot, it's a dependency issue.

What are you using for logging, does it require starting? How about networking? Maybe it needs to connect to a database? Your boot script should definitely be running later, then.

Instead of making the links manually, try adding this near the top of your init script:

### BEGIN INIT INFO
# Provides:       ucloud-test
# Required-Start: $all
# Required-Stop:  
# Default-Start:  2 3 4 5
# Default-Stop:   
# Description:    Test script that needs to run after boot
### END INIT INFO

Then, run insserv ucloud (note, I eliminated runlevels 1 and 6)

Now, if it turns out all you need is networking to come up (this includes loopback devices and bridges!!!) (which I suspect is the case), then you could change $all to $network, but that can be tricky with advanced networking setups. If that's the case, you should probably check into more granular boot hooks (systemd / systemctl).

The other thing to do is make /etc/ucloud-test/ucloud-defaults and include it in your script after the init info instead of relying on other things to put them in the environment, but I strongly suspect that you just need to wait until later in the boot process to start.

Anyway, that should give you a base on which to figure it out. Key takeaway is, don't manually create init links unless you have a very specific reason for doing so that entails not wanting some speicific behavior that the system utilities to manage this would bring.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.