Skip to content

Commit

Permalink
chore: remove sync feature; add restart after agent setup update
Browse files Browse the repository at this point in the history
  • Loading branch information
ArmandMeppa committed Jan 22, 2025
1 parent 13f40da commit 2b33a15
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 61 deletions.
2 changes: 1 addition & 1 deletion scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ DESKTOP_UNIT_FOLDER=${DESKTOP_UNIT_FOLDER:-"$HOME/.config/autostart"}
DESKTOP_UNIT_FILE=${DESKTOP_UNIT_FILE:-"$DESKTOP_UNIT_FOLDER/$CLIENT_NAME.desktop"}

PROFILE=${PROFILE:-"user"}
APP_VERSION=${APP_VERSION:-"0.2.4"}
APP_VERSION=${APP_VERSION:-"0.2.5"}

# Assign app version based on profile
case "$PROFILE" in
Expand Down
6 changes: 1 addition & 5 deletions wazuh-agent-status-client/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,11 @@ require (
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/lxn/walk v0.0.0-20210112085537-c389da54e794 // indirect
github.com/lxn/win v0.0.0-20210218163916-a377121e959e // indirect
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 // indirect
go.opentelemetry.io/otel v1.30.0 // indirect
go.opentelemetry.io/otel/metric v1.30.0 // indirect
go.opentelemetry.io/otel/trace v1.30.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/sys v0.26.0 // indirect
gopkg.in/Knetic/govaluate.v3 v3.0.0 // indirect
)
)
9 changes: 1 addition & 8 deletions wazuh-agent-status-client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
var embeddedFiles embed.FS

var (
statusItem, connectionItem, pauseItem, updateItem, restartItem, syncItem *systray.MenuItem
statusItem, connectionItem, pauseItem, updateItem, restartItem *systray.MenuItem
statusIconConnected, statusIconDisconnected []byte
connectionIconConnected, connectionIconDisconnected []byte
)
Expand Down Expand Up @@ -51,7 +51,6 @@ func onReady() {
pauseItem = systray.AddMenuItem("Pause", "Pause the Wazuh Agent")
restartItem = systray.AddMenuItem("Restart", "Restart the Wazuh Agent")
updateItem = systray.AddMenuItem("Update", "Update the Wazuh Agent")
syncItem = systray.AddMenuItem("Sync", "Sync the Wazuh Agent")
quitItem := systray.AddMenuItem("Quit", "Quit the application")

// Start background status update
Expand Down Expand Up @@ -101,9 +100,6 @@ func handleMenuActions(quitItem *systray.MenuItem) {
case <-updateItem.ClickedCh:
log.Println("Update clicked")
sendCommand("update")
case <-syncItem.ClickedCh:
log.Println("Sync clicked")
sendCommand("sync")
case <-quitItem.ClickedCh:
log.Println("Quit clicked")
systray.Quit()
Expand Down Expand Up @@ -133,9 +129,6 @@ func fetchStatus() (string, string) {

response = strings.TrimSuffix(response, "\n")

// Log the raw response for debugging
log.Printf("Raw response: %s", response)

// Split the string by comma
parts := strings.Split(response, ", ")

Expand Down
14 changes: 0 additions & 14 deletions wazuh-agent-status/darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,9 @@ func updateAgent() {
} else {
log.Printf("[%s] Wazuh agent updated successfully\n", time.Now().Format(time.RFC3339))
}
}

// syncAgent reconnects the Wazuh agent to the manager on Linux
func syncAgent() {
log.Printf("[%s] Syncing Wazuh agent with manager...\n", time.Now().Format(time.RFC3339))

log.Printf("[%s] Deleting client.keys file...\n", time.Now().Format(time.RFC3339))
err := exec.Command("sudo", "rm", "/Library/Ossec/etc/client.keys").Run()
if err != nil {
log.Printf("[%s] Failed to delete the client.keys file: %v\n", time.Now().Format(time.RFC3339), err)
} else {
log.Printf("[%s] client.keys file deleted successfully\n", time.Now().Format(time.RFC3339))
}

restartAgent()

log.Printf("[%s] Wazuh agent synced successfully\n", time.Now().Format(time.RFC3339))
}

func windowsMain() {
Expand Down
14 changes: 0 additions & 14 deletions wazuh-agent-status/linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,9 @@ func updateAgent() {
} else {
log.Printf("[%s] Wazuh agent updated successfully\n", time.Now().Format(time.RFC3339))
}
}

// syncAgent reconnects the Wazuh agent to the manager on Linux
func syncAgent() {
log.Printf("[%s] Syncing Wazuh agent with manager...\n", time.Now().Format(time.RFC3339))

log.Printf("[%s] Deleting client.keys file...\n", time.Now().Format(time.RFC3339))
err := exec.Command("sudo", "rm", "/var/ossec/etc/client.keys").Run()
if err != nil {
log.Printf("[%s] Failed to delete the client.keys file: %v\n", time.Now().Format(time.RFC3339), err)
} else {
log.Printf("[%s] client.keys file deleted successfully\n", time.Now().Format(time.RFC3339))
}

restartAgent()

log.Printf("[%s] Wazuh agent synced successfully\n", time.Now().Format(time.RFC3339))
}

func windowsMain() {
Expand Down
4 changes: 0 additions & 4 deletions wazuh-agent-status/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ func handleConnection(conn net.Conn) {
conn.Write([]byte("Updating the Wazuh Agent...\n"))
updateAgent()
conn.Write([]byte("Updated the Wazuh Agent\n"))
case "sync":
conn.Write([]byte("Syncing the Wazuh Agent...\n"))
syncAgent()
conn.Write([]byte("Synced the Wazuh Agent\n"))
default:
conn.Write([]byte(fmt.Sprintf("Unknown command: %s \n", command)))
}
Expand Down
16 changes: 1 addition & 15 deletions wazuh-agent-status/windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,26 +148,12 @@ func updateAgent() {
} else {
log.Printf("[%s] Wazuh agent updated successfully\n", time.Now().Format(time.RFC3339))
}
}

// syncAgent reconnects the Wazuh agent to the manager on Linux
func syncAgent() {
log.Printf("[%s] Syncing Wazuh agent with manager...\n", time.Now().Format(time.RFC3339))

log.Printf("[%s] Deleting client.keys file...\n", time.Now().Format(time.RFC3339))
cmd := exec.Command("powershell", "-Command", " Remove-Item -Path 'C:\\Program Files (x86)\\ossec-agent\\client.keys'")
err := cmd.Run()
if err != nil {
log.Printf("[%s] Failed to delete the client.keys file: %v\n", time.Now().Format(time.RFC3339), err)
} else {
log.Printf("[%s] client.keys file deleted successfully\n", time.Now().Format(time.RFC3339))
}

restartAgent()

log.Printf("[%s] Wazuh agent synced successfully\n", time.Now().Format(time.RFC3339))
}


// Main function that sets up the service
func windowsMain() {
// Define the service config
Expand Down

0 comments on commit 2b33a15

Please sign in to comment.