2 // Armadillo File Manager
3 // Copyright (c) 2010, Robert Sesek <http://www.bluestatic.org>
5 // This program is free software: you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free Software
7 // Foundation, either version 3 of the License, or any later version.
23 // Set up the basic flags.
24 var configPath *string = flag.String("config", "~/.armadillo", "Path to the configuration file")
25 var jailRoot *string = flag.String("jail", "", "Restrict file operations to this directory root")
26 var port *int = flag.Int("port", 0, "Port to run the server on")
29 // Load the configuration file, if it is present.
30 var configuration = new(config.Configuration)
31 fmt.Printf("Reading configuration from %v\n", *configPath)
32 if len(*configPath) > 0 {
33 *configPath = strings.Replace(*configPath, "~", "$HOME", 1)
34 *configPath = os.ShellExpand(*configPath)
35 error := config.ReadFromFile(*configPath, configuration)
37 fmt.Printf("Error while reading configuration: %v\n", error)
41 // Override configuration values with command line arguments.
43 configuration.JailRoot = *jailRoot
46 configuration.Port = *port
49 if configuration.Port == 0 {
50 fmt.Printf("Failed to start server (invalid port)\n")
55 fmt.Printf("Starting Armadillo on port %d with root:\n %v\n",
56 configuration.Port, configuration.JailRoot)
57 paths.SetConfig(configuration)
58 server.RunBackEnd(configuration)