mirror of
https://github.com/OpenFactorioServerManager/factorio-server-manager.git
synced 2024-12-31 03:11:17 +02:00
Added flag for config file
This commit is contained in:
parent
1b6fef4605
commit
8642b771d5
4
Makefile
4
Makefile
@ -2,5 +2,5 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
build:
|
build:
|
||||||
go build -o $(HOME)/factorio-server-manager/factorio-server-manager
|
go build -o $(HOME)/factorio-server/factorio-server-manager
|
||||||
cp -r app/ $(HOME)/factorio-server-manager/
|
cp -r app/ $(HOME)/factorio-server/
|
||||||
|
@ -25,8 +25,6 @@ RUN curl -s -L -S -k https://www.factorio.com/get-download/$FACTORIO_VERSION/hea
|
|||||||
mkdir -p /var/lib/nginx/tmp && \
|
mkdir -p /var/lib/nginx/tmp && \
|
||||||
chown nginx:root /var/lib/nginx
|
chown nginx:root /var/lib/nginx
|
||||||
|
|
||||||
ADD "conf.json" "/opt/factorio-server/conf.json"
|
|
||||||
|
|
||||||
EXPOSE 80/tcp 443/tcp 34190-34200/udp
|
EXPOSE 80/tcp 443/tcp 34190-34200/udp
|
||||||
|
|
||||||
ENTRYPOINT ["/opt/init.sh"]
|
ENTRYPOINT ["/opt/init.sh"]
|
||||||
|
@ -27,6 +27,6 @@ if [ ! -f /security/passwords.conf ]; then
|
|||||||
echo -n "admin:" >> /security/passwords.conf
|
echo -n "admin:" >> /security/passwords.conf
|
||||||
openssl passwd -apr1 $ADMIN_PASSWORD >> /security/passwords.conf
|
openssl passwd -apr1 $ADMIN_PASSWORD >> /security/passwords.conf
|
||||||
fi
|
fi
|
||||||
ls -R /opt/factorio-server
|
|
||||||
nohup nginx &
|
nohup nginx &
|
||||||
/opt/factorio-server/factorio-server-manager -dir '/opt/factorio' -conf '/opt/factorio-server/conf.json'
|
/opt/factorio-server/factorio-server-manager -dir '/opt/factorio' -conf '/opt/factorio-server/conf.json'
|
||||||
|
@ -462,6 +462,7 @@ func StartServer(w http.ResponseWriter, r *http.Request) {
|
|||||||
// Check if savefile was submitted with request to start server.
|
// Check if savefile was submitted with request to start server.
|
||||||
if FactorioServ.Savefile == "" {
|
if FactorioServ.Savefile == "" {
|
||||||
log.Printf("Error starting Factorio server: %s", err)
|
log.Printf("Error starting Factorio server: %s", err)
|
||||||
|
resp.Success = false
|
||||||
resp.Data = fmt.Sprintf("Error starting Factorio server: %s", err)
|
resp.Data = fmt.Sprintf("Error starting Factorio server: %s", err)
|
||||||
if err := json.NewEncoder(w).Encode(resp); err != nil {
|
if err := json.NewEncoder(w).Encode(resp); err != nil {
|
||||||
log.Printf("Error encoding config file JSON reponse: ", err)
|
log.Printf("Error encoding config file JSON reponse: ", err)
|
||||||
@ -475,7 +476,7 @@ func StartServer(w http.ResponseWriter, r *http.Request) {
|
|||||||
log.Printf("Error starting Factorio server: %s", err)
|
log.Printf("Error starting Factorio server: %s", err)
|
||||||
resp.Data = fmt.Sprintf("Error starting Factorio server: %s", err)
|
resp.Data = fmt.Sprintf("Error starting Factorio server: %s", err)
|
||||||
if err := json.NewEncoder(w).Encode(resp); err != nil {
|
if err := json.NewEncoder(w).Encode(resp); err != nil {
|
||||||
log.Printf("Error encoding config file JSON reponse: ", err)
|
log.Printf("Error encoding start server JSON reponse: ", err)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
7
main.go
7
main.go
@ -22,6 +22,7 @@ type Config struct {
|
|||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
DatabaseFile string `json:"database_file"`
|
DatabaseFile string `json:"database_file"`
|
||||||
|
ConfFile string
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -72,10 +73,14 @@ func parseFlags() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
loadServerConfig("./conf.json")
|
confFile := flag.String("conf", "./conf.json", "Specify location of Factorio Server Manager config file.")
|
||||||
|
config.ConfFile = *confFile
|
||||||
|
loadServerConfig(config.ConfFile)
|
||||||
|
|
||||||
|
// Initialize Factorio Server struct
|
||||||
FactorioServ = initFactorio()
|
FactorioServ = initFactorio()
|
||||||
|
|
||||||
|
// Initialize authentication system
|
||||||
Auth = initAuth()
|
Auth = initAuth()
|
||||||
Auth.createAuthDb(config.DatabaseFile)
|
Auth.createAuthDb(config.DatabaseFile)
|
||||||
Auth.createRoles()
|
Auth.createRoles()
|
||||||
|
@ -17,7 +17,7 @@ type FactorioServer struct {
|
|||||||
AutosaveSlots int `json:"autosave_slots"`
|
AutosaveSlots int `json:"autosave_slots"`
|
||||||
Port int `json:"port"`
|
Port int `json:"port"`
|
||||||
DisallowCmd bool `json:"disallow_cmd"`
|
DisallowCmd bool `json:"disallow_cmd"`
|
||||||
Running bool `json:"bool"`
|
Running bool `json:"running"`
|
||||||
PeerToPeer bool `json:"peer2peer"`
|
PeerToPeer bool `json:"peer2peer"`
|
||||||
AutoPause bool `json:"auto_pause"`
|
AutoPause bool `json:"auto_pause"`
|
||||||
StdOut io.ReadCloser
|
StdOut io.ReadCloser
|
||||||
|
Loading…
Reference in New Issue
Block a user