diff --git a/scripts/lipnsa-chroot.sh b/scripts/lipnsa-chroot.sh deleted file mode 100755 index 81f39e13bcec977da6f3e0466fb33ac6d50affa0..0000000000000000000000000000000000000000 --- a/scripts/lipnsa-chroot.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# lipnsa.sh -- collecting your data for a better world -# Lars Beckers, larsb@fsmpi.rwth-aachen.de, September 2014 - -if [ $# != 1 ]; then - echo "executes a command with proc and sysfs mounted" - echo "called by lipnsa.sh in a chroot environment" - echo "usage: chroot /root /lipnsa-chroot.sh cmd" - exit -fi - -PROCMNT=0 -if [ -f /proc/cmdline ]; then - PROCMNT=1 -fi -SYSFSMNT=0 -if [ -d /sys/class ]; then - SYSFSMNT=1 -fi - -if [ ${PROCMNT} == 0 ]; then - mount -t proc proc /proc -fi -if [ ${SYSFSMNT} == 0 ]; then - mount -t sysfs sysfs /sys -fi - -$1 - -if [ ${PROCMNT} == 0 ]; then - umount /proc -fi -if [ ${SYSFSMNT} == 0 ]; then - umount /sys -fi - diff --git a/scripts/lipnsa.sh b/scripts/lipnsa.sh index 57a5cca2ddbf5bbbabae8e7e7e73b1c79a98ca9f..73a54d854eeae6e0f9e0141d458b035eb3813ba4 100755 --- a/scripts/lipnsa.sh +++ b/scripts/lipnsa.sh @@ -5,6 +5,7 @@ LIPSTICK="/cdrom" LIPSTATS="${LIPSTICK}/lipstats" TARGET="/root" +LOGFUNCTIONSSOURCE="/scripts/casper-functions" if [ $# -gt 0 ]; then echo "collects system information, i.e. hardware and what the kernel thinks about it" @@ -17,7 +18,6 @@ if [ $# -gt 0 ]; then echo "${LIPSTICK} is remounted rw in the process, remounted ro at the end" echo "if there is no dmi-product-uuid available a kernel-random-uuid will be used" echo "some commands are processed outside the initramfs, in a chroot using the prepared system" - echo "for that purpose lipnsa-chroot.sh is copied from the current directory to the target (${TARGET}) and deleted afterwards, but we do not remount the target" echo "" echo "currently lipnsa.sh collects the following:" echo " running architecture" @@ -37,73 +37,75 @@ if [ $# -gt 0 ]; then exit fi +source ${LOGFUNCTIONSSOURCE} + if [ -f /proc/cmdline ]; then grep fnord /proc/cmdline if [ $? == 0 ]; then - echo "lipnsa.sh has been deactivated. :(" + log_warning_msg "lipnsa.sh has been deactivated. :(" exit fi else - echo "It seems that /proc is not mounted. lipnsa.sh aborting." + log_failure_msg "It seems that /proc is not mounted. lipnsa.sh aborting." exit fi if [ ! -d /sys/class ]; then - echo "It seems that /sys is not mounted. lipnsa.sh aborting." + log_failure_msg "It seems that /sys is not mounted. lipnsa.sh aborting." exit fi -echo "This is lipnsa.sh -- collecting your data for a better world" +log_success_msg "This is lipnsa.sh -- collecting your data for a better world" UUID=`cat /sys/class/dmi/id/product_uuid` if [ $? != 0 ]; then - echo "> dmi system-uuid is unavailable, using random uuid" + log_warning_msg "> dmi system-uuid is unavailable, using random uuid" UUID=`cat /proc/sys/kernel/random/uuid` fi BOOTID=`cat /proc/sys/kernel/random/boot_id` -echo "> using ${UUID}/${BOOTID}" +log_success_msg "> using ${UUID}/${BOOTID}" DIR="${LIPSTATS}/${UUID}/${BOOTID}" mount -o remount,rw ${LIPSTICK} mkdir -p "${DIR}" if [ $? != 0 ]; then - echo "> could not create directory, aborting" + log_failure_msg "> could not create directory, aborting" exit fi -echo "> remounted lipstick rw, created directory" +log_success_msg "> remounted lipstick rw, created directory" date +%s > "${DIR}/timestamp" 2>&1 if [ $? != 0 ]; then - echo "> could not save timestamp" + log_failure_msg "> could not save timestamp" else - echo "> saved timestamp" + log_success_msg "> saved timestamp" fi uname -m > "${DIR}/architecture" 2>&1 if [ $? != 0 ]; then - echo "> could not save architecture" + log_failure_msg "> could not save architecture" else - echo "> saved architecture" + log_success_msg "> saved architecture" fi ip link > "${DIR}/ip-link" 2>&1 if [ $? != 0 ]; then - echo "> could not save ip devices" + log_failure_msg "> could not save ip devices" else - echo "> saved ip devices" + log_success_msg "> saved ip devices" fi kmod list > "${DIR}/kmod-list" 2>&1 if [ $? != 0 ]; then - echo "> could not save the formatted module list" + log_failure_msg "> could not save the formatted module list" else - echo "> saved the formatted module list" + log_success_msg "> saved the formatted module list" fi blkid > "${DIR}/blkid" 2>&1 if [ $? != 0 ]; then - echo "> could not save block device information" + log_failure_msg "> could not save block device information" else - echo "> saved block device information" + log_success_msg "> saved block device information" fi if [ -d /sys/firmware/efi ]; then @@ -115,108 +117,121 @@ if [ -d /sys/firmware/efi ]; then fi else echo "no" > "${DIR}/efi" 2>&1 + echo "not found" > "${DIR}/secureboot" 2>&1 fi -echo "> saved detection of efi and secureboot" +log_success_msg "> saved detection of efi and secureboot" cat /proc/cmdline > "${DIR}/cmdline" 2>&1 if [ $? != 0 ]; then - echo "> could not save the kernel command line" + log_failure_msg "> could not save the kernel command line" else - echo "> saved the kernel command line" + log_success_msg "> saved the kernel command line" fi cat /proc/modules > "${DIR}/modules" 2>&1 if [ $? != 0 ]; then - echo "> could not save the module list" + log_failure_msg "> could not save the module list" else - echo "> saved the module list" + log_success_msg "> saved the module list" fi cat /proc/cpuinfo > "${DIR}/cpuinfo" 2>&1 if [ $? != 0 ]; then - echo "> could not save cpu information" + log_failure_msg "> could not save cpu information" else - echo "> saved cpu information" + log_success_msg "> saved cpu information" fi cat /proc/meminfo > "${DIR}/meminfo" 2>&1 if [ $? != 0 ]; then - echo "> could not save memory information" + log_failure_msg "> could not save memory information" else - echo "> saved memory information" + log_success_msg "> saved memory information" fi cat /proc/partitions > "${DIR}/partitions" 2>&1 if [ $? != 0 ]; then - echo "> could not save the partition list" + log_failure_msg "> could not save the partition list" else - echo "> saved the partition list" + log_success_msg "> saved the partition list" fi -cp lipnsa-chroot.sh ${TARGET}/lipnsa-chroot.sh -if [ $? != 0 ]; then - echo "> could not copy into target, skipping chrooted commands" -else # chrooted commands +# chrooted commands # actually lsblk, lscpu and dmidecode work without chroot # but i think it is more sane to not depend on that +mount -t proc proc ${TARGET}/proc +if [ $? != 0 ]; then + log_warning_msg "> could not mount proc on the target, this might produce false results" +fi +mount -t sysfs sysfs ${TARGET}/sys +if [ $? != 0 ]; then + log_warning_msg "> could not mount sysfs on the target, this might produce false results" +fi -chroot ${TARGET} /lipnsa-chroot.sh "lspci -mm" > "${DIR}/lspci" 2>&1 +chroot ${TARGET} lspci -mm > "${DIR}/lspci" 2>&1 if [ $? != 0 ]; then - echo "> could not save listing of pci devices" + log_failure_msg "> could not save listing of pci devices" else - echo "> saved listing of pci devices" + log_success_msg "> saved listing of pci devices" fi -chroot ${TARGET} /lipnsa-chroot.sh lsblk > "${DIR}/lsblk" 2>&1 +chroot ${TARGET} lsblk > "${DIR}/lsblk" 2>&1 if [ $? != 0 ]; then - echo "> could not save listing of block devices" + log_failure_msg "> could not save listing of block devices" else - echo "> saved listing of block devices" + log_success_msg "> saved listing of block devices" fi -chroot ${TARGET} /lipnsa-chroot.sh lscpu > "${DIR}/lscpu" 2>&1 +chroot ${TARGET} lscpu > "${DIR}/lscpu" 2>&1 if [ $? != 0 ]; then - echo "> could not save listing of cpus" + log_failure_msg "> could not save listing of cpus" else - echo "> saved listing of cpus" + log_success_msg "> saved listing of cpus" fi -chroot ${TARGET} /lipnsa-chroot.sh dmidecode > "${DIR}/dmidecode" 2>&1 +chroot ${TARGET} dmidecode > "${DIR}/dmidecode" 2>&1 if [ $? != 0 ]; then - echo "> could not save decoded dmi table" + log_failure_msg "> could not save decoded dmi table" else - echo "> saved decoded dmi table" + log_success_msg "> saved decoded dmi table" fi -chroot ${TARGET} /lipnsa-chroot.sh lsusb > "${DIR}/lsusb" 2>&1 +chroot ${TARGET} lsusb > "${DIR}/lsusb" 2>&1 if [ $? != 0 ]; then grep "unable to initialize libusb: -99" "${DIR}/lsusb" if [ $? != 0 ]; then - echo "> could not save listing of usb devices" + log_failure_msg "> could not save listing of usb devices" else echo "no usb controller found" > "${DIR}/lsusb" 2>&1 - echo "> saved listing of usb devices" + log_success_msg "> saved listing of usb devices" fi else - echo "> saved listing of usb devices" + log_success_msg "> saved listing of usb devices" fi -rm ${TARGET}/lipnsa-chroot.sh -fi # chrooted commands +umount ${TARGET}/sys +if [ $? != 0 ]; then + log_warning_msg "> could not unmount sysfs on the target, this might cause some trouble" +fi +umount ${TARGET}/proc +if [ $? != 0 ]; then + log_warning_msg "> could not unmount proc on the target, this might cause some trouble" +fi +# chrooted commands sync if [ $? != 0 ]; then - echo "> could not flush filesystem buffers" + log_failure_msg "> could not flush filesystem buffers" else - echo "> flushed filesystem buffers" + log_success_msg "> flushed filesystem buffers" fi mount -o remount,ro ${LIPSTICK} if [ $? != 0 ]; then - echo "> could not remount lipstick ro" + log_failure_msg "> could not remount lipstick ro" else - echo "> remounted lipstick ro" + log_success_msg "> remounted lipstick ro" fi -echo "lipnsa.sh has finished, thank you for your cooperation" +log_success_msg "lipnsa.sh has finished, thank you for your cooperation"