262 lines
7.1 KiB
INI
262 lines
7.1 KiB
INI
install
|
|
text
|
|
%include /tmp/source.ks
|
|
reboot --eject
|
|
lang en_US.UTF-8
|
|
keyboard us
|
|
rootpw r00tme
|
|
timezone --utc UTC
|
|
zerombr
|
|
%include /tmp/bootloader.ks
|
|
clearpart --all --initlabel
|
|
autopart
|
|
|
|
%pre
|
|
#!/bin/sh
|
|
|
|
# source
|
|
if test -e /dev/disk/by-uuid/will_be_substituted_with_actual_uuid; then
|
|
echo "harddrive --partition=UUID=will_be_substituted_with_actual_uuid --dir=/" > /tmp/source.ks
|
|
else
|
|
echo "cdrom" > /tmp/source.ks
|
|
fi
|
|
|
|
# bootloader
|
|
drvo=""
|
|
for drv in `ls -1 /sys/block | grep "sd\|hd"`; do
|
|
if (grep -q 0 /sys/block/${drv}/removable); then
|
|
if [ "${drvo}" != "" ]; then
|
|
drvo=${drvo},${drv}
|
|
else
|
|
drvo=${drv}
|
|
fi
|
|
fi
|
|
done
|
|
echo "bootloader --location=mbr --driveorder=${drvo}" > /tmp/bootloader.ks
|
|
|
|
%end
|
|
|
|
%packages --nobase --excludedocs
|
|
@Core
|
|
wget
|
|
curl
|
|
crontabs
|
|
cronie
|
|
puppet-2.7.19
|
|
man
|
|
yum
|
|
openssh-clients
|
|
ntp
|
|
|
|
%post
|
|
|
|
function setconf {
|
|
echo
|
|
echo -n "Enter hostname (FQDN): "; read hostname
|
|
echo -n "Enter device name: "; read device
|
|
echo -n "Enter ip: "; read ip
|
|
echo -n "Enter netmask: "; read netmask
|
|
echo -n "Enter default gw: "; read gw
|
|
echo -n "Enter First DNS server: "; read dns1
|
|
echo -n "Enter Second DNS server: "; read dns2
|
|
hwaddr=`ifconfig $device | grep -i hwaddr | sed -e 's#^.*hwaddr[[:space:]]*##I'`
|
|
echo
|
|
echo You entered:
|
|
show
|
|
echo
|
|
echo -n "Do you want to keep this settings (y/N):"
|
|
read -n 1 answer
|
|
if [[ $answer == "y" || $answer == "Y" ]]; then
|
|
save_cfg
|
|
fi
|
|
echo
|
|
echo -n "Do you want to configure another adapter (y/N):"
|
|
read -n 1 answer
|
|
if [[ $answer == "n" || $answer == "N" || $answer == "" ]]; then
|
|
endconf=1
|
|
fi
|
|
}
|
|
|
|
function show {
|
|
echo "Device: $device, MAC address $hwaddr"
|
|
echo "Hostname: $hostname"
|
|
[ -z $ip ] && echo "IP address: will be obtained via DHCP"
|
|
[ ! -z $ip ] && echo "IP address: $ip Netmask: $netmask"
|
|
echo "Gateway: $gw"
|
|
echo "DNS Server 1: $dns1"
|
|
echo "DNS Server 2: $dns2"
|
|
}
|
|
|
|
function save_cfg {
|
|
scrFile="/etc/sysconfig/network-scripts/ifcfg-$device"
|
|
sed -i -e 's#^\(HOSTNAME=\).*$#\1'"$hostname"'#' /etc/sysconfig/network
|
|
grep -q "^\s*$ip\s+$hostname" /etc/hosts || echo "$ip $hostname" >> /etc/hosts
|
|
echo GATEWAY=$gw >> /etc/sysconfig/network
|
|
|
|
echo DEVICE=$device > $scrFile
|
|
echo ONBOOT=yes >> $scrFile
|
|
echo NM_CONTROLLED=no >> $scrFile
|
|
echo HWADDR=$hwaddr >> $scrFile
|
|
echo USERCTL=no >> $scrFile
|
|
if [ $ip ]; then
|
|
echo BOOTPROTO=static >> $scrFile
|
|
echo IPADDR=$ip >> $scrFile
|
|
echo NETMASK=$netmask >> $scrFile
|
|
[ $dns1 ] && echo DNS1=$dns1 >> $scrFile
|
|
[ $dns2 ] && echo DNS2=$dns2 >> $scrFile
|
|
else
|
|
echo BOOTPROTO=dhcp >> $scrFile
|
|
fi
|
|
}
|
|
|
|
# Default FQDN
|
|
hostname="nailgun.mirantis.com"
|
|
|
|
set -- `cat /proc/cmdline`
|
|
for I in $*; do case "$I" in *=*) eval $I;; esac ; done
|
|
hostname=$hostname
|
|
ip=$ip
|
|
netmask=$netmask
|
|
gw=$gw
|
|
device="eth0"
|
|
hwaddr=`ifconfig $device | grep -i hwaddr | sed -e 's#^.*hwaddr[[:space:]]*##I'`
|
|
|
|
curTTY=`tty`
|
|
exec < $curTTY > $curTTY 2>&1
|
|
clear
|
|
|
|
endconf=0
|
|
show
|
|
echo -n "Press any key to make changes in network configuration"
|
|
read -n 1 -t 5 answer
|
|
if [ $? -gt 128 ]; then
|
|
save_cfg
|
|
else
|
|
while [ $endconf -eq 0 ]; do
|
|
echo
|
|
echo -n "Do you want to configure settings manually (y/N):"
|
|
read -n 1 answer
|
|
if [[ $answer == "y" || $answer == "Y" ]]; then
|
|
setconf
|
|
else
|
|
endconf=1
|
|
fi
|
|
done
|
|
fi
|
|
|
|
tail -F /root/post.log &
|
|
exec 1>/root/post.log 2>&1
|
|
|
|
# Mounting installation source
|
|
SOURCE=/tmp/source
|
|
FS=/tmp/fs
|
|
|
|
echo
|
|
mkdir -p ${SOURCE}
|
|
mkdir -p ${FS}
|
|
|
|
if test -e /dev/disk/by-uuid/will_be_substituted_with_actual_uuid; then
|
|
mount /dev/disk/by-uuid/will_be_substituted_with_actual_uuid ${FS}
|
|
mount -o loop ${FS}/nailgun.iso ${SOURCE}
|
|
else
|
|
mount /dev/cdrom ${SOURCE}
|
|
fi
|
|
|
|
# Copying Repo to the nailgun /var/www directory
|
|
repodir="/var/www/nailgun"
|
|
mkdir -p ${repodir}/centos/6.3/nailgun/x86_64
|
|
cp -r ${SOURCE}/images ${repodir}/centos/6.3/nailgun/x86_64
|
|
cp -r ${SOURCE}/isolinux ${repodir}/centos/6.3/nailgun/x86_64
|
|
cp -r ${SOURCE}/repodata ${repodir}/centos/6.3/nailgun/x86_64
|
|
cp -r ${SOURCE}/Packages ${repodir}/centos/6.3/nailgun/x86_64
|
|
cp ${SOURCE}/more_rpm/MySQL-shared-5.5.28-1.el6.x86_64.rpm ${SOURCE}/more_rpm/MySQL-client-5.5.28-1.el6.x86_64.rpm ${SOURCE}/more_rpm/MySQL-server-5.5.28_wsrep_23.7-1.rhel5.x86_64.rpm ${SOURCE}/more_rpm/galera-23.2.2-1.rhel5.x86_64.rpm ${repodir}
|
|
|
|
# Copying eggs/gems to the nailgun directory
|
|
cp -r ${SOURCE}/eggs ${repodir}
|
|
cp -r ${SOURCE}/gems ${repodir}
|
|
|
|
# Copying bootstrap image
|
|
mkdir -p ${repodir}/bootstrap
|
|
cp -r ${SOURCE}/bootstrap/initramfs.img ${repodir}/bootstrap
|
|
cp -r ${SOURCE}/bootstrap/linux ${repodir}/bootstrap
|
|
|
|
mkdir -p /root/.ssh
|
|
chmod 700 /root/.ssh
|
|
cp ${SOURCE}/bootstrap/bootstrap.rsa /root/.ssh
|
|
chmod 600 /root/.ssh/bootstrap.rsa
|
|
|
|
# Unpacking puppet manifests for master and slave
|
|
cp ${SOURCE}/puppet-slave.tgz ${repodir}/
|
|
mkdir -p /opt/nailgun_puppet
|
|
tar zxf ${SOURCE}/puppet-nailgun.tgz -C /opt/nailgun_puppet
|
|
tar zxf ${SOURCE}/puppet-slave.tgz -C /etc/puppet/modules
|
|
sed -i /etc/puppet/modules/galera/manifests/init.pp -e "s/http:\/\/download.mirantis.com\/epel-fuel\/x86_64/http:\/\/${ip}:8080/"
|
|
mkdir -p /etc/puppet/manifests/
|
|
cp /etc/puppet/modules/osnailyfacter/examples/site.pp /etc/puppet/manifests/site.pp
|
|
|
|
# Prepare local repository specification
|
|
rm /etc/yum.repos.d/CentOS*.repo
|
|
cat > /etc/yum.repos.d/nailgun.repo << EOF
|
|
[nailgun]
|
|
name=Nailgun Local Repo
|
|
baseurl=file:/var/www/nailgun/centos/6.3/nailgun/x86_64
|
|
gpgcheck=0
|
|
EOF
|
|
|
|
# Disable GSSAPI in ssh server config
|
|
sed -i -e "/^\s*GSSAPICleanupCredentials yes/d" -e "/^\s*GSSAPIAuthentication yes/d" /etc/ssh/sshd_config
|
|
|
|
# Copying bootstrap_admin_node.sh , chmod it and adding to the rc.local to run it once
|
|
cp ${SOURCE}/bootstrap_admin_node.sh /usr/local/sbin/bootstrap_admin_node.sh
|
|
chmod 0777 /usr/local/sbin/bootstrap_admin_node.sh
|
|
echo "/usr/local/sbin/bootstrap_admin_node.sh" >> /etc/rc.local
|
|
|
|
# Prepare custom /etc/issue logon banner and script for changing IP in it
|
|
cat > /etc/issue << EOF
|
|
############################################
|
|
# Welcome to the Nailgun server #
|
|
############################################
|
|
Server is running on \m platform
|
|
|
|
Nailgun web UI is available on: http://:8000
|
|
|
|
Default administrator login: root
|
|
Default administrator password: r00tme
|
|
|
|
Please change root password on first login.
|
|
|
|
EOF
|
|
|
|
echo "sed -i \"s%\(^.*able on:\).*$%\1 http://\`ip address show eth0 | awk '/inet / {print \$2}' | cut -d/ -f1 -\`:8000%\" /etc/issue" >>/etc/rc.local
|
|
|
|
# Unmounting source
|
|
umount -f ${SOURCE}
|
|
rm -rf ${SOURCE}
|
|
|
|
umount -f ${FS} || true
|
|
rm -rf ${FS}
|
|
|
|
# Enabling/configuring NTPD and ntpdate services
|
|
echo "server 127.127.1.0" >> /etc/ntp.conf
|
|
echo "fudge 127.127.1.0 stratum 10" >> /etc/ntp.conf
|
|
echo "tos orphan 7" >> /etc/ntp.conf
|
|
|
|
chkconfig ntpd on
|
|
chkconfig ntpdate on
|
|
|
|
# Do not show error message on ntpdate failure. Customers should not be confused
|
|
# if admin node does not have access to the internet time servers.
|
|
sed -i /etc/rc.d/init.d/ntpdate -e 's/\([ $RETVAL -eq 0 ] && success || \)failure/\1success/'
|
|
|
|
# Disabling splash
|
|
sed -i --follow-symlinks -e '/^\skernel/ s/rhgb//' /etc/grub.conf
|
|
sed -i --follow-symlinks -e '/^\skernel/ s/quiet//' /etc/grub.conf
|
|
|
|
# Disabling first console clearing
|
|
sed -i 's/getty/getty --noclear/' /etc/init/tty.conf
|
|
|
|
# Copying default bash settings to the root directory
|
|
cp -f /etc/skel/.bash* /root/
|
|
|
|
%end
|