forked from RDJV/JottaCloudDockerSynology
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
86 lines (66 loc) · 1.78 KB
/
entrypoint.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
#!/bin/bash
# set timezone
rm /etc/localtime
ln -s /usr/share/zoneinfo/$LOCALTIME /etc/localtime
# make sure we are running the latest version of jotta-cli
apt-get update
apt-get install jotta-cli
apt-get autoremove -y
apt-get clean
rm -rf /var/lib/lists/*
# set the jottad user and group id
usermod -u $PUID jottad
usermod --gid $PGID jottad
usermod -a -G $JOTTAD_USER $JOTTAD_GROUP
# start the service
systemctl start jottad
# wait for service to fully start
sleep 5
if [[ "$(jotta-cli status)" =~ ERROR.* ]]; then
echo "First time login"
# Login user
/usr/bin/expect -c "
set timeout 20
spawn jotta-cli login
expect \"accept license (yes/no): \" {send \"yes\n\"}
expect \"Personal login token: \" {send \"$JOTTA_TOKEN\n\"}
expect \"Devicename*: \" {send \"$JOTTA_DEVICE\n\"}
expect \"*device*: \" {send \"$JOTTA_DEVICE_FOUND\n\"}
expect eof
"
# add backup volume
jotta-cli add /backup
jotta-cli add /backup
else
echo "User is logged in"
fi
# load ignore file
if [ -f /config/ignorefile ]; then
echo "loading ignore file"
jotta-cli ignores set /config/ignorefile
fi
# set scan interval
echo "Setting scan interval"
jotta-cli config set scaninterval $JOTTA_SCANINTERVAL
# set download channels
echo "Setting download channels"
jotta-cli config set maxdownloads $JOTTA_MAXDOWNLOADS
# set upload slots
echo "Setting upload channels"
jotta-cli config set maxuploads $JOTTA_MAXUPLOADS
# set download rate
echo "Setting download rate"
jotta-cli config set downloadrate $JOTTA_DOWNLOADRATE
# set upload rate
echo "Setting upload rate"
jotta-cli config set uploadrate $JOTTA_UPLOADRATE
R=0
while [[ $R -eq 0 ]]
do
sleep 15
jotta-cli status >/dev/null 2>&1
R=$?
done
echo "Exiting:"
jotta-cli status
exit 1