20100421: changelin.sh
by dervish on Apr.21, 2010, under Linux, Scripts
#!/bin/sh
# 20100421 – Created by Jamey Hopkins
echo
echo “Change Users Linux/AIX Password”
echo
if [ “$1” = “” ]
then
echo need server list
echo example: $0 servers.txt
echo
exit
fi
if [ ! -f $1 ]
then
echo “Server list $1 not found.”
echo
exit
fi
echo -n “Enter Users Login: ”
read LOGIN
echo “Enter new password”
echo -n “Password: ”
stty -echo
read PASS1
stty echo
echo
echo “Enter password again”
echo -n “Password: ”
stty -echo
read PASS2
stty echo
echo
if [ “$PASS1” != “$PASS2” ]
then
echo passwords did not match
exit
fi
LIST=$1
echo “$LOGIN:$PASS1” >account.info
for X in `cat $LIST`
do
echo Performing Password Change for $LOGIN on $X
scp ./account.info $X: >/dev/null
ssh $X “cat account.info | sudo /usr/sbin/chpasswd” >/dev/null
ssh $X rm account.info
done
rm account.info
20100421: changeilom.sh
by dervish on Apr.21, 2010, under Linux, Scripts
#!/bin/sh
# 20100421 – Jamey Hopkins
echo
echo “Change root password on Sun ILOM cards”
echo
if [ “$1” = “” ]
then
echo need server list
echo example: changeilom.sh servers.txt
exit
fi
if [ ! -f $1 ]
then
echo “Server list $1 not found.”
echo
exit
fi
echo “Enter new password”
echo -n “Password: ”
stty -echo
read PASS1
stty echo
echo
echo “Enter password again”
echo -n “Password: ”
stty -echo
read PASS2
stty echo
echo
if [ “$PASS1” != “$PASS2” ]
then
echo passwords did not match
exit
fi
LIST=$1
echo “user set password 2 $PASS1” >cmnds.ilom
echo “quit” >>cmnds.ilom
for x in `cat $LIST`
do
echo $x
#ssh ${x}.fls ls
scp ./cmnds.ilom ${x}.fls: >/dev/null
echo “Running IPMITOOL”
ssh ${x}.fls “cat cmnds.ilom | sudo ipmitool shell” >/dev/null
ssh ${x}.fls rm cmnds.ilom
done
rm cmnds.ilom
Teach A Man To Fish
by dervish on Apr.16, 2010, under Jokes, Sundry
Give a man a fish; you have fed him for today. Teach a man to fish; and if he doesn’t beat you with the pole, he will resent you for a lifetime.
20091229: find_controller.sh
by dervish on Dec.29, 2009, under Scripts
#!/bin/sh # # Created: 20091229 Jamey Hopkins # Find PCI controller and output matches into $STR.servers # 20100406 jah - added ping check if [ "$1" = "" ] then echo "Please pass a search string." echo "Example: find_controller.sh AAC-RAID" exit else STR="$1" fi >$STR.servers for SERVER in `cat linux.servers` do echo -n $SERVER MSG="Controller not found." ping -c1 $SERVER >/dev/null 2>&1 if [ $? -eq 0 ] then DATA=`ssh $SERVER sudo /sbin/lspci 2>/dev/null | grep $STR` [ "$DATA" != "" ] && MSG="Controller: $DATA" [ "$DATA" != "" ] && echo $SERVER >>$STR.servers # echo what we found echo -e "\t$MSG" else echo -e "\tServer not reachable." fi done
20091222: raidcheck.sh
by dervish on Dec.22, 2009, under Scripts
#!/bin/bash
# raidcheck.sh – search for SAS1064 or Adaptec AAC-RAID controller and report failed drives
#
# Created 20091222 Jamey Hopkins
# Note: replaced by 20110511: raidcheck.sh
process_mpt-status() {
ID=`grep Found status.0 | cut -f2 -d= | cut -f1 -d,`
/usr/sbin/mpt-status -i $ID -s >status.1
C1=`cat status.1 | grep phys_id | wc -l`
C2=`cat status.1 | grep phys_id | grep ONLINE | wc -l`
[ “$C1” = “0” ] && echo “No Drives Found”
[ “$C1” = “$C2” ] && echo “$C2 of $C1 Drives Are Online”
#echo “Controller ID=$ID”
if [ $C2 -lt $C1 ]
then
echo “ERROR: Failed SAS Drive Found”
echo “$C2 of $C1 Drives Are ONLINE”
echo
exit 2
fi
}
AACRAID=”0″;SAS1064=”0″
# search for SAS1064 controller
DATA=`/sbin/lspci | grep SAS1064 2>/dev/null`
if [ “$DATA” != “” ]
then
#echo Process SAS
SAS1064=”1″
# check if mptctl module is loaded
MPT=`/sbin/lsmod | grep mptctl 2>/dev/null`
[ ! -n “$MPT” ] && echo “mptctl module not loaded”
/usr/sbin/mpt-status -p >status.0 2>&1
grep “not found” status.0 >/dev/null
if [ “$?” = “0” -a ! -n “$MPT” ]
then
echo “mpt-status not found in /usr/sbin”
else
process_mpt-status
fi
fi
# search for Adaptec AAC-RAID controller
DATA=`/sbin/lspci | grep AAC-RAID 2>/dev/null`
if [ “$DATA” != “” ]
then
#echo Process AAC-RAID
AACRAID=”1″
STATE=`/usr/StorMan/arcconf getconfig 1 | grep “Logical devices/Failed/Degraded” | cut -f2 -d: | xargs echo`
#echo state is -${STATE}-
if [ “$STATE” != “1/0/0” ]
then
echo ERROR: AAC-RAID Failed Drive Found
echo
exit 2
else
echo “AAC-RAID: No failed or degraded drives found.”
fi
fi
if [ $SAS1064 = 0 -a $AACRAID = 0 ]
then
echo “No controllers found.”
fi
rm status.0 status.1 >/dev/null 2>&1
exit 0