forked from Ankermgmt/ankermake-m5-protocol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-import.sh
executable file
·47 lines (41 loc) · 1.55 KB
/
docker-import.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
#!/bin/sh
set -e
if [ $# -eq 0 ]; then
CONTAINER="ankerctl"
elif [ $# -eq 1 ]; then
CONTAINER="$1"
else
echo "usage: $0 [container-name]"
echo ""
echo " Attempt to auto-import AnkerMake Slicer credentials"
echo " ('login.json') into the specified docker container."
echo ""
echo " Container name default to 'ankerctl' if unspecified."
exit 1
fi
if [ "$(docker container inspect -f "{{.State.Status}}" "${CONTAINER}")" != "running" ]; then
echo ""
echo ">> Container ${CONTAINER} is not running. Please start container before running this script! <<"
exit 1
fi
WINEPREFIX=${WINEPREFIX:-$HOME/.wine}
for root in "${APPDATA}" "${HOME}"; do
for prefix in "Library/Application Support" "$WINEPREFIX/drive_c/users/${USER}/AppData/Local"; do
for suffix in "AnkerMake/AnkerMake_64bit_fp/login.json" "Ankermake/AnkerMake_64bit_fp/login.json"; do
name="$root/$prefix/$suffix";
if [ -f "${name}" ]; then
echo "** Importing ${name} credentials **";
docker cp -L "${name}" ${CONTAINER}:/tmp
if docker exec -it ${CONTAINER} /app/ankerctl.py -k config import /tmp/login.json; then
echo "Configuration imported successfully. Restarting container..."
docker restart ${CONTAINER}
exit $?
else
echo "Configuration import failed :("
fi
else
echo "** No ${name} credentials detected **";
fi
done
done
done