rc.local should support a runparts of rc.local.d

Bug #915215 reported by Scott Moser
24
This bug affects 5 people
Affects Status Importance Assigned to Milestone
systemd (Ubuntu)
Won't Fix
Wishlist
Unassigned
sysvinit (Ubuntu)
Triaged
Wishlist
Scott Moser

Bug Description

the current rc.local script that gets installed is difficult to work with.

For doing simple things like "i just want to run this at the end of boot", the 'exit 0' at the end means that human editing is almost required to do so without possibly breaking other content that might be in it.

ie, right now we have:
---
#!/bin/sh
# some comments here

exit 0
----

that makes it very difficult to add a command.

2 solutions for this:
1.) drop 'exit 0', its completely unnecessary
2.) support runparts

runparts means something that wants to simply add a script can do so, and it can easily be deleted.

ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: initscripts 2.88dsf-13.10ubuntu8
ProcVersionSignature: Ubuntu 3.2.0-7.13-generic 3.2.0-rc7
Uname: Linux 3.2.0-7-generic x86_64
ApportVersion: 1.90-0ubuntu1
Architecture: amd64
Date: Thu Jan 12 10:12:59 2012
EcryptfsInUse: Yes
InstallationMedia: Ubuntu 11.10 "Oneiric Ocelot" - Release amd64 (20111012)
ProcEnviron:
 PATH=(custom, user)
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: sysvinit
UpgradeStatus: Upgraded to precise on 2011-11-07 (65 days ago)

Related branches

Revision history for this message
Scott Moser (smoser) wrote :
Revision history for this message
Scott Moser (smoser) wrote :

just for reference, sed is easly:
  sed -i '$s/^exit 0$//'

Revision history for this message
Scott Moser (smoser) wrote :

better (thanks to rbasak), to just edit out that 'exit 0':
  sed -i '${/^exit 0$/d}' /etc/rc.local

Revision history for this message
Scott Moser (smoser) wrote :

Upon further thought, i think the easiest path here is to simply add a /etc/init.d/rc.local_d script that (or potentially as an upstart job) that runs stuff in /etc/init.d/rc.local.d

that way we dont have to deal with the potential of user having modified /etc/rc.local .

Revision history for this message
Scott Moser (smoser) wrote :

just for reference, but I think i'm not going to use it, here is an upstart job for rc.local.d scripts:

# rc-local-d - run scripts in /etc/rc.local.d in run-parts fashion
# after /etc/rc.local has finished
#
# This extends traditional rc.local to support run-parts

description "run scripts in /etc/rc.local.d at traditional rc.local timeframe"
author "Scott Moser <email address hidden>"

start on stopped rc RUNLEVEL=[2345]
stop on runlevel [016]

console output
task
script
   command -v run-parts >/dev/null || exit 0
   [ -d /etc/rc.local.d ] || exit 0
   exec run-parts /etc/rc.local.d
end script

Scott Moser (smoser)
Changed in sysvinit (Ubuntu):
status: New → In Progress
importance: Undecided → Low
assignee: nobody → Scott Moser (smoser)
Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

Hi Scott,

is there any reason not to first try going through Debian for this?

Revision history for this message
Scott Moser (smoser) wrote :

There has been some discussion on this bug in ubuntu-devel, and I realize that reading some of the comments above may be confusing, so I will summarize here.

 * The suggested merge proposal currently adds functional 'rc.local.d' behavior that would break anything. It does that with a new sysvinit script (rc.local.d). Clint suggested that it could/should be an upstart job, but I do not personally see that as an issue, nor do I think that by itself was blocking (The job could be changed to upstart later).
 * In the conversation on ubuntu-devel [1], Steve Langasek was not overjoyed by the idea of this change. His primary concern seemed to be that it was not sysvinit's job to provide this functionality.

Going forward, to address Steve's concerns, it might be best to simply add an rc.local.d package. I'm not actively pushing on this for 12.04, but may revisit in 12.10.

--
[1] http://irclogs.ubuntu.com/2012/02/07/%23ubuntu-devel.html#t20:12

Changed in sysvinit (Ubuntu):
importance: Low → Wishlist
status: In Progress → Triaged
Revision history for this message
Piotr Henryk Dabrowski (phd) wrote (last edit ):

/etc/rc.local script could simply include:

if [ -d '/etc/rc.local.d' ]; then
    for F in /etc/rc.local.d/*; do
        if [ -f "$F" ] && [ -x "$F" ]; then
            "$F"
        fi
    done
fi

But it will be hard to add this now, as user might have modified /etc/rc.local already.

However a simple systemd service could implement support for /etc/rc.local.d directory.

Revision history for this message
Benjamin Drung (bdrung) wrote :

Systemd has a rc-local.service, but no rc-local@.service for files in /etc/rc.local.d. Please forward this feature request to upstream systemd.

Changed in systemd (Ubuntu):
importance: Undecided → Wishlist
status: New → Triaged
Revision history for this message
Nick Rosbrook (enr0n) wrote :

I don't think this is relevant anymore.

Changed in systemd (Ubuntu):
status: Triaged → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.