From c7e255755a1859c932bd36bbe9c77f1645670ac6 Mon Sep 17 00:00:00 2001 From: Michael Boelen Date: Wed, 21 Jul 2021 00:20:04 +0200 Subject: Added check for outdated language file --- lynis | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'lynis') diff --git a/lynis b/lynis index 0c7635e0..6c865910 100755 --- a/lynis +++ b/lynis @@ -599,11 +599,33 @@ ${NORMAL} Display --indent 2 --text "- Detecting language and localization" --result "${LANGUAGE}" --color WHITE if [ ! -f ${DBDIR}/languages/${LANGUAGE} ]; then Display --indent 4 --text "${YELLOW}Notice:${NORMAL} no language file found for '${LANGUAGE}' (tried: ${DBDIR}/languages/${LANGUAGE})" - if IsDeveloperVersion; then Display --indent 4 --text "See https://github.com/CISOfy/lynis-sdk/documentation/10-translations.md for more details to help translate Lynis"; fi + if IsDeveloperVersion; then Display --indent 4 --text "See https://github.com/CISOfy/lynis-sdk/blob/master/documentation/10-translations.md for more details to help translate Lynis"; fi sleep 5 else - LogText "Importing language file (${DBDIR}/languages/${LANGUAGE})" - . ${DBDIR}/languages/${LANGUAGE} + if SafeFile "${DBDIR}/languages/${LANGUAGE}"; then + LogText "Importing language file (${DBDIR}/languages/${LANGUAGE})" + . ${DBDIR}/languages/${LANGUAGE} + # Check for missing translations if we are a pre-release or less than a week old + if grep -E -q -s "^#" ${DBDIR}/languages/${LANGUAGE}; then + TIME_DIFFERENCE_CHECK=604800 # 1 week + RELEASE_PLUS_TIMEDIFF=$((PROGRAM_RELEASE_TIMESTAMP + TIME_DIFFERENCE_CHECK)) + if IsDeveloperVersion || [ ${NOW} -lt ${RELEASE_PLUS_TIMEDIFF} ]; then + Display --indent 4 --text "Translation file (db/languages/${LANGUAGE}) needs an update" --result "OUTDATED" --color RED + Display --indent 4 --text "=======================================================================" + Display --indent 4 --text "Help other users and translate the missing lines:" + Display --indent 4 --text "1) Go to: https://github.com/CISOfy/lynis/edit/master/db/languages/${LANGUAGE}" + Display --indent 4 --text "2) Translate (some of) the lines starting with a hash (#) and remove the leading hash" + Display --indent 4 --text "3) Commit the changes" + Display --indent 4 --text "Thank you!" + Display --indent 4 --text "Note: no lines with a hash? Look if the file recently has been changed by another translator." + Display --indent 4 --text "=======================================================================" + sleep 30 + fi + fi + else + LogText "Could not import language file due to incorrect permissions" + fi + fi fi LogTextBreak -- cgit v1.2.3