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