Files
apk/dist/init_rc.sh

33 lines
771 B
Bash
Raw Normal View History

2025-12-09 16:20:00 +01:00
#!/bin/bash
# detect if either .bashrc or .zshrc is present
2025-12-09 17:07:20 +01:00
# 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"
2025-12-09 16:20:00 +01:00
else
2025-12-09 17:07:20 +01:00
touch "/home/$BUILD_USER/.bashrc"
SHELL_RC="/home/$BUILD_USER/.bashrc"
2025-12-09 16:20:00 +01:00
fi
echo "Using shell rc file: $SHELL_RC"
# Check if content already exists in the shell rc file and if not, append it
2025-12-09 17:07:20 +01:00
cat /home/"$BUILD_USER"/"$SHELL_RC" | if ! grep -q "ANDROID_HOME" ; then
cat dist/.baserc >> /home/"$BUILD_USER"/"$SHELL_RC" fi
2025-12-09 17:07:20 +01:00
source /home/"$BUILD_USER"/"$SHELL_RC"