Skip to content

Commit

Permalink
Fix compatibility on Mac Bash3
Browse files Browse the repository at this point in the history
  • Loading branch information
yahavi committed Oct 29, 2024
1 parent ab07dc3 commit de06051
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions local-rt-setup/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ var (
artifactoryVarPath = filepath.Join("artifactory", "var")
artifactoryVarEtcPath = filepath.Join(artifactoryVarPath, "etc")
artifactoryVarEtcAccessPath = filepath.Join(artifactoryVarEtcPath, "access")
artifactoryAppBinPath = filepath.Join("artifactory", "app", "bin")

//go:embed system.yaml
systemYaml string
Expand Down Expand Up @@ -103,6 +104,9 @@ func setupLocalArtifactory() (err error) {
if err = os.Chmod(filepath.Join(jfrogHome, artifactoryVarPath), os.ModePerm); err != nil {
return err
}
if err = fixBash3Compatibility(jfrogHome); err != nil {
return err
}
}

if err = createLicenseFile(jfrogHome, license, artifactory6); err != nil {
Expand Down Expand Up @@ -144,6 +148,23 @@ func setupLocalArtifactory() (err error) {
return enableArchiveIndex()
}

// Fix the bash 3 compatibility issue by removing the ,, from the artifactoryCommon.sh file.
func fixBash3Compatibility(jfrogHome string) error {
artifactoryCommonPath := filepath.Join(jfrogHome, artifactoryAppBinPath, "artifactoryCommon.sh")

// Read artifactoryCommon.sh file
content, err := os.ReadFile(artifactoryCommonPath)
if err != nil {
return err
}

// Replace ,, with an empty string
updatedContent := bytes.ReplaceAll(content, []byte(",,"), []byte{})

// Write artifactoryCommon.sh without the ,,
return os.WriteFile(artifactoryCommonPath, []byte(updatedContent), 0755)
}

// Rename the directory that was extracted from the archive, to easily access in the rest of the script.
func renameArtifactoryDir(jfrogHome string) error {
fileInfo, err := os.ReadDir(jfrogHome)
Expand Down

0 comments on commit de06051

Please sign in to comment.