How to create automatic home directories in Solaris 10

To achieve automatic home-directory creation in solaris is little bit difficult. If it is NFS/NIS, we can achieve this through autofs(auto_mater) method. I saw many other post saying that they have achieved this with LDAP by using scripts. I Tried the same method with scripts and it didn’t worked for me.

 

There is another way we can achieve this by using pluggable authentication modules(PAM).Compared to linux, solaris PAM is very limited and there is not much modules on it.

 

Here is the summery :

 

1. installed sun studio( To get gcc and other development tools)
2. compiled Linux PAM modules on solaris
3. copied the modules to security directory
4. included module in /etc/pam.conf

 

Download and install Solaris Studio : http://www.oracle.com/technetwork/server-storage/solarisstudio/downloads/index-jsp-141149.html

 

Download and extract Linux PAM modules : http://www.linux-pam.org/pre/library/Linux-PAM-0.81.tar.gz

 

export PATH

 

PATH=/usr/sfw/bin:/usr/ccs/bin:/opt/sfw/bin:/opt/solarisstudio12.4/bin:$PATH
cd /var/tmp/Linux-PAM-0.81
./configure
cp _pam_aconf.h libpam/include/security
cd modules/pammodutil
gcc -c -O2 -D_REENTRANT -DPAM_DYNAMIC -Wall -fPIC -I../../libpam/include -I../../libpamc/include -Iinclude modutil_cleanup.c
gcc -c -O2 -D_REENTRANT -DPAM_DYNAMIC -Wall -fPIC -I../../libpam/include -I../../libpamc/include -Iinclude modutil_ioloop.c
gcc -c -O2 -D_REENTRANT -DPAM_DYNAMIC -Wall -fPIC -I../../libpam/include -I../../libpamc/include -Iinclude modutil_getpwnam.c -D_POSIX_PTHREAD_SEMANTICS
cd ../pam_mkhomedir
gcc -c -O2 -D_REENTRANT -DPAM_DYNAMIC -Wall -fPIC -I../../libpam/include -I../../libpamc/include -I../pammodutil/include pam_mkhomedir.c
ld -o pam_mkhomedir.so -B dynamic -G -lc pam_mkhomedir.o ../pammodutil/modutil_*.o
cp pam_mkhomedir.so /usr/lib/security/pam_mkhomedir.so.1
cd /usr/lib/security
ln -s pam_mkhomedir.so.1 pam_mkhomedir.so

 

finally comment /home in /etc/auto_master file

 

restart autofs:
svcadm disable autofs
avcadm enable autofs

 

include pam_mkhomedir.so in /etc/pam.conf

 

other session required pam_mkhomedir.so.1 skel=/etc/skel/ umask=0022

Linux Shell Script For Monitoring System network with ping command

Here is a simple script to monitor server IP status with lock. Script will send only 1 email when IP is not reachable.If it came back, it will send another mail

 

#!/bin/bash
NOTIFYEMAIL=ben.george@example.com
SENDEREMAIL=smcadmin@example.com
SERVER=172.16.200.51
PAUSE=2
FAILED=0
DEBUG=0
COUNT=1

while true
do
CS=$(ping -c $COUNT $SERVER | grep ‘received’ | awk -F’,’ ‘{ print $2 }’ | awk ‘{ print $1 }’)
if [ $DEBUG -eq 1 ]
then
echo “STATUS = $CS”
echo “FAILED = $FAILED”
if [ $CS -ne 0 ]
then
echo “$SERVER is up”

elif [ $CS -eq 0 ]
then
echo “$SERVER is down”
fi
fi
if [ $CS -ne 0 ] && [ $FAILED -eq 0 ]
then
FAILED=1
if [ $DEBUG -eq 1 ]
then
echo “$SERVER is back up”
fi
if [ $DEBUG = 0 ]
then
echo “$SERVER is came up at $(date)” | /bin/mailx -s “$SERVER is came up at ” -r “$SENDEREMAIL” “$NOTIFYEMAIL”
fi
elif [ $CS -eq 0 ] && [ $FAILED -eq 1 ]
then
FAILED=0
if [ $DEBUG -eq 1 ]
then
echo “$SERVER failed”
fi
if [ $DEBUG = 0 ]
then
echo “$SERVER went down $(date)” | /bin/mailx -s “$SERVER went down ” -r “$SENDEREMAIL” “$NOTIFYEMAIL”
fi
fi
sleep $PAUSE
done