corrects sh execution

This commit is contained in:
Hyatt 2024-01-22 10:44:21 -06:00
parent 18d295c993
commit b78cdf6a74
Signed by: nhyatt
GPG Key ID: C50D0BBB5BC40BEA

View File

@ -70,7 +70,7 @@ func (c NsUpdateStruct) Delete(record, recordType string) error {
stderr bytes.Buffer stderr bytes.Buffer
) )
command := fmt.Sprintf(`#/bin/env/sh command := fmt.Sprintf(`#/usr/bin/env sh
read -r -d '' DDNS_KEY <<- EOF read -r -d '' DDNS_KEY <<- EOF
key "%s" { key "%s" {
algorithm "%s"; algorithm "%s";
@ -85,7 +85,7 @@ EOF
nsupdate -v -k <(printf '%%s' "${DDNS_KEY}") <(printf '%%s\n\n' "${COMMAND}") nsupdate -v -k <(printf '%%s' "${DDNS_KEY}") <(printf '%%s\n\n' "${COMMAND}")
`, c.Key.Label, c.Key.Algorithm, c.Key.Secret, c.Server, record, strings.ToUpper(recordType)) `, c.Key.Label, c.Key.Algorithm, c.Key.Secret, c.Server, record, strings.ToUpper(recordType))
cmd := exec.Command("/usr/bin/sh", "-c", command) cmd := exec.Command("/usr/bin/env", "sh", "-c", command)
cmd.Stdout = &stdout cmd.Stdout = &stdout
cmd.Stderr = &stderr cmd.Stderr = &stderr
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {
@ -102,7 +102,7 @@ func (c NsUpdateStruct) Create(record, recordType, value string) error {
stderr bytes.Buffer stderr bytes.Buffer
) )
command := fmt.Sprintf(`#/bin/env/sh command := fmt.Sprintf(`#/usr/bin/env sh
read -r -d '' DDNS_KEY <<- EOF read -r -d '' DDNS_KEY <<- EOF
key "%s" { key "%s" {
algorithm "%s"; algorithm "%s";
@ -117,7 +117,7 @@ EOF
nsupdate -v -k <(printf '%%s' "${DDNS_KEY}") <(printf '%%s\n\n' "${COMMAND}") nsupdate -v -k <(printf '%%s' "${DDNS_KEY}") <(printf '%%s\n\n' "${COMMAND}")
`, c.Key.Label, c.Key.Algorithm, c.Key.Secret, c.Server, record, strings.ToUpper(recordType), value) `, c.Key.Label, c.Key.Algorithm, c.Key.Secret, c.Server, record, strings.ToUpper(recordType), value)
cmd := exec.Command("/usr/bin/sh", "-c", command) cmd := exec.Command("/usr/bin/env", "sh", "-c", command)
cmd.Stdout = &stdout cmd.Stdout = &stdout
cmd.Stderr = &stderr cmd.Stderr = &stderr
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {