36 lines
838 B
Go
36 lines
838 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"jonasled.dev/jonasled/cloud-init-windows/cloudinit"
|
|
"jonasled.dev/jonasled/cloud-init-windows/windows"
|
|
)
|
|
|
|
func main() {
|
|
rebootRequired := false
|
|
|
|
var cloudInitConfig cloudinit.CloudInit
|
|
err := cloudInitConfig.Load()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
if windows.GetHostname() != cloudInitConfig.UserData.Hostname {
|
|
fmt.Println("Setting hostname to " + cloudInitConfig.UserData.Hostname)
|
|
windows.SetHostname(cloudInitConfig.UserData.Hostname)
|
|
rebootRequired = true
|
|
}
|
|
|
|
for _, networkconfig := range cloudInitConfig.NetworkConfig.Config {
|
|
networkInterface, err := windows.GetNetworkInterfaceByMac(networkconfig.MacAddress)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
fmt.Println("Setting IP address for Interface " + networkInterface)
|
|
}
|
|
|
|
if rebootRequired {
|
|
fmt.Println("Reboot is required")
|
|
}
|
|
}
|