LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Password
Linux From Scratch This Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.

Notices

Reply
 
Search this Thread
Old 10-01-2005, 05:39 AM   #1
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,428

Rep: Reputation: 53
Where to put the script to be evoked at booting


Hi folks,

I have following script, put on /etc/rc.d/init.d/local
Code:
#!/bin/sh

modprobe snd-pcm-oss
modprobe snd-pcm-oss
amixer set Master 80% unmute
amixer set CD 80% unmute
amixer set PCM 80% unmute
amixer set Line 80% unmute
it can be evoked after bootup.

# ls -l /etc/rc.d/init.d/local
Code:
-rwxr-xr--  1 root root 161 Oct  1 11:34 /etc/rc.d/init.d/local
I need it to be evoked at booting.

Having tried;

# ln -s /etc/rc.d/init.d/local /etc/rc.d/init.d/rc5.d/
# ln -s /etc/rc.d/init.d/local /etc/rc.d/init.d/rc3.d/
# ln -s /etc/rc.d/init.d/local /etc/rc.d/init.d/

Failed. None can work.

I guess it must be installed via "blfs-bootscripts-6.1"

So tried as follows;
# cd /sources/blfs-bootscripts-6.1
# make install-local
Code:
make: *** No rule to make target `install-local'.  Stop
# make install-"/root/local"
Code:
make: *** No rule to make target `install-/root/local'.  Stop
# make install-`/root/local`
Code:
make: *** No rule to make target `install-Simple'.  Stop
none of them can work.

Now put the script on /root/local and start it after bootup. Because "modproble" must be evoked as "root", unable to run the script as "user"

Any advice? TIA

BR
satimis
 
Old 10-01-2005, 06:48 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,414

Rep: Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967
set it as a suitably named service script, e.g /etc/rc.d/init.d/rc5.d/S99local

why are you trying to link it to either rc3.d or rc5.d, do you not know you own choice of runlevel? seems odd for an lfs user.
 
Old 10-01-2005, 06:51 AM   #3
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,414

Rep: Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967
then again the things you are trying to do should be handled elsewhere, alsa should be saving its own settings in shutdown. modules should also be being handled via /etc/modulrs.conf or equivalent.
 
Old 10-01-2005, 07:53 AM   #4
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,428

Original Poster
Rep: Reputation: 53
Hi acid_kewpie,

Tks for your advice.

Quote:
set it as a suitably named service script, e.g /etc/rc.d/init.d/rc5.d/S99local
rc5.d is on /etc/rc.d/

# ls -l /etc/rc.d/
Code:
total 76
drwxr-xr-x  2 root root 4096 Oct  1 15:56 init.d
-rwx------  1 root root 2069 Oct  1 09:11 rc.iptables
drwxr-xr-x  2 root root 4096 Sep 20 07:00 rc0.d
drwxr-xr-x  2 root root 4096 Sep 20 07:00 rc1.d
drwxr-xr-x  2 root root 4096 Sep 10 21:56 rc2.d
drwxr-xr-x  2 root root 4096 Oct  1 15:55 rc3.d
drwxr-xr-x  2 root root 4096 Oct  1 08:41 rc4.d
drwxr-xr-x  2 root root 4096 Oct  1 19:26 rc5.d
drwxr-xr-x  2 root root 4096 Sep 20 07:00 rc6.d
drwxr-xr-x  2 root root 4096 Aug  3 17:46 rcsysinit.d
Tested performed as;
# ln-s /etc/rc.d/init.d/local /etc/rc.d/rc5.d/S99local

What is "S99"?

# ls -l /etc/rc.d/rc5.d/
Code:
total 8
lrwxrwxrwx  1 root root 18 Aug  3 17:46 S10sysklogd -> ../init.d/sysklogd
lrwxrwxrwx  1 root root 18 Oct  1 08:41 S19iptables -> ../init.d/iptables
lrwxrwxrwx  1 root root 17 Aug  3 17:46 S20network -> ../init.d/network
lrwxrwxrwx  1 root root 14 Sep 10 21:56 S25cups -> ../init.d/cups
lrwxrwxrwx  1 root root 11 Oct  1 19:26 S99local -> /etc/rc.d/init.d/local
Rebooted the box. Still failed. Commands did not run at boot

Quote:
why are you trying to link it to either rc3.d or rc5.d, do you not know you own choice of runlevel?
Tried /etc/rc.d/rc5.d first but failed. Then tested /etc/rc3.d but also failed

BR
satimis
 
Old 10-01-2005, 08:03 AM   #5
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,428

Original Poster
Rep: Reputation: 53
Hi acid_kewpie,

Quote:
alsa should be saving its own settings in shutdown.
It did not work. I completed the whole page of "ALSA Utilities-1.0.9a"
http://www.linuxfromscratch.org/blfs...lsa-utils.html

Quote:
modules should also be being handled via /etc/modulrs.conf or equivalent.
I could not find /etc/modulrs.conf nor /etc/modules.conf

# ls /etc | grep mod
# ls /etc | grep mod*
Both no output

# find / -name modulrs.conf
# find / -name modules.conf
Both no output

BR
satimis
 
Old 10-01-2005, 12:25 PM   #6
hoes
Member
 
Registered: Sep 2005
Distribution: debian, linux from scratch
Posts: 93

Rep: Reputation: 20
> # find / -name modulrs.conf
> # find / -name modules.conf
> Both no output

/etc/modules.conf is used by old kernels.
Insmod uses it to look up certain module-aliases and to find out which modules should be loaded at boottime.
The file /etc/modprobe.conf is used by modprobe which you are probably using to load your modules into the kernel.
It could well be that such a file does not exist either.(see explanation about it below)

> What is "S99"?
The S99Local symbolic link indicates that local should be started, that's the S as 99th item.
The 99 is used to specify the order of booting in the current runlevel. So if you called S99Local S10Local it would have started before other things with a large number in the same runlevel.

How do you know it didn't work? Did it give an error or did you check it?
If you checked it, how?
That's useful information which makes sure helping is easier.

One thing still: Maybe you would like your script to be run when your system starts.
Therefor create a link in rcsysinit.d like you did in rc5.d.
I have one question still:
Where have you read you needed tot start such a script?

I have put some basic info about make and modules at the bottom. Read it if you want

Good luck, Hugo




Basic info about loading modules at boottime:
If you have a sysfs which resides in /sys and you use udev, modrprobe will only be invoked by udev. Therefor modprobe wouldn't be used by seperate programs for loading single modules. If it would be used to load all modules separetly a file like /etc/modprobe.conf must exist to indicate which modules should be loaded at boottime. But in a LFS-system udev makes sure the proper modules are loaded automatically by looking in the /sys directory to find every device that exists on your system and afterwards it will call modrpobe to load modules. Therefor modprobe does not need to know itself which modules should be loade and there will be no need for /etc/modprobe.conf.

Basic info about the make command:
make looks for Makefile in the current directory and runs commands specified in it.
Your make install-local doesn't work because no one has ever written how to 'install-local' in the Makefile of the bootscript-project.
 
Old 10-01-2005, 04:33 PM   #7
kjordan
Member
 
Registered: Jul 2004
Distribution: LFS, I felt the itch and scratched it
Posts: 227

Rep: Reputation: 31
/etc/sysconfig/modules is what LFS uses to load modules.


Any particular errors on the alsa scripts? They work fine for me.
 
Old 10-01-2005, 04:52 PM   #8
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
This link might be useful: A look at System V Initialization

It should asnwer most, if not all, the questions you have about the boot script process.
 
Old 10-02-2005, 09:04 AM   #9
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,428

Original Poster
Rep: Reputation: 53
Hi kjordan,

Quote:
/etc/sysconfig/modules is what LFS uses to load modules.
I put following 2 lines on /etc/sysconfig/modules
Code:
modprobe snd-pcm-oss
modprobe snd-seq-os
It did not work.

Then I created /etc/modprobe.conf
Code:
install snd-pcm modprobe -i snd-pcm ; modprobe snd-pcm-oss ; true
install snd-seq modprobe -i snd-seq ; modprobe snd-seq-oss ; true
It worked.

Quote:
Any particular errors on the alsa scripts? They work fine for me.
$ cat /etc/dev.d/snd/alsa.dev
Code:
#!/bin/sh -e
# This script is called by udevd when a change in a device is
# detected, including initial detection upon bootup.
# udevd sets the environment variables ACTION and DEVNAME.

[ "$ACTION" = "add" ] || exit 0
DEV_BASENAME="${DEVNAME##*/}"
N="${DEV_BASENAME#controlC}"
case "$DEV_BASENAME" in
    controlC[0-7])
        x=0
        while [ $x -lt 20 ]; do
            # Wait up to 20 seconds for /usr to be mounted if necessary
            if [ -f /usr/sbin/alsactl ]; then
                /usr/sbin/alsactl restore $N
                exit 0
            fi
            sleep 1
            x=`expr $x + 1
         done & # Put the while command in the background and continue
    ;;
esac
exit 0
I used copy/paste to create it.

$ ls -l /etc/dev.d/snd/alsa.dev
Code:
-rwxr-xr-x  1 root root 703 Sep 20 07:06 /etc/dev.d/snd/alsa.dev
BR
satimis
 
Old 10-02-2005, 11:06 AM   #10
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,428

Original Poster
Rep: Reputation: 53
Hi hoes,

Tks for your advice.

Quote:
Insmod uses it to look up certain module-aliases and to find out which modules should be loaded at boottime.
$ lsmod
Code:
Module                  Size  Used by
snd_pcm_oss            48384  - 
snd_mixer_oss          17120  - 
snd_via82xx            22496  - 
snd_ac97_codec         72664  - 
snd_pcm                81732  - 
snd_timer              20772  - 
snd_page_alloc          7172  - 
snd_mpu401_uart         6144  - 
snd_rawmidi            19616  - 
snd_seq_device          6508  - 
snd                    45252  - 
via_agp                 7200  -
Quote:
The file /etc/modprobe.conf is used by modprobe which you are probably using to load your modules into the kernel.
It could well be that such a file does not exist either.(see explanation about it below)
Created following file

# cat /etc/modprobe.conf
Code:
install snd-pcm modprobe -i snd-pcm ; modprobe snd-pcm-oss ; true
install snd-seq modprobe -i snd-seq ; modprobe snd-seq-oss ; true
Now both of them detected on booting.

Quote:
How do you know it didn't work? Did it give an error or did you check it?
If you checked it, how?
That's useful information which makes sure helping is easier.
If without running following script after booting;
Code:
#!/bin/sh

modprobe snd-pcm-oss
modprobe snd-seq-oss
amixer set Master 80% unmute
amixer set CD 80% unmute
amixer set PCM 80% unmute
amixer set Line 80% unmute
On running TiMidity;

$ timidity Midi_Guitar/
Code:
Couldn't open output device
After running the script;

# /root/local
Code:
Simple mixer control 'Master',0
  Capabilities: pvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 31
  Front Left: Playback 25 [81%] [on]
  Front Right: Playback 25 [81%] [on]
Simple mixer control 'CD',0
  Capabilities: pvolume pswitch pswitch-joined cswitch cswitch-joined cswitch-exclusive
  Capture exclusive group: 0
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: Playback 0 - 31
  Front Left: Playback 25 [81%] [on] Capture [off]
  Front Right: Playback 25 [81%] [on] Capture [off]
Simple mixer control 'PCM',0
  Capabilities: pvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 31
  Front Left: Playback 25 [81%] [on]
  Front Right: Playback 25 [81%] [on]
Simple mixer control 'Line',0
  Capabilities: pvolume pswitch pswitch-joined cswitch cswitch-joined cswitch-exclusive
  Capture exclusive group: 0
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: Playback 0 - 31
  Front Left: Playback 25 [81%] [on] Capture [off]
  Front Right: Playback 25 [81%] [on] Capture [off]
(The script must be run as "root")
# exit
exit
$ timidity Midi_Guitar/
Code:
Playing Midi_Guitar/A Casinha Pequenina_1_Brazil.mid
MIDI file: Midi_Guitar/A Casinha Pequenina_1_Brazil.mid
Format: 1  Tracks: 17  Divisions: 240
Track name: Acoustic Guitar (nylon)
Track name:  - 
....
If commenting out the lines re amixer on the script, TiMidity can play midi files but without sound.

Quote:
One thing still: Maybe you would like your script to be run when your system starts.
Therefor create a link in rcsysinit.d like you did in rc5.d.
Tried before without result.

Quote:
I have one question still:
Where have you read you needed tot start such a script?
Please refer to above.

Others noted with tks.

BR
satimis
 
Old 10-02-2005, 11:09 AM   #11
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,428

Original Poster
Rep: Reputation: 53
Quote:
Originally posted by Dark_Helmet
This link might be useful: A look at System V Initialization

It should asnwer most, if not all, the questions you have about the boot script process.
Hi Dark_Helmet ,

Tks for your link.

BR
satimis
 
Old 10-02-2005, 11:52 AM   #12
hoes
Member
 
Registered: Sep 2005
Distribution: debian, linux from scratch
Posts: 93

Rep: Reputation: 20
> If commenting out the lines re amixer on the script, TiMidity can play midi files but without sound.

I also have alsa on my hostsystem and encountered the same problem.
Alsa is so stupid to mute every channel when the system boots.
If you alsactl, you should really look in its manpage.
I think it's possible to save the configuration of your mixer with that program.

> #!/bin/sh
>
> modprobe snd-pcm-oss
> modprobe snd-seq-oss
> amixer set Master 80% unmute
> amixer set CD 80% unmute
> amixer set PCM 80% unmute
> amixer set Line 80% unmute

You can make LFS load a modules by putting only the name in /etc/sysconfig/modules.
If you also figure out how to use alsactl to save your alsa options at shutdown and load at boottime there will be no need for your script anymore.

Good luck
 
Old 10-02-2005, 01:25 PM   #13
kjordan
Member
 
Registered: Jul 2004
Distribution: LFS, I felt the itch and scratched it
Posts: 227

Rep: Reputation: 31
[QUOTE]Originally posted by satimis
[B]Hi kjordan,

I put following 2 lines on /etc/sysconfig/modules
Code:
modprobe snd-pcm-oss
modprobe snd-seq-os
It did not work.

It doesn't need modprobe, just the name of the module.
 
Old 10-10-2005, 03:39 AM   #14
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,428

Original Poster
Rep: Reputation: 53
Hi hoes,

Quote:
I also have alsa on my hostsystem and encountered the same problem.
Alsa is so stupid to mute every channel when the system boots.
I solved my problem.

If you are still encountering the problem of sound channels muted at boot while running LFS/BLFS, please try follow;

Edit /etc/dev.d/snd/alsa.dev
(refer to the red-color text)

$ cat /etc/dev.d/snd/alsa.dev
Code:
#!/bin/sh -e
# This script is called by udevd when a change in a device is
# detected, including initial detection upon bootup.
# udevd sets the environment variables ACTION and DEVNAME.

[ "$ACTION" = "add" ] || exit 0
DEV_BASENAME="${DEVNAME##*/}"
N="${DEV_BASENAME#controlC}"

echo "action=${ACTION}" >>/root/alsa-trace.txt  # bwkaz
echo "devname=${DEVNAME}" >>/root/alsa-trace.txt  # bwkaz
echo "basename=${DEV_BASENAME}" >>/root/alsa-trace.txt  # bwkaz
echo "N=${N}" >>/root/alsa-trace.txt  # bwkaz
echo "" >>/root/alsa-trace.txt  # bwkaz

case "$DEV_BASENAME" in
    controlC[0-7])
        x=0
#       echo "in alsa.dev" >>/root/alsa-trace.txt
        while [ $x -lt 20 ]; do
            # Wait up to 20 seconds for /usr to be mounted if necessary
            if [ -f /usr/sbin/alsactl ]; then
                /usr/sbin/alsactl restore $N
                exit 0
            fi
            sleep 1
            x=`expr $x + 1 `
        done & # Put the while command in the background and continue
    ;;
esac
exit 0
adding the ` and a space before it.

HTH

BR
satimis
 
Old 10-10-2005, 03:03 PM   #15
sundialsvcs
Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,425

Rep: Reputation: 1159Reputation: 1159Reputation: 1159Reputation: 1159Reputation: 1159Reputation: 1159Reputation: 1159Reputation: 1159Reputation: 1159
A thimbleful of background information about the startup process ...

(1) When Linux finishes basic kernel initialization, it runs one program... init. That program is the ultimate ancestor of all other processes and it never shuts down. {If it tries, you'll get a kernel panic.}

(2) One of the parameters to the startup is the "runlevel," which normally is "5." This will determine exactly what init does next... that is to say, which other programs it decides to run.

(3) init refers to the file /etc/inittab to find out what to do. If you examine this file, you'll see that for runlevel "n" there will be an instruction to execute the stuff in /etc/rc.d/rc.n/. (There's actually a single shell-script, named /etc/rc.d/rc, but you get the idea.)

(4) To do that, init (actually rc...) takes an alphabetized listing of all the files in that directory which begin with the letter "S" (for "S"tartup). And that is why each of the files in the directory begin with "Snn", where nn is a number... to specify the alphabetic-ordering. These commands will be executed in order, given the parameter "start."

(5) All of these files are usually symbolic links to command-files that will be found in /etc/init.d.

(6) If you are switching from one runlevel to another, such as when you're going to/from single-user mode or shutting down or restarting, the Knn scripts are used to "K"ill the old runlevel before "S"tarting the new one.

The init process is not only the startup-manager, but also the "grim reaper" that gets called when any orphaned process dies. It gets notified when power is failing and when power is restored. /etc/inittab controls all aspects of its operation.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Bash put script jnusa Programming 3 09-07-2004 03:31 AM
Where to put iptables script? tentolga Linux - Networking 9 08-28-2004 08:39 AM
PPPD how do I know what to put in the script? jimdaworm Slackware 4 02-29-2004 01:02 PM
Where to put program/script cmfarley19 Linux - General 5 02-26-2004 02:23 PM
How & where to put script? snakedriver Linux - Newbie 2 01-21-2004 08:11 PM


All times are GMT -5. The time now is 10:26 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration