2016-03-30 16:48:52 -05:00
|
|
|
// Copyright 2016 Tim Shannon. All rights reserved.
|
|
|
|
// Use of this source code is governed by the MIT license
|
|
|
|
// that can be found in the LICENSE file.
|
|
|
|
|
2016-03-29 16:43:58 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
|
|
|
|
"git.townsourced.com/config"
|
|
|
|
)
|
|
|
|
|
|
|
|
//settings
|
|
|
|
var (
|
2016-03-30 16:48:52 -05:00
|
|
|
projectDir = "./projects" // /etc/ironsmith/
|
|
|
|
dataDir = "./data" // /var/ironsmith/
|
2016-03-29 16:43:58 -05:00
|
|
|
address = "http://localhost:8026"
|
|
|
|
certFile = ""
|
|
|
|
keyFile = ""
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
settingPaths := config.StandardFileLocations("ironsmith/settings.json")
|
|
|
|
log.Println("IronSmith will use settings files in the following locations (in order of priority):")
|
|
|
|
for i := range settingPaths {
|
|
|
|
log.Println("\t", settingPaths[i])
|
|
|
|
}
|
|
|
|
cfg, err := config.LoadOrCreate(settingPaths...)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalf("Error loading or creating IronSmith settings file: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Printf("IronSmith is currently using the file %s for settings.\n", cfg.FileName())
|
|
|
|
|
|
|
|
projectDir = cfg.String("projectDir", projectDir)
|
|
|
|
dataDir = cfg.String("dataDir", dataDir)
|
|
|
|
address = cfg.String("address", address)
|
|
|
|
certFile = cfg.String("certFile", certFile)
|
|
|
|
keyFile = cfg.String("keyFile", keyFile)
|
|
|
|
|
|
|
|
//prep dirs
|
2016-03-30 16:48:52 -05:00
|
|
|
err = os.MkdirAll(filepath.Join(projectDir, enabledProjectDir), 0777)
|
2016-03-29 16:43:58 -05:00
|
|
|
if err != nil {
|
|
|
|
log.Fatalf("Error Creating project directory at %s: %s", projectDir, err)
|
|
|
|
}
|
|
|
|
|
2016-03-30 16:48:52 -05:00
|
|
|
err = os.MkdirAll(dataDir, 0777)
|
2016-03-29 16:43:58 -05:00
|
|
|
if err != nil {
|
|
|
|
log.Fatalf("Error Creating project data directory at %s: %s", dataDir, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = prepTemplateProject()
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalf("Error Creating project template file: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
//load projects
|
2016-03-30 16:48:52 -05:00
|
|
|
err = projects.load()
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalf("Error loading projects: %s", err)
|
|
|
|
}
|
2016-03-29 16:43:58 -05:00
|
|
|
//start server
|
|
|
|
}
|