ciphermethod.com

Scripts

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...

20091229: find_controller.sh

by 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
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...