Esempio n. 1
0
/*
ReadConfiguration, attiva il GlobalConfiguration.
*/
func ReadConfiguration(filepath string) error {

	c, err := conf.ReadConfigFile(filepath)
	if err == nil {
		GlobalConfiguration = c
	}

	return err
}
Esempio n. 2
0
func main() {
	// get configuration
	port := "8083"
	remoterepo := "http://opam.kino3d.org/hg"

	var confPath = flag.String("conf", "./opamd.conf", "path to configuration file")

	flag.Parse()

	confFile, err := conf.ReadConfigFile(*confPath)
	if err != nil {
		fmt.Print(err)
		return
	}

	eseguible = make(map[string]string, 0)

	confSections := confFile.GetSections()

	for _, s := range confSections {

		extensions, err := confFile.GetString(s, "extensions")
		if err != nil {
			continue
		}

		path, err := confFile.GetString(s, "path")
		if err != nil {
			path = s
		}
		extensions = strings.Replace(extensions, " ", "", -1)

		for _, ext := range strings.Split(extensions, ",") {
			eseguible[ext] = path
		}
	}

	localrepo, err := confFile.GetString("defaults", "localrepo")
	if err != nil {
		fmt.Printf("can't get value for localrepo, check config file, default section\n")
	}
	repo.path = localrepo

	repo.remotePath = remoterepo
	repo.inProgress = false

	// listen for requests on localhost
	fmt.Printf("configuration complete, now listening for requests.\n")
	http.HandleFunc("/open", ServeLocalData)
	http.HandleFunc("/createdirectory", CreateAssetDirectory)
	fmt.Print(http.ListenAndServe("localhost:"+port, nil))
}