Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #7 from xybu92/wip
Browse files Browse the repository at this point in the history
Merged Wip where a potential bug of python-skydrive is patched for now.
  • Loading branch information
xybu committed Mar 31, 2014
2 parents 43083a1 + a0d506a commit 82df2ff
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 2 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.


Expand Down
Empty file removed doc/test.txt
Empty file.
56 changes: 56 additions & 0 deletions experiments/onedrive-d
Original file line number Diff line number Diff line change
@@ -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

6 changes: 6 additions & 0 deletions experiments/stub.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

echo "I am a stub."

exit 0

22 changes: 20 additions & 2 deletions inst_pre_requisites.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# sudo permission required.
#
# @author Xiangyu Bu
# @update Jan 08, 2014
#

# function install_pkg $pkgName
install_pkg() {
Expand All @@ -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."

0 comments on commit 82df2ff

Please sign in to comment.