|
|
|
@ -37,18 +37,17 @@ function fix_users_bashrc { |
|
|
|
build_associative_user_homes |
|
|
|
for user in "${!USER_HOMES[@]}"; do |
|
|
|
local user_bashrc="${USER_HOMES[$user]}/.bashrc" |
|
|
|
local first_change |
|
|
|
echo "read: $user_bashrc" |
|
|
|
[[ ! -f "$user_bashrc" ]] && continue |
|
|
|
cmp -s /etc/skel/.bashrc "$user_bashrc" && continue |
|
|
|
|
|
|
|
local first_change |
|
|
|
if first_change=$(diff /etc/skel/.bashrc "$user_bashrc" | head -n1); then |
|
|
|
echo 'no change' |
|
|
|
if cmp -s /etc/skel/.bashrc "$user_bashrc"; then |
|
|
|
echo 'no change: replaced by skel' |
|
|
|
sudo -u "$user" -- cp "$MIAOU_BASH_DIR"/etc/skel/.bashrc "$user_bashrc" |
|
|
|
else |
|
|
|
if [[ $first_change =~ $appended_regex ]]; then |
|
|
|
elif first_change=$(diff /etc/skel/.bashrc "$user_bashrc" | head -n1); then |
|
|
|
echo 'no change: should not occur' |
|
|
|
elif [[ $first_change =~ $appended_regex ]]; then |
|
|
|
if new_lines=$(diff /etc/skel/.bashrc "$user_bashrc" | grep '^> ' | sed 's/^> //'); then |
|
|
|
echo 'no new lines' |
|
|
|
echo 'no new lines: should not occur' |
|
|
|
else |
|
|
|
sudo -u "$user" -- cp "$MIAOU_BASH_DIR"/etc/skel/.bashrc "$user_bashrc" |
|
|
|
echo -e "$new_lines" | sudo -u "$user" -- tee -a "$user_bashrc" |
|
|
|
@ -60,7 +59,6 @@ function fix_users_bashrc { |
|
|
|
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 |
|
|
|
fi |
|
|
|
done |
|
|
|
sudo mv /etc/skel/.bashrc /etc/skel/.bashrc.ORIGINAL |
|
|
|
echo 'fixing users .bashrc...DONE' |
|
|
|
|