Tuesday, January 24, 2012

Linux - OpenSUSE startup script with systemd

I've been struggling with my opensuse box to execute some scripts as root when the system starts, and I just found the answer to why it wasn't working.

I have found out that in openSUSE 12.1, 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.(1)

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


kdesu kwrite /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.

Description=/etc/init.d/after.local Compatibility



2. Next, we need to add the after-local.service to systemd. Open up a terminal session and run the following command:


sudo systemctl enable /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 

No comments:

Post a Comment