func main() {
	defer func() {
		err := easy_error.Apply(recover())
		if err != nil {
			fmt.Println(err)
			os.Exit(2)
		}
	}()
	flag.Parse()
	server := easy_error.Wrap(tomcat_info.ReadServer(*serverdir)).(*tomcat_info.Server)
	tomcatusers := easy_error.Wrap(server.ReadTomcatUsers()).(*tomcat_info.TomcatUsers)
	usermap := tomcatusers.GetUsersWithRole("manager")
	manager, ok := usermap["manager"]
	if ok {
		fmt.Println(manager.Password)
		return
	} else {
		for _, v := range usermap {
			fmt.Println(v.Password)
			return
		}
	}
	fmt.Println("No manager user exists")
	os.Exit(1)
}
Пример #2
0
func (server *Server) ReadTomcatUsers() (users *TomcatUsers, err error) {
	defer func() {
		err = easy_error.Apply(recover())
	}()
	userfile := easy_error.Wrap(server.GetUserFile()).(string)
	file := easy_error.Wrap(os.Open(server.serverpath + "/" + userfile)).(*os.File)
	decoder := xml.NewDecoder(file)
	users = &TomcatUsers{}
	decoder.Decode(users)
	return
}
Пример #3
0
func ReadServer(serverpath string) (server *Server, err error) {
	defer func() {
		err = easy_error.Apply(recover())
	}()
	file := easy_error.Wrap(os.Open(serverpath + "/conf/server.xml")).(*os.File)
	decoder := xml.NewDecoder(file)
	server = &Server{}
	server.serverpath = serverpath
	decoder.Decode(server)
	return
}
Пример #4
0
func main() {
	defer func() {
		err := easy_error.Apply(recover())
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
	}()
	flag.Parse()
	server := easy_error.Wrap(tomcat_info.ReadServer(*serverdir)).(*tomcat_info.Server)
	port := easy_error.Wrap(server.GetHttpPort()).(int16)
	fmt.Println(port)
}
Пример #5
0
func main() {
	defer func() {
		err := easy_error.Apply(recover())
		if err != nil {
			fmt.Println(err)
			os.Exit(2)
		}
	}()

	flag.Parse()

	if *bestUserWithRole != "" {
		doBestUserWithRole(*bestUserWithRole)
	}
	if *usersWithRole != "" {
		doUsersWithRole(*usersWithRole)
	}
	if *getServerPort {
		doGetServerPort()
	}
}