Skip to content

Commit

Permalink
Add an option to remove curl verbose in log. Logs will be smaller
Browse files Browse the repository at this point in the history
  • Loading branch information
ospring committed Dec 10, 2024
1 parent 6cd647c commit 5b26838
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
6 changes: 6 additions & 0 deletions local_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

SERVICE=$1
TEST_DELETED=$2
NO_CURL_VERBOSE=$3


TestFiles=("ulysses.epub" "01/ulysses.epub" "01/ulysses01.epub" "02/ulysses.epub" "02/ulysses02.epub")
Expand Down Expand Up @@ -80,6 +81,11 @@ then
touch "$Lib/delete_me.epub"
touch "$Lib/01/delete_me.epub"
fi
if [ "$NO_CURL_VERBOSE" = true ]
then
echo "No verbose for curl"
echo "NO_CURL_VERBOSE" >> $UserConfig
fi

src/usr/local/kobocloud/get.sh TEST

Expand Down
6 changes: 4 additions & 2 deletions src/usr/local/kobocloud/get.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ TEST=$1

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

export UserConfig
#check if Kobocloud contains the line "UNINSTALL"
if grep -q '^UNINSTALL$' $UserConfig; then
echo "Uninstalling KoboCloud!"
Expand Down Expand Up @@ -57,7 +57,9 @@ while read url || [ -n "$url" ]; do
if echo "$url" | grep -q '^#'; then
echo "Comment found"
elif echo "$url" | grep -q "^REMOVE_DELETED$"; then
echo "Will match remote"
echo "Will match remote"
elif echo "$url" | grep -q "^NO_CURL_VERBOSE$"; then
echo "Will have no verbose for curl"
else
echo "Getting $url"
if echo $url | grep -q '^https*://www.dropbox.com'; then # dropbox link?
Expand Down
13 changes: 11 additions & 2 deletions src/usr/local/kobocloud/getRemoteFile.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
#!/bin/sh

retry="TRUE"
curl_verbose="TRUE"

if [ "$1" = "NORETRY" ]
then
retry="FALSE"
shift 1
fi

if grep -q '^NO_CURL_VERBOSE$' $UserConfig; then
curl_verbose="FALSE"
fi

linkLine="$1"
localFile="$2"
user="$3"
Expand Down Expand Up @@ -38,8 +43,12 @@ echo "Download:" $curlCommand -k --silent -C - -L --create-dirs --remote-time -o
eval $curlCommand -k --silent -C - -L --create-dirs --remote-time -o \"$localFile\" \"$linkLine\" -v 2>$outputFileTmp
status=$?
echo "Status: $status"
echo "Output: "
cat $outputFileTmp

if [ "$curl_verbose" = "TRUE" ]
then
echo "Output: "
cat $outputFileTmp
fi

statusCode=`grep 'HTTP/' "$outputFileTmp" | tail -n 1 | cut -d' ' -f3`
grep -q "Cannot resume" "$outputFileTmp"
Expand Down
2 changes: 2 additions & 0 deletions src/usr/local/kobocloud/udev_mount.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ 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
echo "# Remove the # from the following line to have less curl verbose in log" >> $UserConfig
echo "#NO_CURL_VERBOSE" >> $UserConfig
fi
fi

Expand Down

0 comments on commit 5b26838

Please sign in to comment.