Created
August 4, 2017 13:14
-
-
Save nikAizuddin/5634251d9785e7c08fe3ff26cdddbb4d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
##============================================================================== | |
## PROBLEM STATEMENT | |
## ----------------- | |
## Currently, transfering files between FreeBSD 10.3 computer and iPhone 6 | |
## (IOS 10.3.3) causes Input/Output errors. The errors are randomly occured | |
## during the file transfering process. Whenever the error occured, the file | |
## transfering process will fail and the computer is required to re-mount the | |
## iPhone again before resuming the file transfering. | |
## | |
## THE PURPOSE OF THIS SCRIPT | |
## -------------------------- | |
## The purpose of this script is to automate the mounting and file transfering | |
## process. If the Input/Output error occured during the file transfering, | |
## the script will re-mount and resume the file transfering process. | |
## | |
## HOW TO USE THIS SCRIPT | |
## ---------------------- | |
## To use this script, simply set the APPID, MOUNTPOINT, SOURCE, and | |
## DESTINATION. The APPID is the iPhone's app id, which can be found using | |
## "ideviceinstaller" tool from | |
## https://github.com/libimobiledevice/ideviceinstaller. | |
## The purpose of specifying the APPID is to transfer files into the app's | |
## local storage. For example, the APPID for Adobe Reader app is | |
## "com.adobe.Adobe-Reader". By specifying this APPID will allow the user to | |
## transfer PDF documents into Adobe Reader local files, which can be read | |
## offline without requiring any cloud services. The MOUNTPOINT is the location | |
## to mount the iPhone's app, SOURCE is the source file's path, and DESTINATION | |
## is where the SOURCE files will be transfered. If the SOURCE is a directory, | |
## the script will transfer all files in the directory. | |
##============================================================================== | |
APPID="com.adobe.Adobe-Reader" | |
MOUNTPOINT="/mnt/iphone" | |
SOURCE="/home/tracy/Documents/ebooks" | |
DESTINATION="${MOUNTPOINT}/" | |
while true | |
do | |
## Wait for 3 seconds, mount the iPhone's app, and then wait | |
## for another 3 seconds | |
sleep 3 | |
ifuse -o allow_other --documents ${APPID} ${MOUNTPOINT} | |
sleep 3 | |
## Begin file transfering as user Tracy (any non-root user). Retry if failed | |
su -m tracy -c "rsync -rv --progress --append ${SOURCE} ${DESTINATION}" | |
retval=$? | |
if [ ${retval} == 0 ]; then | |
echo "Done transfering file!" | |
break | |
else | |
echo "Failed! Retry again in 3 seconds..." | |
sleep 3 | |
## Make sure the iPhone's app isn't mounted | |
umount -v ${MOUNTPOINT} | |
retval=$? | |
if [ ${retval} != 0 ]; then | |
break | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment