33 lines
771 B
Bash
33 lines
771 B
Bash
#!/bin/bash
|
|
|
|
# detect if either .bashrc or .zshrc is present
|
|
|
|
|
|
# check if user is root and change user to builder
|
|
TEMP_USER="builder"
|
|
|
|
if [ "$EUID" -eq 0 ]; then
|
|
BUILD_USER="$TEMP_USER"
|
|
else
|
|
BUILD_USER="$USER"
|
|
fi
|
|
|
|
|
|
if [ -f "/home/$BUILD_USER/.bashrc" ]; then
|
|
SHELL_RC="/home/$BUILD_USER/.bashrc"
|
|
elif [ -f "/home/$BUILD_USER/.zshrc" ]; then
|
|
SHELL_RC="/home/$BUILD_USER/.zshrc"
|
|
else
|
|
touch "/home/$BUILD_USER/.bashrc"
|
|
SHELL_RC="/home/$BUILD_USER/.bashrc"
|
|
fi
|
|
|
|
echo "Using shell rc file: $SHELL_RC"
|
|
|
|
# Check if content already exists in the shell rc file and if not, append it
|
|
|
|
cat /home/"$BUILD_USER"/"$SHELL_RC" | if ! grep -q "ANDROID_HOME" ; then
|
|
cat dist/.baserc >> /home/"$BUILD_USER"/"$SHELL_RC" fi
|
|
|
|
source /home/"$BUILD_USER"/"$SHELL_RC"
|