You are not logged in.
Pages: 1
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
Moving to Installation.
To know or not to know ...
... the questions remain forever.
Offline
Moving to Installation.
Thank you wasn't sure if thats th right category.
Offline
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?).
Offline
I am really into C. How did you you hit on that?
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
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
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
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
Pages: 1