Skip to content

Commit

Permalink
Major revision
Browse files Browse the repository at this point in the history
Added a working Curl

Support for recent nextcloud (maybe owncloud?) with WebDAV

This release is untested on Kobo
  • Loading branch information
fsantini committed Oct 24, 2018
1 parent 0c79306 commit ce1a1fd
Show file tree
Hide file tree
Showing 14 changed files with 3,393 additions and 28 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ KoboCloud keeps a log of each session in the .kobo/kobocloud/get.log file. If so
* Support of Google Drive is in the works.

## Acknowledgment
Thanks to the defunct SendToKobo service for the inspiration of the project and for the basis of the scripts.
Thanks to the defunct SendToKobo service for the inspiration of the project and for the basis of the scripts.
Curl for Kobo was downloaded from here: https://www.mobileread.com/forums/showthread.php?p=3734553
5 changes: 3 additions & 2 deletions Sources_3rdParty/HOWTO_Compile_Curl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export CC=${CROSS}-gcc
export LD=${CROSS}-ld
export AS=${CROSS}-as
export AR=${CROSS}-ar
./Configure -DOPENSSL_NO_HEARTBEATS no-shared os/compiler:arm-linux-gnueabi
./Configure -DOPENSSL_NO_HEARTBEATS no-shared os/compiler:arm-linux-gnueabi -march=armv7
NEW Openssl: ./Configure linux-armv4 no-heartbeats no-shared
make
mkdir lib
mv libssl.a libcrypto.a lib
Expand All @@ -22,4 +23,4 @@ cd curl-7.35.0
# change configure to disable clock_gettime (not available in kobo glibc)
./configure --host=arm-linux-gnueabi --enable-shared=no --with-ssl=/home/francesco/src/openssl-1.0.1f
# change lib/curl_config.h is changed to disable poll
make
make
3,314 changes: 3,314 additions & 0 deletions src/usr/local/kobocloud/ca-bundle.crt

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions src/usr/local/kobocloud/config.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/sh
Logs=/mnt/onboard/.kobo/kobocloud
Lib=/mnt/onboard/.kobo/kobocloud/Library
SD=/mnt/sd/kobocloud
UserConfig=/mnt/onboard/.kobo/kobocloud/kobocloudrc
Dt="date +%Y-%m-%d_%H:%M:%S"
CURL=`dirname $0`/curl
#!/bin/bash

if uname -a | grep -q x86
then
#echo "PC detected"
. `dirname $0`/config_pc.sh
else
. `dirname $0`/config_kobo.sh
fi
7 changes: 7 additions & 0 deletions src/usr/local/kobocloud/config_kobo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
Logs=/mnt/onboard/.kobo/kobocloud
Lib=/mnt/onboard/.kobo/kobocloud/Library
SD=/mnt/sd/kobocloud
UserConfig=/mnt/onboard/.kobo/kobocloud/kobocloudrc
Dt="date +%Y-%m-%d_%H:%M:%S"
CURL="`dirname $0`/curl --cacert \"`dirname $0`/ca-bundle.crt\" "
7 changes: 7 additions & 0 deletions src/usr/local/kobocloud/config_pc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
Logs=/home/francesco/src/KoboCloud
Lib=/home/francesco/src/KoboCloud/Library
SD=/home/francesco/src/KoboCloud
UserConfig=/home/francesco/src/KoboCloud/kobocloudrc
Dt="date +%Y-%m-%d_%H:%M:%S"
CURL=/usr/bin/curl
Binary file modified src/usr/local/kobocloud/curl
Binary file not shown.
2 changes: 1 addition & 1 deletion src/usr/local/kobocloud/get.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#Kobocloud getter

#load config
source `dirname $0`/config.sh
. `dirname $0`/config.sh

#check internet connection
echo "`$Dt` waiting for internet connection"
Expand Down
2 changes: 1 addition & 1 deletion src/usr/local/kobocloud/getDropboxFiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ baseURL="$1"
outDir="$2"

#load config
source `dirname $0`/config.sh
. `dirname $0`/config.sh

# get directory listing
echo "Getting $baseURL"
Expand Down
24 changes: 16 additions & 8 deletions src/usr/local/kobocloud/getOwncloudFiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,25 @@ baseURL="$1"
outDir="$2"

#load config
source `dirname $0`/config.sh
. `dirname $0`/config.sh

# webdav implementation
# https://myserver.com/s/shareLink

shareID=`echo $baseURL | sed -e 's@.*s/\([^/ ]*\)$@\1@'`
davServer=`echo $baseURL | sed -e 's@.*\(http.*\)/s/[^/ ]*$@\1@'`

echo $shareID
echo $davServer

# get directory listing
$CURL -k -L --silent "$baseURL" | # get listing
grep '<a class="name" href=' | # find links
sed -e 's/.*href="\([^"]*\)".*/\1/' -e 's/&amp;/\&/g' | # extract links and replace ampersands
while read linkLine
`dirname $0`/getOwncloudList.sh $shareID $davServer |
while read relativeLink
do
# process line
outFileName=`echo $linkLine | sed 's|.*path=/*\(.*\)|\1|'`
outFileName=`basename $relativeLink`
linkLine=$davServer/$relativeLink
localFile="$outDir/$outFileName"
# get remote file
`dirname $0`/getRemoteFile.sh "$linkLine" "$localFile"
done
`dirname $0`/getRemoteFile.sh "$linkLine" "$localFile" $shareID
done
15 changes: 15 additions & 0 deletions src/usr/local/kobocloud/getOwncloudList.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

user="$1"
davServer="$2"

#load config
. `dirname $0`/config.sh

echo '<?xml version="1.0"?>
<a:propfind xmlns:a="DAV:">
<a:prop><a:resourcetype/></a:prop>
</a:propfind>' |
$CURL -k --silent -i -X PROPFIND -u $user: $davServer/public.php/webdav --upload-file - -H "Depth: 1" | # get the listing
grep -Eo '<d:href>[^<]*[^/]</d:href>' | # get the links without the folders
sed 's@</*d:href>@@g' # remove the hrefs
18 changes: 14 additions & 4 deletions src/usr/local/kobocloud/getRemoteFile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,23 @@

linkLine="$1"
localFile="$2"
user="$3"

#load config
source `dirname $0`/config.sh
. `dirname $0`/config.sh


if [ "$user" = "" ]; then
curlCommand=$CURL
else
curlCommand="$CURL -u $user: "
fi

echo $curlCommand

echo "$linkLine -> $localFile"

remoteSize=`$CURL -k -L --silent --head "$linkLine" | sed -n 's/^Content-Length\: \([0-9]*\).*/\1/ip'`
remoteSize=`$curlCommand -k -L --silent --head "$linkLine" | sed -n 's/^Content-Length\: \([0-9]*\).*/\1/ip'`
if [ -f $localFile ]; then
localSize=`stat -c%s "$localFile"`
else
Expand All @@ -17,9 +27,9 @@ fi
if [ $localSize -ge $remoteSize ]; then
echo "File exists: skipping"
else
$CURL -k --silent -C - -L -o "$localFile" "$linkLine" # try resuming
$curlCommand -k --silent -C - -L -o "$localFile" "$linkLine" # try resuming
if [ $? -ne 0 ]; then
echo "Error resuming: redownload file"
$CURL -k --silent -L -o "$localFile" "$linkLine" # restart download
$curlCommand -k --silent -L -o "$localFile" "$linkLine" # restart download
fi
fi
4 changes: 2 additions & 2 deletions src/usr/local/kobocloud/udev_mount.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
#load config
source `dirname $0`/config.sh
. `dirname $0`/config.sh

#create work dirs
[ ! -e "$Logs" ] && mkdir -p "$Logs" >/dev/null 2>&1
Expand All @@ -16,4 +16,4 @@ mountpoint -q "$SD"
if [ $? -ne 0 ]; then
mount --bind "$Lib" "$SD"
echo sd add /dev/mmcblk1p1 >> /tmp/nickel-hardware-status
fi
fi
4 changes: 2 additions & 2 deletions src/usr/local/kobocloud/udev_program.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ if [ "$ACTION" != "add" ]; then
fi

#load config
source `dirname $0`/config.sh
. `dirname $0`/config.sh

#create work dirs
[ ! -e "$Logs" ] && mkdir -p "$Logs" >/dev/null 2>&1
[ ! -e "$Lib" ] && mkdir -p "$Lib" >/dev/null 2>&1
[ ! -e "$SD" ] && mkdir -p "$SD" >/dev/null 2>&1

#output to log
`dirname $0`/get.sh &> $Logs/get.log &
`dirname $0`/get.sh &> $Logs/get.log &

0 comments on commit ce1a1fd

Please sign in to comment.