0

I've been searching for this a little while now:

How do I, when I change from runlevel 2 to runlevel 5, start f.e. proftpd?

When I go back to runlevel 2, the service should be stopped again.

So - Start ftp-server when changing from runlevel 2 to 5 - Stop ftp-server when changing back

(Sidenote: the ftp-server is not allowed to boot on startup, so that shouldn't change either)

The closest thing I found was this:

# update-rc.d -n <service> start 2 . stop 2 .

ofcourse, that's not correct. Any ideas?

0

If you look at man update-rc.d you can see some examples. Here's what you probably want:

update-rc.d proftpd start 80 5 . stop 20 0 1 2 3 4 6 .

The 80 and 20 are just to make proftpd start later than most other services.

You may need to remove existing links first with: update-rc.d -f proftpd remove.


If you have a newer version of the OS, the above may seem to work, but will not take your options into account. Instead you will need to edit the /etc/init.d/proftpd file and change the headers there to something like this:

#!/bin/sh
### BEGIN INIT INFO
# Provides:          proftpd
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     5
# Default-Stop:      0 1 2 3 4 6
# X-Interactive:     false
# Short-Description: proftpd
### END INIT INFO

And run update-rc.d proftpd defaults instead.

This is because later update-rc.d just call insserv to do the work, and all dependencies and start/stop are now worked out automatically, and you cannot change them.

Check you have the right links with ls -l /etc/rc*/*proftpd. Eg output:

lrwxrwxrwx 1 root root  /etc/rc0.d/K01proftpd -> ../init.d/proftpd
lrwxrwxrwx 1 root root  /etc/rc1.d/K01proftpd -> ../init.d/proftpd
lrwxrwxrwx 1 root root  /etc/rc2.d/K01proftpd -> ../init.d/proftpd
lrwxrwxrwx 1 root root  /etc/rc3.d/K01proftpd -> ../init.d/proftpd
lrwxrwxrwx 1 root root  /etc/rc4.d/K01proftpd -> ../init.d/proftpd
lrwxrwxrwx 1 root root  /etc/rc5.d/S04proftpd -> ../init.d/proftpd
lrwxrwxrwx 1 root root  /etc/rc6.d/K01proftpd -> ../init.d/proftpd
  • Thanks for letting me know there was an actual man page on update-rc.d! I used pretty much the same, did some tweaking to get the best result. Thank you. – Kryptonous Oct 28 '15 at 17:53
  • You are lucky it worked, as I tried it again on a raspberry pi and it didn't work anymore. Things have moved on for more recent debians. Sadly the man page is now wrong. I updated my answer for other readers. – meuh Oct 28 '15 at 18:17

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.