admin: initialize directory structure and required files at launch
This commit is contained in:
parent
7da6f5cd0c
commit
af2fe21d73
2 changed files with 25 additions and 22 deletions
|
@ -143,9 +143,6 @@ func main() {
|
|||
if settings.SettingsDir, err = filepath.Abs(settings.SettingsDir); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if fic.FilesDir, err = filepath.Abs(fic.FilesDir); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if *baseURL != "/" {
|
||||
tmp := path.Clean(*baseURL)
|
||||
baseURL = &tmp
|
||||
|
@ -154,6 +151,30 @@ func main() {
|
|||
baseURL = &tmp
|
||||
}
|
||||
|
||||
// Creating minimal directories structure
|
||||
os.MkdirAll(fic.FilesDir, 0777)
|
||||
os.MkdirAll(pki.PKIDir, 0711)
|
||||
os.MkdirAll(api.TeamsDir, 0777)
|
||||
os.MkdirAll(settings.SettingsDir, 0777)
|
||||
|
||||
// Initialize settings and load them
|
||||
if !settings.ExistsSettings(path.Join(settings.SettingsDir, settings.SettingsFile)) {
|
||||
if err := settings.SaveSettings(path.Join(settings.SettingsDir, settings.SettingsFile), settings.FICSettings{
|
||||
Title: "Challenge FIC",
|
||||
Authors: "Laboratoire SRS, ÉPITA",
|
||||
FirstBlood: fic.FirstBlood,
|
||||
SubmissionCostBase: fic.SubmissionCostBase,
|
||||
AllowRegistration: false,
|
||||
DenyNameChange: false,
|
||||
EnableResolutionRoute: false,
|
||||
PartialValidation: true,
|
||||
EnableExerciceDepend: true,
|
||||
}); err != nil {
|
||||
log.Fatal("Unable to initialize settings.json:", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Database connection
|
||||
log.Println("Opening database...")
|
||||
if err := fic.DBInit(*dsn); err != nil {
|
||||
log.Fatal("Cannot open the database: ", err)
|
||||
|
|
Reference in a new issue