ADD iPhone synchronization script
This commit is contained in:
78
sync-iPhone.sh
Executable file
78
sync-iPhone.sh
Executable file
@@ -0,0 +1,78 @@
|
||||
#!/bin/sh
|
||||
program_list=("ifuse" "ldconfig" "rsync")
|
||||
library_list=("libimobiledevice")
|
||||
sync_folder="$HOME/iPhone"
|
||||
sync_mount="${sync_folder}/.mnt"
|
||||
sync_data="${sync_folder}/data"
|
||||
|
||||
# iteration thru list of programs
|
||||
for program in "${program_list[@]}"
|
||||
do
|
||||
if command -v "${program}" >/dev/null 2>&1
|
||||
then
|
||||
echo "OK, ${program} exists."
|
||||
else
|
||||
echo "Sorry, ${program} does not exists,"
|
||||
echo "you have to install all of these programs first: ${program_list[@]}"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# iteration thru list of libraries
|
||||
for library in "${library_list[@]}"
|
||||
do
|
||||
if ldconfig -p | grep ${library} >/dev/null 2>&1
|
||||
then
|
||||
echo "OK, ${library} exists."
|
||||
else
|
||||
echo "Sorry, the library ${library} is not installed."
|
||||
echo "You have to install the libraries first: ${library_list[@]}"
|
||||
exit 2
|
||||
fi
|
||||
done
|
||||
echo "Create the folder ${sync_mount} ..."
|
||||
if mkdir -p ${sync_mount} >/dev/null 2>&1
|
||||
then
|
||||
echo "done."
|
||||
else
|
||||
echo "Folder ${sync_mount} already exists."
|
||||
fi
|
||||
|
||||
echo "Mount the iPhone into that folder using ifuse ..."
|
||||
if ifuse ${sync_mount}
|
||||
then
|
||||
echo "ok."
|
||||
else
|
||||
echo "did not work. Check your connection to the iPhone."
|
||||
exit 3
|
||||
fi
|
||||
|
||||
echo "RSYNC the iPhone ..."
|
||||
FROM="$sync_mount"/
|
||||
TO="$sync_data"/
|
||||
|
||||
while true
|
||||
do
|
||||
echo "** Synchronization from ${FROM} to ${TO} **"
|
||||
read -n 1 -p"Sync iPhone and delete old files (y)es/(n)o/(c)ancel? " response
|
||||
echo
|
||||
case ${response} in
|
||||
[Nn]* ) rsync -avP "${FROM}" "${TO}"; break;;
|
||||
[YyJj]* ) rsync -avP --delete "${FROM}" "${TO}"; break;;
|
||||
[Cc]* ) break;;
|
||||
* ) echo "Please answer yes, no or cancel.";;
|
||||
esac
|
||||
done
|
||||
echo "Memory usage on the iPhone:" && du -hs ${sync_mount}
|
||||
|
||||
echo "Unmount the iPhone ..."
|
||||
if umount ${sync_mount}
|
||||
then
|
||||
echo "done."
|
||||
else
|
||||
echo "The umounting procedure did not work."
|
||||
fi
|
||||
echo "Remove temporary mount point ..."
|
||||
rmdir ${sync_mount}
|
||||
echo "done."
|
||||
echo "Disk usage:" && du -hs ${sync_folder}
|
||||
Reference in New Issue
Block a user