|
|
|
@ -25,10 +25,24 @@ function install_required_packages { |
|
|
|
. "$MIAOU_BASH_DIR"/tools/pkg_add "${REQUIRED_PKGS[@]}" |
|
|
|
} |
|
|
|
|
|
|
|
function rm_bashrc_skeleton { |
|
|
|
if [[ -e /etc/skel/.bashrc ]]; then |
|
|
|
rm /etc/skel/.bashrc |
|
|
|
echo "skeleton .bashrc removed!" |
|
|
|
function fix_users_bashrc { |
|
|
|
# for new users |
|
|
|
if ! cmp -s /etc/skill/.bashrc "$MIAOU_BASH_DIR"/etc/skel/.bashrc; then |
|
|
|
sudo mv /etc/skill/.bashrc /etc/skill/.bashrc.ORIGINAL |
|
|
|
sudo ln -sf "$MIAOU_BASH_DIR"/etc/skel/.bashrc /etc/skel/.bashrc |
|
|
|
|
|
|
|
# for pre-existant users |
|
|
|
build_associative_user_homes |
|
|
|
for user in "${!USER_HOMES[@]}"; do |
|
|
|
local user_bashrc="${USER_HOMES[$user]}/.bashrc" |
|
|
|
[[ ! -f "$user_bashrc" ]] && next |
|
|
|
cmp -s "$user_bashrc" "$MIAOU_BASH_DIR"/etc/skell/.bashrc && next |
|
|
|
|
|
|
|
local backup="$user_bashrc".ORIGINAL |
|
|
|
sudo -u "$user" -- mv "$user_bashrc" "$backup" |
|
|
|
sudo -u "$user" -- cp "$MIAOU_BASH_DIR"/etc/skell/.bashrc "$user_bashrc" |
|
|
|
>&2 echo "WARN: .bashrc for user <$user> has already been diverged, please resolve conflict manually from backup: $backup" |
|
|
|
done |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
|
@ -116,6 +130,17 @@ function fix_terminfo_ghostty { |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
|
function build_associative_user_homes { |
|
|
|
if [[ ! -v USER_HOMES ]]; then |
|
|
|
declare -gA USER_HOMES |
|
|
|
while IFS=: read -r user _ uid _ _ home _; do |
|
|
|
if [[ $uid -ge 1000 && $user != 'nobody' ]]; then |
|
|
|
USER_HOMES[$user]="$home" |
|
|
|
fi |
|
|
|
done </etc/passwd |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
|
function ghostty_global_config { |
|
|
|
! command -v ghostty >/dev/null && return |
|
|
|
|
|
|
|
@ -137,13 +162,11 @@ function ghostty_global_config { |
|
|
|
echo "config-file = $global_config" >/etc/skel/.config/ghostty/config |
|
|
|
fi |
|
|
|
|
|
|
|
# change ghostty configuration for any normal user UID>=1000 |
|
|
|
mapfile -t normal_users < <(awk -F: '$3 >= 1000 && $1 != "nobody" { print $1 }' /etc/passwd) |
|
|
|
for user in "${normal_users[@]}"; do |
|
|
|
local user_home |
|
|
|
user_home=$(getent passwd "$user" | cut -d: -f6) |
|
|
|
# change ghostty configuration for any normal user |
|
|
|
build_associative_user_homes |
|
|
|
for user in "${!USER_HOMES[@]}"; do |
|
|
|
local user_home="${USER_HOMES[$user]}" |
|
|
|
local user_ghostty_config="$user_home"/.config/ghostty/config.ghostty |
|
|
|
|
|
|
|
if [[ ! -f "$user_ghostty_config" ]]; then |
|
|
|
sudo -u "$user" -- mkdir -p "$user_home"/.config/ghostty |
|
|
|
echo -e "# global config\nconfig-file = /etc/ghostty/config\n" | |
|
|
|
@ -169,7 +192,7 @@ assert_root |
|
|
|
|
|
|
|
DISTRO_LIKE=$(fetch_distro_like) |
|
|
|
install_required_packages |
|
|
|
rm_bashrc_skeleton |
|
|
|
fix_users_bashrc |
|
|
|
fix_terminfo_ghostty |
|
|
|
ghostty_global_config |
|
|
|
link_config_files |
|
|
|
|