# Remediation is applicable only in certain platforms if rpm --quiet -q kernel; then motd_banner_text='^Salut[\s\n]+les[\s\n]+amis,[\s\n]+comment[\s\n]+ça[\s\n]+va[\s\n]+aujourd'hui$' # Multiple regexes transform the banner regex into a usable banner # 0 - Remove anchors around the banner text motd_banner_text=$(echo "$motd_banner_text" | sed 's/^\^\(.*\)\$$/\1/g') # 1 - Keep only the first banners if there are multiple # (dod_banners contains the long and short banner) motd_banner_text=$(echo "$motd_banner_text" | sed 's/^(\(.*\.\)|.*)$/\1/g') # 2 - Add spaces ' '. (Transforms regex for "space or newline" into a " ") motd_banner_text=$(echo "$motd_banner_text" | sed 's/\[\\s\\n\]+/ /g') # 3 - Adds newlines. (Transforms "(?:\[\\n\]+|(?:\\n)+)" into "\n") motd_banner_text=$(echo "$motd_banner_text" | sed 's/(?:\[\\n\]+|(?:\\n)+)/\n/g') # 4 - Remove any leftover backslash. (From any parethesis in the banner, for example). motd_banner_text=$(echo "$motd_banner_text" | sed 's/\\//g') formatted=$(echo "$motd_banner_text" | fold -sw 80) cat </etc/motd $formatted EOF else >&2 echo 'Remediation is not applicable, nothing was done' fi