Skip to content

Commit

Permalink
Merge pull request #23 from lucarota/master
Browse files Browse the repository at this point in the history
Various updates
  • Loading branch information
fsantini authored Jun 12, 2020
2 parents 100a8d1 + 4b9afb2 commit 654b682
Show file tree
Hide file tree
Showing 17 changed files with 422 additions and 251 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Below we describe each step.
### Compilling

- Move to the project directory root
- Open the configuration file located at `src/usr/local/kobocloud/kobocloudrc.tmpl`
- Add the links to the cloud services (see the configuration example that follow below)
- Run `sh ./makeKoboRoot.sh`

The last command will create a `KoboRoot.tgz` archive.
Expand Down
4 changes: 2 additions & 2 deletions src/etc/udev/rules.d/97-kobocloud.rules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
KERNEL=="eth*", RUN+="/usr/local/kobocloud/udev_program.sh"
KERNEL=="wlan*", RUN+="/usr/local/kobocloud/udev_program.sh"
KERNEL=="eth*", ACTION=="add", RUN+="/usr/local/kobocloud/udev_program.sh"
KERNEL=="wlan*", ACTION=="add", RUN+="/usr/local/kobocloud/udev_program.sh"
KERNEL=="lo", RUN+="/usr/local/kobocloud/udev_mount.sh"

590 changes: 371 additions & 219 deletions src/usr/local/kobocloud/ca-bundle.crt

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions src/usr/local/kobocloud/config.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#!/bin/bash

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\" "
2 changes: 1 addition & 1 deletion src/usr/local/kobocloud/config_pc.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
Logs=/tmp/KoboCloud
Lib=/tmp/KoboCloud/Library
SD=/tmp/KoboCloud
SD=/tmp/KoboCloud/sd
UserConfig=/tmp/KoboCloud/kobocloudrc
Dt="date +%Y-%m-%d_%H:%M:%S"
CURL=/usr/bin/curl
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
3 changes: 3 additions & 0 deletions src/usr/local/kobocloud/kobocloudrc.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Add your URLs to this file
# Remove the # from the following line to uninstall KoboCloud
#UNINSTALL
12 changes: 8 additions & 4 deletions src/usr/local/kobocloud/udev_mount.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
#!/bin/sh
#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

if [ ! -e $UserConfig ]; then
echo "# Add your URLs to this file" > $UserConfig
echo "# Remove the # from the following line to uninstall KoboCloud" >> $UserConfig
echo "#UNINSTALL" >> $UserConfig
if [ -e $ConfigFile ]; then
cp $ConfigFile $UserConfig
else
echo "# Add your URLs to this file" > $UserConfig
echo "# Remove the # from the following line to uninstall KoboCloud" >> $UserConfig
echo "#UNINSTALL" >> $UserConfig
fi
fi

#bind mount to subfolder of SD card on reboot
Expand Down
11 changes: 7 additions & 4 deletions src/usr/local/kobocloud/udev_program.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
#!/bin/sh

if [ "$ACTION" != "add" ]; then
exit 1
# udev kills slow scripts
if [ "$SETSID" != "1" ]
then
SETSID=1 setsid "$0" "$@" &
exit
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 &
4 changes: 4 additions & 0 deletions updateCABundle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

curl -o src/usr/local/kobocloud/ca-bundle.crt https://curl.haxx.se/ca/cacert.pem

0 comments on commit 654b682

Please sign in to comment.