From 6bf41f109aa4fdb737d3ece53083cd73c7a1dca6 Mon Sep 17 00:00:00 2001 From: bhrg3se Date: Wed, 16 Sep 2020 18:58:47 +0545 Subject: [PATCH] ref :[server] guacenc copied inside Dockerfile --- build/docker/prod/Dockerfile | 12 ++++++++++-- build/etc/trasa/config/config.toml | 2 +- server/accessproxy/rdpproxy/store.go | 6 ++++++ server/api/logs/store.go | 2 +- server/utils/filesystem.go | 26 ++++++++++++++++++++++++++ 5 files changed, 44 insertions(+), 4 deletions(-) diff --git a/build/docker/prod/Dockerfile b/build/docker/prod/Dockerfile index aa9450da..96697df5 100644 --- a/build/docker/prod/Dockerfile +++ b/build/docker/prod/Dockerfile @@ -27,11 +27,19 @@ COPY dashboard ./ RUN yarn run build -FROM ubuntu:xenial-20200706 - +FROM debian:stable-slim +USER root WORKDIR /trasa +ENV GUACENC_INSTALLED=true +COPY --from=seknox/guacd:v0.0.1 /usr/local/guacamole/bin/guacenc /usr/local/guacamole/bin/guacenc +COPY --from=seknox/guacd:v0.0.1 /usr/local/guacamole/lib/ /usr/local/guacamole/lib/ +COPY --from=seknox/guacd:v0.0.1 /usr/local/guacamole/DEPENDENCIES /usr/local/guacamole/ + RUN apt-get update RUN apt-get install -y --no-install-recommends ca-certificates +RUN apt-get install -y libavcodec-dev libavformat-dev libavutil-dev libswscale-dev ffmpeg +RUN apt-get install -y $(cat /usr/local/guacamole/DEPENDENCIES) + RUN update-ca-certificates COPY --from=gobuilder /go/src/seknox/trasa/server/server . COPY --from=dashbuilder /trasa/build /var/trasa/dashboard diff --git a/build/etc/trasa/config/config.toml b/build/etc/trasa/config/config.toml index a4886d13..bf2c3e5b 100644 --- a/build/etc/trasa/config/config.toml +++ b/build/etc/trasa/config/config.toml @@ -42,7 +42,7 @@ sshlistenAddr = "127.0.0.1:8022" dbListenAddr = "127.0.0.1:3333" guacdEnabled = false - guacdAddr = "127.0.0.1:4822" + guacdAddr = "guacd:4822" [vault] diff --git a/server/accessproxy/rdpproxy/store.go b/server/accessproxy/rdpproxy/store.go index a8d47266..8cad9ea6 100644 --- a/server/accessproxy/rdpproxy/store.go +++ b/server/accessproxy/rdpproxy/store.go @@ -109,6 +109,12 @@ func getGuacencCmd(sessionID string) *exec.Cmd { func getFFMPEGcmd(tempFileDir, sessionID string) *exec.Cmd { + if os.Getenv("GUACENC_INSTALLED") == "true" { + ffmpegCmdStr := fmt.Sprintf("ffmpeg -i %s/%s.guac.m4v %s/%s.mp4", tempFileDir, sessionID, tempFileDir, sessionID) + return exec.Command("/bin/bash", "-c", ffmpegCmdStr) + + } + if runtime.GOOS == "windows" { ffmpegCmdStr := fmt.Sprintf(`ffmpeg.exe -i %s\%s.guac.m4v %s\%s.mp4`, tempFileDir, sessionID, tempFileDir, sessionID) return exec.Command("powershell", "-c", ffmpegCmdStr) diff --git a/server/api/logs/store.go b/server/api/logs/store.go index fd297b8d..606a2b9f 100644 --- a/server/api/logs/store.go +++ b/server/api/logs/store.go @@ -312,7 +312,7 @@ func (s logStore) PutIntoMinio(objectName, logfilepath, bucketName string) error if err != nil { return err } - return os.Rename(logfilepath, newpath) + return utils.MoveFile(logfilepath, newpath) } diff --git a/server/utils/filesystem.go b/server/utils/filesystem.go index eb1b1aa3..5f2dcf77 100644 --- a/server/utils/filesystem.go +++ b/server/utils/filesystem.go @@ -1,6 +1,8 @@ package utils import ( + "fmt" + "io" "os" "runtime" @@ -17,6 +19,30 @@ func CreateDirIfNotExist(dir string) { } } +func MoveFile(sourcePath, destPath string) error { + inputFile, err := os.Open(sourcePath) + if err != nil { + return fmt.Errorf("Couldn't open source file: %s", err) + } + outputFile, err := os.Create(destPath) + if err != nil { + inputFile.Close() + return fmt.Errorf("Couldn't open dest file: %s", err) + } + defer outputFile.Close() + _, err = io.Copy(outputFile, inputFile) + inputFile.Close() + if err != nil { + return fmt.Errorf("Writing to output file failed: %s", err) + } + // The copy was successful, so now delete the original file + err = os.Remove(sourcePath) + if err != nil { + return fmt.Errorf("Failed removing original file: %s", err) + } + return nil +} + func GetETCDir() string { switch runtime.GOOS { case "windows":