#!/bin/bash #these are symbols that will be in /proc/ksyms, if a module is loaded #or compiled in the kernel cat << ENDBEG BACKPACK LINUX DIAGNOSIS PROGRAM This program will attempt to see if your backpack drive is functioning correctly. When this program is done you will want to find out how to use cdrecord and mount. ENDBEG PARPORT="parport_register_driver" PARPORT_PC="parport_pc_probe_port" PARIDE="pi_init" BPCK6="bpck6_connect" BPCK5="bpck_connect" PG="pg_init" PCD="pcd_init" CDROM="register_cdrom" #these are the respective modules to be loaded for each subsystem PARPORT_MOD="parport" PARPORT_PC_MOD="parport_pc" PARIDE_MOD="paride" BPCK6_MOD="bpck6" PG_MOD="pg" PCD_MOD="pcd" CDROM_MOD="cdrom" LOAD_MODULES="" # GET DISTRIBUTION ----------------------------------------------------- PLATFORM="unknown" if [ -e /etc/redhat-release ] then PLATFORM="redhat" elif [ -e /etc/debian ] then PLATFORM="debian" fi echo "Platform is $PLATFORM" # GET KERNEL VERSION ----------------------------------------------------- KERNVER="unknown" if which uname >/dev/null then KERNVER=`uname -r` fi echo "Kernel version is $KERNVER" #Check if root if [ "$UID" != "0" ] then echo "This script needs to be run as root" exit 1 fi # FIND LSMOD ----------------------------------------------------- #try finding lsmod in path otherwise try in /sbin, fail out if not found LSMODPATH=`which lsmod >/dev/null 2>/dev/null` if LSMODPATH="" then if [ -x /sbin/lsmod ] then LSMODPATH="/sbin/lsmod" else echo "Cannot locate lsmod!" echo "have you installed modutils?" exit 1 fi fi # TEST FOR MODULES INSTALLED------------------------------------------ #for each module of the kernel check to see if it is compiled in #this requires the proc filesystem for i in PARPORT PARPORT_PC PARIDE BPCK6 BPCK PG CDROM PCD do MODNAME="${i}_MOD" if $LSMODPATH |grep "^${!MODNAME}" >/dev/null then echo "$i is already loaded as a module" elif grep "${!i}" /proc/ksyms >/dev/null then echo "$i is already compiled in the kernel" else LOAD_MODULES="$LOAD_MODULES ${i}_MOD" fi done # FIND INSMOD ----------------------------------------------------- #try finding insmod in path otherwise try in /sbin, fail out if not found INSMODPATH=`which insmod >/dev/null 2>/dev/null` if INSMODPATH="" then if [ -x /sbin/insmod ] then INSMODPATH="/sbin/insmod" else echo "Cannot locate insmod!" echo "have you installed modutils?" exit 1 fi fi # LOAD MISSING MODULES ----------------------------------------------- FAILED_FLAG="n" PG_MOD_FAILED="n" PCD_MOD_FAILED="n" for i in $LOAD_MODULES do echo -n "Attempting to load ${!i}: " if $INSMODPATH ${!i} >/dev/null 2>/dev/null then echo Success else echo Failed if [ "$i" == "PG_MOD" ] then echo " Is the drive connected to the parallel port?" PG_MOD_FAILED="y" elif [ "$i" == "PCD_MOD" ] then echo " Is the drive connected to the parallel port?" PCD_MOD_FAILED="y" elif [ "$i" == "BPCK6_MOD ] then echo "We will be unable to work with series 6 backpacks" elif [ "$i" == "BPCK_MOD ] then echo "We will be unable to work with series 5 backpacks" else FAILED_FLAG="y" fi fi done if [ "FAILED_FLAG" == "y" ] then echo "Machine is incorrectly configured for parallel port drive usage" exit 1 elif [ "$PG_MOD_FAILED" = "y" ] && [ "$PCD_MOD_FAILED" == "y" ] then echo "Kernel modules are configured, but backpack drive could not be detected" exit 1 else echo "Kernel modules are configured and backpack is detected" fi