Starting services on boot

Discussion in 'Linux' started by sdousley, Oct 2, 2008.

  1. sdousley

    sdousley

    Joined:
    Oct 1, 2008
    Messages:
    29
    Likes Received:
    0
    Hi

    I have installed openssh-server on my Aspire One, and as an ssh server, it does what i need it to. The problem with it is that it doesn't start on boot. So each time i restart the laptop, i have to manually
    Code:
    sudo /etc/init.d/sshd start
    before i can ssh to it.

    What i'd rather have is the ssh server start on boot.

    Now knowing a reasonable amount about Redhat based systems from my previous years working with linux, i know that in the rcX.d folders (where the X is the runlevel number) you have services, those prefixes with a K wont start on boot, those prefixed with an S will start.

    So i checked the default runlevel on my machine (from /etc/inittab) and i have:
    So the AA1 will boot into runlevel 5 by default, so i have checked /etc/rc5.d and can see:
    Code:
    [user@localhost rc5.d]$ ls -al *sshd
    lrwxrwxrwx 1 root root 14 2008-09-30 22:52 S55sshd -> ../init.d/sshd
    This to me says that sshd will start when runlevel 5 is called (if it's not already started). Yet as i say, this doesn't start.

    Does anyone know of any oddities to the service control manager in the Aspire One?
     
    sdousley, Oct 2, 2008
    #1
  2. sdousley

    daldred

    Joined:
    Aug 25, 2008
    Messages:
    887
    Likes Received:
    0
    What, apart from it rewriting its /etc/hosts and fsatb files on every boot, and other weird stuff like that ;) ?

    Anything I want started I'm putting in /etc/rc.local; this appears to run after X has started, but I don't see why that should be an issue for sshd.
     
    daldred, Oct 2, 2008
    #2
  3. sdousley

    kevin

    Joined:
    Sep 18, 2008
    Messages:
    274
    Likes Received:
    0
    Where do you want to start? :)

    Since it probably makes no sense to start sshd without a network connection, my suggestion would be to create a script in /etc/NetworkManager/dispatcher.d to start and stop ssdh. Scripts in this directory are called when a network connection gets make (in which case $2="up") and un-made (in which case $2="down"). I put my network time sync operations in here as well, for the same reason.

    Network startup is late in Linpus compared to traditional unix, and it's possible that the reason your sshd isn't starting is because there's not enough of a network under it to make it start when you call the init script.
     
    kevin, Oct 2, 2008
    #3
  4. sdousley

    cpchan

    Joined:
    Sep 22, 2008
    Messages:
    201
    Likes Received:
    0
    Yes, I know it saids 5 in inittab, but it actually just run rc.S and does not go into runlevel 5.

    Linpus' default init system (which I have since change on my machine) is extremely weird with most of the services start from scripts via ~/.bash_profile using sudo. You have 2 choices, either:

    1. Stick "/etc/init.d/sshd start" in your rc.local
    2. Or uncomment the sshd line (no. 7) in /etc/rc.d/slim/nowait.sh
     
    cpchan, Oct 2, 2008
    #4
  5. sdousley

    sdousley

    Joined:
    Oct 1, 2008
    Messages:
    29
    Likes Received:
    0
    This is the method that I went for as I see putting things in rc.local as a "dirty" way to get things done. This did indeed get ssh to start on boot. Thanks cpchan.
     
    sdousley, Oct 3, 2008
    #5
  6. sdousley

    kevin

    Joined:
    Sep 18, 2008
    Messages:
    274
    Likes Received:
    0
    I have to admit that I find it hard to see the logic in starting ssdh at boot, when it won't do anything useful without a network connection to attach to. One of the good things about Linpus is the way it minimizes the amount of unnecessary boot-time services. I can't really see why undoing that is a good idea. But each to his own, I guess :/
     
    kevin, Oct 3, 2008
    #6
  7. sdousley

    rbil

    Joined:
    Aug 14, 2008
    Messages:
    730
    Likes Received:
    0
    Location:
    The Wet Coast, Canada
    Kevin,

    sshd is the server. So what if the network connection isn't up yet when it fires up? It's there to let a client login to your box and when your system is up and if sshd is running, then they'll be able to do so. No?

    Cheers.
     
    rbil, Oct 3, 2008
    #7
  8. sdousley

    Tux1964

    Joined:
    Aug 31, 2008
    Messages:
    1
    Likes Received:
    0
    Services can be started with the "service" command
    example:

    sudo service sshd status
    sudo service sshd stop
    sudo service sshd start

    Services that you would like to stop and start during startup can be controlled by the "chkconfig" command
    example:

    which service's start at runlevel 5: sudo chkconfig --list|grep 5:eek:n
    start sshd at startup: sudo chkconfig sshd on
    stop sshd at stratup: sudo chkconfig sshd off
     
    Tux1964, Oct 3, 2008
    #8
  9. sdousley

    rbil

    Joined:
    Aug 14, 2008
    Messages:
    730
    Likes Received:
    0
    Location:
    The Wet Coast, Canada
    You SURE about that? The OS on the AAO doesn't follow sys v.

    Cheers.
     
    rbil, Oct 3, 2008
    #9
  10. sdousley

    kevin

    Joined:
    Sep 18, 2008
    Messages:
    274
    Likes Received:
    0
    Well, sure, it won't hurt to have sshd running all the time. And if you invariably have the AA1 connect to the network when it starts, then it doesn't really matter whether you start it from a boot script or from the network manager.

    But if you have the network disconnected most of the time, as I do, starting/stopping sshd from the network manager shaves a few milliseconds off the boot time and a few Mb from the memory when it's not actually in use. And it only takes a few extra lines of script to do it this way. Since I've already had to create a script to do a network time sync when the network comes up (because there's no point doing that at boot time), it's only a matter of adding sshd start/stop to a different script.

    But it's hardly a big deal, either way.
     
    kevin, Oct 4, 2008
    #10
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.