Remove from frontend the settings distribution role
This commit is contained in:
parent
af6e86d4ef
commit
cfde1689cc
@ -110,7 +110,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var dsn = flag.String("dsn", fic.DSNGenerator(), "DSN to connect to the MySQL server")
|
var dsn = flag.String("dsn", fic.DSNGenerator(), "DSN to connect to the MySQL server")
|
||||||
flag.StringVar(&settings.SettingsDir, "settings", settings.SettingsDir, "Base directory where load and save settings")
|
flag.StringVar(&settings.SettingsDir, "settings", "./SETTINGSDIST", "Base directory where load and save settings")
|
||||||
flag.StringVar(&SubmissionDir, "submission", "./submissions", "Base directory where save submissions")
|
flag.StringVar(&SubmissionDir, "submission", "./submissions", "Base directory where save submissions")
|
||||||
flag.StringVar(&TeamsDir, "teams", "./TEAMS", "Base directory where save teams JSON files")
|
flag.StringVar(&TeamsDir, "teams", "./TEAMS", "Base directory where save teams JSON files")
|
||||||
flag.StringVar(&fic.FilesDir, "files", fic.FilesDir, "Request path prefix to reach files")
|
flag.StringVar(&fic.FilesDir, "files", fic.FilesDir, "Request path prefix to reach files")
|
||||||
|
@ -32,7 +32,7 @@ done &
|
|||||||
while ! [ -f SETTINGS/stop ] || [ /tmp/stop -nt SETTINGS/stop ]
|
while ! [ -f SETTINGS/stop ] || [ /tmp/stop -nt SETTINGS/stop ]
|
||||||
do
|
do
|
||||||
# Synchronize static files pages
|
# Synchronize static files pages
|
||||||
rsync -e "$SSH_OPTS" -av --delete PKI TEAMS SETTINGS "${FRONTEND_HOSTNAME}":"${BASEDIR}"
|
rsync -e "$SSH_OPTS" -av --delete PKI TEAMS SETTINGSDIST "${FRONTEND_HOSTNAME}":"${BASEDIR}"
|
||||||
|
|
||||||
# Synchronize submissions
|
# Synchronize submissions
|
||||||
rsync -e "$SSH_OPTS" -av --ignore-existing --delay-updates --temp-dir=.tmp/ --partial-dir=.tmp/ --remove-source-files "${FRONTEND_HOSTNAME}":"${BASEDIR}"/submissions/ submissions/
|
rsync -e "$SSH_OPTS" -av --ignore-existing --delay-updates --temp-dir=.tmp/ --partial-dir=.tmp/ --remove-source-files "${FRONTEND_HOSTNAME}":"${BASEDIR}"/submissions/ submissions/
|
||||||
|
@ -76,7 +76,7 @@ func main() {
|
|||||||
flag.StringVar(&fic.FilesDir, "files", fic.FilesDir, "Base directory where found challenges files, local part")
|
flag.StringVar(&fic.FilesDir, "files", fic.FilesDir, "Base directory where found challenges files, local part")
|
||||||
flag.StringVar(&DashboardDir, "dashbord", "./DASHBOARD", "Base directory where save public JSON files")
|
flag.StringVar(&DashboardDir, "dashbord", "./DASHBOARD", "Base directory where save public JSON files")
|
||||||
flag.StringVar(&TeamsDir, "teams", "./TEAMS", "Base directory where save teams JSON files")
|
flag.StringVar(&TeamsDir, "teams", "./TEAMS", "Base directory where save teams JSON files")
|
||||||
flag.StringVar(&settings.SettingsDir, "settings", settings.SettingsDir, "Base directory where load and save settings")
|
flag.StringVar(&settings.SettingsDir, "settings", "./SETTINGSDIST", "Base directory where load and save settings")
|
||||||
var fwdr = flag.String("forwarder", "", "URL of another dashboard where send traffic to, except static assets")
|
var fwdr = flag.String("forwarder", "", "URL of another dashboard where send traffic to, except static assets")
|
||||||
flag.BoolVar(&fwdPublicJson, "fwdpublicjson", fwdPublicJson, "Also forward public.json files to forwarder")
|
flag.BoolVar(&fwdPublicJson, "fwdpublicjson", fwdPublicJson, "Also forward public.json files to forwarder")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
@ -190,6 +190,20 @@ services:
|
|||||||
- /var/lib/fic/sync
|
- /var/lib/fic/sync
|
||||||
- /var/lib/fic/submissions
|
- /var/lib/fic/submissions
|
||||||
- /var/lib/fic/teams
|
- /var/lib/fic/teams
|
||||||
|
- name: fic-evdist
|
||||||
|
image: nemunaire/fic-evdist:latest
|
||||||
|
binds:
|
||||||
|
- /etc/hosts:/etc/hosts:ro
|
||||||
|
- /var/lib/fic/settings:/srv/SETTINGS
|
||||||
|
- /var/lib/fic/settingsdist:/srv/SETTINGSDIST
|
||||||
|
net: new
|
||||||
|
pid: new
|
||||||
|
ipc: new
|
||||||
|
uts: new
|
||||||
|
runtime:
|
||||||
|
mkdir:
|
||||||
|
- /var/lib/fic/settings
|
||||||
|
- /var/lib/fic/settingsdist
|
||||||
- name: fic-backend
|
- name: fic-backend
|
||||||
image: nemunaire/fic-backend:latest
|
image: nemunaire/fic-backend:latest
|
||||||
env:
|
env:
|
||||||
@ -197,7 +211,7 @@ services:
|
|||||||
binds:
|
binds:
|
||||||
- /etc/hosts:/etc/hosts:ro
|
- /etc/hosts:/etc/hosts:ro
|
||||||
- /var/lib/fic/teams:/srv/TEAMS
|
- /var/lib/fic/teams:/srv/TEAMS
|
||||||
- /var/lib/fic/settings:/srv/SETTINGS:ro
|
- /var/lib/fic/settingsdist:/srv/SETTINGSDIST:ro
|
||||||
- /var/lib/fic/submissions:/srv/submissions
|
- /var/lib/fic/submissions:/srv/submissions
|
||||||
net: /run/netns/fic-backend
|
net: /run/netns/fic-backend
|
||||||
pid: new
|
pid: new
|
||||||
@ -205,7 +219,7 @@ services:
|
|||||||
uts: new
|
uts: new
|
||||||
runtime:
|
runtime:
|
||||||
mkdir:
|
mkdir:
|
||||||
- /var/lib/fic/settings
|
- /var/lib/fic/settingsdist
|
||||||
- /var/lib/fic/submissions
|
- /var/lib/fic/submissions
|
||||||
- /var/lib/fic/teams
|
- /var/lib/fic/teams
|
||||||
- name: fic-dashboard
|
- name: fic-dashboard
|
||||||
@ -216,7 +230,7 @@ services:
|
|||||||
- /var/lib/fic/dashboard:/srv/DASHBOARD:ro
|
- /var/lib/fic/dashboard:/srv/DASHBOARD:ro
|
||||||
- /var/lib/fic/files:/srv/FILES:ro
|
- /var/lib/fic/files:/srv/FILES:ro
|
||||||
- /var/lib/fic/teams:/srv/TEAMS:ro
|
- /var/lib/fic/teams:/srv/TEAMS:ro
|
||||||
- /var/lib/fic/settings:/srv/SETTINGS:ro
|
- /var/lib/fic/settingsdist:/srv/SETTINGSDIST:ro
|
||||||
net: /run/netns/fic-admin
|
net: /run/netns/fic-admin
|
||||||
pid: new
|
pid: new
|
||||||
ipc: new
|
ipc: new
|
||||||
@ -225,7 +239,7 @@ services:
|
|||||||
mkdir:
|
mkdir:
|
||||||
- /var/lib/fic/dashboard
|
- /var/lib/fic/dashboard
|
||||||
- /var/lib/fic/teams
|
- /var/lib/fic/teams
|
||||||
- /var/lib/fic/settings
|
- /var/lib/fic/settingsdist
|
||||||
- name: fic-synchro
|
- name: fic-synchro
|
||||||
image: nemunaire/rsync:5d1f678641de2197041f4bc4c745e7748bedab02
|
image: nemunaire/rsync:5d1f678641de2197041f4bc4c745e7748bedab02
|
||||||
command: ["/bin/ash", "/root/synchro.sh"]
|
command: ["/bin/ash", "/root/synchro.sh"]
|
||||||
@ -237,7 +251,7 @@ services:
|
|||||||
- /var/lib/fic/files:/srv/FILES:ro
|
- /var/lib/fic/files:/srv/FILES:ro
|
||||||
#- /var/lib/fic/pki/ca.key:/srv/PKI/ca.key:ro
|
#- /var/lib/fic/pki/ca.key:/srv/PKI/ca.key:ro
|
||||||
- /var/lib/fic/pki/shared:/srv/PKI/shared:ro
|
- /var/lib/fic/pki/shared:/srv/PKI/shared:ro
|
||||||
- /var/lib/fic/settings:/srv/SETTINGS:ro
|
- /var/lib/fic/settingsdist:/srv/SETTINGSDIST:ro
|
||||||
- /var/lib/fic/submissions:/srv/submissions
|
- /var/lib/fic/submissions:/srv/submissions
|
||||||
- /var/lib/fic/teams:/srv/TEAMS:ro
|
- /var/lib/fic/teams:/srv/TEAMS:ro
|
||||||
- /var/log/frontend:/var/log/frontend
|
- /var/log/frontend:/var/log/frontend
|
||||||
@ -246,7 +260,7 @@ services:
|
|||||||
mkdir:
|
mkdir:
|
||||||
- /var/lib/fic/files
|
- /var/lib/fic/files
|
||||||
- /var/lib/fic/pki/shared
|
- /var/lib/fic/pki/shared
|
||||||
- /var/lib/fic/settings
|
- /var/lib/fic/settingsdist
|
||||||
- /var/lib/fic/ssh
|
- /var/lib/fic/ssh
|
||||||
- /var/lib/fic/submissions
|
- /var/lib/fic/submissions
|
||||||
- /var/lib/fic/teams
|
- /var/lib/fic/teams
|
||||||
|
@ -178,8 +178,7 @@ services:
|
|||||||
binds:
|
binds:
|
||||||
- /etc/hosts:/etc/hosts:ro
|
- /etc/hosts:/etc/hosts:ro
|
||||||
- /var/lib/fic/files:/srv/FILES:ro
|
- /var/lib/fic/files:/srv/FILES:ro
|
||||||
- /var/lib/fic/settings:/srv/SETTINGS:ro
|
- /var/lib/fic/settingsdist:/srv/SETTINGSDIST:ro
|
||||||
- /var/lib/fic/settingsdist:/srv/SETTINGSDIST
|
|
||||||
- /var/lib/fic/startingblock:/srv/startingblock
|
- /var/lib/fic/startingblock:/srv/startingblock
|
||||||
- /var/lib/fic/submissions:/srv/submissions
|
- /var/lib/fic/submissions:/srv/submissions
|
||||||
- /var/lib/fic/teams:/srv/TEAMS:ro
|
- /var/lib/fic/teams:/srv/TEAMS:ro
|
||||||
@ -187,7 +186,6 @@ services:
|
|||||||
runtime:
|
runtime:
|
||||||
mkdir:
|
mkdir:
|
||||||
- /var/lib/fic/files
|
- /var/lib/fic/files
|
||||||
- /var/lib/fic/settings
|
|
||||||
- /var/lib/fic/settingsdist
|
- /var/lib/fic/settingsdist
|
||||||
- /var/lib/fic/startingblock
|
- /var/lib/fic/startingblock
|
||||||
- /var/lib/fic/submissions
|
- /var/lib/fic/submissions
|
||||||
@ -212,7 +210,7 @@ services:
|
|||||||
- /root/.ssh/id_synchro.pub:/root/.ssh/authorized_keys:ro
|
- /root/.ssh/id_synchro.pub:/root/.ssh/authorized_keys:ro
|
||||||
- /var/lib/fic/files:/srv/FILES
|
- /var/lib/fic/files:/srv/FILES
|
||||||
- /var/lib/fic/pki:/srv/PKI
|
- /var/lib/fic/pki:/srv/PKI
|
||||||
- /var/lib/fic/settings:/srv/SETTINGS
|
- /var/lib/fic/settingsdist:/srv/SETTINGSDIST
|
||||||
- /var/lib/fic/submissions:/srv/submissions
|
- /var/lib/fic/submissions:/srv/submissions
|
||||||
- /var/lib/fic/teams:/srv/TEAMS
|
- /var/lib/fic/teams:/srv/TEAMS
|
||||||
- /var/log:/var/log:ro
|
- /var/log:/var/log:ro
|
||||||
@ -221,7 +219,7 @@ services:
|
|||||||
mkdir:
|
mkdir:
|
||||||
- /var/lib/fic/files
|
- /var/lib/fic/files
|
||||||
- /var/lib/fic/pki
|
- /var/lib/fic/pki
|
||||||
- /var/lib/fic/settings
|
- /var/lib/fic/settingsdist
|
||||||
- /var/lib/fic/ssh
|
- /var/lib/fic/ssh
|
||||||
- /var/lib/fic/submissions
|
- /var/lib/fic/submissions
|
||||||
- /var/lib/fic/teams
|
- /var/lib/fic/teams
|
||||||
|
@ -20,8 +20,7 @@ func main() {
|
|||||||
var bind = flag.String("bind", "127.0.0.1:8080", "Bind port/socket")
|
var bind = flag.String("bind", "127.0.0.1:8080", "Bind port/socket")
|
||||||
var prefix = flag.String("prefix", "/", "Request path prefix to strip (from proxy)")
|
var prefix = flag.String("prefix", "/", "Request path prefix to strip (from proxy)")
|
||||||
var teamsDir = flag.String("teams", "./TEAMS/", "Base directory where find existing teams")
|
var teamsDir = flag.String("teams", "./TEAMS/", "Base directory where find existing teams")
|
||||||
flag.StringVar(&settings.SettingsDir, "settings", settings.SettingsDir, "Base directory where read settings")
|
flag.StringVar(&settings.SettingsDir, "settings", "./SETTINGSDIST", "Base directory where read settings")
|
||||||
flag.StringVar(&SettingsDistDir, "settingsDist", SettingsDistDir, "Directory where place settings to distribute")
|
|
||||||
flag.StringVar(&startedFile, "startedFile", startedFile, "Path to the file to create/remove whether or not the challenge is running")
|
flag.StringVar(&startedFile, "startedFile", startedFile, "Path to the file to create/remove whether or not the challenge is running")
|
||||||
flag.StringVar(&SubmissionDir, "submission", "./submissions/", "Base directory where save submissions")
|
flag.StringVar(&SubmissionDir, "submission", "./submissions/", "Base directory where save submissions")
|
||||||
var simulator = flag.String("simulator", "", "Team to simulate (for development only)")
|
var simulator = flag.String("simulator", "", "Team to simulate (for development only)")
|
||||||
@ -68,7 +67,7 @@ func main() {
|
|||||||
http.Handle(fmt.Sprintf("%s/teams.json", *prefix), http.StripPrefix(*prefix, http.FileServer(http.Dir(*teamsDir))))
|
http.Handle(fmt.Sprintf("%s/teams.json", *prefix), http.StripPrefix(*prefix, http.FileServer(http.Dir(*teamsDir))))
|
||||||
http.Handle(fmt.Sprintf("%s/themes.json", *prefix), http.StripPrefix(*prefix, http.FileServer(http.Dir(*teamsDir))))
|
http.Handle(fmt.Sprintf("%s/themes.json", *prefix), http.StripPrefix(*prefix, http.FileServer(http.Dir(*teamsDir))))
|
||||||
http.Handle(fmt.Sprintf("%s/stats.json", *prefix), http.StripPrefix(*prefix, http.FileServer(http.Dir(*teamsDir))))
|
http.Handle(fmt.Sprintf("%s/stats.json", *prefix), http.StripPrefix(*prefix, http.FileServer(http.Dir(*teamsDir))))
|
||||||
http.Handle(fmt.Sprintf("%s/settings.json", *prefix), http.StripPrefix(*prefix, http.FileServer(http.Dir(SettingsDistDir))))
|
http.Handle(fmt.Sprintf("%s/settings.json", *prefix), http.StripPrefix(*prefix, http.FileServer(http.Dir(settings.SettingsDir))))
|
||||||
|
|
||||||
// Serve static assets
|
// Serve static assets
|
||||||
http.Handle(fmt.Sprintf("%s/css/", *prefix), http.StripPrefix(*prefix, http.FileServer(http.Dir(staticDir))))
|
http.Handle(fmt.Sprintf("%s/css/", *prefix), http.StripPrefix(*prefix, http.FileServer(http.Dir(staticDir))))
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"srs.epita.fr/fic-server/settings"
|
"srs.epita.fr/fic-server/settings"
|
||||||
@ -26,24 +24,6 @@ func touchStartedFile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func reloadSettings(config *settings.Settings) {
|
func reloadSettings(config *settings.Settings) {
|
||||||
// Copy the new settings file for distribution
|
|
||||||
if data, err := ioutil.ReadFile(path.Join(settings.SettingsDir, settings.SettingsFile)); err != nil {
|
|
||||||
log.Println("Unable to read settings file:", err)
|
|
||||||
} else if err = ioutil.WriteFile(path.Join(SettingsDistDir, settings.SettingsFile+".tmp"), data, 0644); err != nil {
|
|
||||||
log.Println("Unable to write tmp settings file:", err)
|
|
||||||
} else if err := os.Rename(path.Join(SettingsDistDir, settings.SettingsFile+".tmp"), path.Join(SettingsDistDir, settings.SettingsFile)); err != nil {
|
|
||||||
log.Println("Unable to move new settings file:", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy the challenge info file for distribution
|
|
||||||
if data, err := ioutil.ReadFile(path.Join(settings.SettingsDir, settings.ChallengeFile)); err != nil {
|
|
||||||
log.Println("Unable to read challenge info file:", err)
|
|
||||||
} else if err = ioutil.WriteFile(path.Join(SettingsDistDir, settings.ChallengeFile+".tmp"), data, 0644); err != nil {
|
|
||||||
log.Println("Unable to write tmp challenge info file:", err)
|
|
||||||
} else if err := os.Rename(path.Join(SettingsDistDir, settings.ChallengeFile+".tmp"), path.Join(SettingsDistDir, settings.ChallengeFile)); err != nil {
|
|
||||||
log.Println("Unable to move new challenge info file:", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if challengeStart != config.Start || challengeEnd != config.End {
|
if challengeStart != config.Start || challengeEnd != config.End {
|
||||||
if touchTimer != nil {
|
if touchTimer != nil {
|
||||||
touchTimer.Stop()
|
touchTimer.Stop()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user