mirror of
https://github.com/luckfox-eng29/kvm.git
synced 2026-04-09 18:45:52 +02:00
21 lines
489 B
Go
21 lines
489 B
Go
package kvm
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
const ethernetMacAddressPath = "/userdata/ethaddr.txt"
|
|
|
|
func rpcSetEthernetMacAddress(macAddress string) (interface{}, error) {
|
|
normalized, err := networkState.SetMACAddress(macAddress)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if err := os.WriteFile(ethernetMacAddressPath, []byte(normalized+"\n"), 0644); err != nil {
|
|
return nil, fmt.Errorf("failed to write %s: %w", ethernetMacAddressPath, err)
|
|
}
|
|
return networkState.RpcGetNetworkState(), nil
|
|
}
|
|
|