diff /etc/skel/.bashrc
This commit is contained in:
+19
-10
@@ -26,24 +26,33 @@ function install_required_packages {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function fix_users_bashrc {
|
function fix_users_bashrc {
|
||||||
# for new users
|
if [[ -f /etc/skel/.bashrc ]] && ! cmp -s /etc/skel/.bashrc "$MIAOU_BASH_DIR"/etc/skel/.bashrc; then
|
||||||
if ! cmp -s /etc/skel/.bashrc "$MIAOU_BASH_DIR"/etc/skel/.bashrc; then
|
local skel_count_lines=$(wc -l /etc/skel/.bashrc)
|
||||||
[[ -f /etc/skel/.bashrc ]] && sudo mv /etc/skel/.bashrc /etc/skel/.bashrc.ORIGINAL
|
local appended_regex="^${skel_count_lines}a"
|
||||||
sudo ln -sf "$MIAOU_BASH_DIR"/etc/skel/.bashrc /etc/skel/.bashrc
|
|
||||||
|
|
||||||
# for pre-existant users
|
# for pre-existant users
|
||||||
build_associative_user_homes
|
build_associative_user_homes
|
||||||
for user in "${!USER_HOMES[@]}"; do
|
for user in "${!USER_HOMES[@]}"; do
|
||||||
local user_bashrc="${USER_HOMES[$user]}/.bashrc"
|
local user_bashrc="${USER_HOMES[$user]}/.bashrc"
|
||||||
[[ ! -f "$user_bashrc" ]] && next
|
[[ ! -f "$user_bashrc" ]] && next
|
||||||
cmp -s "$user_bashrc" "$MIAOU_BASH_DIR"/etc/skel/.bashrc && next
|
cmp -s "$user_bashrc" /etc/skel/.bashrc && next
|
||||||
|
|
||||||
local backup="$user_bashrc".ORIGINAL
|
local first_change
|
||||||
sudo -u "$user" -- mv "$user_bashrc" "$backup"
|
first_change=$(diff /etc/skel/.bashrc "$user" | head -n1)
|
||||||
sudo -u "$user" -- cp "$MIAOU_BASH_DIR"/etc/skel/.bashrc "$user_bashrc"
|
|
||||||
>&2 echo "WARN: .bashrc for user <$user> has forked from skeleton, please resolve conflict manually from backup: $backup"
|
if [[ $first_change =~ $appended_regex ]]; then
|
||||||
|
sudo -u "$user" -- cp "$MIAOU_BASH_DIR"/etc/skel/.bashrc "$user_bashrc"
|
||||||
|
diff /etc/skel/.bashrc "$user_bashrc" | grep '^> ' | sed 's/^> //' | tee -a "$user_bashrc"
|
||||||
|
echo "INFO: .bashrc for user <$user> merged succesfully"
|
||||||
|
else
|
||||||
|
local backup="$user_bashrc".ORIGINAL
|
||||||
|
sudo -u "$user" -- mv "$user_bashrc" "$backup"
|
||||||
|
sudo -u "$user" -- cp "$MIAOU_BASH_DIR"/etc/skel/.bashrc "$user_bashrc"
|
||||||
|
>&2 echo "WARN: .bashrc for user <$user> has forked from skeleton, please resolve conflict manually from backup: $backup"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
sudo mv /etc/skel/.bashrc /etc/skel/.bashrc.ORIGINAL
|
||||||
fi
|
fi
|
||||||
|
sudo ln -sf "$MIAOU_BASH_DIR"/etc/skel/.bashrc /etc/skel/.bashrc
|
||||||
}
|
}
|
||||||
|
|
||||||
function link_etc {
|
function link_etc {
|
||||||
|
|||||||
Reference in New Issue
Block a user