Kickstart RHEL6

No se ven bien los < y > :P
# Instalacion modo texto
text
install
skipx

# URL de instalacion
url –url http:///RedHat/6/Server
# Repositorio
repo –name=RHEL-6 –baseurl=http:///RedHat/6/Server
repo –name=Extras –baseurl=http:///extras

# Configuracion general
firstboot –disable
lang es_ES.UTF-8
keyboard es
rootpw –iscrypted firewall –disabled
authconfig –enableshadow –enablemd5
key –skip
selinux –disabled
timezone –utc Europe/Madrid

# Particionamiento con LVM
clearpart –all –initlabel
#zerombr yes
bootloader –location=mbr –md5pass=$1$glLthZeF$u9wREDqB6/O0WYOcZqvnJ.
part /boot –fstype ext3 –size=100 –asprimary
part pv.00 –size=1 –grow –asprimary
volgroup vg00 pv.00
logvol / –fstype ext3 –name=lvroot –vgname=vg00 –size=1024 –grow
logvol swap –fstype swap –name=lvswap –vgname=vg00 –size=512 –grow –maxsize=2048
reboot

# Paquetes
#%packages –resolvedeps
%packages

@core
@base
ntp
kernel-devel
gcc
#dkms-open-vm-tools

%pre
#!/bin/sh
chvt 3
exec < /dev/tty3 > /dev/tty3
clear
echo “- – - – Configuracion de red – - – - ”
echo -en “Introduzca direccion IP: ”
read ip

echo -en “Introduzca hostname: ”
read hostname

chvt 1
exec < /dev/tty1 > /dev/tty1

gateway=`echo $ip | cut -d. -f1,2,3`.254
netmask=
nameserver=

line=”network –bootproto static –ip $ip –netmask $netmask –hostname $hostname –gateway $gateway –nameserver $nameserver”
ks=”/tmp/ks.cfg”
sed -e “/^network/s/^network.*/$line/” $ks > ${ks}.tmp && mv ${ks}.tmp $ks
sed -e “s/ip_tag/$ip/g” $ks > ${ks}.tmp && mv ${ks}.tmp $ks
sed -e “s/gw_tag/$gateway/g” $ks > ${ks}.tmp && mv ${ks}.tmp $ks
sed -e “s/hostname_tag/$hostname/g” $ks > ${ks}.tmp && mv ${ks}.tmp $ks

%post
#!/bin/bash
chvt 3
exec < /dev/tty3 > /dev/tty3
# Banner y motd
MOTD=”Esta maquina es propiedad de y cualquier uso debe estar autorizado por el departamento de correspondiente. Cualquier otro uso sera perseguido y castigado de acuerdo a la legislacion vigente. Cualquier actividad realizada en, desde o hacia este sistema esta sujeta a monitorizacion sin previo aviso.”
echo $MOTD > /etc/motd
chmod 644 /etc/motd

chvt 1
exec < /dev/tty1 > /dev/tty1

IFACE=eth0
IFCFG_ETH0=/etc/sysconfig/network-scripts/ifcfg-eth0
NETWORK=/etc/sysconfig/network
DNS1=
DNS2=
DOMAIN=
NETMASK=
GATEWAY=gw_tag
IP=ip_tag
HOSTNAME=hostname_tag

echo “DEVICE=$IFACE” > $IFCFG_ETH0
echo “BOOTPROTO=static” >> $IFCFG_ETH0
echo “IPADDR=$IP” >> $IFCFG_ETH0
echo “NETMASK=$NETMASK” >> $IFCFG_ETH0
echo “GATEWAY=$GATEWAY” >> $IFCFG_ETH0
echo “ONBOOT=yes” >> $IFCFG_ETH0

echo “NETWORKING=yes”> $NETWORK
echo “HOSTNAME=$HOSTNAME.$DOMAIN” >> $NETWORK

echo “search $DOMAIN” > /etc/resolv.conf
echo “nameserver $DNS1″ >> /etc/resolv.conf
echo “nameserver $DNS2″ >> /etc/resolv.conf

echo “127.0.0.1 localhost.localdomain localhost” > /etc/hosts
echo “127.0.0.1 $HOSTNAME.$DOMAIN $HOSTNAME” >> /etc/hosts

# Script de sincronizacion de ntp
NTPSERVER=
echo “tinker panic 0″ > /etc/ntp.conf
echo “restrict 127.0.0.1″ >> /etc/ntp.conf
echo “restrict default kod nomodify notrap” >> /etc/ntp.conf
echo “server $NTPSERVER” >> /etc/ntp.conf
echo “driftfile /var/lib/ntp/drift” >> /etc/ntp.conf

echo “$NTPSERVER” > /etc/ntp/step-tickers

chkconfig ntpd on

# Comprimir los logs de logrotate
echo “compress” >> /etc/logrotate.conf

# Repositorios locales
BASE=http:///RedHat/repos/RHEL-6.repo
EXTRAS=http:///RedHat/repos/Extras.repo

rm -f /etc/yum.repos.d/*.repo
wget $BASE -P /etc/yum.repos.d/
wget $EXTRAS -P /etc/yum.repos.d/

RPMKEY=http:///centos/RPM-GPG-KEY-CentOS-5
wget $RPMKEY -P /etc/pki/rpm-gpg/

# Deshabilitar servicios innecesarios al arranque
SERVICIOS=”bluetooth cups gpm ip6tables iptables sendmail smartd”
for i in $SERVICIOS
do
chkconfig $i off
done

# Activar el timeout de la shell despues de 5 minutos de inactividad
echo “TMOUT=300″ >> /etc/bashrc
echo “readonly TMOUT” >> /etc/bashrc
echo “export TMOUT” >> /etc/bashrc

# Instalar VMTools
# Q&D
wget http:///vmtools/vmtools.tar.gz
tar xzvf vmtools.tar.gz
vmware-tools-distrib/vmware-install.pl –default
rm -f vmtools.tar.gz
rm -Rf vmware-tools-distrib/

# Actualizar paquetes
#yum -y update
#yum clean packages

# Confirmacion para reiniciar/apagar el equipo

cat << EOF >/usr/local/bin/confirm
#!/bin/bash
prompt()
{
while true
do
echo -n “\$* s/n? ”
read reply
if [ "\$reply" = s -o "\$reply" = S ]
then
return 0
elif [ "\$reply" = n -o "\$reply" = N ]
then
echo “Accion cancelada”
exit 1
else
echo “Por favor, introduce ‘s’ o ‘n’”
fi
done
}

echo “Se va a realizar \$1″
prompt “Esta seguro?”
\$@
EOF

chmod 755 /usr/local/bin/confirm

echo “alias reboot=\”/usr/local/bin/confirm reboot\”" >> /etc/bashrc
echo “alias shutdown=\”/usr/local/bin/confirm shutdown\”" >> /etc/bashrc
echo “alias init=\”/usr/local/bin/confirm init\”" >> /etc/bashrc
echo “alias halt=\”/usr/local/bin/confirm halt\”" >> /etc/bashrc

# Prevenir reinicios accidentales por pulsar ctrl+alt+supr
#sed -i ‘s!^ca::.*!ca::ctrlaltdel:/bin/echo “CTRL + ALT + SUPR is disabled”!g’ /etc/inittab

Post to Twitter Post to Facebook Send Gmail Post to LinkedIn

No Comments »

minWi on diciembre 1st 2011 in CentOS, sysadmin

Trackback URI | Comments RSS

Leave a Reply

  • RSS
  • Facebook
  • Google+
  • LinkedIn
  • Twitter
  • Picasa
  • Flickr
  • YouTube