X-Git-Url: https://git.grml.org/?a=blobdiff_plain;f=autoconfig.functions;h=b7d694c0fe4b0c35238c62c0245059eec5fd8756;hb=c9662c3fb4a680b51d9f7751fa5d82c0988128f7;hp=891242e3a9ad35472cc414c42bb07dac65c2d665;hpb=7bfc241ac64c535dc5c2a28e9fdb1ff55c1d5625;p=grml-autoconfig.git diff --git a/autoconfig.functions b/autoconfig.functions index 891242e..b7d694c 100755 --- a/autoconfig.functions +++ b/autoconfig.functions @@ -184,7 +184,8 @@ KVM=false VIRTUALBOX=false VMWARE=false -if vmware-detect &>/dev/null; then +if virt-what 2>/dev/null | grep -q 'vmware' || \ + imvirt 2>/dev/null | grep -iq "vmware" ; then VIRTUAL=true; VMWARE=true; VIRTUAL_ENV='VMware' fi @@ -904,19 +905,23 @@ fi # -z $INSTALLED # {{{ CPU-detection config_cpu(){ -if checkbootparam 'nocpu'; then - ewarn "Skipping CPU detection as requested on boot commandline." ; eend 0 - return 0 -fi + if checkbootparam 'nocpu'; then + ewarn "Skipping CPU detection as requested on boot commandline." ; eend 0 + return 0 + fi -if [[ $(grep -c processor /proc/cpuinfo) -gt 1 ]] ; then - einfo "Found CPU:" - CPU=$(awk -F: '/^processor/{printf " Processor"$2" is"};/^model name/{printf $2};/^vendor_id/{printf vendor};/^cpu MHz/{printf " %dMHz",int($2)};/^cache size/{printf ","$2" Cache"};/^$/{print ""}' /proc/cpuinfo 2>>$DEBUG) - echo $CPU | sed 's/ \{1,\}/ /g' - eend 0 -else - einfo "Found CPU: `awk -F: '/^processor/{printf " Processor"$2" is"};/^model name/{printf $2};/^vendor_id/{printf vendor};/^cpu MHz/{printf " %dMHz",int($2)};/^cache size/{printf ","$2" Cache"};/^$/{print ""}' /proc/cpuinfo 2>>$DEBUG` " ; eend 0 -fi + if ! [ -x "$(which lscpu)" ] ; then + ewarn "Skipping CPU detection due to lack of lscpu."; eend 0 + return 0 + fi + + local cpu_info num_cpus + + cpu_info="$(lscpu | sed -n '/^Model name:/s/[^:]*:\s*//p')" + num_cpus=$(grep -c processor /proc/cpuinfo) + + einfo "Found ${num_cpus} CPU(s): ${cpu_info}" + eend 0 } # }}} @@ -1987,5 +1992,32 @@ fi } # }}} +# {{{ Easteregg (for 20 years grml.org) +config_easteregg() { + current_date=$(date +%Y-%m-%d) + birthday="2023-09-16" + one_month_later=$(date -d "${current_date} + 1 month" +%Y-%m-%d) + + einfo "You found the birthday easter egg!" ; eend 0 + + # nothing to be done if it's more than one month since $birthday + if ! [[ "${current_date}" == "${birthday}" || "${current_date}" == "${one_month_later}" ]]; then + return 0 + fi + + if [[ -x /bin/toilet && -x /usr/games/lolcat ]] ; then + visualize() { printf "%s\n" "$*" | toilet | /usr/games/lolcat ; } + elif [[ -x /bin/toilet ]] ; then + visualize() { printf "%s\n" "$*" | toilet ; } + else + visualize() { printf "%s\n" "$*" ; } + fi + + visualize " \o/ " + visualize "20 years" + visualize "grml.org" +} +# }}} + ## END OF FILE ################################################################# # vim:foldmethod=marker expandtab ai ft=zsh shiftwidth=2