Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions containers/base/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ COPY entrypoint.sh /entrypoint.sh
COPY fix_user.sh $ENTRYPOINT_DIR/00_fix_user.sh
COPY login_shim.sh $ENTRYPOINT_DIR/01_login_shim.sh

# Add ~/.bashrc.d support to the user's ~/.bashrc
COPY bashrcd_fragment.bash /tmp/bashrcd_fragment.bash
RUN cat /tmp/bashrcd_fragment.bash >> $DEV_USER_HOME/.bashrc \
&& sudo -u $DEV_USER mkdir -m 755 $DEV_USER_HOME/.bashrc.d

# Here we set the entry point to the main entry point script. This script in
# turn execs a chain of other entry points. This allows other images to layer
# their own entry points onto the original entry point.
Expand Down
25 changes: 25 additions & 0 deletions containers/base/bashrcd_fragment.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

########## BASHRC.D BEGIN ##########
declare -a brc_files
bashrc_d="$HOME/.bashrc.d"
if [[ -d $bashrc_d ]]; then
readarray -t -d '' brc_files < \
<(find $bashrc_d -type f -regex '.*\.\(ba\)?sh$' -print0 | LC_ALL=C sort -z)
fi
declare -A brc_elapsed
for brc_file in "${brc_files[@]}"; do
start_time=$EPOCHREALTIME
source "$brc_file"
end_time=$EPOCHREALTIME
brc_elapsed["$brc_file"]=$(awk 'BEGIN {printf "%.2f", '"($end_time - $start_time)}")
done
: "${BASHRC_D_PROFILE:=0}"
if [[ $BASHRC_D_PROFILE -ne 0 ]] && [[ ${#brc_elapsed[@]} -gt 0 ]]; then
echo "Elapsed time to source '.bashrc.d':"
for brc_file in "${!brc_elapsed[@]}"; do
printf "%s %s\n" "${brc_elapsed[$brc_file]}" "$(basename "$brc_file")"
done | sort -rn | while read -r time name; do
printf " - %-20s %10s seconds\n" "$name" "$time"
done
fi
########### BASHRC.D END ###########