Last active
August 29, 2015 14:04
-
-
Save maojj/d811094d70278dac928f to your computer and use it in GitHub Desktop.
An autosync script for bypy(Baidu Yun) on WD My Book Live
This file contains 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/bash | |
# | |
# This is an autosync script for bypy(Baidu Yun) on WD My Book Live | |
# I use it in crontab(erery hour): 0 * * * * /path/to_this_script/autosync.sh | |
# a sync my cost more than an hour, | |
# so use flag file to make sure only one autosync.sh is running.(dirty way) | |
# | |
# About bypy: Python client for Baidu Yun (Personal Cloud Storage) | |
# see: https://github.com/houtianze/bypy | |
# | |
# Author: maojj | |
# Date: 2014-07-29 | |
# | |
LOCAL_BAIDU_PATH="/DataVolume/shares/TDdownload/Baidu" | |
LOCAL_PYTHON="/opt/bin/python2" | |
LOCAL_BYPY_SCRIPT="/DataVolume/baidu/bypy.py" | |
SYNC_METHOD="syncdown" | |
REMOTE_PATH="/" | |
PARAMETER="-v" | |
LOGFILE="$LOCAL_BAIDU_PATH/sync.log" | |
# make sure only run one of this script at one time. | |
FLAG_FILE="$LOCAL_BAIDU_PATH/.__issyning.tag" | |
echo "*******************************************************" >> $LOGFILE | |
echo "Auto sync started:" >> $LOGFILE | |
echo `date` >> $LOGFILE | |
if [[ -f $FLAG_FILE ]]; then | |
echo "Abort for isSyning:" >> $LOGFILE | |
exit 1; | |
fi | |
echo "Begin Syncing" >> $LOGFILE | |
touch $FLAG_FILE | |
# download / path to | |
SYNC_CMD="$LOCAL_PYTHON $LOCAL_BYPY_SCRIPT $SYNC_METHOD $REMOTE_PATH $LOCAL_BAIDU_PATH $PARAMETER" | |
$SYNC_CMD >> $LOGFILE | |
rm -f $FLAG_FILE | |
echo "Sync Finished" >> $LOGFILE | |
echo "*******************************************************" >> $LOGFILE |
This file contains 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
# let my book live sleep at night | |
SHELL=/bin/bash | |
LANG=en_US.UTF-8 | |
LANGUAGE=en | |
LC_CTYPE=en_US.UTF-8 | |
0 10-23 * * * /DataVolume/baidu/autosync.sh |
This file contains 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
#Steps for install python 2.7 on WD My Book Live. | |
#and install for bypy(https://github.com/houtianze/bypy) | |
# | |
#step1 update | |
/opt/bin/ipkg update | |
#step2 install coreutils | |
/opt/bin/ipkg install coreutils | |
#step3 install python2.7 | |
/opt/bin/ipkg install python27 | |
#optional | |
#step4 install easy_install | |
/opt/bin/ipkg install py27-setuptools | |
#step5 install requests for bypy | |
/opt/bin/easy_install-2.7 requests | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment