: "profile start"

# a function is created for sourcing the profile to allow the command "local" to be used
# that allow the "vx" to be disabled only for the current function and define local variables
get_profile() {
    local - files file
    
    set +vx
    # add debug path if not already set
    [ "${PATH/*sbin*/found}" != "found" ] && export PATH="/sbin:/usr/sbin${PATH+:$PATH}"
    [ "${PATH/*debug*/found}" != "found" ] && export PATH="/var/run/debug:${PATH+$PATH:}/usr/sbin/debug"
    [ -z "${PHONE_MODEL:-}" ] && export PHONE_MODEL=$(CLISettings get CURRENT FAB_PHONE_MODEL)
    
    # list the files to source
    files=$(busybox find /etc/profile.d /etc/profile.d_$PHONE_MODEL /tmp/profile.d -type f -name "*.sh" 2>/dev/null)

    # source them
    for file in $files; do
        source $file
    done
}

get_profile
: "profile end"
