|
|
@@ -118,28 +118,7 @@ func (ui *WebUI) rootHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
http.NotFound(w, r)
|
|
|
}
|
|
|
|
|
|
-func runShellAndWrite(w http.ResponseWriter, cmd string) {
|
|
|
- out, err := exec.Command("sh", "-c", cmd).CombinedOutput()
|
|
|
- if err != nil {
|
|
|
- http.Error(w, err.Error()+"\n"+string(out), http.StatusInternalServerError)
|
|
|
- return
|
|
|
- }
|
|
|
- w.Write(out)
|
|
|
-}
|
|
|
-
|
|
|
-func netInterfaces(w http.ResponseWriter, r *http.Request) {
|
|
|
- runShellAndWrite(w, "ifconfig")
|
|
|
-}
|
|
|
-
|
|
|
-func netRoutes(w http.ResponseWriter, r *http.Request) {
|
|
|
- runShellAndWrite(w, "route -n")
|
|
|
-}
|
|
|
-
|
|
|
-func netDNS(w http.ResponseWriter, r *http.Request) {
|
|
|
- runShellAndWrite(w, "cat /etc/resolv.conf")
|
|
|
-}
|
|
|
-
|
|
|
-func logHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
+func serviceLogHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
unit := r.URL.Query().Get("unit")
|
|
|
if unit == "" {
|
|
|
http.Error(w, "missing unit",
|
|
|
@@ -205,3 +184,24 @@ func logHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
flusher.Flush()
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+func runShellAndWrite(w http.ResponseWriter, cmd string) {
|
|
|
+ out, err := exec.Command("sh", "-c", cmd).CombinedOutput()
|
|
|
+ if err != nil {
|
|
|
+ http.Error(w, err.Error()+"\n"+string(out), http.StatusInternalServerError)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ w.Write(out)
|
|
|
+}
|
|
|
+
|
|
|
+func netInterfaces(w http.ResponseWriter, r *http.Request) {
|
|
|
+ runShellAndWrite(w, "ifconfig")
|
|
|
+}
|
|
|
+
|
|
|
+func netRoutes(w http.ResponseWriter, r *http.Request) {
|
|
|
+ runShellAndWrite(w, "route -n")
|
|
|
+}
|
|
|
+
|
|
|
+func netDNS(w http.ResponseWriter, r *http.Request) {
|
|
|
+ runShellAndWrite(w, "cat /etc/resolv.conf")
|
|
|
+}
|