systemd and using the after.local script in openSUSE 12.1/12.2/12.3
by, 12-Nov-2011 at 21:25 (20608 Views)
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):
This is what you put into this file and save it:Code:kdesu kwrite /usr/lib/systemd/system/after-local.service
2. Next, we need to add the after-local.service to systemd. Open up a terminal session and run the following command: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
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:sudo systemctl enable /usr/lib/systemd/system/after-local.service
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:kdesu kwrite /etc/init.d/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.Code:wget -nc http://paste.opensuse.org/view/download/33889052 -O ~/bin/make-after-local ; chmod +x ~/bin/make-after-local ; make-after-local
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
Blogs: asroot : Bash : Packet Filter : C.F.U. : GPU's : fewrup : F.S.M. : H.I. : nVIDIA : LNVHW : N.S.F. : S.A.K.C. : MMCHECK
S.A.S.I. : S.C.L.U. : 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. : SYSEdit : systemd : YaST Power