mirror of https://github.com/jetkvm/kvm.git
fix: ensure symlink to last-crash.log
This commit is contained in:
parent
ece467eba8
commit
403c1f8fa1
25
cmd/main.go
25
cmd/main.go
|
|
@ -117,6 +117,29 @@ func supervise() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func isSymlinkTo(dst, src string) bool {
|
||||
file, err := os.Stat(dst)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
if file.Mode()&os.ModeSymlink != os.ModeSymlink {
|
||||
return false
|
||||
}
|
||||
target, err := os.Readlink(dst)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return target == src
|
||||
}
|
||||
|
||||
func ensureSymlink(dst, src string) error {
|
||||
if isSymlinkTo(dst, src) {
|
||||
return nil
|
||||
}
|
||||
_ = os.Remove(dst)
|
||||
return os.Symlink(src, dst)
|
||||
}
|
||||
|
||||
func createErrorDump(logFile *os.File) {
|
||||
logFile.Close()
|
||||
|
||||
|
|
@ -160,6 +183,8 @@ func createErrorDump(logFile *os.File) {
|
|||
}
|
||||
|
||||
fmt.Printf("error dump created: %s\n", filePath)
|
||||
|
||||
ensureSymlink(filePath, filepath.Join(errorDumpDir, "last-crash.log"))
|
||||
}
|
||||
|
||||
func doSupervise() {
|
||||
|
|
|
|||
|
|
@ -35,14 +35,15 @@ func switchToMainScreen() {
|
|||
}
|
||||
|
||||
func updateDisplay() {
|
||||
nativeInstance.UpdateLabelIfChanged("home_info_ipv4_addr", networkManager.IPv4String())
|
||||
nativeInstance.UpdateLabelAndChangeVisibility("home_info_ipv6_addr", networkManager.IPv6String())
|
||||
if networkManager != nil {
|
||||
nativeInstance.UpdateLabelIfChanged("home_info_ipv4_addr", networkManager.IPv4String())
|
||||
nativeInstance.UpdateLabelAndChangeVisibility("home_info_ipv6_addr", networkManager.IPv6String())
|
||||
nativeInstance.UpdateLabelIfChanged("home_info_mac_addr", networkManager.MACString())
|
||||
}
|
||||
|
||||
_, _ = nativeInstance.UIObjHide("menu_btn_network")
|
||||
_, _ = nativeInstance.UIObjHide("menu_btn_access")
|
||||
|
||||
nativeInstance.UpdateLabelIfChanged("home_info_mac_addr", networkManager.MACString())
|
||||
|
||||
switch config.NetworkConfig.DHCPClient.String {
|
||||
case "jetdhcpc":
|
||||
nativeInstance.UpdateLabelIfChanged("dhcp_client_change_label", "Change to udhcpc")
|
||||
|
|
|
|||
Loading…
Reference in New Issue