From e89c05585c532a4491c4908a2796a3eec9c69410 Mon Sep 17 00:00:00 2001 From: Xiangyu Bu Date: Sun, 30 Mar 2014 18:29:33 -0700 Subject: [PATCH 1/3] A toy daemon script --- experiments/onedrive-d | 56 ++++++++++++++++++++++++++++++++++++++++++ experiments/stub.sh | 6 +++++ 2 files changed, 62 insertions(+) create mode 100755 experiments/onedrive-d create mode 100755 experiments/stub.sh diff --git a/experiments/onedrive-d b/experiments/onedrive-d new file mode 100755 index 0000000..10b4807 --- /dev/null +++ b/experiments/onedrive-d @@ -0,0 +1,56 @@ +#!/bin/bash + +### BEGIN INIT INFO +# Provides: ondrive-d +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start daemon at boot time +# Description: Enable service provided by daemon. +### END INIT INFO + +DAEMON_NAME=onedrive-d +DAEMON_PATH=./stub.sh +DAEMON_USER=$USER + +PIDFILE=/var/run/$DAEMON_NAME.pid + +. /lib/lsb/init-functions + +do_start () { + log_daemon_msg "Starting system $DAEMON_NAME daemon" + start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --user $DAEMON_USER --chuid $DAEMON_USER --startas $DAEMON_PATH + log_end_msg $? +} + +do_stop () { + log_daemon_msg "Stopping system $DAEMON_NAME daemon" + start-stop-daemon --stop --pidfile $PIDFILE --retry 10 + log_end_msg $? +} + +case "$1" in + + start|stop) + do_${1} + ;; + + restart|reload|force-reload) + do_stop + do_start + ;; + + status) + status_of_proc "$DAEMON_NAME" "$DAEMON" && exit 0 || exit $? + ;; + + *) + echo "Usage: /etc/init.d/$DAEMON_NAME {start|stop|restart|status}" + exit 1 + ;; + +esac + +exit 0 + diff --git a/experiments/stub.sh b/experiments/stub.sh new file mode 100755 index 0000000..e12143d --- /dev/null +++ b/experiments/stub.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +echo "I am a stub." + +exit 0 + From 244f868ab1cb01e504c1746c57568d1c421d27ae Mon Sep 17 00:00:00 2001 From: Xiangyu Bu Date: Sun, 30 Mar 2014 18:30:11 -0700 Subject: [PATCH 2/3] Patched potential bug of python-skydrive --- inst_pre_requisites.sh | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/inst_pre_requisites.sh b/inst_pre_requisites.sh index b104242..956c4ff 100755 --- a/inst_pre_requisites.sh +++ b/inst_pre_requisites.sh @@ -6,7 +6,7 @@ # sudo permission required. # # @author Xiangyu Bu -# @update Jan 08, 2014 +# # function install_pkg $pkgName install_pkg() { @@ -20,19 +20,37 @@ install_pkg() { fi } +echo "Installing / upgrading package \"dpkg\"..." +sudo apt-get -y install dpkg + # install Linux packages required for python-skydrive +install_pkg git install_pkg python-pip install_pkg libyaml-dev install_pkg python-yaml install_pkg python-dateutil +install_pkg python-urllib3 # install Linux packages required for skydrive-d install_pkg inotify-tools +echo "install urllib3 pre-requisite for python-skydrive..." +sudo pip install urllib3 --upgrade + # install python-skydrive # Note that to install stuff in system-wide PATH and site-packages, -# elevated privileges are often required. +# privileges need to be elevated. # Use "install --user", ~/.pydistutils.cfg or # virtualenv to do unprivileged installs into custom paths. echo "Installing/Upgrading python-skydrive..." sudo pip install 'git+https://github.com/mk-fg/python-skydrive.git#egg=python-skydrive[standalone]' --upgrade + +# patch python-skydrive to solve ImportError: no module PoolManager +# Issue URL: https://github.com/mk-fg/python-skydrive/issues/13 +#TODO: suppose it is installed in /usr/local/lib/python2.7/dist-packages/skydrive/ for now... +echo "Patching python-skydrive for a potential bug..." +PYTHON_SKYDRIVE_PATH=/usr/local/lib/python2.7/dist-packages/skydrive +sudo sed -i 's/requests.packages.urllib3/urllib3/g' $PYTHON_SKYDRIVE_PATH/*.py +sudo rm -f $PYTHON_SKYDRIVE_PATH/*.pyc +echo "Successfully patched python-skydrive." + From a0d506a69683d208eaa1bbb15cc57b34ba647fc4 Mon Sep 17 00:00:00 2001 From: Xiangyu Bu Date: Sun, 30 Mar 2014 18:38:36 -0700 Subject: [PATCH 3/3] Updated README --- README.md | 8 ++++++++ doc/test.txt | 0 2 files changed, 8 insertions(+) delete mode 100644 doc/test.txt diff --git a/README.md b/README.md index 1aeba5f..37f4373 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,16 @@ Description This project intends to develop a OneDrive (formerly SkyDrive) daemon on (X)ubuntu with mainly Bash script. The server-client interaction is based on python-skydrive (https://github.com/mk-fg/python-skydrive) by Mike Kazantsev. +Notice +-------- +* (Mar 30, 2014, by XB) If you encountered an `ImportError` when python imports `PoolManager()`, please use the `inst_pre_requisite.sh` in **wip** branch which patched the problem for now. + * The issue is tracked at https://github.com/mk-fg/python-skydrive/issues/13 + + Installation -------------- +__Please beware that the program is extremely premature to use in real life scenario.__ + Execute the command: `sudo ./setup.sh` to install the daemon. diff --git a/doc/test.txt b/doc/test.txt deleted file mode 100644 index e69de29..0000000