@@ -266,6 +266,50 @@ type EnableUnitFileChange struct {
266266 Destination string // Destination of the symlink
267267}
268268
269+ // DisableUnitFiles() may be used to disable one or more units in the system (by
270+ // removing symlinks to them from /etc or /run).
271+ //
272+ // It takes a list of unit files to disable (either just file names or full
273+ // absolute paths if the unit files are residing outside the usual unit
274+ // search paths), and one boolean: whether the unit was enabled for runtime
275+ // only (true, /run), or persistently (false, /etc).
276+ //
277+ // This call returns an array with the changes made. The changes list
278+ // consists of structures with three strings: the type of the change (one of
279+ // symlink or unlink), the file name of the symlink and the destination of the
280+ // symlink.
281+ func (c * Conn ) DisableUnitFiles (files []string , runtime bool ) ([]DisableUnitFileChange , error ) {
282+ result := make ([][]interface {}, 0 )
283+ err := c .sysobj .Call ("DisableUnitFiles" , 0 , files , runtime ).Store (& result )
284+ if err != nil {
285+ return nil , err
286+ }
287+
288+ resultInterface := make ([]interface {}, len (result ))
289+ for i := range result {
290+ resultInterface [i ] = result [i ]
291+ }
292+
293+ changes := make ([]DisableUnitFileChange , len (result ))
294+ changesInterface := make ([]interface {}, len (changes ))
295+ for i := range changes {
296+ changesInterface [i ] = & changes [i ]
297+ }
298+
299+ err = dbus .Store (resultInterface , changesInterface ... )
300+ if err != nil {
301+ return nil , err
302+ }
303+
304+ return changes , nil
305+ }
306+
307+ type DisableUnitFileChange struct {
308+ Type string // Type of the change (one of symlink or unlink)
309+ Filename string // File name of the symlink
310+ Destination string // Destination of the symlink
311+ }
312+
269313// Reload instructs systemd to scan for and reload unit files. This is
270314// equivalent to a 'systemctl daemon-reload'.
271315func (c * Conn ) Reload () (string , error ) {
0 commit comments