Skip to content

Commit 0f76b83

Browse files
Bastian-KuhnracicLuka
authored andcommitted
Fix: mk-job (linux) support versions without perl again
Current Linux Distributions like RHEL 8 + 9 do not install Perl as default. So with the Update Checkmk 2.3, mk-job fails there since an earlier workaround for aix/ solaris to get a timestamp using perl, was made a default now for as well Linux. This fix tries to restore the function on GNU Linux again if perl is missing, but without reverting the use of perl as default. Since GNU date should always have the %s parameter, just BSD or BusyBox can lack the support, that's maybe a reasonable approach. CMK-20768 closes: #775 Change-Id: Icf9e182511ef7fa0898883710189b2fcf0960e66
1 parent 8510156 commit 0f76b83

3 files changed

Lines changed: 27 additions & 3 deletions

File tree

agents/mk-job

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,15 @@ main() {
7272
rm "${RUNNING_FILE}" 2>/dev/null
7373
}
7474

75-
echo "start_time $(perl -e 'print time')" >"${TMP_FILE}" 2>/dev/null
75+
try_perl() {
76+
perl -e 'print "start_time " . time . "\n"' >"${TMP_FILE}" 2>/dev/null
77+
}
78+
79+
fallback_date() {
80+
date +"start_time %s" >"${TMP_FILE}" 2>/dev/null
81+
}
82+
try_perl || fallback_date
83+
7684
cp "${TMP_FILE}" "${RUNNING_FILE}" 2>/dev/null
7785

7886
if [ ! -w "${RUNNING_FILE}" ]; then

agents/mk-job.aix

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,15 @@ main() {
7272
rm "${RUNNING_FILE}" 2>/dev/null
7373
}
7474

75-
echo "start_time $(perl -e 'print time')" >"${TMP_FILE}" 2>/dev/null
75+
try_perl() {
76+
perl -e 'print "start_time " . time . "\n"' >"${TMP_FILE}" 2>/dev/null
77+
}
78+
79+
fallback_date() {
80+
date +"start_time %s" >"${TMP_FILE}" 2>/dev/null
81+
}
82+
try_perl || fallback_date
83+
7684
cp "${TMP_FILE}" "${RUNNING_FILE}" 2>/dev/null
7785

7886
if [ ! -w "${RUNNING_FILE}" ]; then

agents/mk-job.solaris

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,15 @@ main() {
7272
rm "${RUNNING_FILE}" 2>/dev/null
7373
}
7474

75-
echo "start_time $(perl -e 'print time')" >"${TMP_FILE}" 2>/dev/null
75+
try_perl() {
76+
perl -e 'print "start_time " . time . "\n"' >"${TMP_FILE}" 2>/dev/null
77+
}
78+
79+
fallback_date() {
80+
date +"start_time %s" >"${TMP_FILE}" 2>/dev/null
81+
}
82+
try_perl || fallback_date
83+
7684
cp "${TMP_FILE}" "${RUNNING_FILE}" 2>/dev/null
7785

7886
if [ ! -w "${RUNNING_FILE}" ]; then

0 commit comments

Comments
 (0)