#!/bin/bash # # RedHat/CentOS/Fedora post install customization utility # created by Tamas Meszaros # # Version 20141215 # # References # RedHat Installation Guide, Deployment Guide, Storage Admin Guide # NSA Security Guide # http://www.firewing1.com/howtos/servers/centos5/security_and_reliability # http://www.server-world.info/en/ # and others mentioned below and in separate script files # # TODO list (known issues): # - not all commands are logged in the logfile # # This script can be freely distributed and modified under GPLv2. # See http://www.gnu.org/licenses/gpl-2.0.html # # Base directory to store files SETUPDIR=/root/post-install # Other locations used by the install scripts LOG=${SETUPDIR}/customizations.log STATDIR=${SETUPDIR}/status VARS=${STATDIR}/variables FWRULESDIR=${SETUPDIR}/firewall-rules mkdir -p ${SETUPDIR} ${FWRULESDIR} ${STATDIR} cd ${SETUPDIR} cat <&1 >/dev/null fi if [ -x /usr/sbin/dmidecode ]; then MANUFACTURER=$(dmidecode -s system-manufacturer) PRODUCT=$(dmidecode -s system-product-name) SERIAL=$(dmidecode -s system-serial-number) else MANUFACTURER=unknown PRODUCT=unknown SERIAL=unknown fi echo "Done." cat << EOF --- SYSTEM INFO -------------------------------------------------------------- Hostname : $HOSTNAME Manufacturer: $MANUFACTURER Product name: $PRODUCT Serial : $SERIAL Distro : ${OS} ${OSVER} Timezone : $TZNAME IP address : $IPADDR ($NETDEV) Network : $IPZONE ------------------------------------------------------------------------------ EOF echo -n "Downloading setup scripts for this distro..." SFILES=${OS}-${OSMAJOR}-setup.tar.gz curl -sf -o ${SFILES} http://blog.mit.bme.hu/meszaros/${SFILES} if [ $? -ne 0 ]; then echo "This OS version (${OS}-${OSMAJOR}) is not supported. Exiting..." exit 1 fi # Erase old setup files \rm -r ${OS}-${OSMAJOR}-setup 2>/dev/null tar xzf ${SFILES} # Moving patches to a separate location \rm -r patches 2> /dev/null mv ${OS}-${OSMAJOR}-setup/patches . cd ${OS}-${OSMAJOR}-setup . .progress_bar.sh . .functions.sh # trap keyboard interrupt (control-c) trap killme SIGINT SCRIPTS=$(ls *.setup) NSCRIPTS=$(ls *.setup | wc -l) echo "${NSCRIPTS} found." if askif "Do you want to list the available setup scripts?" n; then echo "---- Available setup tools supported by ${OS} ${OSMAJOR} -----------------------------" for i in `ls [0-9][0-9]-*.setup`; do grep '# description: ' $i | cut -d: -f 2 done echo "------------------------------------------------------------------------------" echo -n "Press enter: " read pp fi touch ${LOG} clear cat <. In order to monitor what this script is doing open a new session to this machine (${IPADDR}) and issue the following command: tail -f ${LOG} Installing is not everything. The scripts will do some config work but you'll need to review and finalize the software configurations. A list of TODOs will be placed in ${STATDIR} for each installed application. If you mess up anything, just press 'x' and start over. Most scripts will work if you run them again (after deleting their stat file). ------------------------------------------------------------------------------ EOF sleep 2 if askif "Ready?" n; then cat <>${LOG} ############################################################################# # Detailed log of the rhsetup post install scripts # ############################################################################# Run at `date` by `whoami` [`id -u --real`] EOF else exit fi cat <>> `grep '# description: ' $i | cut -d: -f 2` [${defans}] " read pp if [ "${pp}" == "x" ]; then # exit from the loop break fi while [ "${pp}" == "i" ]; do grep '^# info: ' $i | cut -d: -f 2- echo -n ">>> `grep '# description: ' $i | cut -d: -f 2` [${defans}] " read pp done if [ "${pp}" == "" ]; then # use the default answer pp=$defans fi if [ ${pp} == y ]; then rhscript=$i # todo file written by the script TODO=${STATDIR}/${rhscript} grep "Version " "$i" >> ${TODO} cat << EOF >> ${TODO} # run at `date` EOF . $i fi done echo "***************************" echo "******** Finished. ********" echo "***************************" echo "##########################################################################" >> ${LOG}