Created
February 20, 2014 06:01
-
-
Save dannysheehan/9107830 to your computer and use it in GitHub Desktop.
Find users missing .profile and .bashrc files and copy them from /etc/skel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for h in `ls -d1 /home/*` | |
do | |
TUSER=`basename $h` | |
if ! getent passwd $TUSER 2> /dev/null | awk -F: '{print $7}' | grep -v "/bin/bash" | |
then | |
if [ -d $h -a ! -e $h/.profile ] | |
then | |
( su - $TUSER -c "cp /etc/skel/.profile $h" ) && ls -1d $h/.profile | |
else | |
echo $TUSER .profile ok | |
fi | |
if [ -d $h -a ! -e $h/.bashrc ] | |
then | |
( su - $TUSER -c "cp /etc/skel/.bashrc $h" ) && ls -1d $h/.bashrc | |
else | |
echo $TUSER .bashrc ok | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment