SME9 Kickstart

From SME Server
Revision as of 21:24, 22 January 2013 by RequestedDeletion (talk | contribs)
Jump to navigationJump to search

Awaiting 'dashed borders' to be enabled on the wiki. That will show the difference between normal text like this en source code, where code starts and where code ends.

#platform=x86, AMD64, or Intel EM64T
#version=DEVEL - DRAFT
%pre

# eval options
set -- `cat /proc/cmdline`

for I in $*; do case "$I" in *=*) eval $I;; esac; done

# Determine how many drives we have
set $(list-harddrives)
if [ -z "$disks" ]; then
    let numd=$#/2
    d1=$1
    d1_size=$2
    d2=$3
    d2_size=$4
else
    d1=`echo $disks | awk 'BEGIN { FS = "," } ; { print $1 }'`
    d2=`echo $disks | awk 'BEGIN { FS = "," } ; { print $2 }'`
    if [ -z "$d2" ]; then
       numd=2
    else
       numd=4
    fi
fi

if [ $numd -eq 2 ] || [ $raid = "none"  ] ; then
    target=$d1
    if [ $d1 == "sr0" ]; then
	target=$d2
    fi

    cat <<EOF >> /tmp/part-include
    # 1 disk, no raid
    part /boot --fstype ext3 --size 512
    part pv.1 --asprimary --fstype='physical volume (LVM)' --ondisk=$target --size=5000 --grow
EOF
    echo "bootloader --location=mbr --driveorder=\"$d1\" --append=\" rhgb crashkernel=auto quiet\"" > /tmp/bootloader-include
elif [ $numd -ge 3 ]; then

    target1=$d1
    target2=$d2
    if [ $d1 == "sr0" ]; then
	target1=$d2
        target2=$5
    elif [ $d2 == "sr0" ]; then
	target1=$d1
	target2=$5
    elif [ $5 == "sr0" ]; then
	target1=$d1
	target2=$d2
    fi

    cat <<EOF >> /tmp/part-include
    # 2 disks, raid 1
    part raid.00 --asprimary --fstype='raid' --ondisk=$target1 --size=512 # boot
    part raid.01 --asprimary --fstype='raid' --ondisk=$target1 --size=5000 --grow# root

    part raid.10 --asprimary --fstype='raid' --ondisk=$target2 --size=512 # boot
    part raid.11 --asprimary --fstype='raid' --ondisk=$target2 --size=5000 --grow# root

    raid /boot --device=md1 --fstype='ext3' --level=1 raid.00 raid.10
    raid pv.1 --device=md2 --fstype='physical volume (LVM)' --level=1 raid.01 raid.11
EOF
    echo "bootloader --location=mbr --driveorder='$target1,$target2' --append=' rhgb crashkernel=auto quiet '" > /tmp/bootloader-include
fi

# enable dhcp on all network interfaces
for net in `find /sys/class/net/ ! -name lo | cut -d '/' -f5`; do
    echo "network --onboot=yes --bootproto=dhcp --device=$net">>/tmp/network-include
done

# set keyboard
if [ -z $keyboard ]; then
   keyboard=us
fi
echo "keyboard $keyboard" > /tmp/keyboard-include

# set language
if [ -z $lang ]; then
   lang=en_US
fi
echo "lang $lang" > /tmp/lang-include

# set timezone
if [ -z $timezone ]; then
   timezone="--utc Greenwich"
fi
echo "timezone $timezone" > /tmp/timezone-include


%end

# Use text mode install
text
# Install OS instead of upgrade
install
# Firewall configuration
firewall --enabled --ssh
# Use CDROM installation media
cdrom
# Network information
%include /tmp/network-include
# Root password --> needs to be changes for SME9
rootpw --plaintext Nethesis,1234
# System authorization information --> needs to be changes for SME9
auth  --useshadow  --passalgo=sha512
# System keyboard
%include /tmp/keyboard-include
# System language
%include /tmp/lang-include
# SELinux configuration
selinux --permissive
# Do not configure the X Window System
skipx
# Installation logging level
logging --level=debug
# System timezone
%include /tmp/timezone-include
# System bootloader configuration
%include /tmp/bootloader-include
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all  
# Disk partitioning information
%include /tmp/part-include
# LVM
volgroup VolGroup pv.1 
logvol swap --fstype swap --name=lv_swap --vgname=VolGroup --recommended --maxsize=6000
logvol / --fstype ext4 --name=lv_root --vgname=VolGroup --size=5000 --grow  


%post --nochroot --interpreter /bin/bash
exec 1>/mnt/sysimage/root/kickstart-stage1.log 2>&1
echo "Copying extras repo to /root.."
cp -r /mnt/source/extras /mnt/sysimage/root

if [ -f /tmp/raid ]; then
    cat /tmp/raid >> /mnt/sysimage/etc/mdadm.conf
fi
%end

%post --interpreter /bin/bash
exec 1>/root/kickstart-stage2.log 2>&1

TMPEXTRAS_DIR=/tmp/yumextras
EXTRASREPO_DIR=/root/extras

mkdir -p ${TMPEXTRAS_DIR}

echo "Initializing temporary yum repository..."
cat > ${TMPEXTRAS_DIR}/yumextras.conf << EOF
[main]
cachedir=${TMPEXTRAS_DIR}/cache
logfile=${TMPEXTRAS_DIR}/yum.log
debuglevel=2
reposdir=/dev/null
retries=20
obsoletes=1
gpgcheck=0
assumeyes=1
metadata_expire=never
mirrorlist_expire=never

[extras]
name=extras
baseurl=file://${EXTRASREPO_DIR}
enabled=1

EOF

echo "Installing nethserver-core package group..." # --> needs to be changed for SME9
yum -c ${TMPEXTRAS_DIR}/yumextras.conf -y groupinstall nethserver-core

echo "Adjusting services..."

/sbin/chkconfig fcoe off
/sbin/chkconfig iscsi off
/sbin/chkconfig iscsid off
/sbin/chkconfig netfs off
/sbin/chkconfig nfslock off

echo "Enabling first-boot..."
touch /var/spool/first-boot

echo "Removing installation files..."
rm -rfv ${TMPEXTRAS_DIR} ${EXTRASREPO_DIR}

%end