Skip to content

Instantly share code, notes, and snippets.

@jkordani
Last active August 26, 2024 07:53
Show Gist options
  • Save jkordani/d1c42d1d0811425e936d34cdee34a84f to your computer and use it in GitHub Desktop.
Save jkordani/d1c42d1d0811425e936d34cdee34a84f to your computer and use it in GitHub Desktop.
Script to fix MD5Sum errors and something about dep11 icons
#!/bin/bash
## first parameter is optionnal mirror list file
if [[ $1 != "" ]]
then
mirrorlist=$1
else
mirrorlist="/etc/apt/mirror.list"
fi
dataFolder=$(grep -F "set base_path" $mirrorlist | tr -s " " | cut -d' ' -f3)
# ubuservs=$(grep ubuntu.com $mirrorlist | awk '{print $2}' | cut -d '/' -f3 | sort | uniq)
ubuservs=$(grep "ubuntu.com/.* " $mirrorlist | awk '{print $2}' | sort | uniq)
FAILEDPACKAGES=""
echo "Reading and Checking MD5 checksum using file: $dataFolder/var/MD5"
#cd $dataFolder/mirror
rm -f FAILED_MD5.txt
echo "Failed File will be stored in: $(PWD)/FAILED_MD5.txt"
while IFS='' read -r line || [[ -n "$line" ]]; do
echo "Checking: $line"
sum=$(echo $line | cut -d' ' -f1)
filename=$(echo $line | cut -d' ' -f2)
echo "$sum $dataFolder/mirror/$filename" | md5sum -c -
RESULT=$?
if [ $RESULT -ne 0 ];then
echo "$dataFolder/mirror/$filename" >> FAILED_MD5.txt
wget -O $dataFolder/mirror/$filename $filename
echo "$sum $dataFolder/mirror/$filename" | md5sum -c -
SUBRESULT=$?
if [ $SUBRESULT -ne 0 ];then
echo "Sorry failed checksum again for file: $dataFolder/mirror/$filename"
$FAILEDPACKAGES+="$dataFolder/mirror/$filename Failed again, sorry cannot help"
fi
fi
done < "$dataFolder/var/MD5"
#md5sum -c $dataFolder/var/MD5 | grep --line-buffered -i "FAILED" | tee FAILED_MD5.txt
echo $FAILEDPACKAGES
for ubuserv in $ubuservs
do
cd $dataFolder/mirror/$(echo $ubuserv | cut -d '@' -f2 | sed 's/\(.*\)http:\/\/\(.*\)/\1\2/g')/dists
for dist in *; do
dist=$(basename $dist)
for comp in main multiverse universe; do
mkdir -p ${dist}/${comp}/dep11
for size in 48 64 128; do
wget ${ubuserv}/dists/${dist}/${comp}/dep11/icons-${size}x${size}@2.tar.gz -O ${dist}/${comp}/dep11/icons-${size}x${size}@2.tar.gz;
done
done
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment