diff --git a/src/include.d.sh b/src/include.d.sh new file mode 100644 index 0000000..1552362 --- /dev/null +++ b/src/include.d.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# Loop through all users with /bin/bash as their default shell +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 + echo "Processing $username..." + # 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" + echo "Added sourcing logic to $bashrc" + else + echo "Sourcing logic already present in $bashrc" + fi + else + echo "No writable .bashrc found for $username, skipping." + fi + fi +done < /etc/passwd + +echo "Configuration complete." \ No newline at end of file