View RSS Feed

James' openSUSE Bash Scripting (and other things) Blog - Your Comments are Welcome!

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

Rating: 3 votes, 5.00 average.
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):

Code:
kdesu kwrite /usr/lib/systemd/system/after-local.service
OR

Code:
gnomesu gedit /usr/lib/systemd/system/after-local.service
This is what you put into this file and save it:

Code:
#  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
2. Next, we need to add the after-local.service to systemd. Open up a terminal session and run the following command:

Code:
sudo systemctl enable /usr/lib/systemd/system/after-local.service
3. 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):

Code:
kdesu kwrite /etc/init.d/after.local
OR

Code:
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):

Code:
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

Submit "systemd and using the after.local script in openSUSE 12.1/12.2/12.3" to Digg Submit "systemd and using the after.local script in openSUSE 12.1/12.2/12.3" to del.icio.us Submit "systemd and using the after.local script in openSUSE 12.1/12.2/12.3" to StumbleUpon Submit "systemd and using the after.local script in openSUSE 12.1/12.2/12.3" to Google Submit "systemd and using the after.local script in openSUSE 12.1/12.2/12.3" to Facebook Submit "systemd and using the after.local script in openSUSE 12.1/12.2/12.3" to Twitter

Updated 28-Jul-2013 at 15:26 by jdmcdaniel3

Categories
openSUSE Software

Comments

Page 1 of 2 12 LastLast
  1. buckmaster60's Avatar
    Does not seem to work with gnome is OS 12.1, trying to mount cifs and nothing occurs.
  2. jdmcdaniel3's Avatar
    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,
  3. buckmaster60's Avatar
    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.
  4. please_try_again's Avatar
    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

    [CODE]WantedBy=multi-user.target[/CODE]

    with

    [CODE]WantedBy=getty.target[/CODE]

    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.

    [QUOTE]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. [/QUOTE]

    (more info here: http://www.freedesktop.org/wiki/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.
  5. jdmcdaniel3's Avatar
    [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

    [CODE]WantedBy=multi-user.target[/CODE]

    with

    [CODE]WantedBy=getty.target[/CODE]

    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 ([url]http://forums.opensuse.org/english/get-technical-help-here/install-boot-login/469461-bug-nmb-systemd-more-than-1-ethernet-card.html[/url]), 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: [url=http://www.freedesktop.org/wiki/Software/systemd/Incompatibilities]freedesktop.org - Software/systemd/Incompatibilities[/url])


    * 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,
  6. please_try_again's Avatar
    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.
  7. kresh's Avatar
    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!
  8. jdmcdaniel3's Avatar
    [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,
  9. jdmcdaniel3's Avatar
    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.

    [QUOTE] 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. [/QUOTE]

    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

    [CODE]kdesu kwrite /lib/systemd/system/nginx.service[/CODE]

    OR

    [CODE]gnomesu gedit /lib/systemd/system/nginx.service[/CODE]

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


    [CODE]# 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[/CODE]

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

    [CODE]sudo systemctl enable /lib/systemd/system/nginx.service[/CODE]

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

    Thank You,
  10. jdmcdaniel3's Avatar
    Want to see if systemd is being used? Then open up terminal and run the command:

    [CODE]ls -l /sbin/init[/CODE]

    If you get this, you are running systemd:

    [CODE]/sbin/init -> ../bin/systemd[/CODE]

    If you get this, you are not:

    [CODE]/sbin/init -> ../sbin/init[/CODE]

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

    [CODE]systemd-analyze[/CODE]

    And here is the result I get:

    [CODE]Startup finished in 1870ms (kernel) + 6004ms (userspace) = 7875ms[/CODE]

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

    [CODE]Alt-F2: kdesu /usr/bin/systemadm[/CODE]

    OR

    [CODE]Alt-F2: xdg-su -c /usr/bin/systemadm[/CODE]

    And get a screen that looks like this:

    [IMG]http://paste.opensuse.org/view/download/99910682[/IMG]

    Thank You,
    Updated 07-Mar-2012 at 15:50 by jdmcdaniel3
  11. pistazienfresser's Avatar
    On my openSUSE 12.1 GNOME it seems to be a bit different to start the [I]systemd System manager[/I]. I have to give the command
    [CODE]gnomesu /usr/bin/systemadm[/CODE] in the terminal emulator [I]GNOME terminal[/I].

    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:
    [CODE]xdg-su -c /usr/bin/systemadm[/CODE]

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


    Regards
    Martin
  12. jdmcdaniel3's Avatar
    [QUOTE=pistazienfresser;bt408]On my openSUSE 12.1 GNOME it seems to be a bit different to start the [I]systemd System manager[/I]. I have to give the command
    [CODE]gnomesu /usr/bin/systemadm[/CODE] in the terminal emulator [I]GNOME terminal[/I].

    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:
    [CODE]xdg-su -c /usr/bin/systemadm[/CODE]

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


    Regards
    Martin[/QUOTE]

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

    Thank You,
  13. jdmcdaniel3's Avatar
    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,
  14. Rachelsdad's Avatar
    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
  15. jdmcdaniel3's Avatar
    [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,
  16. MarcoMeswara's Avatar
    http://arcierisinasce.wordpress.com/2012/08/01/after-local-opensuse-12-1/
  17. MarcoMeswara's Avatar
    [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
  18. jdmcdaniel3's Avatar
    Copy this line, open up terminal, paste it in and press the enter key:

    [CODE]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[/CODE]

    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,
  19. MarcoMeswara's Avatar
    [QUOTE=jdmcdaniel3;bt643]Copy this line, open up terminal, paste it in and press the enter key:

    [CODE]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[/CODE]

    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 ...
  20. jdmcdaniel3's Avatar
    This documentation and the make-after-local bash script has been updated to place the after-local.service file in the folder location of /usr/lib/systemd/system/ to keep in line with how service files are placed in openSUSE 12.3 but it still works in its old location, for now.

    For more help with systemd, have a look here: [URL="https://forums.opensuse.org/blogs/jdmcdaniel3/sysdcmd-systemd-command-help-config-editor-version-1-0-0-138/"]SysdCmd - systemd Command Help/Config Editor - Blogs - openSUSE Forums[/URL]

    Thank You,
Page 1 of 2 12 LastLast