From 7a24724631399f11c483943463782fb6853cbe88 Mon Sep 17 00:00:00 2001 From: Yahav Itschak Date: Tue, 29 Oct 2024 17:12:56 +0200 Subject: [PATCH] Fix compatibility on Mac Bash3 (#23) --- local-rt-setup/main.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/local-rt-setup/main.go b/local-rt-setup/main.go index ccea3a0..de43caf 100644 --- a/local-rt-setup/main.go +++ b/local-rt-setup/main.go @@ -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 @@ -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 { @@ -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)