ciphermethod.com

Scripts

20110511: raidcheck.sh

by on May.11, 2011, under Scripts

#!/bin/bash

# raidcheck.sh – Search for SAS1064 or Adaptec AAC-RAID controller and report failed/degraded drives
#
# 20091222 jah – Created by Jamey Hopkins
# 20110511 jah – Added support for more than 1 drive. Still defaults to controller 1.
#                      rm UcliEvt.log
#                      Code/error message cleanup/clarification.

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}-
 #STATE=”1/0/1″  # Set STATE for Testing
 STATE2=`echo $STATE | cut -f2 -d’/’`
 STATE3=`echo $STATE | cut -f3 -d’/’`
 if [ “$STATE2” != “0” -o “$STATE3” != “0” ]
 then
  echo “ERROR: AAC-RAID Error – Devices/Failed/Degraded $STATE”
  echo
  exit 2
 else
  echo “AAC-RAID: No Failed or Degraded Drives Found.”
 fi
fi

if [ $SAS1064 = 0 -a $AACRAID = 0 ]
then
 echo “No supported controllers found.”
fi

rm status.0 status.1 >/dev/null 2>&1
rm UcliEvt.log >/dev/null 2>&1

exit 0

1 Comment more...

20110214: yt2.sh

by on Feb.14, 2011, under Linux, Scripts


#!/bin/bash

# randomize website youtube videos created by Jamey Hopkins
# site then uses PHP to display the selected video on the site
# 20100427 jah - youtuberand.sh -> yt2.sh
#                conversion to 0 byte file use
#                cut out email
# 20100527 jah - create a .selected file for reference
# 20110214 jah - use /bin/bash since ubuntu uses dash for sh which is not compat. w/ FILE=($FILES)
#
# NOTE: use vid.1.yt2, vid.same.yt, etc, to specify the same video more than once (increase odds)
#       move *.yt to *.yt.off (or some other extension) to disable selection
#

echo

cd /root/Scripts/yt2.cm

# match specific or all random
# use -- to handle files that start with -
[ "$1" != "" ] && FILES=`ls -- *$1*.yt 2>/dev/null` || FILES=`ls -- *.yt 2>/dev/null`

echo "Matching Files:"
echo "$FILES"

# perform random magic
FILE=($FILES)
NFILES=${#FILE[*]} #count
VID=`echo ${FILE[$((RANDOM%NFILES))]}`

echo
echo "Picked -> $VID"

# send random youtube string to file
echo "$VID" | cut -f1 -d. > /var/www/ciphermethod.com/random.youtube
rm -- *selected >/dev/null 2>&1
cp -- $VID $VID.selected

echo
Leave a Comment more...

20100913: adddirs.sh

by on Sep.13, 2010, under Linux, Scripts

#!/bin/sh
#20100913 – Add log directories to get total log space

for x in `cat linux.servers`
do
  echo $x:
  R=`ssh $x sudo du -h /var/log | tail -1`
  N=`echo $R | cut -f1 -dM`
sum=$(($COUNT + $N))
  COUNT=$sum
  echo $COUNT $N

  echo
done

Leave a Comment more...

20100421: changelin.sh

by 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

Leave a Comment more...

20100421: changeilom.sh

by 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

Leave a Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

But Wait, There's More!

A few highly recommended friends...