forked from MirageNet/unity-runner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
activate.sh
executable file
·97 lines (83 loc) · 2.61 KB
/
activate.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
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env bash
if [[ -n "$UNITY_LICENSE" ]]; then
#
# PERSONAL LICENSE MODE
#
# This will activate Unity, using a license file
#
# Note that this is the ONLY WAY for PERSONAL LICENSES in 2019.
# * See for more details: https://gitlab.com/gableroux/unity3d-gitlab-ci-example/issues/5#note_72815478
#
# The license file can be acquired using `webbertakken/request-manual-activation-file` action.
# Set the license file path
FILE_PATH=UnityLicenseFile.ulf
# Copy license file from Github variables
echo "$UNITY_LICENSE" | tr -d '\r' > $FILE_PATH
##
## Activate license
##
echo "Requesting activation"
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
/opt/unity/Editor/Unity \
-batchmode \
-nographics \
-logFile /dev/stdout \
-quit \
-manualLicenseFile $FILE_PATH
# This is expected to always exit with code 1 (both success and failure).
# Convert to exit code 0 by echoing the current exit code.
echo $?
# Exit code is now 0
##
## Verify activated license
##
echo "Verifying activation"
# Run any command that requires activation to verify
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
/opt/unity/Editor/Unity \
-batchmode \
-nographics \
-logFile /dev/stdout \
-quit
# Store the exit code from the verify command
UNITY_EXIT_CODE=$?
# Display information about the result
if [ $UNITY_EXIT_CODE -eq 0 ]; then
echo "Activation (personal) complete."
else
echo "Unclassified error occured while trying to activate (personal) license."
echo "Exit code was: $UNITY_EXIT_CODE"
fi
# Remove license file
rm -f $FILE_PATH
# Exit with the code from the license verification step
exit $UNITY_EXIT_CODE
else
#
# PROFESSIONAL (SERIAL) LICENSE MODE
#
# This will activate unity, using the activating process.
#
# Note: This is the preferred way for PROFESSIONAL LICENSES.
#
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
/opt/unity/Editor/Unity \
-batchmode \
-nographics \
-logFile /dev/stdout \
-quit \
-serial "$UNITY_SERIAL" \
-username "$UNITY_EMAIL" \
-password "$UNITY_PASSWORD"
# Store the exit code from the verify command
UNITY_EXIT_CODE=$?
# Display information about the result
if [ $UNITY_EXIT_CODE -eq 0 ]; then
echo "Activation (professional) complete."
else
echo "Unclassified error occured while trying to activate (professional) license."
echo "Exit code was: $UNITY_EXIT_CODE"
fi
# Exit with the code from the license verification step
exit $UNITY_EXIT_CODE
fi