Skip to content

Commit b2bb2fb

Browse files
committed
Simplify bash logic to make it more readable and compact
1 parent 7fa6e6e commit b2bb2fb

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

mgradm/shared/templates/postUpgradeScriptTemplate.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,14 @@ import (
1111

1212
const postUpgradeScriptTemplate = `#!/bin/bash
1313
sed 's/cobbler\.host.*/cobbler\.host = localhost/' -i /etc/rhn/rhn.conf;
14-
grep uyuni_authentication_endpoint /etc/cobbler/settings.d/zz-uyuni.settings
15-
if [ $? -eq 1 ]; then
14+
if grep -q uyuni_authentication_endpoint /etc/cobbler/settings.d/zz-uyuni.settings; then
1615
echo 'uyuni_authentication_endpoint: "http://localhost"' >> /etc/cobbler/settings.d/zz-uyuni.settings
1716
else
1817
sed 's/uyuni_authentication_endpoint.*/uyuni_authentication_endpoint: http:\/\/localhost/' \
1918
-i /etc/cobbler/settings.d/zz-uyuni.settings;
2019
fi
2120
22-
grep pam_auth_service /etc/rhn/rhn.conf
23-
if [ $? -eq 1 ]; then
21+
if grep -q pam_auth_service /etc/rhn/rhn.conf; then
2422
echo 'pam_auth_service = susemanager' >> /etc/rhn/rhn.conf
2523
else
2624
sed 's/pam_auth_service.*/pam_auth_service = susemanager/' -i /etc/rhn/rhn.conf;

0 commit comments

Comments
 (0)