Skip to content

Commit

Permalink
Add KoboCloud home env
Browse files Browse the repository at this point in the history
  • Loading branch information
Luca Rota committed Jun 10, 2020
1 parent 1486e60 commit 4b9afb2
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 25 deletions.
7 changes: 4 additions & 3 deletions src/usr/local/kobocloud/config.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/bin/bash

ConfigFile=`dirname $0`/kobocloudrc.tmpl
KC_HOME=$(dirname $0)
ConfigFile=$KC_HOME/kobocloudrc.tmpl

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

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

#check if Kobocloud contains the line "UNINSTALL"
if grep -q '^UNINSTALL$' $UserConfig; then
echo "Uninstalling KoboCloud!"
`dirname $0`/uninstall.sh
$KC_HOME/uninstall.sh
exit 0
fi

Expand All @@ -33,15 +33,15 @@ while read url; do
else
echo "Getting $url"
if echo $url | grep -q '^https*://www.dropbox.com'; then # dropbox link?
`dirname $0`/getDropboxFiles.sh "$url" "$Lib"
$KC_HOME/getDropboxFiles.sh "$url" "$Lib"
elif echo $url | grep -q '^https*://filedn.com'; then
`dirname $0`/getpCloudFiles.sh "$url" "$Lib"
$KC_HOME/getpCloudFiles.sh "$url" "$Lib"
elif echo $url | grep -q '^https*://[^/]*pcloud'; then
`dirname $0`/getpCloudFiles.sh "$url" "$Lib"
$KC_HOME/getpCloudFiles.sh "$url" "$Lib"
elif echo $url | grep -q '^https*://drive.google.com'; then
`dirname $0`/getGDriveFiles.sh "$url" "$Lib"
$KC_HOME/getGDriveFiles.sh "$url" "$Lib"
else
`dirname $0`/getOwncloudFiles.sh "$url" "$Lib"
$KC_HOME/getOwncloudFiles.sh "$url" "$Lib"
fi
fi
done < $UserConfig
Expand Down
4 changes: 2 additions & 2 deletions 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
. `dirname $0`/config.sh
. $(dirname $0)/config.sh

baseURL=`echo "$baseURL" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'`

Expand All @@ -25,7 +25,7 @@ do
outFileName=`echo $linkLine | sed -e 's|.*/\(.*\)?dl=.*|\1|'`
#echo $outFileName
localFile="$outDir/$outFileName"
`dirname $0`/getRemoteFile.sh "$linkLine" "$localFile"
$KC_HOME/getRemoteFile.sh "$linkLine" "$localFile"
if [ $? -ne 0 ] ; then
echo "Having problems contacting Dropbox. Try again in a couple of minutes."
exit
Expand Down
4 changes: 2 additions & 2 deletions src/usr/local/kobocloud/getGDriveFiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ baseURL="$1"
outDir="$2"

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

# get directory listing
echo "Getting $baseURL"
Expand All @@ -26,7 +26,7 @@ do
outFileName=`echo $fileName | tr ' ' '_'`
localFile="$outDir/$outFileName"

`dirname $0`/getRemoteFile.sh "$linkLine" "$localFile"
$KC_HOME/getRemoteFile.sh "$linkLine" "$localFile"
if [ $? -ne 0 ] ; then
echo "Having problems contacting Google Drive. Try again in a couple of minutes."
exit
Expand Down
6 changes: 3 additions & 3 deletions src/usr/local/kobocloud/getOwncloudFiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ baseURL="$1"
outDir="$2"

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

# webdav implementation
# https://myserver.com/s/shareLink
Expand All @@ -16,15 +16,15 @@ echo $shareID
echo $davServer

# get directory listing
`dirname $0`/getOwncloudList.sh $shareID $davServer |
$KC_HOME/getOwncloudList.sh $shareID $davServer |
while read relativeLink
do
# process line
outFileName=`basename $relativeLink`
linkLine=$davServer/$relativeLink
localFile="$outDir/$outFileName"
# get remote file
`dirname $0`/getRemoteFile.sh "$linkLine" "$localFile" $shareID
$KC_HOME/getRemoteFile.sh "$linkLine" "$localFile" $shareID
if [ $? -ne 0 ] ; then
echo "Having problems contacting Owncloud. Try again in a couple of minutes."
exit
Expand Down
2 changes: 1 addition & 1 deletion src/usr/local/kobocloud/getOwncloudList.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ user="$1"
davServer="$2"

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

echo '<?xml version="1.0"?>
<a:propfind xmlns:a="DAV:">
Expand Down
2 changes: 1 addition & 1 deletion src/usr/local/kobocloud/getRemoteFile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ user="$3"
outputFileTmp="/tmp/kobo-remote-file-tmp.log"

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

curlCommand="$CURL"
if [ ! -z "$user" ] && [ "$user" != "-" ]; then
Expand Down
4 changes: 2 additions & 2 deletions src/usr/local/kobocloud/getpCloudFiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ baseURL="$1"
outDir="$2"

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

code=`echo $baseURL | sed 's/.*code=\([a-zA-Z0-9]*\).*/\1/'`

Expand Down Expand Up @@ -35,7 +35,7 @@ do

# process line
localFile="$outDir/$outFileName"
`dirname $0`/getRemoteFile.sh "$linkLine" "$localFile"
$KC_HOME/getRemoteFile.sh "$linkLine" "$localFile"
if [ $? -ne 0 ] ; then
echo "Having problems contacting pCloud. Try again in a couple of minutes."
exit
Expand Down
2 changes: 1 addition & 1 deletion 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
. `dirname $0`/config.sh
. $(dirname $0)/config.sh

#create work dirs
[ ! -e "$Logs" ] && mkdir -p "$Logs" >/dev/null 2>&1
Expand Down
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 @@ -8,12 +8,12 @@ then
fi

#load config
. `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 2>&1 &
$KC_HOME/get.sh > $Logs/get.log 2>&1 &

0 comments on commit 4b9afb2

Please sign in to comment.