Systemd and using the after.local script in openSUSE 12.1/12.2/12.3

I have found out that in openSUSE 12.1/12.2 and now 12.3, some startup scripts do not operate due to the usage of systemd. systemd really speeds up system startup by running the many startup processes in parallel and avoids the usage of shell scripts altogether. That is is good for speed, but not good if you are in need of running something in openSUSE as root when the system is restarted. In my case I was trying to run some VirtualBox mount commands in a VM running openSUSE 12.1/12.2/12.3 and could not get them to work properly. I nominally just add these commands to the /etc/init.d/after.local bash script, but in openSUSE 12.1/12.2/12.3 I found out that by default, after.local is not being run anymore. First off I have a procedure to make /etc/init.d/after.local run as normal, at least it seemed normal AND, I found out that you can instead just use /etc/init.d/boot.local as if it was after.local and it works just as before.

Now, since I figured out how to make after.local work, lets see how that is done.

  1. We need to create the text file after-local.service (shown below) in the folder /usr/lib/systemd/system as root (Alt-F2):
kdesu kwrite /usr/lib/systemd/system/after-local.service

OR

gnomesu gedit /usr/lib/systemd/system/after-local.service

This is what you put into this file and save it:

#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.

[Unit]
Description=/etc/init.d/after.local Compatibility
ConditionFileIsExecutable=/etc/init.d/after.local

[Service]
Type=oneshot
ExecStart=/etc/init.d/after.local
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99

[Install]
WantedBy=multi-user.target
  1. Next, we need to add the after-local.service to systemd. Open up a terminal session and run the following command:
sudo systemctl enable /usr/lib/systemd/system/after-local.service
  1. Finally, you need to edit the file /etc/init.d/after.local as root and add in the stuff you want to run as root when you startup openSUSE (Alt-F2):
kdesu kwrite /etc/init.d/after.local

OR

gnomesu gedit /etc/init.d/after.local

The commands shown here assume you are using KDE, which is the default in openSUSE. Please let me know if you have any questions about using this procedure. I have a script called sasi that can install the after-local file and enable it all for you automatically. Open up a terminal session (in openSUSE 12.1) and run the following command (You can copy and paste it in if you like):

wget -nc http://paste.opensuse.org/view/download/33889052 -O ~/bin/make-after-local ; chmod +x ~/bin/make-after-local ; make-after-local

You must enter the root user password once for the process to complete. This does not actually put anything into the after.local script, which you must do if you have something you want to run on your system startup as root.

If the after.local bash script does not exist, it will now be created for you with this new make-after-local bash script. This script has even been tested with Fedora 16, which also uses systemd and it created the after.local bash script and activated it for you, ready to use.

On openSUSE, as long as the after.local script exists, the make-after-local bash script will not over write it, but indicate the file was not written, which is OK.

This documentaion has been updated to place the after.local.service file in the folder /usr/lib/systemd/system to be inline with the locations used for service files in openSUSE 12.3.

For more help in using systemd, please look here: SysdCmd - systemd Command Help/Config Editor - Blogs - openSUSE Forums

For help with Grub 2 and your Bootup Process: GNU Grub2 Command Listing Helper with --help & Input - Blogs - openSUSE Forums

For Help with Loading Application from Terminal using Zypper: Zypper Command - Zypper Package Management Menu System

For help with Samba, Have a look here: S.A.C.T. - Samba Automated Configuration Tool - Version 1.06 - Blogs - openSUSE Forums

For help in creating a Live USB to Boot openSUSE: S.C.L.U. - SuSE Create Live USB - Version 1.00 - Blogs - openSUSE Forums

Want to compile your own kernel, Have a look here: openSUSE and Installing New Linux Kernel Versions - Blogs - openSUSE Forums

For Help in Editing any System File: SYSEdit - System File Editor

Thank You,

Blogs: asroot : Bash : Packet Filter : C.F.U. : DKMS : Grub 2 & Run Level 3 : GPU’s : fewrup : F.S.M. : H.I. : nVIDIA : LNVHW : N.S.F. : S.A.K.C.
MMCHECK S.A.S.I. : S.A.N.D.I. : S.G.T.B. : S.K.I.M. : S.L.A.V.E. : S.L.R.C. : S.T.A.R.T. : S.U.F.F. : UTC or GMT Time: YaST Power

Does not seem to work with gnome is OS 12.1, trying to mount cifs and nothing occurs.

So, buckmaster, I have used this procedure with GNOME 3.2 and then used the after.local script to map vbox drives when all used in VirtualBox as a Guest. So, after.local does work, but there may be some other issue getting cifs to work there. Perhaps it is too early or before your network is up, but not sure.

That You,

I agree. They have really messed up CIFS in this release 12.1. Please see http://forums.opensuse.org/english/get-technical-help-here/network-internet/468521-problem-samba-opensuse-12-1-re-systemd.html.

Thanks for your help.

Unfortunatley, it doesn’t behave like systemV after.local, meaning it doesn’t run after all services have been started. If you put a command which needs a service that hasn’t been started, it won’t work.

I tried to replace

WantedBy=multi-user.target

with

WantedBy=getty.target

hoping that it would start at a later point. But it didn’t help.

I tried to add LSB headers to after.local, so that it would start the service I need first (rpcbind in my case) and it hanged systemd for 5 minutes or even for ever, but I have been pressing the reset button or used SysReq a lot last night. My netcards don’t get an IP in systemd when nmb is enable (http://forums.opensuse.org/english/get-technical-help-here/install-boot-login/469461-bug-nmb-systemd-more-than-1-ethernet-card.html), I can not mount nfs from script at startup because it won’t wait for the portmapper. Everything in modern Linuxes has to be done asynchronously with the consequence that nothing works properly. I’m out of ideas for now, would like a real after.local functionality though. I noticed that under Fedora (15) /lib/systemd/system/rc-local.service executes /etc/rc.local - which makes sense because rc.local is the script which gets executes after the init process. Only openSUSE calls it “after.local” and executes /etc/init.d/boot.local in systemd - that is executed at the end of the boot process and before entering the runlevels in Sytem V. Anyway trying to replace boot.local with after.local in systemd rc-local.service under openSUSE didn’t work either.

I’m back in system V for now.

Note that there are some areas where systemd currently provides a certain amount of compatibility where we expect this compatibility to be removed eventually. For example, systemd currently provides compatibility with the special non-standardized “boot” and “S” runlevels covering early boot which are used on Suse and Debian systems. We expect to remove this eventually, to keep compatibility kludges out of early boot. Support for SysV init scripts in the normal runlevels (2-5) is expected to stay for a long time however.

(more info here: Incompatibilities)

  • I put my code in CODE and im my quote in QUOTE. If the blog interface doesn’tlike it, I wash my hands of the issue.

[QUOTE=please_try_again;bt284]Unfortunatley, it doesn’t behave like systemV after.local, meaning it doesn’t run after all services have been started. If you put a command which needs a service that hasn’t been started, it won’t work.

I tried to replace

WantedBy=multi-user.target

with

WantedBy=getty.target

hoping that it would start at a later point. But it didn’t help.

I tried to add LSB headers to after.local, so that it would start the service I need first (rpcbind in my case) and it hanged systemd for 5 minutes or even for ever, but I have been pressing the reset button or used SysReq a lot last night. My netcards don’t get an IP in systemd when nmb is enable (http://forums.opensuse.org/english/get-technical-help-here/install-boot-login/469461-bug-nmb-systemd-more-than-1-ethernet-card.html), I can not mount nfs from script at startup because it won’t wait for the portmapper. Everything in modern Linuxes has to be done asynchronously with the consequence that nothing works properly. I’m out of ideas for now, would like a real after.local functionality though. I noticed that under Fedora (15) /lib/systemd/system/rc-local.service executes /etc/rc.local - which makes sense because rc.local is the script which gets executes after the init process. Only openSUSE calls it “after.local” and executes /etc/init.d/boot.local in systemd - that is executed at the end of the boot process and before entering the runlevels in Sytem V. Anyway trying to replace boot.local with after.local in systemd rc-local.service under openSUSE didn’t work either.

I’m back in system V for now.

(more info here: freedesktop.org - Software/systemd/Incompatibilities)

  • I put my code in CODE and im my quote in QUOTE. If the blog interface doesn’tlike it, I wash my hands of the issue.[/QUOTE]

So have you filed a bug report on this issue yet please_try_again?

Thank You,

My wife filled the bug report on the nmb issue - that I could clearly identify and reproduce.
About /lib/systemd/system/rc-local.service not working as I would expect, I can not say that it’s a bug (I don’t know what the developpers had in mind). If you take a look at the services, you will notice that most of the ones starting daemons installed from packages still use sysvinit scripts (that get shadowed and started by systemctl, I don’t know exactly how). On the 12.1 systems I’m (just) starting to install, the exceptions are apache2 and hddtemp (the one I actually ported myself from Fedora - it’s in my repo). I’m sure the systemd team is aware of the portmapper starting too late (or the after.local running too early). The problem doesn’t exist in Fedora 15 though.

Thank you so much. This removed the final barrier that was keeping me from upgrading from 11.4 to 12.1

This was well written with clear instructions. Outstanding!

[QUOTE=kresh;bt287]Thank you so much. This removed the final barrier that was keeping me from upgrading from 11.4 to 12.1

This was well written with clear instructions. Outstanding![/QUOTE]

Gland you like the writeup kresh and thanks for the kind words. Please, if you make any new discoveries on this subject, don’t forget to share them with us here.

Thank You,

A user here using openSUSE 12.1 & nginx ran into a problem with the service not starting properly due to the use of systemd. nginx is included in the standard repositories and its description is as follows.

nginx [engine x] is a HTTP server and IMAP/POP3 proxy server written by Igor Sysoev. It has been running on many heavily loaded Russian sites for more than two years.

Turns out just a few simple steps allows it to run with openSUSE 12.1 and systemd and are as follows: You need to create a text file called nginx.service

kdesu kwrite /lib/systemd/system/nginx.service

OR

gnomesu gedit /lib/systemd/system/nginx.service

Or use vi or nano as root to edit/create this file. The file should contain the following text.

#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.

[Unit]
Description=Nginx - a high performance http(s) server
After=syslog.target network.target

[Service]
Type=forking
ExecStart=/usr/sbin/nginx
ExecReload=/usr/sbin/nginx -s reload

[Install]
WantedBy=multi-user.target

Save the text file and then use the following command to activate this service.

sudo systemctl enable /lib/systemd/system/nginx.service

So this procedure was said to work once. So, if it works for you, you got to let me know here.

Thank You,

Want to see if systemd is being used? Then open up terminal and run the command:

ls -l /sbin/init

If you get this, you are running systemd:

/sbin/init -> ../bin/systemd

If you get this, you are not:

/sbin/init -> ../sbin/init

Want to check your startup speed in systemd? Try this terminal command:

systemd-analyze

And here is the result I get:

Startup finished in 1870ms (kernel) + 6004ms (userspace) = 7875ms

Want to run a systemd Graphic Utility? Open YaST and search on systemd-gtk and when found, install it. To use, just enter:

Alt-F2: kdesu /usr/bin/systemadm

OR

Alt-F2: xdg-su -c /usr/bin/systemadm

And get a screen that looks like this:

http://paste.opensuse.org/view/download/99910682

Thank You,

On my openSUSE 12.1 GNOME it seems to be a bit different to start the systemd System manager. I have to give the command

gnomesu /usr/bin/systemadm

in the terminal emulator GNOME terminal.

It is not working if I enter it in the small line after “Please enter a command:” in the little window that opens
after pressing [Alt] and [F2] simultaneously.

But I am able to start that systemd System Manager after pressing [Alt]+[F2] if I use this command instead:

xdg-su -c /usr/bin/systemadm

Maybe gnomesu is to blame for that?
https://features.opensuse.org/305640
https://bugzilla.novell.com/show_bug.cgi?id=709441
https://bugzilla.novell.com/show_bug.cgi?id=681078

Regards
Martin

[QUOTE=pistazienfresser;bt408]On my openSUSE 12.1 GNOME it seems to be a bit different to start the systemd System manager. I have to give the command

gnomesu /usr/bin/systemadm

in the terminal emulator GNOME terminal.

It is not working if I enter it in the small line after “Please enter a command:” in the little window that opens
after pressing [Alt] and [F2] simultaneously.

But I am able to start that systemd System Manager after pressing [Alt]+[F2] if I use this command instead:

xdg-su -c /usr/bin/systemadm

Maybe gnomesu is to blame for that?
https://features.opensuse.org/305640
https://bugzilla.novell.com/show_bug.cgi?id=709441
https://bugzilla.novell.com/show_bug.cgi?id=681078

Regards
Martin[/QUOTE]

Hey, thanks for the advise Martin. I changed my example to what is working on your system.

Thank You,

If the after.local bash script does not exist, it will now be created for you with this new make-after-local bash script. This script has even been tested with Fedora 16, which also uses systemd and it created the after.local bash script and activated it for you, ready to use.

On openSUSE, as long as the after.local script exists, the make-after-local bash script will not over write it, but indicate the file was not written, which is OK.

Thank You,

Per my previous PM in response to your follow-up of my post to the LARTC list, James, thank you very, very much for this excellent article. I tested this with my iproute2 commands (ip route add… and ip rule add…), and it works like a charm.

Cheers

[QUOTE=Rachelsdad;bt547]Per my previous PM in response to your follow-up of my post to the LARTC list, James, thank you very, very much for this excellent article. I tested this with my iproute2 commands (ip route add… and ip rule add…), and it works like a charm.

Cheers[/QUOTE]

Thanks so much for your kind words and I was very happy to be of help to you.

Thank You,

http://arcierisinasce.wordpress.com/2012/08/01/after-local-opensuse-12-1/

[QUOTE=kresh;bt287]Thank you so much. This removed the final barrier that was keeping me from upgrading from 11.4 to 12.1

This was well written with clear instructions. Outstanding![/QUOTE]

I had this error;

make-after-local

If ‘make-after-local’ is not a typo you can use command-not-found to lookup the package that contains it, like this:
cnf make-after-local

Copy this line, open up terminal, paste it in and press the enter key:

rm ~/bin/make-after-local ; wget -nc http://paste.opensuse.org/view/download/15931498 -O ~/bin/make-after-local ; chmod +x ~/bin/make-after-local ; make-after-local

This line will …

  1. Remove ~/bin/make-after-local should it exist
  2. Download ~/bin/make-after-local from SuSE Paste
  3. Set ~/bin/make-after-local Executable
  4. Run ~/bin/make-after-local

You must enter the root password once to copy the system files when ~/bin/make-after-local is run.

Thank You,

[QUOTE=jdmcdaniel3;bt643]Copy this line, open up terminal, paste it in and press the enter key:

rm ~/bin/make-after-local ; wget -nc http://paste.opensuse.org/view/download/15931498 -O ~/bin/make-after-local ; chmod +x ~/bin/make-after-local ; make-after-local

This line will …

  1. Remove ~/bin/make-after-local should it exist
  2. Download ~/bin/make-after-local from SuSE Paste
  3. Set ~/bin/make-after-local Executable
  4. Run ~/bin/make-after-local

You must enter the root password once to copy the system files when ~/bin/make-after-local is run.

Thank You,[/QUOTE]

Thanx buddy. Realy really appreciate all the effort you are putting into this …