LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 09-16-2013, 07:53 AM   #1
displace
Member
 
Registered: Jan 2013
Location: EU
Distribution: Debian
Posts: 268

Rep: Reputation: 25
Where to run a pre-rc script?


Quick question.

In Debian (wheezy) where is the proper place to put a shell script or a link to a script that has to run at boot, but before any services start (/etc/rcX.d). I need to make some folders on a tmpfs mount or else some services fail to start. I thought of editing the init scripts for each service, but these can get overwritten on apt-get update.

Best regards!
 
Old 09-16-2013, 02:48 PM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
In /etc/inet.d directory you can place your script.

You can use update-rc.d to add the script to your startup properly. You can just place your own symbolic links in each /etc/rc#.d directory; however this is what update-rc.d is for.

Choosing a index which is lower in number than what you want to run before will mean that your script will run in advance of those other ones.

Perform the following check in a command line, here's my example result:

Code:
ls /etc/rc*
/etc/rc.local

/etc/rc0.d:
K02mediatomb     K20openbsd-inetd  README                  S15wpa-ifupdown  S30urandom       S35networking  S60umountroot
K20gmediaserver  K74bluetooth      S10unattended-upgrades  S20sendsigs      S31umountnfs.sh  S40umountfs    S90halt

/etc/rc1.d:
K02mediatomb   K20acpi-support  K20kerneloops     K20rsync  K20speech-dispatcher  K80cups  S30killprocs  S70pppd-dns
K15pulseaudio  K20gmediaserver  K20openbsd-inetd  K20saned  K74bluetooth          README   S70dns-clean  S90single

/etc/rc2.d:
README         S20gmediaserver  S20openbsd-inetd      S25bluetooth  S50pulseaudio  S50saned      S70pppd-dns        S98mediatomb     S99grub-common  S99rc.local
S20fancontrol  S20kerneloops    S20speech-dispatcher  S50cups       S50rsync       S70dns-clean  S90binfmt-support  S99acpi-support  S99ondemand

/etc/rc3.d:
README         S20gmediaserver  S20openbsd-inetd      S25bluetooth  S50pulseaudio  S50saned      S70pppd-dns        S98mediatomb     S99grub-common  S99rc.local
S20fancontrol  S20kerneloops    S20speech-dispatcher  S50cups       S50rsync       S70dns-clean  S90binfmt-support  S99acpi-support  S99ondemand

/etc/rc4.d:
README         S20gmediaserver  S20openbsd-inetd      S25bluetooth  S50pulseaudio  S50saned      S70pppd-dns        S98mediatomb     S99grub-common  S99rc.local
S20fancontrol  S20kerneloops    S20speech-dispatcher  S50cups       S50rsync       S70dns-clean  S90binfmt-support  S99acpi-support  S99ondemand

/etc/rc5.d:
README         S20gmediaserver  S20openbsd-inetd      S25bluetooth  S50pulseaudio  S50saned      S70pppd-dns        S98mediatomb     S99grub-common  S99rc.local
S20fancontrol  S20kerneloops    S20speech-dispatcher  S50cups       S50rsync       S70dns-clean  S90binfmt-support  S99acpi-support  S99ondemand

/etc/rc6.d:
K02mediatomb     K20openbsd-inetd  README                  S15wpa-ifupdown  S30urandom       S35networking  S60umountroot
K20gmediaserver  K74bluetooth      S10unattended-upgrades  S20sendsigs      S31umountnfs.sh  S40umountfs    S90reboot

/etc/rcS.d:
README  S13pcmciautils  S25brltty  S37apparmor  S47lm-sensors  S55urandom  S70x11-common
Scripts with "S" in front of them are startup scripts.

Scripts with "K" in front of them are shutdown scripts.

Say I want to run something before S25bluetooth, but I require S20gmediaserver to be running. Well, I can create a symbolic link (or install via update-rc.d) a script link prepended with S21, S22, S23, or S24 and it will run in the appropriate time.

Notice next that the S25bluetooth and S20mediaserver run only in runlevels 2, 3, 4, and 5. This is actually pretty typical of most systems for scripts that are intended for all user environments. Therefore when you install the script using update-rc.d, you choose 2, 3, 4, and 5 as the runlevels you wish to install it for.
 
Old 09-16-2013, 02:51 PM   #3
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
You can always just place your script in /etc/init.d and then in each of /etc/rc2.d, /etc/rc3.d, /etc/rc4.d, and /etc/rc5.d create same named symbolic links which point to the script in /etc/init.d. The rules would be the same, "S" for startup, and choose a two digit number which places it in the appropriate space of available numbers.
 
Old 09-17-2013, 12:42 AM   #4
displace
Member
 
Registered: Jan 2013
Location: EU
Distribution: Debian
Posts: 268

Original Poster
Rep: Reputation: 25
Wouldn't it be better to just use one entry in rcS.d instead?

https://wiki.debian.org/BootProcess
Quote:
The Debian system goes into runlevel S to initialize the system under the single-user mode to complete hardware initialization etc.
The Debian system switches itself to one of the specified multi-user runlevels (2 to 5) to start the system services.
As far as I see inittab is the earliest configuration before initramfs. Afterwards rcS.d scripts are executed. And finally the services start.
 
Old 09-17-2013, 08:09 AM   #5
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
That would also work. There was some intentions as to how it was done previously but I don't know the history. I've also never booted to any other level besides runlevel 5 except whatever a recovery/restore boot does. As far as the kernel boot process goes, I believe it proceeds through the runlevels and a kernel programmer needing to debug something would care. On an embedded linux system I use, I do exactly what you just said, I place the scripts in /etc/init.d and make a symbolic link in /etc/rcS.d
 
Old 09-17-2013, 10:58 AM   #6
displace
Member
 
Registered: Jan 2013
Location: EU
Distribution: Debian
Posts: 268

Original Poster
Rep: Reputation: 25
Alright then. That's what I'll settle for. I'll reply, if I have any further problems.

Kind regards!
~displace
 
  


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
How to run a pre-built fedora jeos on ESXi Kaustuv Linux - Virtualization and Cloud 5 04-11-2013 10:58 PM
[SOLVED] Cannot run 64-bit pre-compiled binaries on CLFS-Pure64 system corbis_demon Linux From Scratch 2 09-19-2012 02:07 AM
How to get NES to run on the Palm Pre hotrock85 Linux - Newbie 0 07-25-2009 02:43 PM
chroot and run a pre existing Linux install from another one fakie_flip Linux - Software 1 09-25-2006 12:43 PM
on Network Up Script run? On Battery power run script? v2-ncl Linux - General 0 12-08-2003 09:34 AM

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

All times are GMT -5. The time now is 02:43 AM.

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