Go to file
J S 283997b609
feat[read] Updated split-line regex
I updated the regex used in split-line to account for and discard
comments.
I also updated it to account for multiple = signs, such as in
environment variable definitions.
2023-12-21 01:47:21 -05:00
src feat[read] Updated split-line regex 2023-12-21 01:47:21 -05:00
LICENSE feat[license,split-line,readme] Added docs. 2023-12-19 23:12:10 -05:00
packages.lisp feat[license,split-line,readme] Added docs. 2023-12-19 23:12:10 -05:00
README.org feat[license,split-line,readme] Added docs. 2023-12-19 23:12:10 -05:00
systemd-parse.asd feat[license,split-line,readme] Added docs. 2023-12-19 23:12:10 -05:00

Readme

Systemd-parse is a common lisp library to parse .service files into useable data structures, and vice versa. It currently provides two functions: read-service and write-service

Read-service

read-service takes a .service file and returns an association list. The list associates section names with a hash table of the options under each section.

(read-service "dbus.service")

The following sample is taken from dbus.service:

[Unit]
Description=D-Bus System Message Bus
Documentation=man:dbus-broker-launch(1)

[Service]
Type=notify
Sockets=dbus.socket
OOMScoreAdjust=-900

[Install]
Alias=dbus.service

This file is parsed into the following lisp structure: (I illustrate each table as "<table /content/>")

(("Unit" . <table "Description" -> "D-Bus System Message Bus"
                  "Documentation" -> "man:dbus-broker-launch(1)">)
 ("Service" . <table "Type" -> "notify"
                     "Sockets" -> "dbus.socket"
                     "OOMScoreAdjust" -> "-900">)
 ("Install" . <table "Alias" -> "dbus.service">))

Write-service

write-service translates the association list back into a .service file.

(write-service "test.service" my-service-options-list)