MIAOU-BASH is a collection of settings and helpers for leveraging BASH. Developer-friendly, it may be used as solo package with or without the miaou project.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

50 lines
1.2 KiB

#!/bin/bash
# CONSTANTS
MIAOU_BASH_DIR=${MIAOU_BASH_DIR:-/opt/miaou-bash}
ORIGINAL="ORIGINAL"
PREDEFINED_CONFIG_FILES=(/etc/bash.bashrc /etc/inputrc /etc/vim/vimrc)
readonly MIAOU_BASH_DIR ORIGINAL
# FUNCTIONS
function no_more_skeleton {
[[ -e /etc/skel/.bashrc ]] && rm /etc/skel/.bashrc && echo "skeleton .bashrc removed!"
true
}
function predefine_config_files {
for i in "${PREDEFINED_CONFIG_FILES[@]}"; do
local miaou_file
miaou_file="${MIAOU_BASH_DIR}/$(basename "$i")"
if [[ -L "$i" ]]; then
if [[ "$(readlink "$i")" == "${miaou_file}" ]]; then
echo "$i => MIAOU_BASH_DIR already set!"
else
rm "$i"
ln -s "${miaou_file}" "$i"
echo "$i => MIAOU_BASH_DIR freshly defined."
fi
else
mv "$i" "$i.$ORIGINAL"
ln -s "${miaou_file}" "$i"
echo "$i => MIAOU_BASH_DIR freshly defined + .ORIGINAL backuped"
fi
done
}
function bin_miaou_bash {
[[ ! -e /usr/bin/miaou-bash ]] &&
ln -s "$MIAOU_BASH_DIR/bin/miaou-bash" /usr/bin/ &&
echo "miaou-bash globally defined!"
}
# MAIN
set -TEeu -o pipefail
[ "$(id -u)" -ne 0 ] && echo 'root privilege required' && exit 1
no_more_skeleton
predefine_config_files
bin_miaou_bash