LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 10-06-2014, 10:25 AM   #1
nolretou
Member
 
Registered: Apr 2014
Distribution: Slackware
Posts: 98

Rep: Reputation: Disabled
Question Is it wrong to execute "telinit 4" in the rc.local ?


Hi !

I have a bunch of cloned virtualized Qemu relative machines.
Some of them need X to be started.
My idea was to check the MAC address, and if the test is OK, launch telinit 4 from within rc.local .
 
Old 10-06-2014, 11:06 AM   #2
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
I would say it is not a good idea -that's what runlevels are for. Either change the default entry in /etc/inittab or add 'init 4' to the kernel boot parameters. Doing it this, the Right Way, will allow you to access the box in runlevel 3 in case something happens and the GUI won't come up.
 
1 members found this post helpful.
Old 10-06-2014, 11:24 AM   #3
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,057

Rep: Reputation: Disabled
Starting at runlevel 3 then typing startx once or twice a day (laptop used as a desktop) is good enough for me
 
1 members found this post helpful.
Old 10-07-2014, 03:11 AM   #4
nolretou
Member
 
Registered: Apr 2014
Distribution: Slackware
Posts: 98

Original Poster
Rep: Reputation: Disabled
Why is it not a good idea ?

Is there another way to do that ?
 
Old 10-07-2014, 03:51 AM   #5
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,448
Blog Entries: 7

Rep: Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553
Edit /etc/inittab and change this section:

Code:
# Default runlevel. (Do not set to 0 or 6)
id:3:initdefault:
to:

Code:
# Default runlevel. (Do not set to 0 or 6)
id:4:initdefault:
 
Old 10-07-2014, 05:44 AM   #6
nolretou
Member
 
Registered: Apr 2014
Distribution: Slackware
Posts: 98

Original Poster
Rep: Reputation: Disabled
I'd like to do it dynamically.

The machine starts to init 3 by default.

In the rc.local I make a test. If the test is ok, then i would like to go init 4.
 
Old 10-07-2014, 06:28 AM   #7
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,448
Blog Entries: 7

Rep: Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553
Quote:
Originally Posted by nolretou View Post
I'd like to do it dynamically.
What do you mean by this?
 
Old 10-07-2014, 07:07 AM   #8
nolretou
Member
 
Registered: Apr 2014
Distribution: Slackware
Posts: 98

Original Poster
Rep: Reputation: Disabled
I have a read-only Qemu image with a test script launched by rc.local .
I create many relative images with different MAC addresses.
For some MAC addresses, I'd like the relative machines to start graphically.
 
Old 10-07-2014, 07:41 AM   #9
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
The usual and right way to change startup runlevel was mentioned. Now for the reason why not to use rc.local to change it. Take a look at the output of

Quote:
ls /etc/rc*.d/*rc.local*
You will see that its get called in every (multiuser) runlevel. Thus you normaly start into runlevel 3 call rc.local this switches runlevel to 4 which calls rc.local which changes runlevel to 4 which calls rc.local. If telnit actually changes the runlevel if it allready is in the level it ought to change to I do not know. Worse case you have an infinite loop, best case you just change the runlevel. Or you have a script that checks if the runlevel is allready where its ought to be and skips the change of runlevel.

Nother thing to check on if rc.local really is the last thing called in the appropiate runlevel.
 
Old 10-07-2014, 08:57 AM   #10
thirdm
Member
 
Registered: May 2013
Location: Massachusetts
Distribution: Slackware, NetBSD, Debian, 9front
Posts: 316

Rep: Reputation: Disabled
Quote:
Originally Posted by nolretou View Post
Why is it not a good idea ?

Is there another way to do that ?
You could change init. It's not an awfully complicated program.
 
Old 10-07-2014, 09:42 AM   #11
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
Quote:
Originally Posted by nolretou View Post
I have a read-only Qemu image with a test script launched by rc.local .
I create many relative images with different MAC addresses.
For some MAC addresses, I'd like the relative machines to start graphically.
Put the test at the start of /etc/rc.d/rc.4. Exit if the MAC doesn't match your list. Set /etc/inittab to 4.
 
Old 10-07-2014, 10:15 AM   #12
nolretou
Member
 
Registered: Apr 2014
Distribution: Slackware
Posts: 98

Original Poster
Rep: Reputation: Disabled
Ok, the loop may be bad ^^.

Neat trick, Richard !
 
Old 10-08-2014, 10:12 AM   #13
nolretou
Member
 
Registered: Apr 2014
Distribution: Slackware
Posts: 98

Original Poster
Rep: Reputation: Disabled
With the rc.4 trick, I have an annoying "respawn" message coming in the console. I tried to get rid of this without success.
 
Old 10-08-2014, 10:43 AM   #14
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
Bad advice on my part. You shouldn't exit rc.4, but stay in it; the display managers that are launched aren't running as daemons.

So instead of exiting, run in a while loop with a sleep like so...
Code:
while /bin/true; do sleep 10; done
 
Old 10-08-2014, 11:08 AM   #15
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
Oh, the tangled web we weave, when first we practice to...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] IPv6 "link-local" fe80:: vs "unique local address (ULA)" fc00:: + fd00:: psycroptic Linux - Networking 4 08-07-2014 12:51 AM
Failed to execute child process "/usr/local/eclipse/eclipse" (No such file or directo raju k Linux - Newbie 1 06-07-2013 02:47 AM
"failed to execute child process" "Input/output error" fl.bratu Fedora 4 12-15-2008 04:03 AM
Execute "telinit q" while programs are running ? Vilius AIX 1 11-26-2008 09:54 AM
SuSE Linux will not boot. FAILSAFE, then "telinit 5" works mindthief Linux - Software 0 12-08-2006 07:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 02:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration