#!/bin/bash # Adding CASA pam entries to pam files. for file in "/etc/pam.d/login" "/etc/pam.d/sshd" "/etc/pam.d/xdm" "/etc/pam.d/gdm" "/etc/pam.d/kdm" do if [ -f $file ] then sed -i '/pam_micasa/d' $file var=`grep pam_unix2.so $file` entry=`echo -e "auth\t required\tpam_micasa.so"` if [ "$var" != "" ] then sed -i "/^auth.*required.*pam_unix2.so/a$entry" $file continue fi var2=`grep common-auth $file` if [ "$var2" != "" ] then sed -i "/^auth.*include.*common-auth/a$entry" $file continue fi sed -i "0,/^auth/s/^\(auth.*\)/\1\n$entry/" $file fi done