-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·54 lines (46 loc) · 1.54 KB
/
setup.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
#!/bin/sh
set -e
SETUP_CONF="${SPIDEROAK_STATEDIR}/setup.conf"
remove_setup_config() {
rm -f "$SETUP_CONF"
}
trap remove_setup_config EXIT
SPIDEROAK_ONE="/usr/bin/SpiderOakONE"
if [ -z "$SPIDEROAK_USER" ] && [ -r "/docker/secrets/spideroak_user.conf" ]; then
SPIDEROAK_USER="$(base64 -d < "/docker/secrets/spideroak_user.conf")"
fi
if [ -z "$SPIDEROAK_PASSWORD" ] && [ -r "/docker/secrets/spideroak_password.conf" ]; then
SPIDEROAK_PASSWORD="$(base64 -d < "/docker/secrets/spideroak_password.conf")"
fi
if [ -z "$SPIDEROAK_DEVICE" ] && [ -r "/docker/configs/spideroak_device.conf" ]; then
SPIDEROAK_DEVICE="$(cat "/docker/configs/spideroak_device.conf")"
fi
if [ -z "$SPIDEROAK_USER" ]; then
echo "spideroak_user.conf not properly set-up and mounted"
exit 1
fi
if [ -z "$SPIDEROAK_PASSWORD" ]; then
echo "spideroak_password.conf not properly set-up and mounted"
exit 1
fi
if [ -z "$SPIDEROAK_DEVICE" ]; then
echo "spideroak_device.conf not properly set-up and mounted"
exit 1
fi
echo "Backup mounts:"
mount | awk '{print $3}' | grep "^$SPIDEROAK_BACKUPDIR"
if [ ! -f "$SPIDEROAK_STATEDIR/local.dat" ]; then
{
echo "{"
echo "\"username\":\"${SPIDEROAK_USER}\","
echo "\"password\":\"${SPIDEROAK_PASSWORD}\","
echo "\"device_name\":\"${SPIDEROAK_DEVICE}\","
echo "\"reinstall\":false"
echo "}"
} > "$SETUP_CONF"
"$SPIDEROAK_ONE" --setup="$SETUP_CONF"
remove_setup_config
else
echo "Previous configuration exists; please remove before proceeding"
exit 1
fi