feat[all] Wrote initial read-file functionality
I created the first version of READ-SYSTEM. It parses a .service file into an associative list of hash-tables.
This commit is contained in:
commit
9474199299
5
packages-systemd.lisp
Normal file
5
packages-systemd.lisp
Normal file
@ -0,0 +1,5 @@
|
||||
(defpackage :service-edit
|
||||
(:use :common-lisp))
|
||||
|
||||
(defpackage :service-opts
|
||||
(:use :common-lisp))
|
28
src/read-service.lisp
Normal file
28
src/read-service.lisp
Normal file
@ -0,0 +1,28 @@
|
||||
;(in-package :service-edit)
|
||||
(defun read-service (filename)
|
||||
(let* ((p (merge-pathnames filename))
|
||||
(section-scanner (ppcre:create-scanner "^\\[(.*)\\]$"))
|
||||
(sections nil)
|
||||
(lines (uiop:read-file-lines p))
|
||||
(cursec nil))
|
||||
(dolist (line lines)
|
||||
(ppcre:register-groups-bind (match) (section-scanner line)
|
||||
(if match
|
||||
(progn (setf sections (acons (read-from-string match ) (make-hash-table) sections))
|
||||
(setf cursec match))
|
||||
(split-line line (cdr (assoc cursec sections)))
|
||||
)))
|
||||
sections))
|
||||
|
||||
(defun split-line (line value-table)
|
||||
(ppcre:register-groups-bind (first second) ("(.*)=(.*)" line)
|
||||
(setf (gethash first value-table ) second )))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
;; Testing macro for convenience
|
||||
(defmacro test ()
|
||||
(list 'read-service "/home/user/sst/src/test.service"))
|
22
src/test.service
Normal file
22
src/test.service
Normal file
@ -0,0 +1,22 @@
|
||||
[Unit]
|
||||
Description=D-Bus System Message Bus
|
||||
Documentation=man:dbus-broker-launch(1)
|
||||
DefaultDependencies=false
|
||||
After=dbus.socket
|
||||
Before=basic.target shutdown.target
|
||||
Requires=dbus.socket
|
||||
Conflicts=shutdown.target
|
||||
|
||||
[Service]
|
||||
Type=notify
|
||||
Sockets=dbus.socket
|
||||
OOMScoreAdjust=-900
|
||||
LimitNOFILE=16384
|
||||
ProtectSystem=full
|
||||
PrivateTmp=true
|
||||
PrivateDevices=true
|
||||
ExecStart=/usr/bin/dbus-broker-launch --scope system --audit
|
||||
ExecReload=/usr/bin/busctl call org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus ReloadConfig
|
||||
|
||||
[Install]
|
||||
Alias=dbus.service
|
Loading…
Reference in New Issue
Block a user