You are not logged in.

#1 2012-09-11 19:42:47

blackst0rm
Member
Registered: 2012-09-11
Posts: 9

Systemd: Migrationscript

Hello

I've written a little python script which I want to share.
It is used to migrate an arch linux installation from the SysV init to systemd.
It will parse your rc.conf and generates the config files needed by systemd.
Your system configuration will not be touched, the generated files will be stored in the folder from which this script was invoked.
Optionally you can specify an ouput directory for the generated scripts. Run the script with -h option to get more help.

If you have some problems with the script fell free to ask in this thread.

Download link:
http://home.htw-berlin.de/~s0529396/sys … ate.tar.gz

Last edited by blackst0rm (2012-09-11 20:36:16)

Offline

#2 2012-09-11 20:30:32

bernarcher
Forum Fellow
From: Germany
Registered: 2009-02-17
Posts: 2,281

Re: Systemd: Migrationscript

Moving to Installation.


To know or not to know ...
... the questions remain forever.

Offline

#3 2012-09-11 20:35:41

blackst0rm
Member
Registered: 2012-09-11
Posts: 9

Re: Systemd: Migrationscript

bernarcher wrote:

Moving to Installation.

Thank you wasn't sure if thats th right category.

Offline

#4 2012-09-11 20:43:58

Stebalien
Member
Registered: 2010-04-27
Posts: 1,237
Website

Re: Systemd: Migrationscript

Interesting script. A few coding comments:
* Did you have any particular reason for choosing python instead of bash? Using bash and sourcing /etc/rc.conf would have been more robust and much easier.
* Python has multi-line strings ('''string that can span multiple lines''')
* Instead of

if verbose:
    print 'message'

defining a debug method and just calling it would be more concise:

>>> def debug(msg):
...     if verbose:
...         print msg

>>> debug('message')

* You could move the config file writing functionality into a function that takes a path and config options).

>>> def write_conf(filename, **options):
...     filepath = outputDir + filename
...     with open(filepath, 'w') as conf_file:
...         conf_file.writelines('%s=%s' % pair for pair in options.iteritems())
...     debug('wrote ' + filepath)
>>> write_conf('vconsole.conf', KEYMAP=keymap, FONT=consolefont, FONT_MAP=fontmap)

* You write really clean, readable code (do you have a background in C?).


Steven [ web : git ]
GPG:  327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C
Do not email: honeypot@stebalien.com

Offline

#5 2012-09-11 21:05:51

blackst0rm
Member
Registered: 2012-09-11
Posts: 9

Re: Systemd: Migrationscript

I am really into C. How did you you hit on that? wink
To be honest my first thought was implementing it as a little c program but I dropped it at second thought.

I must confess that I am much more fit in python than in bash. That's the reason why I chose python as script language for this script.

Thank you for your comments. I wanted to restructure the code anyway. It was a quick and dirty script at first because I had to repeat the same thing on my notebook and thought it would be a good idea to automate at least some parts.

Offline

#6 2012-09-11 23:30:48

slint
Member
Registered: 2009-05-22
Posts: 31

Re: Systemd: Migrationscript

If systemd is already running, you can also use the various dbus apis to change this configs.

http://www.freedesktop.org/wiki/Softwar … /hostnamed
http://www.freedesktop.org/wiki/Softwar … /timedated
http://www.freedesktop.org/wiki/Softwar … md/localed


I already thought about creating a small command line tool for changing those settings, but I haven't come around that yet

Offline

#7 2012-09-11 23:40:58

blackst0rm
Member
Registered: 2012-09-11
Posts: 9

Re: Systemd: Migrationscript

The intention of this script is not to change values in a running systemd configuration but to help migrating from an legacy SysV init arch linux system to an pure systemd system.
But you are right, a command line tool to configure those things would be nice.

Last edited by blackst0rm (2012-09-12 00:09:26)

Offline

#8 2012-09-12 12:23:51

blackst0rm
Member
Registered: 2012-09-11
Posts: 9

Re: Systemd: Migrationscript

Update:

The script now supports blacklisting of modules.
created git repository at github
https://github.com/sfenzke/arch-linux-S … tionscript

Last edited by blackst0rm (2012-09-12 13:28:32)

Offline

Board footer

Powered by FluxBB