diff --git a/.vagrant/machines/default/libvirt/created_networks b/.vagrant/machines/default/libvirt/created_networks index 5e0f6ab..2e2c2cf 100644 --- a/.vagrant/machines/default/libvirt/created_networks +++ b/.vagrant/machines/default/libvirt/created_networks @@ -8,3 +8,5 @@ 5533801d-70e3-4c21-9942-82d20930c789 5533801d-70e3-4c21-9942-82d20930c789 5533801d-70e3-4c21-9942-82d20930c789 +5533801d-70e3-4c21-9942-82d20930c789 +5533801d-70e3-4c21-9942-82d20930c789 diff --git a/README.md b/README.md index 75ce45d..0771799 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,9 @@ On Debian 12, you will need the following dependencies: apt install -y git wget podman make gcc libgpgme-dev build-essential pkgconf pkgconf-bin libdevmapper-dev libbtrfs-dev ``` +## Installing +Executing `make install` will install and start podterminal as a systemd service, including an example config file. + ## Running To run the built binary, just execute it as root. You will have to have Podman installed and its socket enabled. Currently you have to set the Image, port etc. directly in the Source Code, however that should be eventually moved into diff --git a/exampleconfig.yaml b/exampleconfig.yaml index 7d48846..fa8704c 100644 --- a/exampleconfig.yaml +++ b/exampleconfig.yaml @@ -9,7 +9,7 @@ envvars: # HTTP_PROXY: 192.168.0.10 # Container Image you want to use -image: lscr.io/linuxserver/webtop +image: git.jmbit.de/jmb/webtop-plus:latest # Maximum age of Session maxage: 10800 # Port Podterminal should listen to @@ -17,9 +17,8 @@ port: 80 # Files that will be copied into container on startup skel: /etc/podterminal/skel.tar.gz skel_target: /config -skel_chown: true -# Currently useless -skel_owner: "abc" +# Overrides UID/GID from tar archive to container user +skel_chown: false ssl: false ssl_cert: /etc/ssl/certs/ssl-cert-snakeoil.pem ssl_cert_key: /etc/ssl/private/ssl-cert-snakeoil.key diff --git a/pods/skel.go b/pods/skel.go index d3218ff..e8eb0c7 100644 --- a/pods/skel.go +++ b/pods/skel.go @@ -1,10 +1,13 @@ package pods import ( + "bytes" "fmt" + "io" "log" "net/http" "os" + "strings" "github.com/containers/podman/v4/pkg/bindings" "github.com/containers/podman/v4/pkg/bindings/containers" @@ -65,7 +68,36 @@ func CopySkelToContainer(id string) error { return err } log.Println(response.StatusCode, response.Body) + if viper.GetString("skel_user") != "" { + chownSkel(id) + + } // Manually chown the Directory, because podmans chown is sometimes unreliable return response.Process(nil) } + +func chownSkel(id string) { + command := fmt.Sprintf( + "chown -R %s %s \n\n", + viper.GetString("skel_user"), + viper.GetString("skel_target"), + ) + done := make(chan bool) + detachKeys := "\n\n" + commandReader := strings.NewReader(command) + var output bytes.Buffer + outputWriter := io.Writer(&output) + options := &containers.AttachOptions{ + DetachKeys: &detachKeys, + } + + err := containers.Attach(Socket, id, commandReader, outputWriter, outputWriter, done, options) + + if err != nil { + log.Printf("Error: %v \n %s\n", err, output.String()) + } else { + log.Println(output.String()) + } + +} diff --git a/readConfig.go b/readConfig.go index f9f6891..9b91e50 100644 --- a/readConfig.go +++ b/readConfig.go @@ -12,14 +12,14 @@ func readConfigFile() { viper.SetConfigFile("/etc/podterminal/config.yaml") viper.SetDefault("port", 80) viper.SetDefault("ip_addr", "0.0.0.0") - viper.SetDefault("image", "lscr.io/linuxserver/webtop") + viper.SetDefault("image", "git.jmbit.de/jmb/webtop-plus:latest") viper.SetDefault("maxAge", 10800) viper.SetDefault("dri", false) viper.SetDefault("dir_node", "/dev/dri/renderD128") viper.SetDefault("skel", "/etc/podterminal/skel.tar.gz") viper.SetDefault("skel_chown", false) viper.SetDefault("skel_target", "/") - viper.SetDefault("skel_owner", "abc") + viper.SetDefault("skel_user", "") viper.SetDefault("block_filebrowser", false) viper.SetDefault("envvars", map[string]string{ diff --git a/web/reverseProxy.go b/web/reverseProxy.go index 099bc84..2e39907 100644 --- a/web/reverseProxy.go +++ b/web/reverseProxy.go @@ -58,7 +58,7 @@ func containerProxy(c *gin.Context) { } // Soft fail Skel - _ = pods.CopySkelToContainer(ct) + // _ = pods.CopySkelToContainer(ct) proxies[ct], err = createReverseProxy(fmt.Sprintf("http://%s:3000", ctip))