Difficulty: ★★☆☆☆
Note: I have not been able to test some desktop environments, but the script should be able to solve the checks without problems.
This tutorial will help you to self-test iso images (installers) with any SHA hash.
- The program temporarily generates text files with the prefix “autocheck”, you can open them if you want to observe their content
- The program does not connect to the internet nor does it depend on it to function, therefore it is necessary that you have the SHA text file, provided by the page or server where do i download the installer
If you suffer an error that I have not realized or perhaps have not managed to imagine any action by the user that causes an error, post an answer with a small description of what happens.
-
Execute:
sudo nano --backup /usr/local/bin/check-iso
-
Copy-paste the following in there:
#!/bin/bash internalversion="v-0.4.6" internalkeyname="autocheck-global" sample0="\\|" example0=".iso\\|.img.xz\\|.iso.torrent" ###############################translations ESlang=$(locale -a | grep -o es_ | wc -l) ENlang=$(locale -a | grep -o en_ | wc -l) ########process cleaner processcleaner=$(ls | grep "autochekbaselist\|autochekcompletelist\|autochekfinalarmor\|autochektypesha" | wc -l) processcleanerlist=$(ls | grep "autochekbaselist\|autochekcompletelist\|autochekfinalarmor\|autochektypesha") if (($processcleaner > 0)) ; then ####cleaner ES if (( $ESlang == 1 && $ENlang == 0 )) ; then echo -e "parece que el procesamiento anterior\ \nno finalizo correctamente\ \nesto evito que el programa elimine los archivos temporales\ \nlos archivos temporales pueden ser identificados\ \npor los siguientes nombres:\ \n$processcleanerlist\ \n" read -p "¿realizar limpieza ahora? responde s/n: " answerprocesscleaner fi if [[ $answerprocesscleaner == s ]] ; then rm autochekbaselist \ autochekcompletelist \ autochekfinalarmor \ autochektypesha 2>/dev/null fi #cleaner ES finish ####cleaner ES unusual if (( $ESlang == 1 && $ENlang == 1 )) ; then echo -e "parece que el procesamiento anterior\ \nno finalizo correctamente\ \nesto evito que el programa elimine los archivos temporales\ \nlos archivos temporales pueden ser identificados\ \npor los siguientes nombres:\ \n$processcleanerlist\ \n" read -p "¿realizar limpieza ahora? responde s/n: " answerprocesscleaner fi if [[ $answerprocesscleaner == s ]] ; then rm autochekbaselist \ autochekcompletelist \ autochekfinalarmor \ autochektypesha 2>/dev/null fi #cleaner ES unusual finish ####cleaner EN if (( $ESlang == 0 && $ENlang == 1 )) ; then echo -e "it seems that the above processing\ \ndid not finish correctly\ \nthis prevented the program from deleting the temporary files\ \nthe temporary files can be identified\ \nby the following names:\ \n$processcleanerlist\ \n" read -p "¿clean now? reply y/n: " answerprocesscleaner fi if [[ $answerprocesscleaner == y ]] ; then rm autochekbaselist \ autochekcompletelist \ autochekfinalarmor \ autochektypesha 2>/dev/null fi #cleaner EN finish ####cleaner default EN if (( $ESlang == 0 && $ENlang == 0 )) ; then echo -e "it seems that the above processing\ \ndid not finish correctly\ \nthis prevented the program from deleting the temporary files\ \nthe temporary files can be identified\ \nby the following names:\ \n$processcleanerlist\ \n" read -p "¿clean now? reply y/n: " answerprocesscleaner fi if [[ $answerprocesscleaner == y ]] ; then rm autochekbaselist \ autochekcompletelist \ autochekfinalarmor \ autochektypesha 2>/dev/null fi #cleaner default EN finish fi #process cleaner finish #########ES if (( $ESlang == 1 && $ENlang == 0 )) ; then echo -e "version: $internalversion\ \nnombre clave: $internalkeyname\ \nnota:\ \n-el programa genera temporalmente archivos de texto\ \ncon el prefijo autocheck\ \npuede abrirlos si desea observar su contenido\ \n-el programa no se conecta a internet ni depende de este\ \npara funcionar, por lo tanto es necesario que usted posea\ \nel archivo de texto SHA proporcionado por la pagina o servidor\ \ndonde descargo el instalador\ \n-el programa necesita el nombre original del archivo\ \nde texto SHA o que almenos incluya SHA(formato) sha(formato)\ \n-el programa trabaja en el directorio actual, por lo tanto\ \nno entra en conflicto con subdirectorios\ \n-si el programa se detuvo por alguna razon y puede observar\ \nalgunos archivos temporales, ejecute nuevamente el programa\ \nel hara la limpieza por usted\ \npor favor, escriba el tipo de archivo con el que desea trabajar\ \nopciones comunes:\ \n\t\t.iso\ \n\t\t.img.xz\ \n\t\t.iso.torrent\ \ntambien puede ingresar parte del nombre o el nombre completo del archivo\ \nsi lo que desea es trabajar con multiples tipos de archivo" echo "por favor separe las ordenes de trabajo con: $sample0" echo "por ejemplo: $example0" echo "" echo "presione ctrl+c para salir" read -rp "trabajar con: " workorder fi #########ES finish #########ES unusual if (( $ESlang == 1 && $ENlang == 1 )) ; then echo -e "version: $internalversion\ \nnombre clave: $internalkeyname\ \nnota:\ \n-el programa genera temporalmente archivos de texto\ \ncon el prefijo autocheck\ \npuede abrirlos si desea observar su contenido\ \n-el programa no se conecta a internet ni depende de este\ \npara funcionar, por lo tanto es necesario que usted posea\ \nel archivo de texto SHA proporcionado por la pagina o servidor\ \ndonde descargo el instalador\ \n-el programa necesita el nombre original del archivo\ \nde texto SHA o que almenos incluya SHA(formato) sha(formato)\ \n-el programa trabaja en el directorio actual, por lo tanto\ \nno entra en conflicto con subdirectorios\ \n-si el programa se detuvo por alguna razon y puede observar\ \nalgunos archivos temporales, ejecute nuevamente el programa\ \nel hara la limpieza por usted\ \npor favor, escriba el tipo de archivo con el que desea trabajar\ \nopciones comunes:\ \n\t\t.iso\ \n\t\t.img.xz\ \n\t\t.iso.torrent\ \ntambien puede ingresar parte del nombre o el nombre completo del archivo\ \nsi lo que desea es trabajar con multiples tipos de archivo" echo "por favor separe las ordenes de trabajo con: $sample0" echo "por ejemplo: $example0" echo "" echo "presione ctrl+c para salir" read -rp "trabajar con: " workorder fi #########ES unusual finish #########EN if (( $ESlang == 0 && $ENlang == 1 )) ; then echo -e "version: $internalversion\ \nkey name: $internalkeyname\ \nnote:\ \n-the program temporarily generates text files\ \nwith the prefix autocheck\ \nyou can open them if you want to observe their content\ \n-the program does not connect to the internet nor does it depend on it\ \nto function, therefore it is necessary that you have\ \nthe SHA text file provided by the page or server\ \nwhere you downloaded the installer\ \n-the program needs the original name of the file\ \nSHA text or at least include SHA(format) sha(format)\ \n-the program works in the current directory, therefore\ \ndoes not conflict with subdirectories\ \n-if the program stopped for any reason and you can see\ \nsome temporary files, run the program again\ \nhe will do the cleaning for you\ \nplease write the type of file you want to work with\ \ncommon options:\ \n\t\t.iso\ \n\t\t.img.xz\ \n\t\t.iso.torrent\ \nyou can also enter part of the name or the full name of the file\ \nif you want to work with multiple file types" echo "please separate work orders with: $sample0" echo "for example: $example0" echo "" echo "press ctrl+c to go out" read -rp "work with: " workorder fi #########EN finish #########default EN if (( $ESlang == 0 && $ENlang == 0 )) ; then echo -e "version: $internalversion\ \nkey name: $internalkeyname\ \nnote:\ \n-the program temporarily generates text files\ \nwith the prefix autocheck\ \nyou can open them if you want to observe their content\ \n-the program does not connect to the internet nor does it depend on it\ \nto function, therefore it is necessary that you have\ \nthe SHA text file provided by the page or server\ \nwhere you downloaded the installer\ \nthe program needs the original name of the file\ \nSHA text or at least include SHA(format) sha(format)\ \n-the program works in the current directory, therefore\ \ndoes not conflict with subdirectories\ \n-if the program stopped for any reason and you can see\ \nsome temporary files, run the program again\ \nhe will do the cleaning for you\ \nplease write the type of file you want to work with\ \ncommon options:\ \n\t\t.iso\ \n\t\t.img.xz\ \n\t\t.iso.torrent\ \nyou can also enter part of the name or the full name of the file\ \nif you want to work with multiple file types" echo "please separate work orders with: $sample0" echo "for example: $example0" echo "" echo "press ctrl+c to go out" read -rp "work with: " workorder fi #########default EN finish ###############translations finish ###############################engine shafileBigdoor=$(find . -maxdepth 1 -type f \( -iname "*sha*" ! -iname "*autochecksha*" ! -iname "*auto*" ! -iname "*check*" \) -exec cat {} \; | grep -o "$workorder" | wc -l) workorderfileBigdoor=$(ls -N | grep "$workorder" | grep -v "(*)" 2>/dev/null | wc -l) if (( $shafileBigdoor > 0 && $workorderfileBigdoor > 0 )) ; then listofISOSmalldoor=$(ls -N | grep "$workorder" | grep -v "(*)" 2>/dev/null | sed ':a;N;$!ba;s/\n/\\|/g') openlistshafindtwinsNAMESmalldoor=$(find . -maxdepth 1 -type f \( -iname "*sha*" ! -iname "*autocheck*" \) -exec cat {} \; | sed 's/*/ /g' | grep "$listofISOSmalldoor" 2>/dev/null | awk '{print $2}' | wc -l) ######print no compatible shafileSmalldoor=$(find . -maxdepth 1 -type f \( -iname "*sha*" ! -iname "*autochecksha*" ! -iname "*auto*" ! -iname "*check*" \) -exec cat {} \; | grep "$workorder" | awk '{print $2}' | sort -u) ###print no compatible finish if (( $openlistshafindtwinsNAMESmalldoor > 0 )) ; then listofISO=$(ls -N | grep "$workorder" | grep -v "(*)" 2>/dev/null | sed ':a;N;$!ba;s/\n/\\|/g') openlistshafindtwinsNAME=$(find . -maxdepth 1 -type f \( -iname "*sha*" ! -iname "*autocheck*" \) -exec cat {} \; | sed 's/*/ /g' | grep "$listofISO" 2>/dev/null | awk '{print $2}' | sort) openlistshafindtwinsALL=$(find . -maxdepth 1 -type f \( -iname "*sha*" ! -iname "*autocheck*" \) -exec cat {} \; | sed 's/*/ /g' | grep "$listofISO" 2>/dev/null | sort -k2) twins=$(find . -maxdepth 1 -type f \( -iname "*sha*" ! -iname "*autocheck*" \) -exec cat {} \; | sed 's/*/ /g' | awk '{print $2}' | grep "$listofISO" 2>/dev/null | sort -u) ########baselist section echo -e "$twins" > autochekbaselist sed -i 's/^/find . -maxdepth 1 -type f \\( -iname "*sha*" ! -iname "*autocheck*" ! -iname "*auto*" ! -iname "*check*" ! -iname "*test*" \\) -exec grep -l /g; s/$/ {} \\; | grep -oh "\\w*SHA*\\w*\\|\\w*sha*\\w*" 2>\/dev\/null | sed /g' autochekbaselist sed -i "s/$/'s\/([0-9])\/ \/' | grep -Eo '[0-9]{1,}' 2>\/dev\/null/g" autochekbaselist ####baselist section finish ########completelist section echo -e "$openlistshafindtwinsNAME" > autochekcompletelist ####completelist section finish ########typesha section echo -e "$(sh autochekbaselist)" > autochektypesha sed -i 's/^/sha/g; s/$/sum/g' autochektypesha paste autochektypesha autochekcompletelist -d " " > autochekfinalarmor ####typesha section finish sum=$(sh autochekfinalarmor | sort -k2) if [[ $openlistshafindtwinsALL == $sum ]] ; then echo -e "\e[42m:-) revised\e[0m" echo -e "\e[44mSHA text file\n$openlistshafindtwinsALL\e[0m" echo -e "\e[45mISO processed file\n$sum\e[0m" else echo -e "\e[41m:-( revised\e[0m" echo -e "\e[44mSHA text file\n$openlistshafindtwinsALL\e[0m" echo -e "\e[45mISO processed file\n$sum\e[0m" fi awk -v t=$SECONDS 'BEGIN{t=int(t*1000); printf "(HH:MM:SS): %d:%02d:%02d\n", t/3600000, t/60000%60, t/1000%60}' echo -e "$openlistshafindtwinsALL" > 'autochekoutput s h a text file' echo -e "$sum" > 'autochekoutput s u m processed file' ########register of corrupt if [[ $openlistshafindtwinsALL != $sum ]] ; then diff 'autochekoutput s h a text file' 'autochekoutput s u m processed file' > 'autochek unapprovedfiles' fi ####register of corrupt finish ########corrupt alert corruptalert=$(cat 'autochek unapprovedfiles' 2>\/dev\/null | wc -l) if (($corruptalert > 0)) ; then echo -e "\n((((( unapproved files )))))\n\n$(cat 'autochek unapprovedfiles')" fi ####corrupt alert finish rm autochekbaselist \ autochekcompletelist \ autochekfinalarmor \ autochektypesha 2>/dev/null ########registry cleaner registrycleaner=$(ls | grep "autochekoutput s h a text file\|autochekoutput s u m processed file\|autochek unapprovedfiles" | wc -l) registrycleanerlist=$(ls | grep "autochekoutput s h a text file\|autochekoutput s u m processed file\|autochek unapprovedfiles") if (($registrycleaner > 0)) ; then ####cleaner ES if (( $ESlang == 1 && $ENlang == 0 )) ; then echo -e "\n¿desea conservar las copias del resultado?\ \npuedes consultar las copias del resultado\ \nen los archivos con los nombres:\ \n$registrycleanerlist\ \n" read -p "¿conservar? responde s/n: " answerregistrycleaner fi #cleaner ES finish ####cleaner ES unusual if (( $ESlang == 1 && $ENlang == 1 )) ; then echo -e "\n¿desea conservar las copias del resultado?\ \npuedes consultar las copias del resultado\ \nen los archivos con los nombres:\ \n$registrycleanerlist\ \n" read -p "¿conservar? responde s/n: " answerregistrycleaner fi #cleaner ES unusual finish ####cleaner EN if (( $ESlang == 0 && $ENlang == 1 )) ; then echo -e "\n¿you want to keep copies of the result?\ \nyou can check the copies of the result\ \nin the files with the names:\ \n$registrycleanerlist\ \n" read -p "¿keep? reply y/n: " answerregistrycleaner fi #cleaner EN finish ####cleaner default EN if (( $ESlang == 0 && $ENlang == 0 )) ; then echo -e "\n¿you want to keep copies of the result?\ \nyou can check the copies of the result\ \nin the files with the names:\ \n$registrycleanerlist\ \n" read -p "¿keep? reply y/n: " answerregistrycleaner fi #cleaner default EN finish if [[ $answerregistrycleaner == n ]] ; then rm 'autochekoutput s h a text file' 'autochekoutput s u m processed file' 'autochek unapprovedfiles' 2>/dev/null fi fi ########registry cleaner finish else echo -e "\e[41mpossible NO compatible FILES\e[0m" echo -e "\e[45mSHA text file\e[0m" echo -e "\e[44m$shafileSmalldoor\e[0m" fi else echo -e "\e[41mNO FILES to work\e[0m" fi ###############engine finish ########credits internalauthor="jhonatan castañeta" echo -e "\nauthor: $internalauthor\n" ####credits finish
-
Grant execution permissions:
chmod a+x /usr/local/bin/check-iso
-
now you will open the terminal in the same directory and execute:
check-iso