Browse Source

fix: [base] avoid appending new bits of code in ``~/.bash_profile``

This script was not idempotent, and that was an oversight.
boris/docuseal
Valentin Lab 1 year ago
parent
commit
12a0c75b96
  1. 17
      precise/base-0k/hooks/install.d/30-customize.sh

17
precise/base-0k/hooks/install.d/30-customize.sh

@ -18,12 +18,20 @@ parse_git_branch() {
export PS1="\[\033[0;37m\][\[\033[1;30m\]\u\[\033[0;37m\]@\[\033[1;30m\]\H\[\033[0;37m\]]-[\[\033[1;34m\]\w\[\033[0;37m\]]\\\$(parse_git_branch)\n\[\033[1;37m\]\\$ \[\033[0;37m\]"
EOF
if [ -f /root/.bashrc.pre-install ]; then
cp /root/.bashrc.pre-install /root/.bashrc
protect_pre_install() {
local filename="$1"
if [ -f "$filename".pre-install ]; then
cp "$filename".pre-install "$filename"
else
cp /root/.bashrc /root/.bashrc.pre-install
if ! [ -e "$filename" ]; then
touch "$filename"
fi
cp "$filename" "$filename".pre-install
fi
}
protect_pre_install "/root/.bashrc"
if ! type -p fzf; then
@ -119,6 +127,9 @@ export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
EOF
protect_pre_install "/root/.bash_profile"
cat <<EOF >> /root/.bash_profile
## XXXvlab:

Loading…
Cancel
Save