General NAS-Central Forums

Welcome to the NAS community
It is currently Fri Sep 22, 2017 7:01 pm

All times are UTC




Post new topic Reply to topic  [ 15 posts ] 
Author Message
PostPosted: Thu Nov 21, 2013 9:59 am 
Offline

Joined: Thu Nov 21, 2013 9:51 am
Posts: 10
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:
root@LG-NAS:/etc# runlevel
unknown


Before breaking things, what do you suggest to make the service start at boot time?

Thanks!


Top
 Profile  
 
PostPosted: Thu Nov 21, 2013 1:22 pm 
Offline

Joined: Mon Jun 16, 2008 10:45 am
Posts: 6039
Call it in /etc/rc.local?


Top
 Profile  
 
PostPosted: Thu Nov 21, 2013 1:50 pm 
Offline

Joined: Thu Nov 21, 2013 9:51 am
Posts: 10
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?


Top
 Profile  
 
PostPosted: Thu Nov 21, 2013 7:27 pm 
Offline

Joined: Mon Jun 16, 2008 10:45 am
Posts: 6039
rc.local is called at the end of the boot process. You could call your scripts in it:
Code:
/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


Top
 Profile  
 
PostPosted: Fri Nov 22, 2013 7:19 am 
Offline

Joined: Thu Nov 21, 2013 9:51 am
Posts: 10
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?


Top
 Profile  
 
PostPosted: Fri Nov 22, 2013 8:45 am 
Offline

Joined: Mon Jun 16, 2008 10:45 am
Posts: 6039
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.


Top
 Profile  
 
PostPosted: Fri Nov 22, 2013 9:07 am 
Offline

Joined: Thu Nov 21, 2013 9:51 am
Posts: 10
Ok, and what about editing runlevel.conf, is this wrong?


Top
 Profile  
 
PostPosted: Fri Nov 22, 2013 9:38 am 
Offline

Joined: Mon Jun 16, 2008 10:45 am
Posts: 6039
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.


Top
 Profile  
 
PostPosted: Fri Nov 22, 2013 9:48 am 
Offline

Joined: Thu Nov 21, 2013 9:51 am
Posts: 10
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?


Top
 Profile  
 
PostPosted: Fri Nov 22, 2013 10:09 am 
Offline

Joined: Mon Jun 16, 2008 10:45 am
Posts: 6039
The desired runlevel is defined in /etc/inittab.


Top
 Profile  
 
PostPosted: Tue Nov 26, 2013 10:33 am 
Offline

Joined: Thu Nov 21, 2013 9:51 am
Posts: 10
My inittab says

# The default runlevel.
id:2:initdefault:

but it seems wrong...

How comes "runlevel" outputs "unknown"?


Top
 Profile  
 
PostPosted: Tue Nov 26, 2013 4:14 pm 
Offline

Joined: Mon Jun 16, 2008 10:45 am
Posts: 6039
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:
#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.


Top
 Profile  
 
PostPosted: Wed Nov 27, 2013 7:30 am 
Offline

Joined: Thu Nov 21, 2013 9:51 am
Posts: 10
Ok, but if /etc/inittab says runlevel 2, why my NAS ends up in runlevel S?


Top
 Profile  
 
PostPosted: Wed Nov 27, 2013 9:02 am 
Offline

Joined: Mon Jun 16, 2008 10:45 am
Posts: 6039
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.


Top
 Profile  
 
PostPosted: Wed Nov 27, 2013 9:06 am 
Offline

Joined: Thu Nov 21, 2013 9:51 am
Posts: 10
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group