2 // Armadillo File Manager
3 // Copyright (c) 2010-2012, 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.
13 "github.com/rsesek/armadillo/config"
14 "github.com/rsesek/armadillo/server"
22 configPath = flag.String("config", "~/.armadillo", "Path to the configuration file")
23 jailRoot = flag.String("jail", "", "Restrict file operations to this directory root")
24 port = flag.Int("port", 0, "Port to run the server on")
30 // Load the configuration file, if it is present.
31 var configuration = new(config.Configuration)
32 fmt.Printf("Reading configuration from %v\n", *configPath)
33 if len(*configPath) > 0 {
34 *configPath = strings.Replace(*configPath, "~", "$HOME", 1)
35 *configPath = os.ExpandEnv(*configPath)
36 error := config.ReadFromFile(*configPath, configuration)
38 fmt.Printf("Error while reading configuration: %v\n", error)
42 // Override configuration values with command line arguments.
44 configuration.JailRoot = *jailRoot
47 configuration.Port = *port
50 if configuration.Port == 0 {
51 fmt.Printf("Failed to start server (invalid port)\n")
56 fmt.Printf("Starting Armadillo on port %d with root:\n %v\n",
57 configuration.Port, configuration.JailRoot)
58 server.RunBackEnd(configuration)