Warning: sem_get() [function.sem-get]: failed for key 0x152b: Permission denied in /home1/maymaylu/public_html/sprackle/wp-content/plugins/wp-cache/wp-cache-phase2.php on line 98
[M@sprackle.org ~]$ « [M@sprackle.org ~]$ logger "Just my script depo in cyberspace"

Lazy – CSV to LDIF

#!/bin/bash
# AUTHOR: M@sprackle.org
# PURPOSE: To convert a CSV to LDIF
# LIMITATIONS: Expects the following format use in the CSV.
# Surname,GivenName,UID,Mail,Phone,Description
# It's not pretty and I could move it to a for loop but this
# really worked on populating a LDAP phone directory.
# You can really tell how lazy I was on this one....
# INSTALL: change script to +x and run with a file option
# USE: modify the FILENAME on the cat and run.
# $ diffy
cat FILENAME.csv | awk -F, '{print "dn: uid="$3",ou=addressbook,dc=example,dc=com""\n""objectClass: top""\n""objectClass: organizationalPerson""\n""objectClass: inetorgperson""\n""objectClass: person""\n""uid: "$3"\n""cn: "$2,$1"\n""mail: "$4"\n""givenName: "$2"\n""sn: "$1"\n""telephoneNumber: "$5"\n""description: "$6"\n"}

Post to Twitter Tweet This Post Post to Digg Digg This Post

Android FFMPEG converter

#!/bin/bash
# AUTHOR: M@sprackle.org
# PURPOSE: To convert one file or many files to Android format and size.
# LIMITATIONS: Get the Cancel button working in Zenity pop-up
# INSTALL: Place this script in "~/.gnome2/nautilus-scripts/Android"
# and set to execute `chmod +x ~/.gnome2/nautilus-scripts/Android`
# USE: Just right click on a file or folder that contains files you
# would like to convert to an Android format.  This was converted from
# my already used iPhone script.
#
# Where do you want all of these files to be saved?
# You should NOT have to edit below this line
SAVESPOT="/home/mwells/AndroidMovies"
#
# Same as above I just wanted a single place to find my files
		if [ ! -d $SAVESPOT ]; then
			mkdir $SAVESPOT
		fi
# Lets see if this was a single file or a Directory
if [ -f "$1" ]; then
#
# Let's cut up the name so it's not example.avi.mp4
NEWNAME=`echo "$1" | awk -F. '{print $1}'`
#
# Run the command - I found all these flags on some website.
# So far they're good.
ffmpeg -i "$1" -s 480x256 -vcodec mpeg4 -acodec libfaac -ac 1 -ar 16000 -r 13 -ab 32000 -aspect 3:2 -padtop 32 -padbottom 32 $SAVESPOT/"$NEWNAME".mp4 

Post to Twitter Tweet This Post Post to Digg Digg This Post

Parental Tech Support

#!/bin/bash
# AUTHOR -
# M@ - M@sprackle.org GPG Public Key ID:  0x4ADEA413
# NAME -
# HelpMe
# SYNOPSIS -
# Use as needed
# DESCRIPTION -
# This is just a script I wrote to help my mom and dad. Mom is on a
# MAC these days and Dad is on a Fedora Core 11 laptop.  So in order
# to help them as needed I wrote this.
# This uses port forwarding with SSH so that I can connect to port 8181 on my
# local system and it actually goes to their local port X over the SSH tunnel.
# This way they don't need to poke holes in the router/Firewall.
# The MAC can use VNC but can't X-Forward
# Fedora can do either but I prefer SSH
# REVISIONS -
# 1.0

# My Server/IP - I use my DDNS name to come home.
SERVER='ddnsdomainfor.home.com'

# SSH
function SSH {
ssh -L 8181:localhost:22 ${SERVER}
}

# VNC
function VNC {
ssh -L 8181:localhost:5900 ${SERVER}
}

# Ask what they would like
echo "
Would you like to enable SSH or VNC?
"
select APP in "VNC" "SSH";
do
	[ -z "${APP}" ] && echo "Please enter a vaild number" || break;
	done
${APP}

Post to Twitter Tweet This Post Post to Digg Digg This Post

Fun/bored with Torrents

#!/bin/bash
# AUTHOR -
# M@ - M@sprackle.org GPG Public Key ID:  0x4ADEA413
# NAME -
# fc11Downers
# SYNOPSIS -
# `*/20  * * * /PATH/TO/fc11Downers
# DESCRIPTION -
# Just a bittorrent downloader that would pull the Fedora Core 11 DVD when it dropped.
# I was kinda bored and a co-worker and I joked about this so I thought it would be fun.
# I think this would be interesting in a loop if you had a linux distro that updated weekly
# and you wanted to get all the new versions off bittorrent each week.
# I think version two will read in a file and loop it.  For weekly linux distros only though,
# those are legal on bittorrent.
# REVISIONS -
# 1.0

URLTOLOOK="http://torrent.fedoraproject.org"
WHATTOPULL="Fedora-11-x86_64-DVD.torrent"
# Check to see if the DVD has posted yet.
links -source ${URLTOLOOK} > /tmp/site
egrep ${WHATTOPULL} /tmp/site
	if [ $? == "0" ]; then
		if [ -f /tmp/${WHATTOPULL}.lock ];then
			exit
		fi
		egrep ${WHATTOPULL} /tmp/complete
		 if [ $? != "0" ]; then
		 exit
		 fi
	touch /tmp/${WHATTOPULL}.lock
bittorrent-console --save_in ~/Download --forwarded_port 7325 $(egrep ${WHATTOPULL} \
/tmp/site | awk -F"href=" '{print $2}' | awk -F\" '{print $2}')
	fi
rm /tmp/${WHATTOPULL}.lock
echo ${WHATTOPULL} > /tmp/complete

Post to Twitter Tweet This Post Post to Digg Digg This Post

dumstr – Subversion/Satellite Server script

#!/bin/bash
# AUTHOR -
# M@ - M@sprackle.org GPG Public Key ID:  0x4ADEA413
# NAME -
# dumstr = a Satellite used to map subterranean facilites and tectonic plates
# http://www.satnews.com/cgi-bin/display_story.cgi?number=796520090
# SYNOPSIS -
# ./dumstr
# DESCRIPTION -
# In order to check in and out files of Subversion and upload
# them to a Red Hat Satellite Server configuration channel and be deployed
# REQUIRMENTS -
# This script assumes a certain setup of the subversion and
# Satellite server.  Example is below with a DNS server
# Subversion server repositories are inside a ConfigChannels repo.
# Within the ConfigChannel a repo for 'DNS'.
# Within the DNS there could be multiple folders but for this assume 'ZONES'
# The Satellite server would have a configuration channel called.
# DNS-ZONES and inside are the zone files to be deployed to systems.
# REVISIONS -
# 1.0

# Subversion Server
SUBVERSIONSERVER="https://svn.example.com/svn/repository/satelliteServer/ConfigChannels/"
# Satellite Server
SATELLITESERVER="satellite.example.com"
#
# Check to see that you have the rhncfg-manager RPM installed
if [ ! -f "/usr/bin/rhncfg-manager" ];
	then
	echo "
You must have the rhncfg-management RPM installed.
$ sudo up2date rhncfg-management"
	exit 1
	fi
#
# Check to see that you have the subversion RPM installed
if [ ! -f "/usr/bin/svn" ];
        then
        echo "
You must have the svn RPM installed.
$ sudo up2date subversion subversion-devel
"
        exit 1
        fi
#
clear
# Begin Function List

# Check in files modified to the Subversion Server
function CHECKITIN {
   echo "
What local working copies would you like to check back in?
(enter the number)
###
"
   select LOCALSVN in `ls ~/subversion`;
   do
   [ -z "${LOCALSVN}" ] && echo "Please enter a vaild number" || break;
        done
echo "
Please select the subdirectory
"
        select LOCALSVNSUB in `ls ~/subversion/${LOCALSVN}`;
        do
        [ -z "${LOCALSVNSUB}" ] && echo "Please enter a vaild number" || break;
        done
echo "
Please add a comment of why this file was changed.
Hitting 'Enter' will submit."
read COMMENTIN

   cd ~/subversion/${LOCALSVN}/${LOCALSVNSUB}/
   svn commit -m "${COMMENTIN}" | tee /tmp/checkin

export CHANNEL4ME=${LOCALSVNSUB}-${LOCALSVN}
}

# Check files out of Subversion
function CHECKITOUT {
   echo "
Getting Subversion channel lists, please wait.
"
        select SVNCHANNEL in `svn list ${SUBVERSIONSERVER}`;
        do
        [ -z "${SVNCHANNEL}" ] && echo "Please enter a vaild number" || break;
        done
   clear
   echo "

Looking further into your Channels.
You may be prompted for a login and to accept the Subversion certificate.
Please wait. . . . . . . . .

Please select option Channel to download
(enter the number)
###
"
   select APIP in `svn list ${SUBVERSIONSERVER}/${SVNCHANNEL}/trunk`;
   do
        [ -z "${APIP}" ] && echo "Please enter a vaild number" || break;
        done
   clear
   if [ ! -d ~/subversion/${SVNCHANNEL} ]; then
   mkdir -p ~/subversion/${SVNCHANNEL}
   fi
svn co ${SUBVERSIONSERVER}/${SVNCHANNEL}/trunk/${APIP} ~/subversion/${SVNCHANNEL}/${APIP}
      exit
}

# Satellite Server Uploads
function SATELLITECALL {

# Move to the directory we're working in.
# This helps with pathing during uploads to the Satellite Server
cd ~/subversion/${LOCALSVN}/${LOCALSVNSUB}/

for i in `egrep Sending /tmp/checkin | awk '{print $2}'`
do

#Push the files to the server
sudo rhncfg-manager --server-name=${SATELLITESERVER} update \
--channel=${LOCALSVNSUB}-${LOCALSVN} --dest-file=/${i} ${i}

if [ $? != "0" ]; then
        cd -
        echo "Commit failed Please try again"
                CHECKITIN
        fi
        echo "
 - - - RHN Push good - - -
 - There is a bug in the Satellite Server software -
 - Bug 467189
 - Please check the permissions within the channel
"

done
}

# End Fucntion List

# Ensure that a working folder exists for the user
if [ ! -d ~/subversion ];
	then
	mkdir -p ~/subversion
	echo "
A new folder has been created in your home directory called 'subversion'
All exports will be placed here"
	fi

# What do you want dumstr to do
echo "
What do you need to do in subversion?
(enter the number)
###
"
select CHECKION in "Check In" "Check Out";
        do
         [ -z "${CHECKION}" ] && echo "Please enter a vaild number" || break;
        done
clear

# What do I do
if [ "${CHECKION}" == "Check Out" ]; then

# Call the Check out function
	CHECKITOUT

elif [ "${CHECKION}" == "Check In" ]; then

# Call the Check in function
		CHECKITIN
	if [ $? != "0" ]; then
	cd -
	echo "Commit failed Please try again"
		CHECKITIN
	fi

	cd -
	echo "
	 - - Checkin good - -
Would you like to update the files you've just checked in to the Satellite Server?
	"
select YNMORE in "Yes" "No";
	do
	 [ -z "${YNMORE}" ] && echo "Please enter a vaild number" || break;
        done

	if [ "${YNMORE}" == "Yes" ]; then

# If files are ready to be updated call Satellite function
		SATELLITECALL
	fi
	exit 0
fi
rm /tmp/checkin
unset CHANNEL4ME

Post to Twitter Tweet This Post Post to Digg Digg This Post

replaceAfriend script to annoy

#!/bin/bash
# AUTHOR -
# M@ - M@sprackle.org GPG Public Key ID:  0x4ADEA413
# NAME -
# replaceAfriend
# SYNOPSIS -
# ./replaceAfriend
# DESCRIPTION -
# I have a shirt from thinkgeek.com that says
# "Go away or I will replace you with a very small shell script"
# so I wanted to make that a true statement.  I opted to pick random
# lines in a few ways.
# http://www.thinkgeek.com/tshirts-apparel/unisex/frustrations/374d/
# REVISIONS -
# Only one published at this time.
# LIMITATIONS -
# You'll need to break this because it loops forever.

# Here is the location of your file that has your friends favorite quotes
FRIENDFILE='/home/username/.myfriends'

# What's the Max interval(in seconds) you want to go without interuption
INTERVAL='600'

function annoyingloop {
perl -le 'sleep rand ${INTERVAL}'
sed -n $((1+$RANDOM%`wc -l ${FRIENDFILE} | cut -f 1 -d ' '`))p ${FRIENDFILE} | festival --tts
annoyingloop
}

annoyingloop

Content of .myfriends file

hello friend how are you doing today, what's for lunch
Hey can I ask you a quick question
what time do you wake up?
Hey I just thought I would come over.  Oh you look busy, what do you want to do for lunch?
Are you going to drink the rest of this coffee?
Quick question for you..

Post to Twitter Tweet This Post Post to Digg Digg This Post

SSH Pub Key Scanner

#!/bin/bash
# AUTHOR -
# M@ - M@sprackle.org GPG Public Key ID:  0x4ADEA413
# NAME -
# sshKeyORama
# SYNOPSIS -
# ./sshKeyORama
# DESCRIPTION -
# A script to harvest all ssh public keys from a network
# REVISIONS -
# Only one published at this time.
# LIMITATIONS -
# TBD

# IP class C to scan
IPADDR='192.168.0'

# Scan the entire class C for public keys
for i in $(seq 254)
do

# Ensure that the host is live by looking up the IP in DNS.
host ${IPADDR}.$i
	if [ $? == 0 ];
	then
	# If DNS returns that the IP is listed then grab the public keys
	# You could kill the if then and just have the line below if you didn't care about dns.
	# ssh-keyscan -t rsa ${IPADDR}.$i >> ~/ssh_known_hosts
	ssh-keyscan -t rsa $(host ${IPADDR}.$i | awk '{print $5}') >> ~/ssh_known_hosts
	# This ssh_known_hosts file can be placed in /etc/ssh/ssh_known_hosts
	# every users will then get these keys in their local .ssh/known_hosts file
	fi
done

Post to Twitter Tweet This Post Post to Digg Digg This Post

Master IPTables

These are some awesome videos for iptables; I really enjoyed them and if you as well make sure you tell the guys over at Linux Journal.
I find embedded videos annoying so I’m just putting these links up.

Mastering IPTables by Linux Journal

http://www.linuxjournal.com/

IPTables Episode one

IPTables Episode two

IPTables Episode three

Post to Twitter Tweet This Post Post to Digg Digg This Post

IPA Link from Red Hat

This is just a great video and link to the Enterprise IPA Server.
Red Hat IPA Server

Post to Twitter Tweet This Post Post to Digg Digg This Post

RSYNC Laptop backup

#!/bin/bash
# AUTHOR -
# M@ - M@sprackle.org GPG Public Key ID:  0x4ADEA413
# NAME -
# lappyVonRsync
# SYNOPSIS -
# `15 1 * * * /home/username/scripts/lappyVonRsync`
# DESCRIPTION -
# To keep my NFS share in sync with my laptop ~
# REVISIONS -
# Only one published at this time.
# LIMITATIONS -
# I only allow the sync to occur if my laptop is  hard wired and on my internal network.

# My home
HOMEDIR="/home/username/"
SHARENAME="/Share/username"
SERVER="192.168.227.254"

# Look at the eth0 to see if the system is on my internal network.
/sbin/ifconfig eth0 | egrep "192.168.227"

# Since it is start the rsync.
if [ $? == "0" ]; then

# rsync command
rsync -vaz --exclude-from="${HOMEDIR}.rsync/exclude" -e ssh --delete ${HOMEDIR} ${SERVER}:${SHARENAME}
fi

Post to Twitter Tweet This Post Post to Digg Digg This Post