N1A1DD1: startup configuration

LG Electronics
Post Reply
pdario
Posts: 10
Joined: Thu Nov 21, 2013 9:51 am

N1A1DD1: startup configuration

Post by pdario » Thu Nov 21, 2013 9:59 am

Hello, I have a "rooted" LG N1A1DD1; I installed a couple of services using deb files, they seem alright apart that they not start automatically.

I found my NAS does not have /etc/rc?.d directories as it seems using file-rc.

I see the two services are listed in file runlevel.conf like this
20 0,1,6 2,3,4,5 /etc/init.d/btsync

but most of other services seem set to run at runlevel S.

I also have this output

Code: Select all

root@LG-NAS:/etc# runlevel
unknown
Before breaking things, what do you suggest to make the service start at boot time?

Thanks!

Mijzelf
Posts: 6196
Joined: Mon Jun 16, 2008 10:45 am

Re: N1A1DD1: startup configuration

Post by Mijzelf » Thu Nov 21, 2013 1:22 pm

Call it in /etc/rc.local?

pdario
Posts: 10
Joined: Thu Nov 21, 2013 9:51 am

Re: N1A1DD1: startup configuration

Post by pdario » Thu Nov 21, 2013 1:50 pm

Well, maybe... :lol:

I see that's a script: what should I put there?

"service <service> start"?

What about runlevel.conf, should I leave it untouched?

Mijzelf
Posts: 6196
Joined: Mon Jun 16, 2008 10:45 am

Re: N1A1DD1: startup configuration

Post by Mijzelf » Thu Nov 21, 2013 7:27 pm

rc.local is called at the end of the boot process. You could call your scripts in it:

Code: Select all

/etc/init.d/sshd start
A google on runlevel.conf shows that it's an alternative for systemV init scripts. And so it's documented, and you can edit it.
http://www.debianadmin.com/manpages/run ... anpage.htm

pdario
Posts: 10
Joined: Thu Nov 21, 2013 9:51 am

Re: N1A1DD1: startup configuration

Post by pdario » Fri Nov 22, 2013 7:19 am

I'm trying to put pieces together.
I found that update-rc is able to manipulate runlevel.conf, so it could be that to be used instead of editing rc.local.

If I just put the start command in rc.local, I expect the service not being stopped properly at shutdown, what do you think?

Mijzelf
Posts: 6196
Joined: Mon Jun 16, 2008 10:45 am

Re: N1A1DD1: startup configuration

Post by Mijzelf » Fri Nov 22, 2013 8:45 am

pdario wrote:If I just put the start command in rc.local, I expect the service not being stopped properly at shutdown, what do you think?
If will not be stopped through the startscript, but it will get a SIGTERM signal. (And if it's still there a few seconds later, it will get a SIGKILL. Then the box will just poweroff/reboot).
For many services (daemons in Linux speak) sending a SIGTERM *is* the proper way, which is also invoked by the startscript.

pdario
Posts: 10
Joined: Thu Nov 21, 2013 9:51 am

Re: N1A1DD1: startup configuration

Post by pdario » Fri Nov 22, 2013 9:07 am

Ok, and what about editing runlevel.conf, is this wrong?

Mijzelf
Posts: 6196
Joined: Mon Jun 16, 2008 10:45 am

Re: N1A1DD1: startup configuration

Post by Mijzelf » Fri Nov 22, 2013 9:38 am

No. It's not a firmware specific file, and it can be handled by update-rc, so you can just use it.

I recommend to make a backup of the file, use update-rc to add your daemons, and then have a look at the resulting file. If you don't trust it, you can put back your backup before rebooting.
Acutally this is a nicer way than the SystemV way, where it's much more difficult to make a backup of the current startup configuration.

pdario
Posts: 10
Joined: Thu Nov 21, 2013 9:51 am

Re: N1A1DD1: startup configuration

Post by pdario » Fri Nov 22, 2013 9:48 am

I'm experimenting, but I don't understand why there's no defined runlevel.
It seems it all stops at runlevel S, where can I confirm this?

Should I put btsync at runlevel S?

Mijzelf
Posts: 6196
Joined: Mon Jun 16, 2008 10:45 am

Re: N1A1DD1: startup configuration

Post by Mijzelf » Fri Nov 22, 2013 10:09 am

The desired runlevel is defined in /etc/inittab.

pdario
Posts: 10
Joined: Thu Nov 21, 2013 9:51 am

Re: N1A1DD1: startup configuration

Post by pdario » Tue Nov 26, 2013 10:33 am

My inittab says

# The default runlevel.
id:2:initdefault:

but it seems wrong...

How comes "runlevel" outputs "unknown"?

Mijzelf
Posts: 6196
Joined: Mon Jun 16, 2008 10:45 am

Re: N1A1DD1: startup configuration

Post by Mijzelf » Tue Nov 26, 2013 4:14 pm

pdario wrote:How comes "runlevel" outputs "unknown"?
I guess it's never stored. Don't where it is supposed to be. I haven't the source of GNU runlevel here (if that exists), but this is the implementation in Busybox:

Code: Select all

#include <stdio.h>
#include <utmp.h>
#include <time.h>
#include <stdlib.h>

#include "busybox.h"

int runlevel_main(int argc, char *argv[])
{
  struct utmp *ut;
  char prev;

  if (argc > 1) utmpname(argv[1]);

  setutent();
  while ((ut = getutent()) != NULL) {
        if (ut->ut_type == RUN_LVL) {
                prev = ut->ut_pid / 256;
                if (prev == 0) prev = 'N';
                printf("%c %c\n", prev, ut->ut_pid % 256);
                endutent();
                return (0);
        }
  }

  printf("unknown\n");
  endutent();
  return (1);
}
So apparently Busybox init stores the current runlevel in /var/run/utmp. Don't know if Debian init (and especially the one which does 'runlevel.conf') does the same.

pdario
Posts: 10
Joined: Thu Nov 21, 2013 9:51 am

Re: N1A1DD1: startup configuration

Post by pdario » Wed Nov 27, 2013 7:30 am

Ok, but if /etc/inittab says runlevel 2, why my NAS ends up in runlevel S?

Mijzelf
Posts: 6196
Joined: Mon Jun 16, 2008 10:45 am

Re: N1A1DD1: startup configuration

Post by Mijzelf » Wed Nov 27, 2013 9:02 am

Why do you think it's in runlevel S? You can't read the current runlevel you say.

It's normal that all scripts in runlevel S are executed, followed by all scripts from the target runlevel. However, of course it's possible that there is a blocking script, which stops the 'runlevel pump' (my word, don't know the canonical word), so the the current runlevel isn't stored.
ps -A might show if some lingering startscript is running.

pdario
Posts: 10
Joined: Thu Nov 21, 2013 9:51 am

Re: N1A1DD1: startup configuration

Post by pdario » Wed Nov 27, 2013 9:06 am

Well, because I had to move a service to runlevel S to make it start

From this

20 0,1,6 2,3,4,5 /etc/init.d/btsync

to this

41 0,6 S /etc/init.d/btsync

Post Reply