Rename $k to $device
This commit is contained in:
parent
4a46f213b1
commit
caa057fdb8
36
fullusb.sh
36
fullusb.sh
|
@ -1,7 +1,8 @@
|
|||
#!/bin/bash
|
||||
# script to copy data on usb keys
|
||||
# Script to copy data on usb keys
|
||||
|
||||
# dependances : aptitude install ncurses-bin parted dosfstools (mlabel devenu inutile)
|
||||
# dependencies : aptitude install ncurses-bin parted dosfstools
|
||||
# mlabel is now useless
|
||||
|
||||
# text color in bash
|
||||
normal=$(tput sgr0)
|
||||
|
@ -11,12 +12,11 @@ green=$(tput setaf 2)
|
|||
# dependencies check
|
||||
i=0
|
||||
for arg in "tput" "parted" "mkdosfs"; do
|
||||
|
||||
hash "${arg}"
|
||||
if [[ $? -gt 0 ]]; then
|
||||
hash "${arg}"
|
||||
if [[ $? -gt 0 ]]; then
|
||||
printf "%40s\n" "${red}Error: Could not find \"$arg\" application.${normal}";
|
||||
i=$((i+1))
|
||||
fi
|
||||
fi
|
||||
done
|
||||
[[ $i -eq 0 ]] || exit $i
|
||||
|
||||
|
@ -54,29 +54,29 @@ case $keysearchid in
|
|||
# if $keysearchid=1: for i in 1
|
||||
# if $keysearchid=2: for i in 1 2
|
||||
do
|
||||
[[ $i == 1 ]] && k="sdb" || k="sdc" # if 3 or more keys this line has to be adapt
|
||||
parted -s /dev/$k mklabel msdos
|
||||
parted /dev/$k mkpart -a optimal primary fat32 0% 100%
|
||||
mkdosfs -F 32 -I -n $keylabel /dev/${k}1
|
||||
# fatlabel /dev/${k}1 $keylabel # Cette commande est remplacée par l’option -n de la commande précédente
|
||||
mkdir "${mountpath}"$k
|
||||
mount /dev/${k}1 "${mountpath}"$k
|
||||
cp -r $wherethefilesare/* "${mountpath}"$k/
|
||||
[[ $i == 1 ]] && device="sdb" || device="sdc" # if 3 or more keys this line has to be adapt
|
||||
parted -s /dev/"${device}" mklabel msdos
|
||||
parted /dev/"${device}" mkpart -a optimal primary fat32 0% 100%
|
||||
mkdosfs -F 32 -I -n $keylabel /dev/"${device}"1
|
||||
# fatlabel /dev/${device}1 $keylabel # Cette commande est remplacée par l’option -n de la commande précédente
|
||||
mkdir "${mountpath}""${device}"
|
||||
mount /dev/"${device}"1 "${mountpath}""${device}"
|
||||
cp -r $wherethefilesare/* "${mountpath}""${device}"/
|
||||
sync
|
||||
# Generate the md5sum for the mountpoint
|
||||
pushd "${mountpath}""${k}"
|
||||
pushd "${mountpath}""${device}"
|
||||
find . -type f -exec md5sum {} \; | sort > "${destmd5}"
|
||||
popd
|
||||
# Umount the key
|
||||
umount "${mountpath}"$k
|
||||
rmdir "${mountpath}"$k
|
||||
umount "${mountpath}""${device}"
|
||||
rmdir "${mountpath}""${device}"
|
||||
# Compare the md5sum
|
||||
diff -q "${sourcemd5}" "${destmd5}"
|
||||
if [[ $? -gt 0 ]]; then
|
||||
printf "%40s\n" "${red}Error: MD5 diff detected.${normal}";
|
||||
exit 1
|
||||
else
|
||||
printf "%40s\n" "${green}MD5 check OK for ${k}.${normal}"
|
||||
printf "%40s\n" "${green}MD5 check OK for ${device}.${normal}"
|
||||
fi
|
||||
done
|
||||
printf "%40s\n" "${green}DONE${normal}"
|
||||
|
|
Loading…
Reference in New Issue