Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compatibility on Mac Bash3 #23

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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, 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