brent timothy saner on 8 May 2017 05:55:00 -0700

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Systemd Startup Sequence Question

On 05/08/2017 08:32 AM, Casey Bralla wrote:
> I've decided I am not a fan of systemd.   I was very familiar with Debian's 
> sysvinit and Gentoo's OpenRC systems, and could easily add/delete services 
> with high reliability.   One thing I loved in both systems was the easy way of 
> adding misc programs to be run at the end of the boot sequence (/etc/rc.local 
> for Debian and /etc/local.d in Gentoo).
> I have always used these to mount my NFS share drives at the end of boot-up.
> Now that I'm running Arch with systemd, things are not so simple.   AFAIK, 
> Arch has no simple built-in system to run a misc program at boot time.  
> However, I loaded an rc.local program from the Arch User Repository (AUR), 
> which is supposed to be functionally equivalent to the Debian system I'm 
> familar with.
> Except, mounting NFS shares does not work.  I get a "network name not 
> recognized" error at start-up.   Once I log in, however, I can manually run 
> the rc.local batch file and the shares mount without any trouble.
> I presume rc-local is running before the entire entworking system is 
> operational.   Is there a way I can delay the rc.local batch file until truly 
> all other systemd processes have started?
> Anybody got any ideas?
> TIA!

first step, stop and learn[0] to create[1] unit[2] files[3]. trust me.
you'll thank me in about two weeks. they're easy to learn and simple INI
structured. speaking as someone who's written RC/sysVinit scripts and
systemd unit files, i vastly prefer the latter.

secondly, systemd uses a parallel and dependency-based init system, NOT
a sequential system. forget rc.local or any tool trying to retrogradedly
slap in functionality of it. it's holding you back.

to implement your own startup process, create a unit file. if you have a
script you're trying to run that you wrote yourself, you'll probably
want something like this:

Description=Some Custom Jobby Doodad
# Based on your email, you probably want as a dependency.
# You can specify multiply dependencies, though.

# "oneshot" is a blocking operation, but you get state status.
# "simple" is non-blocking but you don't get reliable reporting on
#   the process' exit code.
# If User and Group aren't specified, defaults to root.


write it as /etc/systemd/system/foobar.service (obviously replacing
foobar with something more descriptive). note that this is a terribly
barebones unit file. refer to the links i give at the footnote for info
on creating more complex units; it's immensely powerful.


systemctl daemon-reload
systemctl enable foobar.service  # or whatever you named it
# and optionally, start it immediately if you need it now
systemctl start foobar.service

done. that's it. that's literally it. i'd encourage you to look at the
other system/package-provided unit files in /usr/lib/systemd/system/ for
other examples.


Attachment: signature.asc
Description: OpenPGP digital signature

Philadelphia Linux Users Group         --
Announcements -
General Discussion  --