func configInit() { t, err := template.ParseFiles(filepath.Join(common.UiDirGet(), "config.html")) if err != nil { log.Printf("config.html parse failed %v\n", err) return } else { configTemplate = t } configChannel = make(chan configRequest) ConfigRun() web.ServMux.Handle("/config/", http.RedirectHandler("/ui/config.html", http.StatusMovedPermanently)) web.ServMux.HandleFunc("/config/all/", configHandle) os.MkdirAll(filepath.Join(common.BaseDir, "config"), 0700) if common.System && platform.PlatformGet() == platform.Windows { err = common.Cacls(filepath.Join(common.BaseDir, "config"), "/p", "NT AUTHORITY\\SYSTEM:f", "BUILTIN\\Administrators:F") if err != nil { log.Printf("Failed to run cacls %v\n", err) os.Exit(-1) } } processConfig() m.updatePaths(&allConfigs) }
func webServerInit() { defaultUI = new(uiServer) ServMux = http.NewServeMux() ServMux.Handle("/status/", http.RedirectHandler("/ui/status.html", http.StatusMovedPermanently)) ServMux.HandleFunc("/auth/", authHandle) ServMux.Handle("/ui/", FileServer(http.FileServer(http.Dir(common.UiDirGet())), "/ui")) ServMux.HandleFunc("/update/", update) }