Download mods and headless server
till working on improvements to code this more like a savepoint.
This commit is contained in:
@@ -1 +1,35 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func downloadHeadless() {
|
||||
var c = readCfg("config.yml")
|
||||
headlessQuery := fmt.Sprintf("https://www.factorio.com/get-download/latest/headless/linux64?username=%s&token=%s", c.Factoryman.UserName, c.Factoryman.ApiToken)
|
||||
|
||||
dlerr := download("./factorio.tar.xz", headlessQuery)
|
||||
if dlerr != nil {
|
||||
log.Fatalf("Unable to download: %v", dlerr)
|
||||
}
|
||||
|
||||
err := os.MkdirAll(c.Server.ServDir, os.ModePerm)
|
||||
if err != nil {
|
||||
fmt.Printf("Error creating directory: %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println("tar", "-xf", "factorio.tar.xz", "-C", c.Server.ServDir+"/")
|
||||
cmd := exec.Command("tar", "-xf", "factorio.tar.xz", "-C")
|
||||
|
||||
// 2. Run and capture Standard Output
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Println(err)
|
||||
fmt.Println(string(out))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user