systemd-parse/README.org

46 lines
1.3 KiB
Org Mode
Raw Normal View History

#+title: 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.
#+begin_src common-lisp
(read-service "dbus.service")
#+end_src
The following sample is taken from =dbus.service=:
#+begin_example
[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
#+end_example
This file is parsed into the following lisp structure:
(I illustrate each table as "<table /content/>")
#+begin_src common-lisp
(("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">))
#+end_src
* Write-service
=write-service= translates the association list back into a =.service= file.
#+begin_src common-lisp
(write-service "test.service" my-service-options-list)
#+end_src