#! /bin/bash

Codename=`lsb_release -c|tail -n 1|awk {'print $2'}`
Arch=`dpkg --print-architecture`

aptsourcecheck ()
{
echo "check "$1
echo "total number is: "`grep $1 $ILOG |wc -l`
grep $1 $ILOG |grep -v " InRelease"|grep -v "Release "|grep -v " Packages "|grep -v " Translation-en "|grep -v " Contents "|grep -v " DEP-11 "
RNUM=`
grep $1 $ILOG |grep -v " InRelease"|grep -v "Release "|grep -v " Packages "|grep -v " Translation-en "|grep -v " Contents "|grep -v " DEP-11 " \
|wc -l`
echo "remote apt get deb package number is: " $RNUM
echo
}

searchstring ()
{
echo "search $1"
grep "$1" $ILOG
echo "total number is: "`grep "$1" $ILOG |wc -l`
echo
}

echo "atzlinux install check tools"

atzinfo |tee  base-atzinfo
echo
df |tee df
echo
dpkg -l > dpkg-l
echo
apt list ~o
echo "orphan pkg number is: "`apt list ~o|grep -v ...|wc -l`
echo

ILOG="/var/log/installer/syslog"

head -n 1 $ILOG
tail -n 1 $ILOG
echo

debconf-get-selections > debconf-get-selections
debconf-get-selections --installer > installer-debconf-get-selections

APTATZURL="https://apt.atzlinux.com/atzlinux"
aptsourcecheck $APTATZURL
ATZMURLOP="http://mirrors.op123.ren:60000/atzlinux"
aptsourcecheck $ATZMURLOP
ATZMURLFUN="https://fun.ie8.pub:2443/atzlinux"
aptsourcecheck $ATZMURLFUN
TMURL="https://mirrors.tencent.com/debian"
aptsourcecheck $TMURL

echo "check remote get stable apt index files:"
for i in main contrib non-free non-free-firmware
	do
	searchstring "debian $Codename/$i $Arch Packages"
	done

searchstring ' E: '
searchstring '需要被卸载'
searchstring "warning: Failed to install"
searchstring " failed "
searchstring " Failed "
searchstring " error "
echo
echo "Run hw-probe -all -upload .... to upload hardward info"
hw-probe -all -upload
