Saturday, December 29, 2012

could have sworn I published this years ago

#! /bin/bash
# Title: install-chrome
# Author: BroknDodge
# License: BSD
# Version: 0.0.5
#
# Special thanks to the following Vectorians for their help and suggestions:
# Daniel stretchedthin uelsk8ts
# hata_ph rbistolfi MOE-lnx
#
# Very Special thanks to the folks at Chromium.org and Google
# without whom there wouldn't be anything to install
#

#------------------------------------------#
# Setting up the Environment

enablePlugins="$1"
tmp="/tmp"
release="0"
chromeURL="http://dl.google.com/linux/deb/"

nssURL="http://connie.slackware.com/~alien/slackbuilds/mozilla-nss/pkg/12.2"
nssPackage="mozilla-nss-3.12.3-i486-1alien.tgz"

#------------------------------------------#
# Making sure the system is sane

if [ $UID != 0 ]; then
echo "You must run this script as root."
exit 1
fi

if [ -d "$tmp/install-chrome" ]; then # check for and create temp dir
# Will enter here if dir doesn't exist
rm -R $tmp/install-chrome # hope you didn't have anything
mkdir $tmp/install-chrome # stored there
else
mkdir $tmp/install-chrome
fi

#------------------------------------------#

function trim() # function for trimming white space from my arrays
{
trimmed=$1
trimmed=${trimmed%% }
trimmed=${trimmed## }

echo $trimmed
}


function dotests {

echo Running tests...
#------------------------------------------#
# check for lzma

haveLZMA=`which lzma` # check for and getting lzma
if [ "$haveLZMA" == "" ]; then
slapt-get --install lzma
fi

#------------------------------------------#

#------------------------------------------#
# check for nss = 3.12.3

nssInstalled=`slapt-get --search nss-3.12.3` # I really need to check the version
nssInstalled=${nssInstalled#*=} # as well, but this build seems to
nssInstalled=${nssInstalled%]*} # work best with 3.12.3

if [ "$nssInstalled" != "yes" ]; then
installnss
fi
#------------------------------------------#

#------------------------------------------#
# check for GConf

gconfInstalled=`slapt-get --search GConf-2.22.0` # VL-Light doesn't ship with GConf
gconfInstalled=${gconfInstalled#*=}
gconfInstalled=${gconfInstalled%]*}

if [ "$gconfInstalled" != "no" ]; then
slapt-get --install GConf
fi

}
#------------------------------------------#


function simlinks {
cd /usr/lib
if [ ! -f "libnspr4.so.0d" ]; then
ln -s libnspr4.so libnspr4.so.0d
fi

if [ ! -f "libnss3.so.1d" ]; then
ln -s libnss3.so libnss3.so.1d
fi

if [ ! -f "libnssutil3.so.1d" ]; then
ln -s libnssutil3.so libnssutil3.so.1d
fi

if [ ! -f "libplc4.so.0d" ]; then
ln -s libplc4.so libplc4.so.0d
fi

if [ ! -f "libplds4.so.0d" ]; then
ln -s libplds4.so libplds4.so.0d
fi

if [ ! -f "libsmime3.so.1d" ]; then
ln -s libsmime3.so libsmime3.so.1d
fi

if [ ! -f "libssl3.so.1d" ]; then
ln -s libssl3.so libssl3.so.1d
fi


}

function installnss {

cd $tmp/install-chrome
wget $nssURL/$nssPackage
if [ ! -f "$nssPackage" ]; then
echo "For some reason wget didnt pull nss from Connies"
echo "slackware site"
return 1
fi
installpkg $nssPackage

rm $nssPackage

}

function installchrome {

cd $tmp/install-chrome
wget http://dl.google.com/linux/deb/dists/stable/main/binary-i386/Packages.gz
gunzip Packages.gz
rm -f Packages.gz
IFS='
'

declare -a fn=( `grep 'Filename:' Packages` ) # assign grep output to a variable
for i in 0 $((${#fn[@]} - 1))
do
fn[$i]=$(trim "${fn[$i]#*:}")
done

chromeFilename="${fn[$release]}"
chromePackage="${chromeFilename##*/}"

wget $chromeURL$chromeFilename

if [ ! -f "$chromePackage" ]; then # quit running if wget failed
echo "Something went wrong while retrieving" # and kick out a sane error msg
echo "Google Chrome"
return 1
fi

echo "Unpacking the deb file"
ar -x $tmp/install-chrome/$chromePackage

if [ ! -f "data.tar.lzma" ]; then # quit running if ar failed
echo "Something went wrong while unpacking" # and kick out a sane error msg
echo "the .deb file"
return 1
fi

echo "Extracting Google Chrome"
lzma -d data.tar.lzma
if [ ! -f "data.tar" ]; then # quit running if lzma failed
echo "Something went wrong while extracting" # and kick out a sane error msg
echo "Google Chrome"
return 1
fi

cd /
echo "Installing Google Chrome"

tar xf $tmp/install-chrome/data.tar
if [ ! -f "/opt/google/chrome/google-chrome" ]; then # let me know if chrome wasn't
echo "Installation failed while moving files" # installed correctly
echo ""
return 1
fi
echo "Installation Complete!"

}

function main {
echo
echo "WARNING WARNING WARNING WARNING WARNING"
echo "This script may severely damage your system"
echo "Dont say I didnt WARN you"
echo
echo "Are you sure you want me to Monkey with your System? [yes/no]"
echo "[for your safety you must type yes to proceed]"
echo

read YN
if [ "$YN" = "yes" ]; then
if [ -d "/opt/google/chrome" ]; then
echo "Looks like Google Chrome is already installed"
echo "Do you want to remove it and reinstall? [yes/no]"
read yn
if [ "$yn" = "yes" ]; then
rm -R /opt/google/chrome
rm /usr/share/applications/google-chrome.desktop
dotests
simlinks
installchrome
else
return
fi
else
dotests
simlinks
installchrome

fi
elif [ "$YN" = "no" ]; then
return
else
main
fi

}

main

unfinished rant from IDK when

I'm working up a really good rant.  A couple of weeks ago, during the launch of the Space Shuttle Atlantis, I began to look around at the available commercial low earth orbit options.  That search, somehow, wound up on renewable energy.  Go figure, guess that's why they call it surfing.  I began to notice a pattern regarding renewable energy.  Every single attempt to replace so called "dirty energy" with something clean and sustainable was met with opposition from the environmental lobby.  That's right, opposition!  The environmental lobby wants us to quit using oil, coal and other "dirty energy" but they won't let us move on to something cleaner!  We are stuck in the dark ages of energy production because the environmental groups won't let us move on to new state of the art energy production.  Some of the technology needed to completely eliminate our dependence on "dirty energy" has existed for almost 50 years. Why do we have to continue using 80 to 90 year old dirty technology when much newer greener technology has existed for so long?

Solar Energy
Apparently, while the environmental lobby wants us to use renewable solar energy, they don't want us to actually build all those solar panels.  How is it possible to use solar energy without building and installing the panels?  Look people, there will ALWAYS, be an impact on wildlife.  Wildlife will adjust.  Please, pick an evil!  Do we continue to pollute the environment with hundreds of billions of gallons of pollution every day, or do we impact a few hundred thousand acres of wild life for a clean renewable energy source?  Make up our minds for us!  The old saying goes something like: you can't have your cake and eat it too!

One such solar farm could produce 850 MW of power.  That would replace two small coal powered plants or one big one.  Displacing millions of gallons of pollution each year!  Sure, a few lizards would have to move.  But how many species around the world would be saved by reducing our carbon foot print?  I am reminded of the fictional Vulcan's from the Star Trek franchise.  "In any case, were I to invoke logic, logic clearly dictates that the needs of the many outweigh the needs of the few." -- Spock (Star Trek II).

Wind Energy

Blizzard of '12

So my power has been off since Christmas day. Blizzard of '12 hit Arkansas hard. Over 180k homes lost power. My whole neighborhood was restored a couple of days ago, but the houses on my side of the street and the even side of the street behind me are on a different line. My next door neighbors meter loop was pulled off the house by very tall bushes they refuse to cut and I don't have the legal right to cut. That was the only reason our power was still off. My neighbor 2 houses down pointed that out to me today (Saturday) about 4pm. He informed me that he had called Entergy (our power company) 3-4 times each day. He also told me that he had contacted his city councilman a number of times. I went directly looking for an Entergy supervisor. They drive white Chevy Colorado pick-ups with the Entergy logo on the door. Pretty easy to spot. I found one and chased him for 6 blocks. Once I chased him down, I explained the situation with as much detail as I could. Gave him addresses and exactly which pole fed our line. Pointed out the fusible link that was blown. I checked back on my house around 6pm and found power was back on. Sort of. My lights were dim and the heaters weren't running. There was a funny electric odor in the home. If you have ever smelt that specific odor, when some electronic thing died, then you know exactly what I'm talking about. I started unhooking heaters. Each heater unhooked made the lights brighter. After all heaters were unhooked, I decided to check the voltage in my home. I used my trusty volt meter (thanks Mandy for keeping me in 9 volt batteries) to check the voltage at one outlet... 103 volts. that should read 110-124 volts. So I got a serious low voltage problem. I thought maybe the power company didn't unhook the neighbors downed meter loop from the line. I ran out and found the crew that had done the work. They acted like they had no idea what I was talking about. Said they were from North Carolina and didn't know what Entergy was up to. I went back to my home and thought for a minute. I decided that the compressor on the refrigerator would burn up at that voltage so I unplugged it. For some reason I checked the voltage again and it was 116 volts. That's almost normal. Then I realized there was a significant problem with my power connection. After a few minutes of thought, I found a good flashlight and check the power pole in my back yard. While unhooking the neighbors downed meter loop, the Entergy contractors had knocked one of my power lines loose. Anchor and all. Since it was the neutral leg, and my nearly new meter loop meets current electrical code (neutral leg bridges to ground leg) I had some low voltage power. The electrical ground being sunk deep into water saturated earth was completing an electrical circuit and allowing power to flow. Thing is, the ground wire was far too thin to carry 200 amps of electricity. That created a situation where the ground wire was heating up and very near to burning my house down, thus the electrical smell in the home. I figured it out just in time and cut all the breakers, including the main breaker. Now, here it is a few hours later and I've been drinking and thinking (thanks for the 6 pack Allison). My neighbor 2 doors down mentioned calling his City Councilman about this problem. Wait a second, Code Enforcement knocks on my door every 3 months or so saying a City Councilman complained about something (grass too tall, wrecked vehicle, color of paint on the house...). After some thought, while heading to get another pack of smokes, I realized this prick 2 doors down has caused all of my problems with code enforcement for nearly 5 years!!! Damn. Now he has electricity and I still don't!!! WTF!!! The seriously f'd thing is, if this man came to me tomorrow, even tho I still don't have power, and told me his family was hungry because he couldn't find the money to feed them. I would take what little food I have left in my pantry, to feed my wife and 3 kids, and give it too him. Then I would tell him if it wasn't enough let me know and I would do what I could. Everyone that knows me personally, knows I would do exactly that. So what do I do now? This man has come very close to causing my family to be homeless more than once! I have no idea how to handle this right now.