Update src/include.d.sh
This commit is contained in:
parent
80d5d584df
commit
652c220b6c
|
@ -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
|
||||
# Check if the user's home directory exists
|
||||
if [[ -d "$homedir" ]]; then
|
||||
bashrc="$homedir/.bashrc"
|
||||
if [[ -d "$homedir" && -w "$bashrc" ]]; then
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue