Posts

Showing posts from May, 2015

Script to ask Network configuration via kickstart

%pre #!/bin/bash echo -n "Enter FQDN Hostname: " > /dev/tty1 read HOSTN echo -n "Enter IP Address:" > /dev/tty1 read IP echo -n "Enter the Netmask:" > /dev/tty1 read MASK echo -n "Enter Gateway:" > /dev/tty1 read GW echo -n "Enter Nameserver:" > /dev/tty1 read DNS echo "network --device eth0 --bootproto=static --ip=${IP} --netmask=${MASK} --gateway=${GW} --nameserver=${DNS} --hostname=${HOSTN}" > /tmp/network.txt %post --noroot #!/bin/bash # bring in hostname collected from %pre, then source it ###### cp -Rvf /etc/sysconfig/network /mnt/sysimage/etc/sysconfig/network cp -Rvf /etc/sysconfig/resolv.conf /mnt/sysimage/etc/resolv.conf # Set-up eth0 with hostname cp /etc/sysconfig/network-scripts/ifcfg-eth0  /mnt/sysimage/etc/sysconfig/network-scripts/ifcfg-eth0 # force hostname change /mnt/sysimage/bin/hostname $HOSTNAME rhn-profile-sync

Kickstar script to join linux machine to FreeIPA

First create the host on IPA Server and provide one time password in this example the password is "secret" # Get the hostname to set as the host principal chvt 3 exec </dev/tty3> /dev/tty3 clear /bin/hostname > /tmp/hostname.txt # Run the client install script echo Installing IPA Client sleep 5 /usr/sbin/ipa-client-install --domain=ipdomain.example.com --enable-dns-updates --mkhomedir -w secret --realm=IPADOMAIN.EXAMPLE.COM --server=server01.ipdomain.example.com --unattended rm -f /etc/krb5.conf cat > /etc/krb5.conf << "EOF" includedir /var/lib/sss/pubconf/krb5.include.d/ [logging]  default = FILE:/var/log/krb5libs.log  kdc = FILE:/var/log/krb5kdc.log  admin_server = FILE:/var/log/kadmind.log [libdefaults]  default_realm = IPADOMAIN.EXAMPLE.COM  dns_lookup_realm = false  dns_lookup_kdc = true  rdns = false  ticket_lifetime = 24h  forwardable = yes  udp_preference_limit = 0  default_ccach

Installation Script for Splunk

#!/bin/bash echo "Splunk Installation" yum install splunk<version> -y --nogpgcheck usermod -G <group that splunk is going to be join> splunk /opt/splunkforwarder/bin/splunk enable boot-start -user splunk --accept-license su splunk -c "/opt/splunkforwarder/bin/splunk add forward-server splunk.example.com:9997" su splunk -c "/opt/splunkforwarder/bin/splunk edit user admin -password password -auth admin:password" su splunk -c "/opt/splunkforwarder/bin/splunk start" for dir in $(find /var/point -mindepth 1 -maxdepth 1 -type d) do su splunk -c "/opt/splunkforwarder/bin/splunk add monitor $dir/logs -index $env -sourcetype $(basename $dir)" done chkconfig splunk on echo "Installation complete"

Hardening Script

#!/bin/bash function set_parameter { sed -i -e "s|^$2.*|$2$3|" $1 egrep "^$2*" $1 > /dev/null ||echo "$2$3" >> $1 } #--------------------------------------------------------------------------------------------------------------- function add_line { egrep "^$2" $1 > /dev/null || echo "$2" >> $1 } #--------------------------------------------------------------------------------------------------------------- echo '# This file contains the auditctl rules that are loaded # whenever the audit daemon is started via the initscripts. # The rules are simply the parameters that would be passed # to auditctl. # First rule - delete all -D # Increase the buffers to survive stress events. # Make this bigger for busy systems -b 8192 # Feel free to add below this line. See auditctl man page -a always,exit -F arch=b32 -S adjtimex -S settimeofday -S stime -k timechange