diff options
| author | Frédéric "LpSolit" Buclin <lpsolit@mageia.org> | 2025-12-13 03:30:58 +0100 |
|---|---|---|
| committer | Dan Fandrich <danf@mageia.org> | 2025-12-12 20:13:12 -0800 |
| commit | 197650b84d9ff5c696fb1dafa9237c3354542137 (patch) | |
| tree | 55a1aa9195fb7443d72e87e4145cd9a55f7efd0c | |
| parent | 974184d3189f75f270217c166683e3e6f5400328 (diff) | |
| download | dorsync-197650b84d9ff5c696fb1dafa9237c3354542137.tar dorsync-197650b84d9ff5c696fb1dafa9237c3354542137.tar.gz dorsync-197650b84d9ff5c696fb1dafa9237c3354542137.tar.bz2 dorsync-197650b84d9ff5c696fb1dafa9237c3354542137.tar.xz dorsync-197650b84d9ff5c696fb1dafa9237c3354542137.zip | |
Fix dorsync with udisks2 (mga#34826)
The output of udisks and udisksctl are different, and they do not
display the same fields. Now use udevadm to get the missing data.
| -rw-r--r-- | dorsync | 67 |
1 files changed, 23 insertions, 44 deletions
@@ -17,7 +17,7 @@ password="" ############################################ # To exclude directories from sync, create # -# a file, dorsync.skip in the start folder # # +# a file, dorsync.skip in the start folder # # containing the directory names only, one # # per line. # ############################################ @@ -43,7 +43,7 @@ rsyncargs=() rsyncargs+=" -avHP" # Check required packages are installed -deps=(coreutils udisks sed grep rsync) +deps=(coreutils udisks2 sed grep rsync) for dep in ${deps[@]}; do if ! rpm --quiet -q $dep; then echo "You need to install $dep to run this program" @@ -53,9 +53,7 @@ done [[ ${#baddep} > 0 ]] && exit 1 if [[ -e dorsync.skip ]]; then - while read line; do - rsyncargs+=" --exclude=$line" - done < dorsync.skip + rsyncargs+=" --exclude-from=dorsync.skip" fi rsyncargs+=" rsync://$user@bcd.mageia.org/isos/$release/ ." cd "$location" @@ -272,34 +270,19 @@ fi # Function to list USB sticks liststicks () { - usbs="" - for device in /sys/block/*/device - do - if echo $(readlink -f $device)|egrep -q "usb" - then - adisk=`echo $device | cut -f4 -d/` - usbs="$usbs /dev/$adisk" - fi - done - - # Find info for each from udisks i=0 - for usb in $usbs + for usb in $(lsblk -ndpro NAME,RM,TRAN,TYPE | grep "1 usb disk$" | cut -f1 -d" ") do - showinfo=`udisks --show-info $usb` - isremovable=`echo "$showinfo" | grep " removable:"| cut -f2 -d: | sed 's/^[ ]*//'` - - # Check udisks shows it as removable - if [ $isremovable = 1 ] - then - usbdev[$i]="$usb" - found[$i]=`echo "$showinfo" | grep " detected at:"| cut -f2- -d: | sed 's/^[ ]*//'` - vendor[$i]=`echo "$showinfo" | grep "vendor:" | cut -f2 -d: | sed 's/^[ ]*//'` - model[$i]=`echo "$showinfo" | grep "model:" | cut -f2 -d: | sed 's/^[ ]*//'` - sizebytes[$i]=`echo "$showinfo" | grep " size:" | cut -f2 -d: | sed 's/^[ ]*//'` - sizegb[$i]=`echo "scale=1;${sizebytes[$i]}/1024/1024/1024" | bc` - (( i++ )) - fi + showinfo=`udisksctl info -b $usb` + usbdev[$i]="$usb" + found[$i]=`date` + sizebytes[$i]=`echo "$showinfo" | grep " Size:" | cut -f2 -d: | sed 's/^[ ]*//'` + sizegb[$i]=`echo "scale=1;${sizebytes[$i]}/1024/1024/1024" | bc` + + showinfo=`udevadm info -q property -n $usb` + vendor[$i]=`echo "$showinfo" | grep "ID_VENDOR=" | cut -f2 -d=` + model[$i]=`echo "$showinfo" | grep "ID_MODEL=" | cut -f2 -d=` + (( i++ )) done } @@ -402,16 +385,14 @@ dodump () { total=${#found[@]} fi - # Now there is a USB print the info + # Now there is a USB. Print the info + echo "" + echo "USB drives found:" + echo "" + echo -e " Device\tSize\tWhen Found\t\t\tModel" + for (( i=0; i<=$(( $total -1 )); i++ )) do - if [ $i = 0 ] - then - echo "" - echo "USB drives found:" - echo "" - echo -e " Device\tSize\tWhen Found\t\t\tModel" - fi echo -e "$((i+1))) ${usbdev[$i]}\t${sizegb[$i]}Gb\t${found[$i]}\t${vendor[$i]} ${model[$i]}" done @@ -429,14 +410,12 @@ echo "" done # List the ISOs + echo "" + echo "List of ISOs:" + total=${#iso[@]} for (( i=0; i<=$(( $total -1 )); i++ )) do - if [ $i = 0 ] - then - echo "" - echo "List of ISOs:" - fi echo "$(($i+1))) ${iso[$i]}" done echo "" |
