1846428 Members
3043 Online
110256 Solutions
New Discussion

home directory

 
Jayesh shah
Frequent Advisor

home directory

Hi,

Does anyone have a script which can tell whether a user's home directory is

1. mounted (source and permissions)
2. Automounted (source and permissions)
3. exist on Local system
4. does no exist

Regards
Jayesh
5 REPLIES 5
malay boy
Trusted Contributor

Re: home directory

Jayesh,
You can accompish this using combination of bdf and ll.

Hope this help

regards
mB
There are three person in my team-Me ,myself and I.
Bharat Katkar
Honored Contributor

Re: home directory

Jayesh it is difficult to write srcipt which suits to your environment and setup.
What i can suggest is try writing script using command like this and may be some other's what you feel suitable. It should be simple one.

1. #mount
Tell you about filesystem mounted
2. # ps -ef | grep
Give you what process you are looking for.

That should help.
Regards,
You need to know a lot to actually know how little you know
Elmar P. Kolkman
Honored Contributor

Re: home directory

Though not foolproof, the next will do some things you want...
I've no automount to test it, but wildcards for automounting homedirs won't work with this. By supplying more info on your setup, I might be able to solve that for you.

Also to check if a homedir is mounted, you might look for a .profile in the homedirs.

Good luck, hope you can build what you want on this base.

Elmar

#!/usr/bin/ksh
cat /etc/passwd | cut -d: -f 6 | while read hdir
do
currentdev=$(bdf $hdir 2>/dev/null| awk '{print $1}')
autofs=$(grep $hdir /etc/auto_master 2>/dev/null| awk '{print $NF}')

echo "$hdir\t\c"
if [ -n "$currentdev" ]
then
echo "Mounted: $currentdev"
else
echo "Unmounted"
fi

if [ -n "$autofs" ]
then
echo "Automount: $autofs"
else
echo "No automount"
fi
Every problem has at least one solution. Only some solutions are harder to find.
iminus
Frequent Advisor

Re: home directory

1. bdf
2. cat /etc/fstab | grep
3,4. showmount -a (if the directory shows here, it's nfs, i.e. not on local system)
hope it helps
Chris Wilshaw
Honored Contributor

Re: home directory

In addition to the other suggestions, the pwck command can tell you if a home directory does not exist. It will report as below;

temp:*:4000:20:TEMP ID:/home/temp:/usr/bin/sh
Login directory not found