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
config_log(){
if checkbootparam 'log' || checkbootparam 'debug' ; then
export DEBUG="/tmp/grml.log.`date +%Y%m%d`"
- touch $DEBUG
- einfo "Bootparameter log found. Log files: ${DEBUG} and /var/log/boot"
- eindent
- einfo "Starting bootlogd." # known to be *very* unreliable :(
- bootlogd -r -c >>$DEBUG 2>&1 ; eend $?
- eoutdent
+ touch "${DEBUG}"
+ einfo "Bootparameter log found, debug log file from grml-autoconfig available at '${DEBUG}'"
else
DEBUG="/dev/null"
fi
# {{{ 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
}
# }}}
}
# }}}
+# {{{ Easteregg (for 20 years grml.org)
+display_easteregg() {
+ einfo "You found the birthday easter egg!" ; eend 0
+
+ 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"
+}
+
+config_easteregg() {
+ checkbootparam 'noeasteregg' && return 0
+
+ zmodload zsh/datetime 2>/dev/null || return 0
+ zmodload zsh/mathfunc 2>/dev/null || return 0
+
+ local birthday=1694822400 # := 2023-09-16 -> TZ=UTC date -d "2023-09-16" +%s
+ local one_month=$[24*30*3600]
+ local pi=3.14159265358979323846
+ local magic=$(( one_month/(pi/2) )) # normalization factor, used to map the [birthday;birthday+-one_month] range onto [0;+-pi/2]
+
+ if [[ $(( abs(birthday-EPOCHSECONDS) )) -le $one_month ]] ; then
+ if [[ $(( rand48() )) -le $(( cos((birthday-EPOCHSECONDS)/magic) )) ]] ; then
+ display_easteregg
+ fi
+ fi
+
+ return 0
+}
+# }}}
+
## END OF FILE #################################################################
# vim:foldmethod=marker expandtab ai ft=zsh shiftwidth=2