skel still doesn't work properly,sadly
ci/woodpecker/push/woodpecker Pipeline failed
Details
ci/woodpecker/push/woodpecker Pipeline failed
Details
parent
82bccb9d1f
commit
39c969ec51
|
@ -6,3 +6,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
|
5533801d-70e3-4c21-9942-82d20930c789
|
||||||
|
5533801d-70e3-4c21-9942-82d20930c789
|
||||||
|
5533801d-70e3-4c21-9942-82d20930c789
|
||||||
|
|
|
@ -17,6 +17,9 @@ port: 80
|
||||||
# Files that will be copied into container on startup
|
# Files that will be copied into container on startup
|
||||||
skel: /etc/podterminal/skel.tar.gz
|
skel: /etc/podterminal/skel.tar.gz
|
||||||
skel_target: /config
|
skel_target: /config
|
||||||
|
skel_chown: true
|
||||||
|
# Currently useless
|
||||||
|
skel_owner: "abc"
|
||||||
ssl: false
|
ssl: false
|
||||||
ssl_cert: /etc/ssl/certs/ssl-cert-snakeoil.pem
|
ssl_cert: /etc/ssl/certs/ssl-cert-snakeoil.pem
|
||||||
ssl_cert_key: /etc/ssl/private/ssl-cert-snakeoil.key
|
ssl_cert_key: /etc/ssl/private/ssl-cert-snakeoil.key
|
||||||
|
|
19
pods/skel.go
19
pods/skel.go
|
@ -1,25 +1,31 @@
|
||||||
package pods
|
package pods
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/containers/podman/v4/pkg/bindings"
|
"github.com/containers/podman/v4/pkg/bindings"
|
||||||
|
"github.com/containers/podman/v4/pkg/bindings/containers"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CopySkelToContainer copies an Archive into the containers root
|
// CopySkelToContainer copies an Archive into the containers root
|
||||||
func CopySkelToContainer(id string) error {
|
func CopySkelToContainer(id string) error {
|
||||||
|
chownBool := viper.GetBool("skel_chown")
|
||||||
log.Println("Copying skel Archive to container")
|
log.Println("Copying skel Archive to container")
|
||||||
var err error
|
var err error
|
||||||
conn, err := bindings.GetClient(Socket)
|
conn, err := bindings.GetClient(Socket)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
options := containers.CopyOptions{
|
||||||
|
Chown: &chownBool,
|
||||||
|
}
|
||||||
|
|
||||||
fileInfo, err := os.Stat(viper.GetString("skel"))
|
fileInfo, err := os.Stat(viper.GetString("skel"))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Could not access Skel archive")
|
log.Println("Could not access Skel archive")
|
||||||
return err
|
return err
|
||||||
|
@ -33,9 +39,14 @@ func CopySkelToContainer(id string) error {
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
params := url.Values{}
|
params, err := options.ToParams()
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Could not parse skel options", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
params.Set("path", viper.GetString("skel_target"))
|
params.Set("path", viper.GetString("skel_target"))
|
||||||
|
|
||||||
|
fmt.Println("Container", id, " Params: ", params.Encode())
|
||||||
response, err := conn.DoRequest(
|
response, err := conn.DoRequest(
|
||||||
Socket,
|
Socket,
|
||||||
file,
|
file,
|
||||||
|
@ -50,9 +61,11 @@ func CopySkelToContainer(id string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if response.StatusCode != http.StatusOK {
|
if response.StatusCode != http.StatusOK {
|
||||||
log.Println("Error putting archive into container: ")
|
log.Println("Error putting archive into container: ", response.StatusCode, response.Body)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Println(response.StatusCode, response.Body)
|
log.Println(response.StatusCode, response.Body)
|
||||||
|
|
||||||
|
// Manually chown the Directory, because podmans chown is sometimes unreliable
|
||||||
return response.Process(nil)
|
return response.Process(nil)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,9 @@ func readConfigFile() {
|
||||||
viper.SetDefault("dri", false)
|
viper.SetDefault("dri", false)
|
||||||
viper.SetDefault("dir_node", "/dev/dri/renderD128")
|
viper.SetDefault("dir_node", "/dev/dri/renderD128")
|
||||||
viper.SetDefault("skel", "/etc/podterminal/skel.tar.gz")
|
viper.SetDefault("skel", "/etc/podterminal/skel.tar.gz")
|
||||||
|
viper.SetDefault("skel_chown", false)
|
||||||
viper.SetDefault("skel_target", "/")
|
viper.SetDefault("skel_target", "/")
|
||||||
|
viper.SetDefault("skel_owner", "abc")
|
||||||
viper.SetDefault("block_filebrowser", false)
|
viper.SetDefault("block_filebrowser", false)
|
||||||
viper.SetDefault("envvars",
|
viper.SetDefault("envvars",
|
||||||
map[string]string{
|
map[string]string{
|
||||||
|
|
|
@ -57,16 +57,8 @@ func containerProxy(c *gin.Context) {
|
||||||
c.Abort()
|
c.Abort()
|
||||||
}
|
}
|
||||||
|
|
||||||
err = pods.CopySkelToContainer(ct)
|
// Soft fail Skel
|
||||||
|
_ = pods.CopySkelToContainer(ct)
|
||||||
if err != nil {
|
|
||||||
c.HTML(
|
|
||||||
500,
|
|
||||||
"Error",
|
|
||||||
fmt.Sprintf("[%s] Could not copy skel archive to container: %v", sessionID, err),
|
|
||||||
)
|
|
||||||
c.Abort()
|
|
||||||
}
|
|
||||||
|
|
||||||
proxies[ct], err = createReverseProxy(fmt.Sprintf("http://%s:3000", ctip))
|
proxies[ct], err = createReverseProxy(fmt.Sprintf("http://%s:3000", ctip))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue