Fedora/CentOS Bash Library

by nbebout
0 deployments · 0 still active · last rev. 7 years ago

Compatible with: No distros currently supported
						#!/bin/bash

###########################################################
# System
###########################################################

function system_update {
  yum -y update
}

function system_primary_ip {
  # returns the primary IP assigned to eth0
  echo $(ifconfig eth0 | awk -F: '/inet addr:/ {print $2}' | awk '{ print $1 }')
}

function get_rdns {
  # calls host on an IP address and returns its reverse dns
  if [ ! -e /usr/bin/host ]; then
   yum -y install bind-utils > /dev/null
  fi
  echo $(host $1 | awk '/pointer/ {print $5}' | sed 's/\.$//')
}

function get_rdns_primary_ip {
  # returns the reverse dns of the primary IP assigned to this system
  echo $(get_rdns $(system_primary_ip))
}

function install_basics {
  yum install -y jwhois rsync openssh-clients wget
}