-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.sh
42 lines (37 loc) · 1.25 KB
/
upload.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
#!/bin/bash
####### VARIABLES BEGIN #######
# Define the variables - use the following lines in this section as the settings
## Folder where you intend to save the files to be uploaded to the remarkable cloud
WATCH_FOLDER="/root/sync/sync"
## Path to rmapi (use the command "whereis rmapi" to find it out)
RMAPI_PATH="/root/go/bin/rmapi"
## Path to the configuration file of rmapi
RMAPI_CONFIG_PATH="/root/.config/rmapi/rmapi.conf"
## Link to your rmfakecloud installation or just use rmCloud link
RMAPI_HOST="https://remarkable.mydomain.com"
## Define path to rmapi (use the command "whereis rmapi" to find out)
RMAPI_UPLOAD_CMD="/root/go/bin/rmapi -ni put"
SLEEP_TIME=10
####### VARIABLES END #######
####### SCRIPT BEGIN #######
uploaded_files=()
while true; do
new_files=()
for file in "$WATCH_FOLDER"/*.pdf; do
if ! [[ "${uploaded_files[*]}" =~ "${file}" ]]; then
new_files+=("$file")
fi
done
for file in "${new_files[@]}"; do
sleep $SLEEP_TIME
if RMAPI_CONFIG=$RMAPI_CONFIG_PATH RMAPI_HOST=$RMAPI_HOST $RMAPI_UPLOAD_CMD "$file"; then
echo "Successfully uploaded $file"
uploaded_files+=("$file")
rm "$file"
else
echo "Upload failed for $file"
fi
####### SCRIPT END #######
done
sleep $SLEEP_TIME
done