46 lines
1.3 KiB
Bash
Executable File
46 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Ensure machine ID is randomized for personal license activation
|
|
if [[ "$UNITY_SERIAL" = F* ]]; then
|
|
echo "Randomizing machine ID for personal license activation"
|
|
dbus-uuidgen > /etc/machine-id && mkdir -p /var/lib/dbus/ && ln -sf /etc/machine-id /var/lib/dbus/machine-id
|
|
fi
|
|
|
|
if [[ "$RUN_AS_HOST_USER" == "true" ]]; then
|
|
echo "Running as host user"
|
|
|
|
fullProjectPath="$GITHUB_WORKSPACE/$PROJECT_PATH"
|
|
|
|
# Stop on error if we can't set up the user
|
|
set -e
|
|
|
|
# Get host user/group info so we create files with the correct ownership
|
|
USERNAME=$(stat -c '%U' "$fullProjectPath")
|
|
USERID=$(stat -c '%u' "$fullProjectPath")
|
|
GROUPNAME=$(stat -c '%G' "$fullProjectPath")
|
|
GROUPID=$(stat -c '%g' "$fullProjectPath")
|
|
|
|
groupadd -g $GROUPID $GROUPNAME
|
|
useradd -u $USERID -g $GROUPID $USERNAME
|
|
usermod -aG $GROUPNAME $USERNAME
|
|
mkdir -p "/home/$USERNAME"
|
|
chown $USERNAME:$GROUPNAME "/home/$USERNAME"
|
|
|
|
# Normally need root permissions to access when using su
|
|
chmod 777 /dev/stdout
|
|
chmod 777 /dev/stderr
|
|
|
|
# Don't stop on error when running our scripts as error handling is baked in
|
|
set +e
|
|
|
|
# Switch to the host user so we can create files with the correct ownership
|
|
su $USERNAME -c "$SHELL -c 'source /steps/run_steps.sh'"
|
|
else
|
|
echo "Running as root"
|
|
|
|
# Run as root
|
|
source /steps/run_steps.sh
|
|
fi
|
|
|
|
exit $?
|