Compare commits

...

2 Commits
v0.3.0 ... main

Author SHA1 Message Date
Fábio Kaiser Rauber 882df2ef9d Fix runcmd substitution for install script 6 months ago
Fábio Kaiser Rauber dfc0af972c Flatcar has read-only /usr 6 months ago
  1. 13
      main.go

13
main.go

@ -11,6 +11,7 @@ import (
"os"
"os/exec"
"os/user"
"path/filepath"
"strconv"
"strings"
"unicode"
@ -190,6 +191,16 @@ func processUserData(configDriveDir string) error {
//write files
for _, file := range cc.WriteFiles {
// Replace "/usr/local" with "/opt" in Path, since Flatcar has read-only /usr
file.Path = strings.Replace(file.Path, "/usr/local", "/opt", -1)
// Create directory if it does not exist
dir := filepath.Dir(file.Path)
err := os.MkdirAll(dir, 0755)
if err != nil {
log.Printf("Error creating directory %s: %s", dir, err)
}
perm, err := file.OSPermissions()
if err != nil {
log.Printf("Invalid file permissions for %s: %s", file.Path, file.Permissions)
@ -215,7 +226,7 @@ func processUserData(configDriveDir string) error {
// Run commands
for _, cmd := range cc.RunCmd {
cmdArgs := strings.Fields(cmd)
cmdArgs := strings.Fields(strings.Replace(cmd, "/usr/local/custom_script", "/opt/custom_script", -1))
output, err := exec.Command(cmdArgs[0], cmdArgs[1:]...).CombinedOutput()
if err != nil {
log.Printf("Error running command '%s': %s\n%s", cmd, err, output)

Loading…
Cancel
Save