
Finished configuring the init/shell commands Updated readme Fixed issue with missing /boot/efi directory Added new config module for setting/retrieving vm configs Updated machine setup Fixed issue with missing files added config to docs section added x86_64 support fixed issue with x86_64 update and updated README Added some content to README Added markdown export of org file Updated readme to reflect the need for guile-next Removed guile from install example exported changes to md Updated README fixed issue with sed compatibility (bsd/gnu) regenerated readme markdown Removed readme markdown file for org alternative Updated project license updated autocompile to include for now updated script updated script updated script updated msg script updated license updated to test testing testing testing testing testing testing testing testing testing testing testing
51 lines
1.5 KiB
Scheme
51 lines
1.5 KiB
Scheme
(define-module (msg config)
|
|
#:use-module (ice-9 ftw)
|
|
#:use-module (ice-9 rdelim)
|
|
#:declarative? #f
|
|
#:export (manage-config))
|
|
(define config-data #f)
|
|
|
|
;;; Function to load a config file
|
|
(define (load-config config-file)
|
|
(if (file-exists? config-file)
|
|
(call-with-input-file config-file
|
|
(lambda (port)
|
|
(read port)))
|
|
(begin
|
|
(display "Config file not found, creating default config")
|
|
(newline)
|
|
;; Return a default value (in this case, #f)
|
|
(values #f))))
|
|
|
|
;;; Function to save a config file
|
|
(define (save-config filename config)
|
|
(with-output-to-file filename
|
|
(lambda ()
|
|
(display (format #f "~A" config)))))
|
|
|
|
;;; Function to create a default config
|
|
(define (create-default-config )
|
|
'( ;; Default configuration values
|
|
(cpu . "4")
|
|
(mem . "4")
|
|
;; Add more default key-value pairs as needed
|
|
))
|
|
|
|
(define (manage-config filename)
|
|
(let* ((config (load-config filename))
|
|
(default-config (create-default-config)))
|
|
(cond
|
|
((eq? config #f)
|
|
(begin
|
|
(display "Creating default config...\n")
|
|
(save-config filename default-config)
|
|
(set! config default-config)
|
|
(values config)))
|
|
((unspecified? config)
|
|
(begin
|
|
(display "Invalid config file. Reverting to default config...\n")
|
|
(save-config filename default-config)
|
|
(set! config default-config)
|
|
(values config)))
|
|
(else
|
|
(values config)))))
|