Month: July 2009

Programmatically installing a list of Linux Packages read from a file


The only thing that you would have to change in the following is the name of the file (file0) and then the command to load the RPMs … they use up2date here but you could change out to “rpm -Uvh $line”. 

My text file is just a list of packages (each package on a separate line). 

#!/bin/bash
#Check to make sure that the file containing the list of packages is present
file0=”/home/oracle/rh_packages.txt”
if [ -f “$file0” ]; then
  while read line
  do up2date $line
  done < “$file0”
else
  echo -n “List of packages is not available, skipping package install”
fi

Bash Script to set up Oracle Identity Environment on Linux


#!/bin/bash

#############################################################

# Created on: 2/17/09

# Last Updated: 07/09/09

# Version 2.1.6

#############################################################

#clear the screen

clear

#check for root user (this script must be run as root)

if [[ $EUID -ne 0 ]]; then

echo “This script must be run as root” 1>&2

exit 1

fi

# Confirm Start of Installation

echo -n “Are you sure that you want to continue? [y/n] ”

read resp

if [ $resp != “Y” ] || [ $resp != “y” ]

then

echo “Exiting Installation”

exit

fi

# Create the Oracle User

echo “Creating ‘oracle’ user and groups”

echo “check if group oinstall exist:”

egrep “oinstall” /etc/group >/dev/null

if [ $? -eq 0 ]; then

echo “group: oinstall already exists”

else

groupadd oinstall

echo “group: oinstall added.”

fi

echo “check if dba group exists:”

egrep “dba” /etc/group >/dev/null

if [ $? -eq 0 ]; then

echo “group: dba already exists”

else

groupadd dba

echo “group: dba added.”

fi

echo “check to see if ‘oracle’ exists”

egrep “oracle” /etc/passwd >/dev/null

if [ $? -eq 0 ]; then

echo “oracle already exists.”

else

useradd -g oinstall -G dba -d /home/oracle -m -s /bin/bash oracle

echo “user: oracle added.n”

passwd oracle

fi

# Creating Oracle Base Directory

echo “Create Oracle_Base directory”echo “Create Oracle_Base directory”

echo -e “Please enter the full of the Oracle Home”

read oh

mkdir -p $oh

chown -R oracle:oinstall $oh

# Kernel Parameter Modifications.

echo “Making kernel changes permanant by modifying /etc/sysctl.conf”

echo “# Kernel parameters required by Oracle” >> /etc/sysctl.conf

echo “kernel.msgmni = 2878” >> /etc/sysctl.conf

echo “kernel.msgmax = 8192” >> /etc/sysctl.conf

echo “kernel.msgmnb = 65535” >> /etc/sysctl.conf

echo “kernel.sem = 256 32000 100 142” >> /etc/sysctl.conf

echo “kernel.shmall = 2097152” >> /etc/sysctl.conf

echo “kernel.shmmax = 4294967295” >> /etc/sysctl.conf

echo “kernel.shmmni = 4096” >> /etc/sysctl.conf

echo “fs.file-max = 131072” >> /etc/sysctl.conf

echo “net.ipv4.ip_local_port_range = 20000 65000” >> /etc/sysctl.conf

echo “Finished modifying /etc/sysctl.conf”

# Flush the sysctl.conf file after making the above changes.

/sbin/sysctl -p

# change to the oracle home directory

cd /home/oracle

echo “Create Environment source file:”

touch /home/oracle/infra.env

echo “ORACLE_BASE=/opt/oracle; export ORACLE_BASE” >> /home/oracle/infra.env

echo “ORACLE_HOME=$ORACLE_BASE/ias1; export ORACLE_HOME” >> /home/oracle/infra.env

echo “LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32:/lib:/user/local/bin; export LD_LIBRARY_PATH” >> /home/oracle/infra.env

echo “ORACLE_SID=orcl; export ORACLE_SID” >> /home/oracle/infra.env

echo “PATH=/usr/bin:$ORACLE_HOME/bin:$ORACLE_HOME/opmn/bin:$PATH; export PATH” >> /home/oracle/infra.env

# Change ownership of infra.env to oracle:oinstall

chown oracle:oinstall /home/oracle/infra.env

clear

echo -e “Oracle Environment Setup is Complete.”

exit 1