--- mcore-src/trunk/mcore-tools/src/modules/hwinfo/hardware.control.class.in 2015/09/10 13:16:57 2488 +++ mcore-src/trunk/mcore-tools/src/modules/hwinfo/hardware.control.class.in 2015/09/10 14:11:50 2498 @@ -1,5 +1,6 @@ # $Id$ +provide hardware require hwdetection require mysql @@ -9,9 +10,23 @@ local cmd local netcard_driver + local networking + local hostname + local domain local graphic_driver local monitor_info local monitor_resolution + local hwdetected + + # first check if hardware detect was already done + hwdetected=$(mysqldo "select hwdetected from client_serials where serial=${serial};") + if [[ ${hwdetected} = 1 ]] + then + decho "hardware detection already run, aborting" + return 0 + else + decho "running hardware detection" + fi nsslsay_queue_init nsslsay_queue_add "nocolors" @@ -19,21 +34,32 @@ netcard_driver=$(control_client "${serial}" run-queue) if [[ -n ${netcard_driver} ]] then - decho "netcard_driver='${netcard_driver}'" - import_resource cfg_network "${serial}" module "${netcard_driver}" + decho "netcard_driver='${netcard_driver}'" + import_resource cfg_network "${serial}" module "${netcard_driver}" else decho "no netcard_driver found" fi - if [[ -z $(mysqldo "select networking from cfg_network where serial=${serial};") ]] + networking=$(mysqldo "select networking from cfg_network where serial=${serial};") + if [[ -z ${networking} ]] || [[ ${networking} = NULL ]] then # set network to dhcp + decho "networking='dhcp'" import_resource cfg_network "${serial}" networking "dhcp" fi - if [[ -z $(mysqldo "select hostname from cfg_network where serial=${serial};") ]] + hostname=$(mysqldo "select hostname from cfg_network where serial=${serial};") + if [[ -z ${hostname} ]] || [[ ${hostname} = NULL ]] then # set hostname to MCORE_DEFAULT_HOSTNAME + decho "hostname='${MCORE_DEFAULT_HOSTNAME}'" import_resource cfg_network "${serial}" hostname "${MCORE_DEFAULT_HOSTNAME}" fi + domain=$(mysqldo "select domain from cfg_network where serial=${serial};") + if [[ -z ${domain} ]] || [[ ${domain} = NULL ]] + then + # set domain to MCORE_DEFAULT_DOMAIN + decho "hostname='${MCORE_DEFAULT_DOMAIN}'" + import_resource cfg_network "${serial}" domain "${MCORE_DEFAULT_DOMAIN}" + fi nsslsay_queue_init nsslsay_queue_add "nocolors" @@ -49,7 +75,7 @@ nsslsay_queue_init nsslsay_queue_add "nocolors" - nsslsay_queue_add "get hardware.detect info minitor" + nsslsay_queue_add "get hardware.detect info monitor" monitor_info=$(control_client "${serial}" run-queue) monitor_resolution="${monitor_info##*;}" if [[ -n ${monitor_resolution} ]] @@ -59,4 +85,7 @@ else decho "no monitor_resolution found" fi + + # update the hwdetected flags + import_resource client_serial "${serial}" hwdetected 1 }