Skip to content

Commit c73b192

Browse files
authored
Remove WipeDevice method (home-assistant#225)
WipeDevice was called by the haos-wipe.service when the OS was marked for wipe. However, that was removed in [1] and replaced by shell script present on the OS itself, so there should be no longer any user of this service. Remove it from OS Agent code to have only a single way for the device wipe. [1] home-assistant/operating-system#3916
1 parent 02c5dd5 commit c73b192

File tree

1 file changed

+0
-48
lines changed

1 file changed

+0
-48
lines changed

system/system.go

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package system
22

33
import (
4-
"context"
54
"fmt"
65
"os"
76
"strings"
@@ -10,7 +9,6 @@ import (
109
"github.com/godbus/dbus/v5/introspect"
1110
"github.com/godbus/dbus/v5/prop"
1211

13-
"github.com/home-assistant/os-agent/udisks2"
1412
logging "github.com/home-assistant/os-agent/utils/log"
1513
)
1614

@@ -28,52 +26,6 @@ type system struct {
2826
conn *dbus.Conn
2927
}
3028

31-
func getAndCheckBusObjectFromLabel(udisks2helper udisks2.UDisks2Helper, label string) (dbus.BusObject, error) {
32-
dataBusObject, err := udisks2helper.GetBusObjectFromLabel(label)
33-
if err != nil {
34-
return nil, dbus.MakeFailedError(err)
35-
}
36-
37-
dataFilesystem := udisks2.NewFilesystem(dataBusObject)
38-
dataMountPoints, err := dataFilesystem.GetMountPointsString(context.Background())
39-
if err != nil {
40-
return nil, dbus.MakeFailedError(err)
41-
}
42-
43-
if len(dataMountPoints) > 0 {
44-
return nil, dbus.MakeFailedError(fmt.Errorf("Device with label \"%s\" is mounted at %s, aborting.", label, dataMountPoints))
45-
}
46-
47-
return dataBusObject, nil
48-
}
49-
50-
func (d system) WipeDevice() (bool, *dbus.Error) {
51-
logging.Info.Printf("Wipe device data.")
52-
53-
udisks2helper := udisks2.NewUDisks2(d.conn)
54-
dataBusObject, err := getAndCheckBusObjectFromLabel(udisks2helper, labelDataFileSystem)
55-
if err != nil {
56-
return false, dbus.MakeFailedError(err)
57-
}
58-
59-
overlayBusObject, err := getAndCheckBusObjectFromLabel(udisks2helper, labelOverlayFileSystem)
60-
if err != nil {
61-
return false, dbus.MakeFailedError(err)
62-
}
63-
64-
err = udisks2helper.FormatPartition(dataBusObject, "ext4", labelDataFileSystem)
65-
if err != nil {
66-
return false, dbus.MakeFailedError(err)
67-
}
68-
err = udisks2helper.FormatPartition(overlayBusObject, "ext4", labelOverlayFileSystem)
69-
if err != nil {
70-
return false, dbus.MakeFailedError(err)
71-
}
72-
logging.Info.Printf("Successfully wiped device data.")
73-
74-
return true, nil
75-
}
76-
7729
func (d system) ScheduleWipeDevice() (bool, *dbus.Error) {
7830

7931
data, err := os.ReadFile(kernelCommandLine)

0 commit comments

Comments
 (0)