diff /etc/skel/.bashrc
This commit is contained in:
+15
-17
@@ -37,29 +37,27 @@ function fix_users_bashrc {
|
|||||||
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"
|
||||||
|
local first_change
|
||||||
echo "read: $user_bashrc"
|
echo "read: $user_bashrc"
|
||||||
[[ ! -f "$user_bashrc" ]] && continue
|
[[ ! -f "$user_bashrc" ]] && continue
|
||||||
cmp -s /etc/skel/.bashrc "$user_bashrc" && continue
|
if cmp -s /etc/skel/.bashrc "$user_bashrc"; then
|
||||||
|
echo 'no change: replaced by skel'
|
||||||
local first_change
|
|
||||||
if first_change=$(diff /etc/skel/.bashrc "$user_bashrc" | head -n1); then
|
|
||||||
echo 'no change'
|
|
||||||
sudo -u "$user" -- cp "$MIAOU_BASH_DIR"/etc/skel/.bashrc "$user_bashrc"
|
sudo -u "$user" -- cp "$MIAOU_BASH_DIR"/etc/skel/.bashrc "$user_bashrc"
|
||||||
else
|
elif first_change=$(diff /etc/skel/.bashrc "$user_bashrc" | head -n1); then
|
||||||
if [[ $first_change =~ $appended_regex ]]; then
|
echo 'no change: should not occur'
|
||||||
if new_lines=$(diff /etc/skel/.bashrc "$user_bashrc" | grep '^> ' | sed 's/^> //'); then
|
elif [[ $first_change =~ $appended_regex ]]; then
|
||||||
echo 'no new lines'
|
if new_lines=$(diff /etc/skel/.bashrc "$user_bashrc" | grep '^> ' | sed 's/^> //'); then
|
||||||
else
|
echo 'no new lines: should not occur'
|
||||||
sudo -u "$user" -- cp "$MIAOU_BASH_DIR"/etc/skel/.bashrc "$user_bashrc"
|
|
||||||
echo -e "$new_lines" | sudo -u "$user" -- tee -a "$user_bashrc"
|
|
||||||
echo "INFO: .bashrc for user <$user> merged succesfully"
|
|
||||||
fi
|
|
||||||
else
|
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"
|
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"
|
echo -e "$new_lines" | sudo -u "$user" -- tee -a "$user_bashrc"
|
||||||
|
echo "INFO: .bashrc for user <$user> merged succesfully"
|
||||||
fi
|
fi
|
||||||
|
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
|
fi
|
||||||
done
|
done
|
||||||
sudo mv /etc/skel/.bashrc /etc/skel/.bashrc.ORIGINAL
|
sudo mv /etc/skel/.bashrc /etc/skel/.bashrc.ORIGINAL
|
||||||
|
|||||||
Reference in New Issue
Block a user