diff --git a/.gitignore b/.gitignore index d344ba6..0a361fc 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ config.json +env/ +remotegameplay \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..73f69e0 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..f5e11cb --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/remotegameplay.iml b/.idea/remotegameplay.iml new file mode 100644 index 0000000..5e764c4 --- /dev/null +++ b/.idea/remotegameplay.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..656df7b --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/Akilan1999/remotegameplay + +go 1.16 diff --git a/main.go b/main.go new file mode 100644 index 0000000..f72e13f --- /dev/null +++ b/main.go @@ -0,0 +1,87 @@ +package main + +import ( + "bufio" + "fmt" + "os" + "os/exec" +) + +func main() { + err := LaplaceConfig() + if err != nil { + fmt.Println(err) + } + _, err = LaplaceServer(23424) + if err != nil { + fmt.Println(err) + } +} + +// LaplaceConfig Sets up the laplace configuration +func LaplaceConfig() error { + // Setting up environment variable Laplace + curDir := os.Getenv("PWD") + os.Setenv("LAPLACE", curDir) + + cmd := exec.Command("./laplace","-setconfig") + + // USE THE FOLLOWING TO DEBUG + //cmdReader, err := cmd.StdoutPipe() + //if err != nil { + // fmt.Fprintln(os.Stderr, "Error creating StdoutPipe for Cmd", err) + // return + //} + // + //// the following is used to print output of the command + //// as it makes progress... + //scanner := bufio.NewScanner(cmdReader) + //go func() { + // for scanner.Scan() { + // fmt.Printf("%s\n", scanner.Text()) + // // + // // TODO: + // // send output to server + // } + //}() + // + //if err := cmd.Start(); err != nil { + // return err + //} + + if err := cmd.Run(); err != nil { + return err + } + + return nil +} + +// LaplaceServer Executes the laplace server +func LaplaceServer(port int)(*exec.Cmd, error) { + cmd := exec.Command("./laplace","-tls","-addr","0.0.0.0:" + fmt.Sprint(port)) + + // USE THE FOLLOWING TO DEBUG + cmdReader, err := cmd.StdoutPipe() + if err != nil { + fmt.Fprintln(os.Stderr, "Error creating StdoutPipe for Cmd", err) + return nil, err + } + + // the following is used to print output of the command + // as it makes progress... + scanner := bufio.NewScanner(cmdReader) + go func() { + for scanner.Scan() { + fmt.Printf("%s\n", scanner.Text()) + // + // TODO: + // send output to server + } + }() + + if err = cmd.Run(); err != nil { + return nil, err + } + + return cmd, nil +} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e69de29 diff --git a/site.yml b/site.yml new file mode 100644 index 0000000..1d10af4 --- /dev/null +++ b/site.yml @@ -0,0 +1,11 @@ +--- + +- hosts: all + + tasks: + - name: set config for laplace + ansible.builtin.script: ./laplace -setconfig + + - name: run laplace + ansible.builtin.script: ./laplace -tls -addr 0.0.0.0:8888 +