-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathentrypoint.sh
executable file
·52 lines (45 loc) · 1.74 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
#!/bin/bash
if [[ -z "${START_DATE}" ]] || [ "$START_DATE" = "YYYY-MM-DD" ]; then
echo "START_DATE variable is not set, please do so before using this image"
exit
elif [[ -z "${NS_HOST}" ]] || [ "$NS_HOST" = "https://mynightscout.azurewebsites.net" ]; then
echo "NS_HOST variable is not set, please do so before using this image"
exit
fi
if [[ -z "${AUTOTUNE_PREFS}" ]] || [ "$AUTOTUNE_PREFS" = "" ]; then
echo "No extra preferences supplied"
else
echo "Extra preferences: [${AUTOTUNE_PREFS}]"
fi
if ! [[ -s /data/profile.json ]]; then
echo "No profile.json detected, please specify a volume mount for '/data/' and create 'profile.json' in the mount"
exit
else
cp /data/profile.json /openaps/settings/profile.json
cp /data/profile.json /openaps/settings/pumpprofile.json
cp /data/profile.json /openaps/settings/autotune.json
fi
TIMEZONE="$(jq '.timezone' /data/profile.json | tr -d \")"
echo "TIMEZONE: ${TIMEZONE}"
if [[ "${TIMEZONE}" = "null" ]]; then
echo "No timezone detected in profile, exiting as to not provide inaccurate results"
exit
else
if [[ -f /usr/share/zoneinfo/"${TIMEZONE}" ]]; then
cp /usr/share/zoneinfo/"${TIMEZONE}" /etc/localtime
else
echo "Nonexistent timezone specified, exiting"
exit
fi
fi
date
id
ls -l /data /openaps
oref0-autotune --dir=/openaps --ns-host="${NS_HOST}" --start-date="${START_DATE}" ${AUTOTUNE_PREFS}
if ! [[ -s /openaps/autotune/autotune_recommendations.log ]]; then
echo "No recommendations found, perhaps the command failed?"
else
cp /openaps/autotune/autotune_recommendations.log /data/autotune_recommendations.log
cp /openaps/autotune/profile.json /data/autotune-profile.json
echo "Recommendations copied to /data/autotune_recommendations.log, check your volume mount"
fi