File tree 4 files changed +48
-2
lines changed
4 files changed +48
-2
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ rpm: $(APP_OUT)
50
50
51
51
install : $(APP_OUT )
52
52
install $(APP_OUT ) $(DESTDIR ) /usr/bin
53
- install -g 0 -o 0 -m 0644 lxc-wrapper.1.gz /usr/share/man/man1/
53
+ install -g 0 -o 0 -m 0644 dist/root/usr/share/man/man1/ lxc-wrapper.1.gz /usr/share/man/man1/
54
54
55
55
bin :
56
56
@mkdir bin
Original file line number Diff line number Diff line change @@ -96,7 +96,6 @@ Commands:
96
96
(format t "
97
97
Overridable variables and default values for all commands (must be BEFORE the command):
98
98
--default-shell=/bin/bash
99
- --debug
100
99
101
100
" ))
102
101
Original file line number Diff line number Diff line change 133
133
(format t " done.~% " )
134
134
(init-lxc cli-name *hosts-file* ))))
135
135
136
+ (defcommand autostart (name args)
137
+ " autostart NAME
138
+ Toggles the autostart status of the container named NAME
139
+
140
+ Overridable variables and default values (must be BEFORE the command):
141
+ --lxc-default-folder=/var/lib/lxc/
142
+ --lxc-config=config"
143
+ (declare (ignore args))
144
+ (let* ((cli-name (adapt-arg name))
145
+ (lxc-path (merge-pathnames *lxc-config*
146
+ (merge-pathnames
147
+ (concatenate ' string cli-name " /" )
148
+ *lxc-default-folder* )))
149
+ (config-content (alexandria :read-file-into-string
150
+ lxc-path)))
151
+ (if (lxc-config-has-autostart config-content)
152
+ (toggle-autostart-value lxc-path config-content)
153
+ (add-autostart-line lxc-path))))
154
+
136
155
(defun adapt-arg (name)
137
156
" Adapts an argument to string"
138
157
(when (symbolp name)
Original file line number Diff line number Diff line change 81
81
(cl-ppcre :scan-to-strings " \\ n\\ s*lxc\\ .utsname\\ s*=\\ s*(\\ w+)" config)
82
82
(declare (ignore match))
83
83
(elt name 0 )))
84
+
85
+ (defun lxc-config-has-autostart (content)
86
+ " Finds out if a content holds the autostart line"
87
+ (cl-ppcre :scan " lxc\\ .start\\ .auto" content))
88
+
89
+ (defun toggle-autostart-value (file content)
90
+ " Toggles the autostart value"
91
+ (let ((value (parse-integer
92
+ (elt
93
+ (multiple-value-bind (match val)
94
+ (cl-ppcre :scan-to-strings " lxc\\ .start\\ .auto\\ s*=\\ s*(\\ d+)"
95
+ content)
96
+ (declare (ignore match))
97
+ val)
98
+ 0 ))))
99
+ (alexandria :write-string-into-file
100
+ (cl-ppcre :regex-replace " lxc\\ .start\\ .auto\\ s*=\\ s*\\ d+"
101
+ content
102
+ (format nil
103
+ " lxc.start.auto = ~A "
104
+ (if (= value 0 ) 1 0 )))
105
+ file
106
+ :if-exists :overwrite )))
107
+
108
+ (defun add-autostart-line (file)
109
+ " Adds the autostart line in the file"
110
+ (with-open-file (f file :direction :output :if-exists :append )
111
+ (format f " lxc.start.auto = 1" )))
You can’t perform that action at this time.
0 commit comments