Tuesday, July 10, 2012

Patching or Installing Java in Ubuntu from a POB recipe

Patching Java is just about reinstalling it. I commonly use symlinks so changing from version to version should be easy. Massively updating Java is important especially when a security update is placed by Oracle.

Remoto-IT can be used to remotely deploy the below recipe. Note that it uses a mounting point and some simple common recipes that allows to mount to the correct CIFS mounting point:
#!/bin/bash -e

USAGE="Usage: `basename $0`      "
POB_LOCAL_RES_DIR="/mnt/pob-resource-repository"
CREDENTIALS_PATH="/root/projects/cifs/cifs_smbmount.txt"

distributionFileName=$1
distributionVersion=$2
windowsDomain=$3
linuxUser=$4
linuxGroup=$5
cifsDirectory=$6

if [ $# -ne "6" ] 
then
 echo $USAGE
  exit 1 
fi

common/umount-path.sh $POB_LOCAL_RES_DIR
common/mount-cifs.sh $cifsDirectory $POB_LOCAL_RES_DIR $CREDENTIALS_PATH $windowsDomain $linuxUser $linuxGroup
cp /mnt/pob-resource-repository/$distributionFileName /opt/
cd /opt
rm -fr /opt/$distributionVersion
chmod +x $distributionFileName
echo "yes" "\n" | ./$distributionFileName 1>/dev/null
rm -f $distributionFileName
rm -f /usr/bin/java /usr/bin/javac /usr/bin/jar
ln -s /opt/$distributionVersion/bin/java /usr/bin/java
ln -s /opt/$distributionVersion/bin/javac /usr/bin/javac
ln -s /opt/$distributionVersion/bin/jar /usr/bin/jar
chown -R $linuxUser:$linuxGroup /opt/$distributionVersion/
java -version
The above is invoked as in:
common/java.sh jdk-6u33-linux-x64.bin jdk1.6.0_33 myWindowsDomain myLinuxUser myLinuxGroup //filer.sample.com/pob-resource-repository
And as you already noticed there are two recipes it relies upon. One to mount:
#!/bin/bash -e
# mount-cifs.sh

USAGE="Usage: `basename $0` <cifsPath> <localPath> <credentialsPath> <domain> <uid> <gid>"

cifsPath=$1
localPath=$2
credentialsPath=$3
domain=$4
uid=$5
gid=$6


if [ $# -ne "6" ] 
then
 echo $USAGE
  exit 1 
fi

if ! grep -qs "$localPath" /proc/mounts; then
    mount -t cifs "$cifsPath" "$localPath" -o credentials=$credentialsPath,domain=$domain,file_mode=0600,dir_mode=0700,uid=$uid,gid=$gid
fi
And the one to unmount:
#!/bin/bash -e
# umount-path.sh

USAGE="Usage: `basename $0` <localPath>"

localPath=$1


if [ $# -ne "1" ] 
then
 echo $USAGE
  exit 1 
fi

if grep -qs "$localPath" /proc/mounts; then
    umount "$localPath"
fi
Of course it is expected CIFS to be available and a file with the credentials to exist. Here is a sample POB recipe that I use to make sure CIFS is installed:
#!/bin/bash -e
# cifs.sh

apt-get -q -y install smbfs
mkdir -p /mnt/pob-resource-repository
mkdir -p  /root/projects/cifs
cd /root/projects/cifs
svn export http://svn.sample.com/repos/reporting/environment/production/settings/bhub-tomcat-all/cifs_smbmount.txt

No comments:

Followers