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. 21
      precise/base-0k/hooks/install.d/30-customize.sh

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

@ -18,13 +18,21 @@ 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\]" 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 EOF
if [ -f /root/.bashrc.pre-install ]; then
cp /root/.bashrc.pre-install /root/.bashrc
else
cp /root/.bashrc /root/.bashrc.pre-install
fi
protect_pre_install() {
local filename="$1"
if [ -f "$filename".pre-install ]; then
cp "$filename".pre-install "$filename"
else
if ! [ -e "$filename" ]; then
touch "$filename"
fi
cp "$filename" "$filename".pre-install
fi
}
protect_pre_install "/root/.bashrc"
if ! type -p fzf; then if ! type -p fzf; then
@ -119,6 +127,9 @@ export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
EOF EOF
protect_pre_install "/root/.bash_profile"
cat <<EOF >> /root/.bash_profile cat <<EOF >> /root/.bash_profile
## XXXvlab: ## XXXvlab:

Loading…
Cancel
Save