first
This commit is contained in:
1
modules/hardware/detect/config.sh
Normal file
1
modules/hardware/detect/config.sh
Normal file
@@ -0,0 +1 @@
|
||||
POSTINSTALL_HARDWARE_DETECT_REPORT_FILE="/var/log/postinstall-debian/hardware-report.txt"
|
||||
4
modules/hardware/detect/metadata.conf
Normal file
4
modules/hardware/detect/metadata.conf
Normal file
@@ -0,0 +1,4 @@
|
||||
MODULE_ID="hardware/detect"
|
||||
MODULE_NAME="Detection hardware"
|
||||
MODULE_CATEGORY="hardware"
|
||||
MODULE_DESCRIPTION="Installe les outils de detection et genere un rapport materiel"
|
||||
43
modules/hardware/detect/module.sh
Normal file
43
modules/hardware/detect/module.sh
Normal file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
MODULE_HARDWARE_DETECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
MODULE_HARDWARE_DETECT_PROJECT_ROOT="$(cd "$MODULE_HARDWARE_DETECT_DIR/../../.." && pwd)"
|
||||
|
||||
# shellcheck source=lib/package.sh
|
||||
source "$MODULE_HARDWARE_DETECT_PROJECT_ROOT/lib/package.sh"
|
||||
# shellcheck source=modules/hardware/detect/config.sh
|
||||
source "$MODULE_HARDWARE_DETECT_DIR/config.sh"
|
||||
# shellcheck source=modules/hardware/detect/metadata.conf
|
||||
source "$MODULE_HARDWARE_DETECT_DIR/metadata.conf"
|
||||
|
||||
module_detect_metadata() {
|
||||
printf '%s|%s|%s\n' "$MODULE_ID" "$MODULE_NAME" "$MODULE_DESCRIPTION"
|
||||
}
|
||||
|
||||
module_detect_install() {
|
||||
package_refresh_indexes
|
||||
package_install lshw pciutils usbutils dmidecode
|
||||
|
||||
mkdir -p "$(dirname "$POSTINSTALL_HARDWARE_DETECT_REPORT_FILE")"
|
||||
{
|
||||
printf '== lshw -short ==\n'
|
||||
lshw -short 2>/dev/null || true
|
||||
printf '\n== lspci ==\n'
|
||||
lspci 2>/dev/null || true
|
||||
printf '\n== lsusb ==\n'
|
||||
lsusb 2>/dev/null || true
|
||||
printf '\n== dmidecode -t system ==\n'
|
||||
dmidecode -t system 2>/dev/null || true
|
||||
} > "$POSTINSTALL_HARDWARE_DETECT_REPORT_FILE"
|
||||
|
||||
log_info "Rapport hardware genere : $POSTINSTALL_HARDWARE_DETECT_REPORT_FILE"
|
||||
ui_success "Rapport hardware genere"
|
||||
}
|
||||
|
||||
module_detect_test() {
|
||||
package_is_installed lshw || return 1
|
||||
package_is_installed pciutils || return 1
|
||||
package_is_installed usbutils || return 1
|
||||
package_is_installed dmidecode || return 1
|
||||
test -s "$POSTINSTALL_HARDWARE_DETECT_REPORT_FILE"
|
||||
}
|
||||
35
modules/hardware/detect/tests.sh
Normal file
35
modules/hardware/detect/tests.sh
Normal file
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
MODULE_HARDWARE_DETECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$MODULE_HARDWARE_DETECT_DIR/../../.." && pwd)"
|
||||
|
||||
# shellcheck source=lib/ui.sh
|
||||
source "$PROJECT_ROOT/lib/ui.sh"
|
||||
# shellcheck source=lib/log.sh
|
||||
source "$PROJECT_ROOT/lib/log.sh"
|
||||
# shellcheck source=lib/package.sh
|
||||
source "$PROJECT_ROOT/lib/package.sh"
|
||||
# shellcheck source=core/runtime.sh
|
||||
source "$PROJECT_ROOT/core/runtime.sh"
|
||||
# shellcheck source=modules/hardware/detect/module.sh
|
||||
source "$MODULE_HARDWARE_DETECT_DIR/module.sh"
|
||||
|
||||
runtime_init "$PROJECT_ROOT"
|
||||
log_init
|
||||
|
||||
if ! package_is_installed lshw; then
|
||||
printf 'hardware-detect test SKIPPED: lshw not installed\n'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! test -f /var/log/postinstall-debian/hardware-report.txt; then
|
||||
printf 'hardware-detect test SKIPPED: report not generated\n'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if module_detect_test; then
|
||||
printf 'hardware-detect test OK\n'
|
||||
else
|
||||
printf 'hardware-detect test FAILED\n' >&2
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user