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.

46 lines
1.1 KiB

#!/usr/bin/env miaou-bash
# CONSTANTS
readonly REQUIRED_PKGS=(file jq vim)
readonly ORIGINAL="ORIGINAL"
readonly PREDEFINED_CONFIG_FILES=(/etc/bash.bashrc /etc/inputrc)
# FUNCTIONS
function required_packages {
"$MIAOU_BASH_DIR/tools/idem_apt_install" "${REQUIRED_PKGS[@]}"
}
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}/etc/$(basename "$i")"
if [[ -L "$i" ]]; then
if [[ "$(readlink "$i")" == "${miaou_file}" ]]; then
echo "$i => MIAOU_BASH_DIR already set!"
else
ln -sf "${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
}
# MAIN
[ "$UID" -ne 0 ] && echo 'root privilege required' && exit 1
source "$MIAOU_BASH_DIR/lib/functions.bash"
required_packages
no_more_skeleton
predefine_config_files