Skip to content
This repository has been archived by the owner on Mar 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #45 from seknox/docker-guacenc-fix
Browse files Browse the repository at this point in the history
Docker guacenc fix
  • Loading branch information
flyinghermit authored Sep 17, 2020
2 parents 515f85a + 166dd12 commit 3516def
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 8 deletions.
12 changes: 10 additions & 2 deletions build/docker/prod/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion build/etc/trasa/config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
14 changes: 10 additions & 4 deletions server/accessproxy/rdpproxy/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,34 +88,40 @@ func (s GWStore) uploadSessionLog(authlog *logs.AuthLog) error {
func getGuacencCmd(sessionID string) *exec.Cmd {
if os.Getenv("GUACENC_INSTALLED") == "true" {
guacencCmdStr := fmt.Sprintf(
"/usr/local/guacamole/bin/guacenc -f /tmp/trasa/accessproxy/guac/%s.guac", sessionID)
"nice -n 10 /usr/local/guacamole/bin/guacenc -f /tmp/trasa/accessproxy/guac/%s.guac", sessionID)

return exec.Command("/bin/sh", "-c", guacencCmdStr)

}

if runtime.GOOS == "windows" {
guacencCmdStr := fmt.Sprintf(
"docker.exe exec guacd /usr/local/guacamole/bin/guacenc -f /tmp/trasa/accessproxy/guac/%s.guac", sessionID)
"docker.exe exec guacd nice -n 10 /usr/local/guacamole/bin/guacenc -f /tmp/trasa/accessproxy/guac/%s.guac", sessionID)

return exec.Command("powershell", "-c", guacencCmdStr)
}

guacencCmdStr := fmt.Sprintf(
"sudo docker exec guacd /usr/local/guacamole/bin/guacenc -f /tmp/trasa/accessproxy/guac/%s.guac", sessionID)
"sudo docker exec guacd nice -n 10 /usr/local/guacamole/bin/guacenc -f /tmp/trasa/accessproxy/guac/%s.guac", sessionID)
return exec.Command("/bin/bash", "-c", guacencCmdStr)

}

func getFFMPEGcmd(tempFileDir, sessionID string) *exec.Cmd {

if os.Getenv("GUACENC_INSTALLED") == "true" {
ffmpegCmdStr := fmt.Sprintf("nice -n 10 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)

}

ffmpegCmdStr := fmt.Sprintf("sudo ffmpeg -i %s/%s.guac.m4v %s/%s.mp4", tempFileDir, sessionID, tempFileDir, sessionID)
ffmpegCmdStr := fmt.Sprintf("sudo nice -n 10 ffmpeg -i %s/%s.guac.m4v %s/%s.mp4", tempFileDir, sessionID, tempFileDir, sessionID)
return exec.Command("/bin/bash", "-c", ffmpegCmdStr)

}
2 changes: 1 addition & 1 deletion server/api/logs/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

}

Expand Down
26 changes: 26 additions & 0 deletions server/utils/filesystem.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package utils

import (
"fmt"
"io"
"os"
"runtime"

Expand All @@ -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":
Expand Down

0 comments on commit 3516def

Please sign in to comment.