fix(activate): only exit if activation fails

This commit is contained in:
Jibbajabbafic 2020-01-15 21:48:01 +00:00 committed by Webber Takken
parent a6607a341e
commit d27df56d26

View File

@ -1,6 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Try personal activation
if [[ -n "$UNITY_LICENSE" ]]; then if [[ -n "$UNITY_LICENSE" ]]; then
LICENSE_MODE="personal"
# #
# PERSONAL LICENSE MODE # PERSONAL LICENSE MODE
# #
@ -42,23 +44,12 @@ if [[ -n "$UNITY_LICENSE" ]]; then
# TODO - Derive exit code by grepping success statement # TODO - Derive exit code by grepping success statement
UNITY_EXIT_CODE=$(echo $ACTIVATION_OUTPUT | grep 'config is NOT valid, switching to default' | wc -l) UNITY_EXIT_CODE=$(echo $ACTIVATION_OUTPUT | grep 'config is NOT valid, switching to default' | wc -l)
# 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 # Remove license file
rm -f $FILE_PATH rm -f $FILE_PATH
# Exit with the code from the license verification step # Try professional activation
if [ $UNITY_EXIT_CODE -ne 0 ]; then
exit $UNITY_EXIT_CODE
fi
elif [[ -n "$UNITY_SERIAL" && -n "$UNITY_EMAIL" && -n "$UNITY_PASSWORD" ]]; then elif [[ -n "$UNITY_SERIAL" && -n "$UNITY_EMAIL" && -n "$UNITY_PASSWORD" ]]; then
LICENSE_MODE="professional"
# #
# PROFESSIONAL (SERIAL) LICENSE MODE # PROFESSIONAL (SERIAL) LICENSE MODE
# #
@ -66,6 +57,7 @@ elif [[ -n "$UNITY_SERIAL" && -n "$UNITY_EMAIL" && -n "$UNITY_PASSWORD" ]]; then
# #
# Note: This is the preferred way for PROFESSIONAL LICENSES. # Note: This is the preferred way for PROFESSIONAL LICENSES.
# #
xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \ xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \
/opt/Unity/Editor/Unity \ /opt/Unity/Editor/Unity \
-batchmode \ -batchmode \
@ -79,18 +71,8 @@ elif [[ -n "$UNITY_SERIAL" && -n "$UNITY_EMAIL" && -n "$UNITY_PASSWORD" ]]; then
# Store the exit code from the verify command # Store the exit code from the verify command
UNITY_EXIT_CODE=$? UNITY_EXIT_CODE=$?
# Display information about the result # Exit since personal and professional modes failed
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
else else
# Exit since no license and no serial number provided!
echo "No personal or professional licenses provided!" echo "No personal or professional licenses provided!"
echo "Please ensure you have setup one of these licensing methods:" echo "Please ensure you have setup one of these licensing methods:"
echo " - Personal: Set the UNITY_LICENSE environment variable." echo " - Personal: Set the UNITY_LICENSE environment variable."
@ -98,3 +80,13 @@ else
echo "See https://github.com/webbertakken/unity-builder#usage for details." echo "See https://github.com/webbertakken/unity-builder#usage for details."
exit 1; exit 1;
fi fi
# Display information about the result
if [ $UNITY_EXIT_CODE -eq 0 ]; then
echo "Activation ($LICENSE_MODE) complete."
else
# Exit with the code from the license verification step
echo "Unclassified error occured while trying to activate ($LICENSE_MODE) license."
echo "Exit code was: $UNITY_EXIT_CODE"
exit $UNITY_EXIT_CODE
fi