0 Members and 1 Guest are viewing this topic.
#!/bin/bash# Autors: Misko_2083, Ralphy# Tomado desde: https://www.linuxliteos.com/forums/tutorials/a-simple-way-to-check-md5sum/15/# Adapted by : tuto## ###################################################################### Imagesic="/usr/share/icons/Faenza/actions/32/system-run.png"# ### User selected file.file="$@"if [ -z "$@" ]; then szPath=$(zenity --file-selection --title="Checksum - Select file..." --file-filter='Image files (ISO,IMG) | *.iso *.ISO *.img *.IMG' --file-filter='All files | *') if [ "$?" -eq "1" ]; then exit 0 else file="$szPath" fifiwhile (true); do MD5=(`echo "" | awk '{print "md5sum","✍","MD5", $0}'`) SHA1=(`echo "" | awk '{print "sha1sum","✍","SHA-1", $0}'`) SHA224=(`echo "" | awk '{print "sha224sum","✍","SHA-224", $0}'`) SHA256=(`echo "" | awk '{print "sha256sum","✍","SHA-256", $0}'`) SHA384=(`echo "" | awk '{print "sha384sum","✍","SHA-384", $0}'`) SHA512=(`echo "" | awk '{print "sha512sum","✍","SHA-512", $0}'`) # ### Main dialog. selected=$(zenity --list --width=180 --height="248" --window-icon="$ic" --hide-header --title=" Checksum" \ --text="File: <b>${file##*/}</b>\n\nSelect the Hash algorithm\n" --hide-column="1" --separator="," \ --print-column="1,3" \ --column="Checksum" \ --column="" \ --column="Hash" "${MD5[@]}" "${SHA1[@]}" "${SHA224[@]}" "${SHA256[@]}" "${SHA384[@]}" "${SHA512[@]}") # ### If quit is clicked then exit. if [ "${PIPESTATUS[0]}" -ne "0" ]; then exit 0 fi # ### Read selection and split it. checksum=$(awk -F, '{print $1}' <<<$selected) dialog=$(awk -F, '{print $2}' <<<$selected) if [ "$checksum" == "" ]; then zenity --warning --window-icon="warning" --text="\nNo Hash algorithm was selected. Please, try again. " --timeout="3"; continue else : fi # ### Temp sum file. TMPF="/tmp/sum" # ### Common function - If cancel then remove $TMPF and exit. action_cancel() { if [ "${PIPESTATUS[2]}" -ne "0" ]; then rm $TMPF; exit 0 fi } action_sum() { sum=`cat $TMPF`; zenity --info --title="$dialog" --text="\nFile:<b> ${file##*/} </b>\n\n$dialog: $sum" --ok-label="Ok"; rm -f $TMPF } action_compare() { zenity --question --window-icon="$ic" --title="Hash Check" --text="You want verify the calculated hash?" --cancel-label="No" --ok-label="Yes" if [ "$?" != "0" ]; then exit 0 else ctrlsum=`zenity --entry --window-icon="$ic" --title="Hash Check" --text="Enter a control sum value" --cancel-label="Close" --ok-label="Ok"`; if [ "$ctrlsum" != "" ] && [ "$ctrlsum" == "$sum" ]; then zenity --info --window-icon="$ic" --title="Hash Check" --text="<b>Checksum</b> is correct.\nThe file is complete." elif [ "$ctrlsum" != "" ] && [ "$ctrlsum" != "$sum" ]; then zenity --error --title="Hash Check" --text="<b>Checksum no match</b>.\nThe file is incomplete or corrupt."; continue else exit 0 fi exit 0 fi } "$checksum" "$file" | tee >(cut -d ' ' -f1 > $TMPF) | zenity --window-icon="info" --progress --title="$dialog" --text="File:\n<b> ${file##*/} </b>\n\n- Calculating $dialog. Please, wait..." --pulsate --auto-close action_cancel action_sum action_comparedoneexit
Name: ChecksumDescription: Calculates checksum.Command: /usr/scripts/checksum %fPattern: *Appearance: Check all the boxes except Directoriessave the script as checksummake executablecopy the file to /usr/scripts
#!/bin/bash# Misko_2083, Ralphyic="/usr/share/icons/Faenza/actions/32/system-run.png"# user selected filefile="$@"if [ -z "$@" ]; then szPath=$(zenity --file-selection --title="Checksum - Select file..." --file-filter='Image files (ISO,IMG) | *.iso *.ISO *.img *.IMG' --file-filter='All files | *');if [ "$?" -eq "1" ]; then exit 0; else file="$szPath"; fi; fiwhile (true); doMD5=(`echo "" | awk '{print "md5sum","✍","MD5", $0}'`); SHA1=(`echo "" | awk '{print "sha1sum","✍","SHA-1", $0}'`)SHA224=(`echo "" | awk '{print "sha224sum","✍","SHA-224", $0}'`); SHA256=(`echo "" | awk '{print "sha256sum","✍","SHA-256", $0}'`)SHA384=(`echo "" | awk '{print "sha384sum","✍","SHA-384", $0}'`); SHA512=(`echo "" | awk '{print "sha512sum","✍","SHA-512", $0}'`)# main dialogselected=$(zenity --list --width=180 --height=248 --window-icon="$ic" --hide-header --title=" Checksum" --text="File: <b>${file##*/}</b>\n\nSelect the Hash algorithm\n" \--hide-column="1" --separator="," --print-column="1,3" --column="Checksum" --column="" --column="Hash" "${MD5[@]}" "${SHA1[@]}" "${SHA224[@]}" "${SHA256[@]}" "${SHA384[@]}" "${SHA512[@]}")# If Quit is clicked then exitif [ "${PIPESTATUS[0]}" -ne "0" ]; then exit 0; fi# read selection and split itchecksum=$(awk -F, '{print $1}' <<<$selected)dialog=$(awk -F, '{print $2}' <<<$selected)if [ "$checksum" == "" ]; then zenity --warning --window-icon="warning" --text="\nNo Hash algorithm was selected. Please try again. " --timeout="3"; continue; else :; fi# temp sum fileTMPF="/tmp/sum"# common function - if cancel then remove $TMPF and exitaction_cancel() { if [ "${PIPESTATUS[2]}" -ne "0" ]; then rm $TMPF; exit 0; fi }action_sum() { sum=`cat $TMPF`; zenity --info --title="$dialog" --text="\nFile:<b> ${file##*/} </b>\n\n$dialog: $sum"; rm -f $TMPF & exit 0; }"$checksum" "$file" | tee >(cut -d ' ' -f1 > $TMPF) |zenity --window-icon="info" --width=240 --progress --title="$dialog" --text="File:<b> ${file##*/} </b>\n\n- Calculating $dialog. Please wait..." --pulsate --auto-closeaction_cancelaction_sumdoneexit
if ( $($(CertUtil -hashfile C:PATH_to_FILE\File_name.iso MD5)[1] -replace " ","") -eq "PASTE_HASH_between_quotes" ) { echo "ok" }
Wow! Excellent job misko_2083!Just loaded it on my LL 2.0 desktop -- works great.
I think I need a sub menu in my right-click menu for all of misko's and Jerry's scripts.
#!/bin/bash# Misko_2083file="$@"MD5=(`echo "" | awk '{print "TRUE","MD5", $0}'`)SHA1=(`echo "" | awk '{print "FALSE","SHA-1", $0}'`)SHA224=(`echo "" | awk '{print "FALSE","SHA-224", $0}'`)SHA256=(`echo "" | awk '{print "FALSE","SHA-256", $0}'`)SHA384=(`echo "" | awk '{print "FALSE","SHA-384", $0}'`)SHA512=(`echo "" | awk '{print "FALSE","SHA-512", $0}'`)selection=$(zenity --list --radiolist --height=300 --title="Checksum" --text="File: <b>${file##*/}</b>\nPick the hash algorithm." --column="Pick" --column="Hash" "${MD5[@]}" "${SHA1[@]}" "${SHA224[@]}" "${SHA256[@]}" "${SHA384[@]}" "${SHA512[@]}")# If Quit is clicked then exitif [ "${PIPESTATUS[0]}" -ne "0" ]; then exit 0fiecho $selection | grep "MD5" > /dev/nullif [ $? = 0 ];then md5sum "$file" | tee >(cut -d ' ' -f1 > /tmp/sum) |zenity --progress --title="MD5sum" --text="Calculating MD5 for:\n${file##*/}" --pulsate --auto-close # If Cancel is clicked then remove temporary file and exit if [ "${PIPESTATUS[2]}" -ne "0" ]; then rm /tmp/sum exit 0 fi sum=`cat /tmp/sum` zenity --info --title="MD5sum" --text="MD5sum : $sum\nFile : ${file##*/}" rm /tmp/sum exit 0fiecho $selection | grep "SHA-1" > /dev/nullif [ $? = 0 ];then sha1sum "$file" | tee >(cut -d ' ' -f1 > /tmp/sum) |zenity --progress --title="SHA-1" --text="Calculating SHA-1 for:\n${file##*/}" --pulsate --auto-close # If Cancel is clicked then remove temporary file and exit if [ "${PIPESTATUS[2]}" -ne "0" ]; then rm /tmp/sum exit 0 fi sum=`cat /tmp/sum` zenity --info --title="SHA-1" --text="SHA-1: $sum\nFile : ${file##*/}" rm /tmp/sum exit 0fiecho $selection | grep "SHA-224" > /dev/nullif [ $? = 0 ];then sha224sum "$file" | tee >(cut -d ' ' -f1 > /tmp/sum) |zenity --progress --title="SHA-224" --text="Calculating SHA-224 for:\n${file##*/}" --pulsate --auto-close # If Cancel is clicked then remove temporary file and exit if [ "${PIPESTATUS[2]}" -ne "0" ]; then rm /tmp/sum exit 0 fi sum=`cat /tmp/sum` zenity --info --title="SHA-224" --text="SHA-224 : $sum\nFile : ${file##*/}" rm /tmp/sum exit 0fiecho $selection | grep "SHA-256" > /dev/nullif [ $? = 0 ];then sha256sum "$file" | tee >(cut -d ' ' -f1 > /tmp/sum) |zenity --progress --title="SHA-256" --text="Calculating SHA-256 for:\n${file##*/}" --pulsate --auto-close # If Cancel is clicked then remove temporary file and exit if [ "${PIPESTATUS[2]}" -ne "0" ]; then rm /tmp/sum exit 0 fi sum=`cat /tmp/sum` zenity --info --title="SHA-256" --text="SHA-256 : $sum\nFile : ${file##*/}" rm /tmp/sum exit 0fiecho $selection | grep "SHA-384" > /dev/nullif [ $? = 0 ];then sha384sum "$file" | tee >(cut -d ' ' -f1 > /tmp/sum) |zenity --progress --title="SHA-384" --text="Calculating SHA-384 for:\n${file##*/}" --pulsate --auto-close # If Cancel is clicked then remove temporary file and exit if [ "${PIPESTATUS[2]}" -ne "0" ]; then rm /tmp/sum exit 0 fi sum=`cat /tmp/sum` zenity --info --title="SHA-384" --text="SHA-384 : $sum\nFile : ${file##*/}" rm /tmp/sum exit 0fiecho $selection | grep "SHA-512" > /dev/nullif [ $? = 0 ];then sha512sum "$file" | tee >(cut -d ' ' -f1 > /tmp/sum) |zenity --progress --title="SHA-512" --text="Calculating SHA-512 for:\n${file##*/}" --pulsate --auto-close # If Cancel is clicked then remove temporary file and exit if [ "${PIPESTATUS[2]}" -ne "0" ]; then rm /tmp/sum exit 0 fi sum=`cat /tmp/sum` zenity --info --title="SHA-512" --text="SHA-512 : $sum\nFile : ${file##*/}" rm /tmp/sum exit 0fi
Do you think it might be better as a single script where you select which Checksum to verify? I imagine a dialog pops up where the user can choose SHA1 or MD5.