Sunday, March 8, 2015

$ more remove-kernel.nsh
#!/opt/bladelogic/NSH/bin/nsh

OLD_KERNEL="kernel-devel-2.6.18-238.el5"

USER_CHOICE=$1
SERVER_FILE=$2
if [ -z $USER_CHOICE ]
then
    echo usage: remove-kernel-5.6.nsh --check  {server_list_file}
    echo usage: remove-kernel-5.6.nsh --remove {server_list_file} --yes
    exit 0
fi
if [ -z $SERVER_FILE ]
then
    echo usage: remove-kernel-5.6.nsh --check  {server_list_file}
    echo usage: remove-kernel-5.6.nsh --remove {server_list_file} --yes
    exit 0
fi
if [ ! -f $SERVER_FILE ]
then
    echo file $SERVER_FILE does not exist
    echo please check and try again
    exit 4
fi
if [ "$USER_CHOICE" = "--check" ]
then
    for i in $(cat $SERVER_FILE)
    do
        echo
        echo checking $i
        nexec $i uname -a
        nexec $i rpm -qa | grep kernel
    done
    echo
elif [ "$USER_CHOICE" = "--remove" ]
then
    CONFIRM=$3
    if [ "$CONFIRM" != "--yes" ]
    then
        echo
        echo please provide the confirmation parameter
        echo and try again
        exit 8
    fi
    for i in $(cat $SERVER_FILE)
    do
        echo
        echo removing $i
        nexec $i uname -a

        # make sure the current kernel is not the one we want to remove
        CURR_KERNEL=$(nexec $i uname -r)
        if [ "$CURR_KERNEL" = "$OLD_KERNEL" ]
        then
            echo
            echo WARNING!
            echo Server $i is running on kernel $CURR_KERNEL
            echo this kernel version will NOT be removed!
            echo please investigate
            echo
        else
            echo before
            nexec $i rpm -qa kernel
            echo removing 5.6
            nexec $i rpm -e $OLD_KERNEL
            echo after
            nexec $i rpm -qa kernel
        fi
    done
    echo

else
    # no valid choice
    echo usage: remove-kernel-5.6.nsh --check  {server_list_file}
    echo usage: remove-kernel-5.6.nsh --remove {server_list_file}
fi
$

# more master.sh
if [ -f /var/tmp/exclude.file ]
then
mv /var/tmp/exclude.file /var/tmp/sethu/bak/exclude.file.$$
fi
ls /opt/ | egrep -v "TWeagent|autosys|SUNW|sfw|sun|taddm|jumpstart|local|patrol|" | awk '{print "/opt/" $1 "/"}'
ls /usr | egrep -v `cat /var/tmp/usr.d` |awk '{print "/usr/" $1"/"}'
echo list opt and usr do manually
echo /system/ > /var/tmp/exclude.file
cat /etc/mnttab |grep  /fmacdata/ | egrep   "nfs|autofs" |  awk '{print $2}' | sed 's,/fmacdata,,g' >> /var/tmp/sethu/exclude.fmacdata
cat /etc/mnttab |grep  /fmac/ | egrep   "nfs|autofs" |  awk '{print $2}' | sed 's,/fmac,,g' >> /var/tmp/sethu/exclude.fmac
#
$ cat User_compare_script.ksh
for id in `/opt/quest/bin/vastool search -b dc=fhlmc,dc=com cn=hac_$1_gg member 2>/dev/null |cut -f2 -d'='|sed s/,CN//|sed s/,OU//|grep -v -i GG`
do id $id 2>/dev/null;
done | awk -F"(" '{if(NF==3) {print $2"     "$3};}' | sed 's/) gid=/    /g' | sed 's/)//' | awk '{print $1}' | sort | uniq>/tmp/$1_oldserver_userlist.txt
for id in `/opt/quest/bin/vastool search -b dc=fhlmc,dc=com cn=hac_$2_gg member 2>/dev/null |cut -f2 -d'='|sed s/,CN//|sed s/,OU//|grep -v -i GG`
do id $id 2>/dev/null;
done | awk -F"(" '{if(NF==3) {print $2"     "$3};}' | sed 's/) gid=/    /g' | sed 's/)//' | awk '{print $1}' | sort | uniq>/tmp/$2_newserver_userlist.txt
diff /tmp/$1_oldserver_userlist.txt /tmp/$2_newserver_userlist.txt 2>&1 /dev/null
RESULT=$?
if [ ${RESULT} -ne 0 ]
then
    echo "Differences found in the user list between servers $1 and $2 ...."
    echo "Please chk the list under tmp ..Output Of the Diff command ...."
    diff /tmp/$1_oldserver_userlist.txt /tmp/$2_newserver_userlist.txt  | egrep "<|>"
fi
$


bash-3.2# cat /etc/auto_home
#!/bin/ksh
NONAS='
# specify local mounts
jay -rw     samserv01:/export/home:&
dev -rw     samserv01:/export/home:&
ram -rw     samserv02:/export/home:&
'
if [ -x /etc/auto_home_local ]; then
        exec /etc/auto_home_local $1
        exit 0
fi
if ( echo "$NONAS" |grep "^$1[  ]" >/dev/null 2>&1 ); then
        echo "$NONAS" | grep "^$1[      ]" | awk '{print $NF}'
        exit 0
fi
case $1 in
        nobody|nobody2) exit
        ;;
        [rk][0-9][0-9]*) echo sama:/export/home/$1
        ;;
        [A-Za-z]*) echo sam:/export/home/$1
        ;;
esac
bash-3.2# hostname
myclienthost
bash-3.2#
bash-3.2# ls -l /etc/auto_home_local
/etc/auto_home_local: No such file or directory

No comments:

Post a Comment