forked from fsantini/KoboCloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
local_test.sh
executable file
·113 lines (102 loc) · 2.68 KB
/
local_test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
SERVICE=$1
TEST_DELETED=$2
TestFiles=("ulysses.epub" "01/ulysses.epub" "01/ulysses01.epub" "02/ulysses.epub" "02/ulysses02.epub")
sha1=d07c5da10d4666766d1b796ba420cffca0ac440c
TestSubdirs=false
if [ "$SERVICE" = "dropbox" ]
then
URL='https://www.dropbox.com/sh/qql9j10qldxfvkx/AAB6Fl2AEL78gD27fUNfEgJQa'
elif [ "$SERVICE" = "pcloud" ]
then
URL='https://u.pcloud.link/publink/show?code=kZBWSsXZPYXgN8YJtmjGSKNCQERxG80M2WiX'
elif [ "$SERVICE" = "box" ]
then
URL='https://app.box.com/s/1y5e82xbyksuywamih7vu08yaiefqm65'
elif [ "$SERVICE" = "nextcloud" ]
then
##URL: domain.com/
URL='https://nc01.adruna.org/s/XmtwFWBYxjNobGA'
elif [ "$SERVICE" = "nextcloudpath" ]
then
##URL: domain.com/nextcloud/
URL='https://nc02.adruna.org/nextcloud/s/7zMe6kjyEHKr4TL'
elif [ "$SERVICE" = "nextcloudsubdir" ]
then
##URL: domain.com/
##Test scenario:
##main/
# ├── 01/
# │ ├── ulysses.epub
# │ ├── ulysses01.epub
# ├── 02/
# │ ├── ulysses.epub
# │ ├── ulysses02.epub
│ # ├── ulysses.epub
URL='https://nc01.adruna.org/s/Y72RfYJM79jct8N'
TestSubdirs=true
elif [ "$SERVICE" = "nextcloudsubdirpath" ]
then
##URL: domain.com/nextcloud
##Test scenario:
##main/
# ├── 01/
# │ ├── ulysses.epub
# │ ├── ulysses01.epub
# ├── 02/
# │ ├── ulysses.epub
# │ ├── ulysses02.epub
│ # ├── ulysses.epub
URL='https://nc02.adruna.org/nextcloud/s/wsA7DSNjfYgBmw4'
TestSubdirs=true
elif [ "$SERVICE" = "gdrive" ]
then
URL='https://drive.google.com/drive/folders/1Wi37shmjG56L1D8OSdIZstkUfnpTsdAp'
TestSubdirs=true
else
echo "Unknown service"
exit 1
fi
. src/usr/local/kobocloud/config_pc.sh
mkdir -p $Lib
for file in ${TestFiles[@]}
do
rm "$Lib/$file"
done
echo $URL > $UserConfig
if [ "$TEST_DELETED" = true ]
then
echo "Testing for deleted files"
echo "REMOVE_DELETED" >> $UserConfig
mkdir -p "$Lib/01"
touch "$Lib/delete_me.epub"
touch "$Lib/01/delete_me.epub"
fi
src/usr/local/kobocloud/get.sh TEST
if [ "$TEST_DELETED" = true ]
then
if [ -f "$Lib/delete_me.epub" ] || [ -f "$Lib/01/delete_me.epub" ]
then
echo "Files not deleted!"
exit 1
else
echo "Files deleted successfully"
fi
fi
for file in ${TestFiles[@]}
do
echo "Testing $file"
if sha1sum $Lib/$file | grep $sha1
then
echo OK
if [ "$TestSubdirs" != true ] # if we only want to test one file, exit
then
exit 0
fi
else
echo Failed
exit 1
fi
done
# if we reached here, we are good
exit 0