aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dorsync74
1 files changed, 53 insertions, 21 deletions
diff --git a/dorsync b/dorsync
index 624b636..caf5809 100644
--- a/dorsync
+++ b/dorsync
@@ -54,33 +54,60 @@ for dep in "${deps[@]}"; do
done
[[ ${#baddep} -gt 0 ]] && exit 1
+if [ ! -d "$location" ]; then
+ echo "Directory $location does not exist."
+ echo "Please create this directory or fix your 'location' parameter in dorsync.conf."
+ exit
+fi
+
cd "$location"
+rsync_url="rsync://$user@bcd.mageia.org/isos/$release/"
+
+select_isos () {
+ isos=`RSYNC_PASSWORD="$password" rsync --list-only --no-recursive "$rsync_url" | tr -s ' ' | cut -f5 -d" " | grep -i "mageia"`
+ rm -f dorsync.skip
+ echo -e "\nFor each of the following ISOs, press Y to download/update it, or any other key to skip it:\n"
+ for iso in $isos; do
+ read -r -n1 -e -p " $iso : " yn
+ if [[ $yn = [Yy] ]]; then
+ echo "+$iso" >> dorsync.skip
+ else
+ echo "$iso" >> dorsync.skip
+ fi
+ done
+ echo -e "\nYour selection has been saved in dorsync.skip.\n"
+}
# Function to do the actual rsync and run checks afterwards
dorsync () {
-rsync_url="rsync://$user@bcd.mageia.org/isos/$release/"
+if [ -e dorsync.skip ]; then
+ echo -e "\ndorsync.skip file found:\n"
+ cat dorsync.skip | while read -r iso
+ do
+ if [[ `echo "$iso" | cut -c 1` = '+' ]]; then
+ iso=`echo "$iso" | cut -c 2-`
+ echo -e " $iso $green SELECTED $endcolour"
+ else
+ echo -e " $iso $red SKIPPED $endcolour"
+ fi
+ done
+ echo -e "\nDo you want to continue with this selection?"
+ read -r -n1 -e -p "Press Y to continue, or any other key to modify this list: " yn
+ if [[ $yn != [Yy] ]]; then
+ select_isos
+ fi
+else
+ echo -e "\nNo dorsync.skip file found. Do you really want to download/update all ISOs?"
+ read -r -n1 -e -p "Press Y to continue with all ISOs, or any other key to choose which ISOs to select: " yn
+ if [[ $yn != [Yy] ]]; then
+ select_isos
+ fi
+fi
+
rsyncargs=("-avHP")
if [ -e dorsync.skip ]; then
rsyncargs+=("--exclude-from=dorsync.skip")
-else
- echo ""
- echo "No dorsync.skip file found. Do you really want to download/update all ISOs?"
- read -r -n1 -e -p "Press C to choose which ISOs to select, or any other key to continue with all ISOs: " cc
- if [[ $cc = [Cc] ]]; then
- isos=`RSYNC_PASSWORD="$password" rsync --list-only --no-recursive "$rsync_url" | tr -s ' ' | cut -f5 -d" " | grep -i "mageia"`
- echo -e "\nFor each of the following ISOs, press Y to download/update it, or any other key to skip it:"
- for iso in $isos; do
- read -r -n1 -e -p " $iso : " yc
- if [[ $yc = [Yy] ]]; then
- echo "+$iso" >> dorsync.skip
- else
- echo "$iso" >> dorsync.skip
- fi
- done
- rsyncargs+=("--exclude-from=dorsync.skip")
- echo -e "\nYour selection has been saved in dorsync.skip.\n"
- fi
fi
echo "Starting rsync.."
@@ -298,12 +325,17 @@ fi
# Function to list USB sticks
liststicks () {
i=0
- for usb in $(lsblk -ndpro NAME,RM,TRAN,TYPE | grep "1 usb disk$" | cut -f1 -d" ")
+ for usb in $(lsblk -ndpro NAME,TRAN,TYPE | grep "usb disk$" | cut -f1 -d" ")
do
showinfo=`udisksctl info -b "$usb"`
+ usb_size=`echo "$showinfo" | grep " Size:" | cut -f2 -d: | sed 's/^[ ]*//'`
+ # Ignore empty drives.
+ if [ $usb_size = 0 ]; then
+ continue
+ fi
usbdev[i]="$usb"
found[i]=`date`
- sizebytes[i]=`echo "$showinfo" | grep " Size:" | cut -f2 -d: | sed 's/^[ ]*//'`
+ sizebytes[i]=$usb_size
sizegb[i]=`echo "scale=1;${sizebytes[i]}/1024/1024/1024" | bc`
showinfo=`udevadm info -q property -n "$usb"`