Created
December 13, 2014 00:09
-
-
Save Gabelbombe/a7145e63e213c4ab4a66 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Update servers, run via parallel | |
# | |
# CPR : Jd Daniel :: Ehime-ken | |
# MOD : 2014-12-12 @ 16:06:39 | |
# VER : 1b | |
# REF : http://www.gnu.org/software/parallel/ | |
# | |
# 5.5 or 6.6 | |
usage() { echo "Usage: $0 [-v <5.x|6.x>] [-o <string>]" 1>&2; exit 1; } | |
if [[ "$1" =~ "^((-{1,2})([Hh]$|[Hh][Ee][Ll][Pp])|)$" ]]; then | |
usage | |
else | |
while [[ $# -gt 0 ]]; do | |
opt="$1"; shift | |
current_arg="$1" | |
if [[ "$current_arg" =~ ^-{1,2}.* ]]; then | |
echo "==> WARNING: You may have left an argument blank. Double check your command." | |
fi | |
case "$opt" in | |
"-v"|"--version" ) vermajor="$1"; shift;; | |
"-o"|"--org" ) org_unit="$1"; shift;; | |
* ) echo "==> ERROR: Invalid option: \""$opt"\"" >&2 | |
exit 1;; | |
esac | |
done | |
fi | |
if [[ "$vermajor" == "" || "$org_unit" == "" ]]; then | |
echo "ERROR: Options -v and -o require arguments." >&2; exit 1 | |
fi | |
cp -f /etc/resolv.conf.prod /etc/resolv.conf | |
/etc/init.d/ntpd stop | |
server="$(head -n1 /etc/ntp.conf |grep prefer |awk '{print$2}')" | |
if [ -z "${server}" ]; then | |
echo 'Server is empty, exiting....'; exit 1 | |
fi | |
ntpdate "${server}" | |
## if OEL6 | |
if [ 6 == "$(lsb_release -r |awk '{print$2}' |head -c1)" ]; then | |
cp -f /etc/ntp.conf.prod /etc/ntp.conf | |
fi | |
## Mounting /depot/scripts | |
echo "pxcel001_dm4:/depot_master/mnt /nfs/infra nfs ro,nosuid,soft 0 0" >> /etc/fstab | |
mkdir -p /nfs/infra | |
## Mounting the Linux Depot | |
echo "pxcel001_dm2:/depot_linux_x86/mnt /depot/linux_x86 nfs ro,nosuid,soft 0 2" >> /etc/fstab | |
mkdir -p /depot/linux_x86 | |
## Mounting the USEC security share | |
echo "pxcel001_dm4:/UNIX_SECURITY_SCRIPTS/mnt/scripts /depot/USEC nfs ro,nosuid,soft 0 2" >> /etc/fstab | |
mkdir -p /depot/USEC | |
mount -a | |
yum clean all --enablerepo=ol6_addons* & | |
mkdir -p /etc/puppetlabs/facter/facts.d | |
echo -e "##############################################\n\noel_version=${vermajor}\norganization=EITorganizational_unit=${org_unit}\npci=NO_PCI\nserver_type=APP\n\n##############################################" >> /etc/puppetlabs/facter/facts.d/build.txt | |
if [ '5' == "$(echo $vermajor |head -c1)" ]; then | |
sed -ie "s/certname = .*/ certname = $(hostname)/g" /etc/puppetlabs/puppet/puppet.conf | |
rm -rf /etc/puppetlabs/puppet/ssl/ | |
fi | |
puppet agent -t --waitforcert 120 --onetime | |
bash /nfs/infra/automation/bin/fix_bash_patch | |
if [ '6.5' == "${vermajor}" ]; then | |
umount -a -t vxfs | |
rpm -Uvh /nfs/infra/veritas/sw/OEL/*.rpm | |
mount -a | |
fi | |
echo "Completed without errors...."; exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment