From 652c220b6c4bb1153563cc5f385030d3dcc26327 Mon Sep 17 00:00:00 2001 From: colin Date: Mon, 9 Dec 2024 16:05:59 -0500 Subject: [PATCH] Update src/include.d.sh --- src/include.d.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/include.d.sh b/src/include.d.sh index 1552362..27a449a 100644 --- a/src/include.d.sh +++ b/src/include.d.sh @@ -6,10 +6,16 @@ echo "Configuring all users with /bin/bash as their default shell..." while IFS=: read -r username _ _ _ _ homedir shell; do # Check if the shell is /bin/bash if [[ "$shell" == "/bin/bash" ]]; then - # Check if the user's home directory exists and .bashrc is present - bashrc="$homedir/.bashrc" - if [[ -d "$homedir" && -w "$bashrc" ]]; then + # Check if the user's home directory exists + if [[ -d "$homedir" ]]; then + bashrc="$homedir/.bashrc" echo "Processing $username..." + # Create .bashrc if it doesn't exist + if [[ ! -f "$bashrc" ]]; then + echo "Creating $bashrc..." + touch "$bashrc" + chown "$username:$username" "$bashrc" # Adjust ownership + fi # Add the sourcing logic if not already present if ! grep -q "/etc/profile.d/" "$bashrc"; then echo 'for script in /etc/profile.d/*.sh; do if [ -r "$script" ]; then . "$script"; fi; done' >> "$bashrc" @@ -18,7 +24,7 @@ while IFS=: read -r username _ _ _ _ homedir shell; do echo "Sourcing logic already present in $bashrc" fi else - echo "No writable .bashrc found for $username, skipping." + echo "Home directory for $username not found, skipping." fi fi done < /etc/passwd