commit 9474199299c884d81b1bf670bf90ca563ccedaf7 Author: J S Date: Tue Dec 19 16:29:39 2023 -0500 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. diff --git a/packages-systemd.lisp b/packages-systemd.lisp new file mode 100644 index 0000000..161d7b7 --- /dev/null +++ b/packages-systemd.lisp @@ -0,0 +1,5 @@ +(defpackage :service-edit + (:use :common-lisp)) + +(defpackage :service-opts + (:use :common-lisp)) diff --git a/src/read-service.lisp b/src/read-service.lisp new file mode 100644 index 0000000..72185c8 --- /dev/null +++ b/src/read-service.lisp @@ -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")) diff --git a/src/test.service b/src/test.service new file mode 100644 index 0000000..d2c1e26 --- /dev/null +++ b/src/test.service @@ -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 diff --git a/sst.asd b/sst.asd new file mode 100644 index 0000000..e19755c --- /dev/null +++ b/sst.asd @@ -0,0 +1,9 @@ +(defsystem :systemd-parse + :depends-on (:cl-ppcre) + :components ((:file "packages-systemd") + (:module "src" + :serial t + :components ((:file "read-service") + (:file "write-service") + (:file "service-opts") + ))))