+ if [[ $( whoami ) == 'root' ]];then
+ root_string='-root'
+ fi
+
+ debug_data_dir="inxi$bsd_string-$host-$(date +%Y%m%d-%H%M%S)-$1$root_string"
+
+ if [[ $B_IRC == 'false' ]];then
+ if [[ -n $ALTERNATE_FTP ]];then
+ ftp_upload=$ALTERNATE_FTP
+ fi
+ echo "Starting debugging data collection type: $1"
+ echo -n "Checking/creating required directories... "
+ if [[ ! -d $SCRIPT_DATA_DIR ]];then
+ mkdir $SCRIPT_DATA_DIR
+ fi
+ echo 'completed'
+ cd $SCRIPT_DATA_DIR
+ if [[ -d $SCRIPT_DATA_DIR/$debug_data_dir ]];then
+ echo 'Deleting previous xiin data directory...'
+ rm -rf $SCRIPT_DATA_DIR/$debug_data_dir
+ fi
+ mkdir $SCRIPT_DATA_DIR/$debug_data_dir
+ if [[ -f $SCRIPT_DATA_DIR/$debug_data_dir.tar.gz ]];then
+ echo 'Deleting previous tar.gz file...'
+ rm -f $SCRIPT_DATA_DIR/$debug_data_dir.tar.gz
+ fi
+
+ echo 'Collecting system info: sensors, lsusb, lspci, lspci -v data, plus /proc data'
+ echo 'also checking for dmidecode data: note, you must be root to have dmidecode work.'
+ echo "Data going into: $SCRIPT_DATA_DIR/$debug_data_dir"
+ # bsd tools http://cb.vu/unixtoolbox.xhtml
+ # freebsd
+ if type -p pciconf &>/dev/null;then
+ pciconf -l -cv &> $debug_data_dir/bsd-pciconf-cvl.txt
+ pciconf -vl &> $debug_data_dir/bsd-pciconf-vl.txt
+ pciconf -l &> $debug_data_dir/bsd-pciconf-l.txt
+ else
+ touch $debug_data_dir/bsd-pciconf-absent
+ fi
+ # openbsd
+ if type -p pcidump &>/dev/null;then
+ pcidump &> $debug_data_dir/bsd-pcidump-openbsd.txt
+ pcidump -v &> $debug_data_dir/bsd-pcidump-v-openbsd.txt
+ else
+ touch $debug_data_dir/bsd-pcidump-openbsd-absent
+ fi
+ # netbsd
+ if type -p pcictl &>/dev/null;then
+ pcictl list &> $debug_data_dir/bsd-pcictl-list-netbsd.txt
+ pcictl list -n &> $debug_data_dir/bsd-pcictl-list-n-netbsd.txt
+ else
+ touch $debug_data_dir/bsd-pcictl-netbsd-absent
+ fi
+ if type -p sysctl &>/dev/null;then
+ sysctl -a &> $debug_data_dir/bsd-sysctl-a.txt
+ else
+ touch $debug_data_dir/bsd-sysctl-absent
+ fi
+ if type -p usbdevs &>/dev/null;then
+ usbdevs -v &> $debug_data_dir/bsd-usbdevs-v.txt
+ else
+ touch $debug_data_dir/bsd-usbdevs-absent
+ fi
+ if type -p kldstat &>/dev/null;then
+ kldstat &> $debug_data_dir/bsd-kldstat.txt
+ else
+ touch $debug_data_dir/bsd-kldstat-absent
+ fi
+ # diskinfo -v <disk>
+ # fdisk <disk>
+ dmidecode &> $debug_data_dir/dmidecode.txt
+
+ get_repo_data "$SCRIPT_DATA_DIR/$debug_data_dir"
+
+ if type -p shopt &>/dev/null;then
+ shopt -s nullglob
+ a_distro_ids=(/etc/*[-_]{release,version})
+ shopt -u nullglob
+ echo ${a_distro_ids[@]} &> $debug_data_dir/etc-distro-files.txt
+ for distro_file in ${a_distro_ids[@]} /etc/issue
+ do
+ if [[ -f $distro_file ]];then
+ cat $distro_file &> $debug_data_dir/distro-file${distro_file//\//-}
+ fi
+ done
+ fi
+ dmesg &> $debug_data_dir/dmesg.txt
+ lscpu &> $debug_data_dir/lscpu.txt
+ lspci &> $debug_data_dir/lspci.txt
+ lspci -k &> $debug_data_dir/lspci-k.txt
+ lspci -knn &> $debug_data_dir/lspci-knn.txt
+ lspci -n &> $debug_data_dir/lspci-n.txt
+ lspci -nn &> $debug_data_dir/lspci-nn.txt
+ lspci -mm &> $debug_data_dir/lspci-mm.txt
+ lspci -mmnn &> $debug_data_dir/lspci-mmnn.txt
+ lspci -mmnnv &> $debug_data_dir/lspci-mmnnv.txt
+ lspci -v &> $debug_data_dir/lspci-v.txt
+ lsusb &> $debug_data_dir/lsusb.txt
+ if type -p hciconfig &>/dev/null;then
+ hciconfig -a &> $debug_data_dir/hciconfig-a.txt
+ else
+ touch $debug_data_dir/hciconfig-absent
+ fi
+ ls /sys &> $debug_data_dir/ls-sys.txt
+ ps aux &> $debug_data_dir/ps-aux.txt
+ ps -e &> $debug_data_dir/ps-e.txt
+ ps -p 1 &> $debug_data_dir/ps-p-1.txt
+ cat /proc/1/comm &> $debug_data_dir/proc-1-comm.txt
+ runlevel &> $debug_data_dir/runlevel.txt
+ if type -p rc-status &>/dev/null;then
+ rc-status -a &> $debug_data_dir/rc-status-a.txt
+ rc-status -l &> $debug_data_dir/rc-status-l.txt
+ rc-status -r &> $debug_data_dir/rc-status-r.txt
+ else
+ touch $debug_data_dir/rc-status-absent
+ fi
+ if type -p systemctl &>/dev/null;then
+ systemctl list-units &> $debug_data_dir/systemctl-list-units.txt
+ systemctl list-units --type=target &> $debug_data_dir/systemctl-list-units-target.txt
+ else
+ touch $debug_data_dir/systemctl-absent
+ fi
+ if type -p initctl &>/dev/null;then
+ initctl list &> $debug_data_dir/initctl-list.txt
+ else
+ touch $debug_data_dir/initctl-absent
+ fi
+ sensors &> $debug_data_dir/sensors.txt
+ if type -p strings &>/dev/null;then
+ touch $debug_data_dir/strings-present
+ else
+ touch $debug_data_dir/strings-absent
+ fi
+ local id_dir='/sys/class/power_supply/'
+ local ids=$( ls $id_dir 2>/dev/null )
+ if [[ -n $ids ]];then
+ for batid in $ids
+ do
+ cat $id_dir$batid'/uevent' &> $debug_data_dir/sys-power-supply-$batid.txt
+ done
+ else
+ touch $debug_data_dir/sys-power-supply-none
+ fi
+
+ # leaving this commented out to remind that some systems do not
+ # support strings --version, but will just simply hang at that command
+ # which you can duplicate by simply typing: strings then hitting enter, you will get hang.
+ # strings --version &> $debug_data_dir/strings.txt
+ if type -p nvidia-smi &>/dev/null;then
+ nvidia-smi -q &> $debug_data_dir/nvidia-smi-q.txt
+ nvidia-smi -q -x &> $debug_data_dir/nvidia-smi-xq.txt
+ else
+ touch $debug_data_dir/nvidia-smi-absent
+ fi
+ head -n 1 /proc/asound/card*/codec* &> $debug_data_dir/proc-asound-card-codec.txt
+ if [[ -f /proc/version ]];then
+ cat /proc/version &> $debug_data_dir/proc-version.txt
+ else
+ touch $debug_data_dir/proc-version-absent
+ fi
+ echo $CC &> $debug_data_dir/cc-content.txt
+ ls /usr/bin/gcc* &> $debug_data_dir/gcc-sys-versions.txt
+ if type -p gcc &>/dev/null;then
+ gcc --version &> $debug_data_dir/gcc-version.txt
+ else
+ touch $debug_data_dir/gcc-absent
+ fi
+ if type -p clang &>/dev/null;then
+ clang --version &> $debug_data_dir/clang-version.txt
+ else
+ touch $debug_data_dir/clang-absent
+ fi
+ cat /etc/src.conf &> $debug_data_dir/bsd-etc-src-conf.txt
+ cat /etc/make.conf &> $debug_data_dir/bsd-etc-make-conf.txt
+ cat /etc/issue &> $debug_data_dir/etc-issue.txt
+ cat $FILE_LSB_RELEASE &> $debug_data_dir/lsb-release.txt
+ cat $FILE_OS_RELEASE &> $debug_data_dir/os-release.txt
+ cat $FILE_ASOUND_DEVICE &> $debug_data_dir/proc-asound-device.txt
+ cat $FILE_ASOUND_VERSION &> $debug_data_dir/proc-asound-version.txt
+ cat $FILE_CPUINFO &> $debug_data_dir/proc-cpu-info.txt
+ cat $FILE_MEMINFO &> $debug_data_dir/proc-meminfo.txt
+ cat $FILE_MODULES &> $debug_data_dir/proc-modules.txt
+ cat /proc/net/arp &> $debug_data_dir/proc-net-arp.txt
+ # bsd data
+ cat /var/run/dmesg.boot &> $debug_data_dir/bsd-var-run-dmesg.boot.txt
+ echo $COLS_INNER &> $debug_data_dir/cols-inner.txt
+
+ check_recommends_user_output &> $debug_data_dir/check-recommends-user-output.txt
+ # first download and verify xiin
+ if [[ $B_UPLOAD_DEBUG_DATA == 'true' || $1 == 'disk' || $1 == 'sys' || $1 == 'all' ]];then
+ touch $SCRIPT_DATA_DIR/$debug_data_dir/xiin-error.txt
+ echo "Downloading required tree traverse tool $xiin_file..."
+ if [[ -f xiin && ! -f $xiin_file ]];then
+ mv -f xiin $xiin_file
+ fi
+ # -Nc is creating really weird download anomolies, so using -O instead
+ case $DOWNLOADER in
+ curl)
+ xiin_download="$( curl -s $xiin_url )" || downloader_error=$?
+ ;;
+ fetch)
+ xiin_download="$( fetch -q -o - $xiin_url )" || downloader_error=$?
+ ;;
+ ftp)
+ xiin_download="$( ftp -o - $xiin_url 2>/dev/null )" || downloader_error=$?
+ ;;
+ wget)
+ xiin_download="$( wget -q -O - $xiin_url )" || downloader_error=$?
+ ;;
+ no-downloader)
+ downloader_error=1
+ ;;
+ esac
+ # if nothing got downloaded kick out error, otherwise we'll use an older version
+ if [[ $downloader_error -gt 0 && ! -f $xiin_file ]];then
+ echo -e "ERROR: Failed to download required file: $xiin_file\nMaybe the remote site is down or your networking is broken?"
+ echo "Continuing with incomplete data collection."
+ echo "$xiin_file download failed and no existing $xiin_file" >> $debug_data_dir/xiin-error.txt
+ elif [[ -n $( grep -s '# EOF' <<< "$xiin_download" ) || -f $xiin_file ]];then
+ if [[ -n $( grep -s '# EOF' <<< "$xiin_download" ) ]];then
+ echo "Updating $xiin_file from remote location"
+ echo "$xiin_download" > $xiin_file
+ else
+ echo "Using local $xiin_file due to download failure"
+ fi
+ b_run_xiin='true'
+ else
+ echo -e "ERROR: $xiin_file downloaded but the program file data is corrupted.\nContinuing with incomplete data collection."
+ echo "$xiin_file downloaded but the program file data is corrupted." >> $debug_data_dir/xiin-error.txt
+ fi
+ fi
+ # note, only bash 4> supports ;;& for case, so using if/then here
+ if [[ $1 == 'disk' || $1 == 'sys' || $1 == 'all' ]];then
+ xiin_data_file=$SCRIPT_DATA_DIR/$debug_data_dir/xiin-sys.txt
+ echo 'Collecting networking data...'
+ ifconfig &> $debug_data_dir/ifconfig.txt
+ ip addr &> $debug_data_dir/ip-addr.txt
+ if [[ $b_run_xiin == 'true' && -z $BSD_TYPE ]];then
+ echo $Line
+ echo "Running $xiin_file tool now on /sys..."
+ echo "Using Python version:" && python --version
+ python --version &> $debug_data_dir/python-version.txt
+ python ./$xiin_file -d /sys -f $xiin_data_file
+ if [[ $? -ne 0 ]];then
+ error=$?
+ echo -e "ERROR: $xiin_file exited with error $error - removing data file.\nContinuing with incomplete data collection."
+ echo "Continuing with incomplete data collection."
+ rm -f $xiin_data_file
+ echo "$xiin_file data generation failed with python error $error" >> $debug_data_dir/xiin-error.txt
+ fi
+ echo $Line
+ fi
+ fi
+ if [[ $1 == 'xorg' || $1 == 'all' ]];then
+ if [[ $B_RUNNING_IN_DISPLAY != 'true' ]];then
+ echo 'Warning: only some of the data collection can occur if you are not in X'
+ touch $debug_data_dir/warning-user-not-in-x
+ fi
+ if [[ $B_ROOT == 'true' ]];then
+ echo 'Warning: only some of the data collection can occur if you are running as Root user'
+ touch $debug_data_dir/warning-root-user
+ fi
+ echo 'Collecting Xorg log and xorg.conf files'
+ if [[ -e $FILE_XORG_LOG ]];then
+ cat $FILE_XORG_LOG &> $debug_data_dir/xorg-log-file.txt
+ else
+ touch $debug_data_dir/xorg-log-file-absent
+ fi
+ if [[ -e /etc/X11/xorg.conf ]];then
+ cat /etc/X11/xorg.conf &> $debug_data_dir/xorg-conf.txt
+ else
+ touch $debug_data_dir/xorg-conf-file-absent
+ fi
+ if [[ -n $( ls /etc/X11/xorg.conf.d/ 2>/dev/null ) ]];then
+ ls /etc/X11/xorg.conf.d &> $debug_data_dir/ls-etc-x11-xorg-conf-d.txt
+ xorg_d_files=$(ls /etc/X11/xorg.conf.d)
+ for xorg_file in $xorg_d_files
+ do
+ cat /etc/X11/xorg.conf.d/$xorg_file &> $debug_data_dir/xorg-conf-d-$xorg_file.txt
+ done
+ else
+ touch $debug_data_dir/xorg-conf-d-files-absent
+ fi
+ echo 'Collecting X, xprop, glxinfo, xrandr, xdpyinfo data, wayland, weston...'
+ if type -p weston-info &>/dev/null; then
+ weston-info &> $debug_data_dir/weston-info.txt
+ else
+ touch $debug_data_dir/weston-info-absent
+ fi
+ if type -p weston &>/dev/null; then
+ weston --version &> $debug_data_dir/weston-version.txt
+ else
+ touch $debug_data_dir/weston-absent
+ fi
+ if type -p xprop &>/dev/null; then
+ xprop -root &> $debug_data_dir/xprop_root.txt
+ else
+ touch $debug_data_dir/xprop-absent
+ fi
+ if type -p xprop &>/dev/null; then
+ glxinfo &> $debug_data_dir/glxinfo.txt
+ else
+ touch $debug_data_dir/glxinfo-absent
+ fi
+ if type -p xdpyinfo &>/dev/null; then
+ xdpyinfo &> $debug_data_dir/xdpyinfo.txt
+ else
+ touch $debug_data_dir/xdpyinfo-absent
+ fi
+ if type -p xrandr &>/dev/null; then
+ xrandr &> $debug_data_dir/xrandr.txt
+ else
+ touch $debug_data_dir/xrandr-absent
+ fi
+ if type -p X &>/dev/null; then
+ X -version &> $debug_data_dir/x-version.txt
+ else
+ touch $debug_data_dir/x-absent
+ fi
+ if type -p Xorg &>/dev/null; then
+ Xorg -version &> $debug_data_dir/xorg-version.txt
+ else
+ touch $debug_data_dir/xorg-absent
+ fi
+
+ echo $GNOME_DESKTOP_SESSION_ID &> $debug_data_dir/gnome-desktop-session-id.txt
+ # kde 3 id
+ echo $KDE_FULL_SESSION &> $debug_data_dir/kde3-full-session.txt
+ echo $KDE_SESSION_VERSION &> $debug_data_dir/kde-gte-4-session-version.txt
+ if type -p kf5-config &>/dev/null; then
+ kf5-config --version &> $debug_data_dir/kde-kf5-config-version-data.txt
+ elif type -p kf6-config &>/dev/null; then
+ kf6-config --version &> $debug_data_dir/kde-kf6-config-version-data.txt
+ elif type -p kf$KDE_SESSION_VERSION-config &>/dev/null; then
+ kf$KDE_SESSION_VERSION-config --version &> $debug_data_dir/kde-kf$KDE_SESSION_VERSION-KSV-config-version-data.txt
+ else
+ touch $debug_data_dir/kde-kf-config-absent
+ fi
+ if type -p plasmashell &>/dev/null; then
+ plasmashell --version &> $debug_data_dir/kde-plasmashell-version-data.txt
+ else
+ touch $debug_data_dir/kde-plasmashell-absent
+ fi
+ if type -p kwin_x11 &>/dev/null; then
+ kwin_x11 --version &> $debug_data_dir/kde-kwin_x11-version-data.txt
+ else
+ touch $debug_data_dir/kde-kwin_x11-absent
+ fi
+ if type -p kded4 &>/dev/null; then
+ kded4 --version &> $debug_data_dir/kded4-version-data.txt
+ elif type -p kded5 &>/dev/null; then
+ kded5 --version &> $debug_data_dir/kded5-version-data.txt
+ elif type -p kded &>/dev/null; then
+ kded --version &> $debug_data_dir/kded-version-data.txt
+ else
+ touch $debug_data_dir/kded-$KDE_SESSION_VERSION-absent
+ fi
+ # kde 5/plasma desktop 5, this is maybe an extra package and won't be used
+ if type -p about-distro &>/dev/null; then
+ about-distro &> $debug_data_dir/kde-about-distro.txt
+ else
+ touch $debug_data_dir/kde-about-distro-absent
+ fi
+ echo $XDG_CURRENT_DESKTOP &> $debug_data_dir/xdg-current-desktop.txt
+ fi
+ if [[ $1 == 'disk' || $1 == 'all' ]];then
+ echo 'Collecting dev, label, disk, uuid data, df...'
+ ls -l /dev &> $debug_data_dir/dev-data.txt
+ ls -l /dev/disk &> $debug_data_dir/dev-disk-data.txt
+ ls -l /dev/disk/by-id &> $debug_data_dir/dev-disk-id-data.txt
+ ls -l /dev/disk/by-label &> $debug_data_dir/dev-disk-label-data.txt
+ ls -l /dev/disk/by-uuid &> $debug_data_dir/dev-disk-uuid-data.txt
+ # http://comments.gmane.org/gmane.linux.file-systems.zfs.user/2032
+ ls -l /dev/disk/by-wwn &> $debug_data_dir/dev-disk-wwn-data.txt
+ ls -l /dev/disk/by-path &> $debug_data_dir/dev-disk-path-data.txt
+ ls -l /dev/mapper &> $debug_data_dir/dev-disk-mapper-data.txt
+ readlink /dev/root &> $debug_data_dir/dev-root.txt
+ df -h -T -P --exclude-type=aufs --exclude-type=squashfs --exclude-type=unionfs --exclude-type=devtmpfs --exclude-type=tmpfs --exclude-type=iso9660 --exclude-type=devfs --exclude-type=linprocfs --exclude-type=sysfs --exclude-type=fdescfs &> $debug_data_dir/df-h-T-P-excludes.txt
+ df -T -P --exclude-type=aufs --exclude-type=squashfs --exclude-type=unionfs --exclude-type=devtmpfs --exclude-type=tmpfs --exclude-type=iso9660 --exclude-type=devfs --exclude-type=linprocfs --exclude-type=sysfs --exclude-type=fdescfs &> $debug_data_dir/df-T-P-excludes.txt
+ df -T -P --exclude-type=aufs --exclude-type=squashfs --exclude-type=unionfs --exclude-type=devtmpfs --exclude-type=tmpfs --exclude-type=iso9660 --exclude-type=devfs --exclude-type=linprocfs --exclude-type=sysfs --exclude-type=fdescfs --total &> $debug_data_dir/df-T-P-excludes-total.txt
+ df -h -T &> $debug_data_dir/bsd-df-h-T-no-excludes.txt
+ df -h &> $debug_data_dir/bsd-df-h-no-excludes.txt
+ df -k -T &> $debug_data_dir/bsd-df-k-T-no-excludes.txt
+ df -k &> $debug_data_dir/bsd-df-k-no-excludes.txt
+ atacontrol list &> $debug_data_dir/bsd-atacontrol-list.txt
+ camcontrol devlist &> $debug_data_dir/bsd-camcontrol-devlist.txt
+ # bsd tool
+ mount &> $debug_data_dir/mount.txt
+ btrfs filesystem show &> $debug_data_dir/btrfs-filesystem-show.txt
+ btrfs filesystem show --mounted &> $debug_data_dir/btrfs-filesystem-show-mounted.txt
+ # btrfs filesystem show --all-devices &> $debug_data_dir/btrfs-filesystem-show-all-devices.txt
+ gpart list &> $debug_data_dir/bsd-gpart-list.txt
+ gpart show &> $debug_data_dir/bsd-gpart-show.txt
+ gpart status &> $debug_data_dir/bsd-gpart-status.txt
+ swapctl -l -k &> $debug_data_dir/bsd-swapctl-l-k.txt
+ swapon -s &> $debug_data_dir/swapon-s.txt
+ sysctl -b kern.geom.conftxt &> $debug_data_dir/bsd-sysctl-b-kern.geom.conftxt.txt
+ sysctl -b kern.geom.confxml &> $debug_data_dir/bsd-sysctl-b-kern.geom.confxml.txt
+ zfs list &> $debug_data_dir/bsd-zfs-list.txt
+ zpool list &> $debug_data_dir/bsd-zpool-list.txt
+ zpool list -v &> $debug_data_dir/bsd-zpool-list-v.txt
+ df -P --exclude-type=aufs --exclude-type=squashfs --exclude-type=unionfs --exclude-type=devtmpfs --exclude-type=tmpfs --exclude-type=iso9660 &> $debug_data_dir/df-P-excludes.txt
+ df -P &> $debug_data_dir/bsd-df-P-no-excludes.txt
+ cat /proc/mdstat &> $debug_data_dir/proc-mdstat.txt
+ cat $FILE_PARTITIONS &> $debug_data_dir/proc-partitions.txt
+ cat $FILE_SCSI &> $debug_data_dir/proc-scsi.txt
+ cat $FILE_MOUNTS &> $debug_data_dir/proc-mounts.txt
+ cat /proc/sys/dev/cdrom/info &> $debug_data_dir/proc-cdrom-info.txt
+ ls /proc/ide/ &> $debug_data_dir/proc-ide.txt
+ cat /proc/ide/*/* &> $debug_data_dir/proc-ide-hdx-cat.txt
+ cat /etc/fstab &> $debug_data_dir/etc-fstab.txt
+ cat /etc/mtab &> $debug_data_dir/etc-mtab.txt
+ fi
+ echo 'Creating inxi output file now. This can take a few seconds...'
+ echo "Starting $SCRIPT_NAME from: $start_directory"
+ cd $start_directory
+ $SCRIPT_PATH/$SCRIPT_NAME -F${debug_i}Rfrploudmxxx -c 0 -@ 8 -y 120 > $SCRIPT_DATA_DIR/$debug_data_dir/inxi-F${debug_i}Rfrploudmxxxy120.txt
+ cp $LOG_FILE $SCRIPT_DATA_DIR/$debug_data_dir
+ if [[ -f $SCRIPT_DATA_DIR/$debug_data_dir.tar.gz ]];then
+ echo "Found and removing previous tar.gz data file: $debug_data_dir.tar.gz"
+ rm -f $SCRIPT_DATA_DIR/$debug_data_dir.tar.gz
+ fi
+ cd $SCRIPT_DATA_DIR
+ echo 'Creating tar.gz compressed file of this material now. Contents:'
+ echo $Line
+ tar -cvzf $debug_data_dir.tar.gz $debug_data_dir
+ echo $Line
+ echo 'Cleaning up leftovers...'
+ rm -rf $debug_data_dir
+ echo 'Testing gzip file integrity...'
+ gzip -t $debug_data_dir.tar.gz
+ if [[ $? -gt 0 ]];then
+ echo 'Data in gz is corrupted, removing gzip file, try running data collector again.'
+ rm -f $debug_data_dir.tar.gz
+ echo "Data in gz is corrupted, removed gzip file" >> $debug_data_dir/gzip-error.txt
+ else
+ echo 'All done, you can find your data gzipped directory here:'
+ completed_gz_file=$SCRIPT_DATA_DIR/$debug_data_dir.tar.gz
+ echo $completed_gz_file
+ if [[ $B_UPLOAD_DEBUG_DATA == 'true' ]];then
+ echo $Line
+ if [[ $b_run_xiin == 'true' ]];then
+ echo "Running automatic upload of data to remote server $ftp_upload now..."
+ python ./$xiin_file --version
+ python ./$xiin_file -u $completed_gz_file $ftp_upload
+ if [[ $? -gt 0 ]];then
+ echo $Line
+ echo "Error: looks like the ftp upload failed. Error number: $?"
+ echo "The ftp upload failed. Error number: $?" >> $debug_data_dir/xiin-error.txt
+ fi
+ else
+ echo 'Unable to run the automoatic ftp upload because of an error with the xiin download.'
+ echo "Unable to run the automoatic ftp upload because of an error with the xiin download" >> $debug_data_dir/xiin-error.txt
+ fi
+ else
+ echo 'You can upload this here using most file managers: ftp.techpatterns.com/incoming'
+ echo 'then let a maintainer know it is uploaded.'
+ fi
+ fi
+ else
+ echo 'This feature only available in console or shell client! Exiting now.'
+ fi
+ exit 0
+}
+
+check_recommends_user_output()
+{
+ local Line=$LINE1
+ local gawk_version='N/A' sed_version='N/A' sudo_version='N/A' python_version='N/A'
+ local downloaders_bsd=''
+
+ if [[ $B_IRC == 'true' ]];then
+ print_screen_output "Sorry, you can't run this option in an IRC client."
+ exit 1
+ fi
+ if [[ -n $BSD_TYPE ]];then
+ downloaders_bsd='
+ fetch:BSD-only~BSD-only~BSD-only~:-i_wan_ip;-w/-W;-U/-!_[11-15]_(BSDs)
+ ftp:ftp-OpenBSD-only~ftp-OpenBSD-only~ftp-OpenBSD-only~:-i_wan_ip;-w/-W;-U/-!_[11-15]_(OpenBSD_only)'
+ fi
+ initialize_paths
+ print_lines_basic "0" "" "$SCRIPT_NAME will now begin checking for the programs it needs to operate. First a check of the main languages and tools $SCRIPT_NAME uses. Python is only for debugging data collection."
+ echo $Line
+ echo "Bash version: $( bash --version 2>&1 | awk 'BEGIN {IGNORECASE=1} /^GNU bash/ {print $4}' )"
+ if type -p gawk &>/dev/null;then
+ gawk_version=$( gawk --version 2>&1 | awk 'BEGIN {IGNORECASE=1} /^GNU Awk/ {print $3}' )
+ fi
+ if type -p sed &>/dev/null;then
+ sed_version=$( sed --version 2>&1 | awk 'BEGIN {IGNORECASE=1} /^GNU sed version/ {print $4}' )
+ if [[ -z $sed_version ]];then
+ # note: bsd sed shows error with --version flag
+ sed_version=$( sed --version 2>&1 | awk 'BEGIN {IGNORECASE=1} /^sed: illegal option/ {print "BSD sed"}' )
+ fi
+ fi
+ if type -p sudo &>/dev/null;then
+ sudo_version=$( sudo -V 2>&1 | awk 'BEGIN {IGNORECASE=1} /^Sudo version/ {print $3}' )
+ fi
+ if type -p python &>/dev/null;then
+ python_version=$( python --version 2>&1 | awk 'BEGIN {IGNORECASE=1} /^Python/ {print $2}' )
+ fi
+ echo "Gawk version: $gawk_version"
+ echo "Sed version: $sed_version"
+ echo "Sudo version: $sudo_version"
+ echo "Python version: $python_version"
+ echo $Line
+
+ echo "Test One: Required System Directories (Linux Only)."
+ print_lines_basic "0" "" "If one of these system directories is missing, $SCRIPT_NAME cannot operate:"
+ echo
+ check_recommends_items 'required-dirs'
+
+ echo "Test Two: Required Core Applications."
+ print_lines_basic "0" "" "If one of these applications is missing, $SCRIPT_NAME cannot operate:"
+ echo
+ check_recommends_items 'required-apps'
+
+ print_lines_basic "0" "" "Test Three: Script Recommends for Graphics Features."
+ print_lines_basic "0" "" "NOTE: If you do not use X these do not matter (like a headless server). Otherwise, if one of these applications is missing, $SCRIPT_NAME will have incomplete output:"
+ echo
+ check_recommends_items 'recommended-x-apps'
+
+ echo 'Test Four: Script Recommends for Remaining Features.'
+ print_lines_basic "0" "" "If one of these applications is missing, $SCRIPT_NAME will have incomplete output:"
+ echo
+ check_recommends_items 'recommended-apps'
+
+ echo 'Test Five: Script Recommends for Remaining Features.'
+ print_lines_basic "0" "" "One of these downloaders needed for options -i/-w/-W (-U/-! [11-15], if supported):"
+ echo
+ check_recommends_items 'downloaders'
+
+ echo 'Test Six: System Directories for Various Information.'
+ echo '(Unless otherwise noted, these are for GNU/Linux systems)'
+ print_lines_basic "0" "" "If one of these directories is missing, $SCRIPT_NAME may have incomplete output:"
+ echo
+ check_recommends_items 'system-dirs'
+
+ echo 'Test Seven: System Files for Various Information.'
+ echo '(Unless otherwise noted, these are for GNU/Linux systems)'
+ print_lines_basic "0" "" "If one of these files is missing, $SCRIPT_NAME may have incomplete output:"
+ echo
+ check_recommends_items 'system-files'
+
+ echo 'All tests completed.'
+}
+# args: $1 - check item
+check_recommends_items()
+{
+ local item='' item_list='' item_string='' missing_items='' missing_string=''
+ local package='' application='' feature='' type='' starter='' finisher=''
+ local package_deb='' package_pacman='' package_rpm=''
+ local print_string='' separator='' width=56
+ local required_dirs='/proc /sys'
+ # package-owner: 1 - debian/ubuntu; 2 - arch; 3 - yum/rpm
+ # pardus: pisi sf -q /usr/bin/package
+ local required_apps='
+ df:coreutils~coreutils~coreutils~:partition_data
+ gawk:gawk~gawk~gawk~:core_tool
+ grep:grep~grep~grep~:string_search
+ lspci:pciutils~pciutils~pciutils~:hardware_data
+ ps:procps~procps~procps~:process_data
+ readlink:coreutils~coreutils~coreutils~:
+ sed:sed~sed~sed~:string_replace
+ tr:coreutils~coreutils~coreutils~:character_replace
+ uname:uname~coreutils~coreutils~:kernel_data
+ wc:coreutils~coreutils~coreutils~:word_character_count
+ '
+ local x_recommends='
+ glxinfo:mesa-utils~mesa-demos~glx-utils_(openSUSE_12.3_and_later_Mesa-demo-x)~:-G_glx_info
+ xdpyinfo:X11-utils~xorg-xdpyinfo~xorg-x11-utils~:-G_multi_screen_resolution
+ xprop:X11-utils~xorg-xprop~x11-utils~:-S_desktop_data
+ xrandr:x11-xserver-utils~xrandr~x11-server-utils~:-G_single_screen_resolution
+ '
+ local recommended_apps='
+ dig:dnsutils~dnsutils~bind-utils:-i_first_wlan_ip_default_test
+ dmidecode:dmidecode~dmidecode~dmidecode~:-M_if_no_sys_machine_data;_-m_memory
+ file:file~file~file~:-o_unmounted_file_system
+ hciconfig:bluez~bluez-utils~bluez-utils~:-n_-i_bluetooth_data
+ hddtemp:hddtemp~hddtemp~hddtemp~:-Dx_show_hdd_temp
+ ifconfig:net-tools~net-tools~net-tools~:-i_ip_lan-deprecated
+ ip:iproute~iproute2~iproute~:-i_ip_lan
+ sensors:lm-sensors~lm_sensors~lm-sensors~:-s_sensors_output
+ strings:binutils~~~:-I_sysvinit_version
+ lsusb:usbutils~usbutils~usbutils~:-A_usb_audio;-N_usb_networking
+ modinfo:module-init-tools~module-init-tools~module-init-tools~:-Ax,-Nx_module_version
+ runlevel:sysvinit~sysvinit~systemd~:-I_runlevel
+ sudo:sudo~sudo~sudo~:-Dx_hddtemp-user;-o_file-user
+ uptime:procps~procps~procps~:-I_uptime_(check_which_package_owns_Debian)
+ '
+
+ local downloaders="
+ wget:wget~wget~wget~:-i_wan_ip;-w/-W;-U/-!_[11-15]_(if_supported)
+ curl:curl~curl~curl~:-i_wan_ip;-w/-W;-U/-!_[11-15]_(if_supported)
+ $downloaders_bsd
+ "
+ local recommended_dirs='
+ /sys/class/dmi/id:-M_system,_motherboard,_bios
+ /dev:-l,-u,-o,-p,-P,-D_disk_partition_data
+ /dev/disk/by-label:-l,-o,-p,-P_partition_labels
+ /dev/disk/by-uuid:-u,-o,-p,-P_partition_uuid
+ '
+ local recommended_files="
+ $FILE_ASOUND_DEVICE:-A_sound_card_data
+ $FILE_ASOUND_VERSION:-A_ALSA_data
+ $FILE_CPUINFO:-C_cpu_data
+ $FILE_LSB_RELEASE:-S_distro_version_data_[deprecated]
+ $FILE_MDSTAT:-R_mdraid_data
+ $FILE_MEMINFO:-I_memory_data
+ $FILE_OS_RELEASE:-S_distro_version_data
+ $FILE_PARTITIONS:-p,-P_partitions_data
+ $FILE_MODULES:-G_module_data
+ $FILE_MOUNTS:-P,-p_partition_advanced_data
+ $FILE_DMESG_BOOT:-D,-d_disk_data_[BSD_only]
+ $FILE_SCSI:-D_Advanced_hard_disk_data_[used_rarely]
+ $FILE_XORG_LOG:-G_graphics_driver_load_status
+ "
+
+ if [[ -n $COLS_INNER ]];then
+ if [[ $COLS_INNER -ge 90 ]];then
+ width=${#LINE1} # match width of $LINE1
+ elif [[ $COLS_INNER -ge 78 ]];then
+ width=$(( $COLS_INNER - 11 ))
+ fi
+ fi
+
+ case $1 in
+ downloaders)
+ item_list=$downloaders
+ item_string='Downloaders'
+ item_string=''
+ missing_string='downloaders, and their corresponding packages,'
+ type='applications'
+ ;;
+ required-dirs)
+ item_list=$required_dirs
+ item_string='Required file system'
+ item_string=''
+ missing_string='system directories'
+ type='directories'
+ ;;
+ required-apps)
+ item_list=$required_apps
+ item_string='Required application'
+ item_string=''
+ missing_string='applications, and their corresponding packages,'
+ type='applications'
+ ;;
+ recommended-x-apps)
+ item_list=$x_recommends
+ item_string='Recommended X application'
+ item_string=''
+ missing_string='applications, and their corresponding packages,'
+ type='applications'
+ ;;
+ recommended-apps)
+ item_list=$recommended_apps
+ item_string='Recommended application'
+ item_string=''
+ missing_string='applications, and their corresponding packages,'
+ type='applications'
+ ;;
+ system-dirs)
+ item_list=$recommended_dirs
+ item_string='System directory'
+ item_string=''
+ missing_string='system directories'
+ type='directories'
+ ;;
+ system-files)
+ item_list=$recommended_files
+ item_string='System file'
+ item_string=''
+ missing_string='system files'
+ type='files'
+ ;;
+ esac
+ # great trick from: http://ideatrash.net/2011/01/bash-string-padding-with-sed.html
+ # left pad: sed -e :a -e 's/^.\{1,80\}$/& /;ta'
+ # right pad: sed -e :a -e 's/^.\{1,80\}$/ &/;ta'
+ # center pad: sed -e :a -e 's/^.\{1,80\}$/ & /;ta'
+
+ for item in $item_list
+ do
+ if [[ $( awk -F ":" '{print NF-1}' <<< $item ) -eq 0 ]];then
+ application=$item
+ package=''
+ feature=''
+ location=''
+ elif [[ $( awk -F ":" '{print NF-1}' <<< $item ) -eq 1 ]];then
+ application=$( cut -d ':' -f 1 <<< $item )
+ package=''
+ feature=$( cut -d ':' -f 2 <<< $item )
+ location=''
+ else
+ application=$( cut -d ':' -f 1 <<< $item )
+ package=$( cut -d ':' -f 2 <<< $item )
+ location=$( type -p $application )
+ if [[ $( awk -F ":" '{print NF-1}' <<< $item ) -eq 2 ]];then
+ feature=$( cut -d ':' -f 3 <<< $item )
+ else
+ feature=''
+ fi
+ fi
+ if [[ -n $feature ]];then
+ print_string="$item_string$application (info: $( sed 's/_/ /g' <<< $feature ))"
+ else
+ print_string="$item_string$application"
+ fi
+
+ starter="$( sed -e :a -e 's/^.\{1,'$width'\}$/&./;ta' <<< $print_string )"
+ if [[ -z $( grep '^/' <<< $application ) && -n $location ]] || [[ -d $application || -f $application ]];then
+ if [[ -n $location ]];then
+ finisher=" $location"
+ else
+ finisher=" Present"
+ fi
+ else
+ finisher=" Missing"
+ missing_items="$missing_items$separator$application:$package"
+ separator=' '
+ fi
+
+ echo "$starter$finisher"
+ done
+ echo
+ if [[ -n $missing_items ]];then
+ echo "The following $type are missing from your system:"
+ for item in $missing_items
+ do
+ application=$( cut -d ':' -f 1 <<< $item )
+ if [[ $type == 'applications' ]];then
+ echo
+ package=$( cut -d ':' -f 2 <<< $item )
+ package_deb=$( cut -d '~' -f 1 <<< $package )
+ package_pacman=$( cut -d '~' -f 2 <<< $package )
+ package_rpm=$( cut -d '~' -f 3 <<< $package )
+ echo "Application: $application"
+ print_lines_basic "0" "" "To add to your system, install the proper distribution package for your system:"
+ print_lines_basic "0" "" "Debian/Ubuntu:^$package_deb^:: Arch Linux:^$package_pacman^:: Redhat/Fedora/Suse:^$package_rpm"
+ elif [[ $type == 'directories' ]];then
+ echo "Directory: $application"
+ elif [[ $type == 'files' ]];then
+ echo "File: $application"
+ fi
+ done
+ if [[ $item_string == 'System directory' ]];then
+ print_lines_basic "0" "" "These directories are created by the kernel, so don't worry if they are not present."
+ fi
+ else
+ echo "All the $( cut -d ' ' -f 1 <<< $item_string | sed -e 's/Re/re/' -e 's/Sy/sy/' ) $type are present."
+ fi
+ echo $Line
+}
+
+#### -------------------------------------------------------------------
+#### print / output cleaners
+#### -------------------------------------------------------------------
+
+# inxi speaks through here. When run by Konversation script alias mode, uses DCOP
+# for dcop to work, must use 'say' operator, AND colors must be evaluated by echo -e
+# note: dcop does not seem able to handle \n so that's being stripped out and replaced with space.
+print_screen_output()
+{
+ eval $LOGFS
+ # the double quotes are needed to avoid losing whitespace in data when certain output types are used
+ # trim off whitespace at end
+ local print_data="$( echo -e "$1" )"
+
+ # just using basic debugger stuff so you can tell which thing is printing out the data. This
+ # should help debug kde 4 konvi issues when that is released into sid, we'll see. Turning off
+ # the redundant debugger output which as far as I can tell does exactly nothing to help debugging.
+ if [[ $DEBUG -gt 5 ]];then
+ if [[ $KONVI -eq 1 ]];then
+ # konvi doesn't seem to like \n characters, it just prints them literally
+ # print_data="$( tr '\n' ' ' <<< "$print_data" )"
+ # dcop "$DCPORT" "$DCOPOBJ" say "$DCSERVER" "$DCTARGET" "konvi='$KONVI' saying : '$print_data'"
+ print_data="KP-$KONVI: $print_data"
+ elif [[ $KONVI -eq 2 ]];then
+ # echo "konvi='$KONVI' saying : '$print_data'"
+ print_data="KP-$KONVI: $print_data"
+ else
+ # echo "printing out: '$print_data'"
+ print_data="P: $print_data"
+ fi
+ fi
+ if [[ $KONVI -eq 1 && $B_DCOP == 'true' ]]; then ## dcop Konversation (<= 1.1 (qt3))
+ # konvi doesn't seem to like \n characters, it just prints them literally
+ $print_data="$( tr '\n' ' ' <<< "$print_data" )"
+ dcop "$DCPORT" "$DCOPOBJ" say "$DCSERVER" "$DCTARGET" "$print_data"
+ elif [[ $KONVI -eq 3 && $B_QDBUS == 'true' ]]; then ## dbus Konversation (> 1.2 (qt4))
+ qdbus org.kde.konversation /irc say "$DCSERVER" "$DCTARGET" "$print_data"
+# elif [[ $IRC_CLIENT == 'X-Chat' ]]; then
+# qdbus org.xchat.service print "$print_data\n"
+ else
+ # the -n is needed to avoid double spacing of output in terminal
+ echo -ne "$print_data\n"
+ fi
+ eval $LOGFE
+}
+
+## this handles all verbose line construction with indentation/line starter
+## args: $1 - null (, actually: " ") or line starter; $2 - line content
+create_print_line()
+{
+ eval $LOGFS
+ # convoluted, yes, but it works to trim spaces off end
+ local line=${2%${2##*[![:space:]]}}
+ printf "${C1}%-${INDENT}s${C2} %s" "$1" "$line${CN}"
+ eval $LOGFE
+}
+
+# this removes newline and pipes.
+# args: $1 - string to clean
+remove_erroneous_chars()
+{
+ eval $LOGFS
+ ## RS is input record separator
+ ## gsub is substitute;
+ gawk '
+ BEGIN {
+ RS=""
+ }
+ {
+ gsub(/\n$/,"") ## (newline; end of string) with (nothing)
+ gsub(/\n/," "); ## (newline) with (space)
+ gsub(/^ *| *$/, "") ## (pipe char) with (nothing)
+ gsub(/ +/, " ") ## ( +) with (space)
+ gsub(/ [ ]+/, " ") ## ([ ]+) with (space)
+ gsub(/^ +| +$/, "") ## (pipe char) with (nothing)
+ printf $0
+ }' "$1" ## prints (returns) cleaned input
+ eval $LOGFE
+}
+
+#### -------------------------------------------------------------------
+#### parameter handling, print usage functions.
+#### -------------------------------------------------------------------
+
+# Get the parameters. Note: standard options should be lower case, advanced or testing, upper
+# args: $1 - full script startup args: $@
+get_parameters()
+{
+ eval $LOGFS
+ local opt='' downloader_test='' debug_data_type='' weather_flag='wW:'
+ local use_short='true' # this is needed to trigger short output, every v/d/F/line trigger sets this false
+
+ # if distro maintainers don't want the weather feature disable it
+ if [[ $B_ALLOW_WEATHER == 'false' ]];then
+ weather_flag=''
+ fi
+ if [[ $1 == '--version' ]];then
+ print_version_info
+ exit 0
+ elif [[ $1 == '--help' ]];then
+ show_options
+ exit 0
+ elif [[ $1 == '--recommends' ]];then
+ check_recommends_user_output
+ exit 0
+ # the short form only runs if no args output args are used
+ # no need to run through these if there are no args
+ # reserved for future use: -g for extra Graphics; -m for extra Machine; -d for extra Disk
+ elif [[ -n $1 ]];then
+ while getopts AbBc:CdDfFGhHiIlmMnNopPrRsSt:uUv:V${weather_flag}xy:zZ%@:!: opt
+ do
+ case $opt in
+ A) B_SHOW_AUDIO='true'
+ use_short='false'
+ ;;
+ b) use_short='false'
+ B_SHOW_BASIC_CPU='true'
+ B_SHOW_BASIC_RAID='true'
+ B_SHOW_DISK_TOTAL='true'
+ B_SHOW_GRAPHICS='true'
+ B_SHOW_INFO='true'
+ B_SHOW_MACHINE='true'
+ B_SHOW_BATTERY='true'
+ B_SHOW_NETWORK='true'
+ B_SHOW_SYSTEM='true'
+ ;;
+ B) B_SHOW_BATTERY_FORCED='true'
+ B_SHOW_BATTERY='true'
+ use_short='false'
+ ;;
+ c) if [[ $OPTARG =~ ^[0-9][0-9]?$ ]];then
+ case $OPTARG in
+ 99)
+ B_RUN_COLOR_SELECTOR='true'
+ COLOR_SELECTION='global'
+ ;;
+ 98)
+ B_RUN_COLOR_SELECTOR='true'
+ COLOR_SELECTION='irc-console'
+ ;;
+ 97)
+ B_RUN_COLOR_SELECTOR='true'
+ COLOR_SELECTION='irc-virtual-terminal'
+ ;;
+ 96)
+ B_RUN_COLOR_SELECTOR='true'
+ COLOR_SELECTION='irc'
+ ;;
+ 95)
+ B_RUN_COLOR_SELECTOR='true'
+ COLOR_SELECTION='virtual-terminal'
+ ;;
+ 94)
+ B_RUN_COLOR_SELECTOR='true'
+ COLOR_SELECTION='console'
+ ;;
+ *)
+ B_COLOR_SCHEME_SET='true'
+ ## note: not sure about this, you'd think user values should be overridden, but
+ ## we'll leave this for now
+ if [[ -z $COLOR_SCHEME ]];then
+ set_color_scheme "$OPTARG"
+ fi
+ ;;
+ esac
+ else
+ error_handler 3 "$OPTARG"