blob: 41e6b74c14e101cb1e59932c6845ad88fa8c65c1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
|
#version=DEVEL
# System authorization information
auth --useshadow --enablemd5
# Install OS instead of upgrade
install
# License agreement
eula --agreed
# Use text mode install
text
# Firewall configuration
firewall --disabled
firstboot --disable
# Keyboard layouts
# old format: keyboard us
# new format:
keyboard --vckeymap=us --xlayouts='us'
network --onboot no --device eth0 --bootproto dhcp --noipv6
network --onboot no --device eth1 --bootproto dhcp --noipv6
network --onboot no --device eth2 --bootproto dhcp --noipv6
# System language
lang en_US.UTF-8
# Installation logging level
logging --level=info
# Reboot after installation
reboot
# Root password
rootpw root
# SELinux configuration
selinux --disabled
# System services
services --enabled="NetworkManager,sshd"
# Do not configure the X Window System
skipx
# System timezone
timezone America/Los_Angeles --isUtc
# System bootloader configuration
%include /tmp/bootloader.ks
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
%include /tmp/partition.ks
%pre
#!/bin/sh
set -x -v
exec 1>/tmp/ks-pre.log 2>&1
# Once root's homedir is there, copy over the log.
while : ; do
sleep 10
if [ -d /mnt/sysimage/root ]; then
cp /tmp/ks-pre.log /mnt/sysimage/root/
logger "Copied %pre section log to system"
break
fi
done &
# hard drivedd
drives=(`ls -1 /sys/block | grep "sd\|hd\|vd\|cciss"`)
default_drive=${drives[0]}
for I in `cat /proc/cmdline`; do case "$I" in *=*) eval $I;; esac ; done
tgtdrive=$default_drive
format_confirmed="no"
if [ ${#drives[@]} -lt 1 ]; then
exec < /dev/tty3 > /dev/tty3 2>&1
chvt 3
clear
echo
echo '********************************************************************'
echo '* E R R O R *'
echo '* *'
echo '* There is no suitable media available for installation. *'
echo '* Please attach a drive and try again. *'
echo '* *'
echo '********************************************************************'
echo
read -p "Press Enter to shut down the system: " _
poweroff
fi
# verify tgtdrive is at least 30GB
tgtdrivesize=$(( $(cat "/sys/class/block/${tgtdrive}/size") / 2 / 1024 ))
if [ $tgtdrivesize -lt 30720 ]; then
exec < /dev/tty3 > /dev/tty3 2>&1
chvt 3
clear
echo
echo '********************************************************************'
echo '* E R R O R *'
echo '* *'
echo '* Your disk is under 30GB in size. Installation cannot continue. *'
echo '* Restart installation with a larger disk. *'
echo '* *'
echo '********************************************************************'
echo
read -p "Press Enter to restart: " _
reboot
fi
vgremove -ff os
dd if=/dev/zero of=/dev/${tgtdrive} bs=10M count=10
sleep 3
hdparm -z /dev/${tgtdrive}
parted -s /dev/${tgtdrive} mklabel gpt
parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary 0 24
parted -s /dev/${tgtdrive} set 1 bios_grub on
parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary fat16 24 224
parted -s /dev/${tgtdrive} set 2 boot on
parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary 224 424
sleep 3
hdparm -z /dev/${tgtdrive}
# partition
cat << EOF > /tmp/partition.ks
part swap --asprimary --fstype="swap" --ondisk=sda --size=3072
part /boot --asprimary --fstype="ext3" --ondisk=sda --size=500
part pv.64 --fstype="lvmpv" --ondisk=sda --size=$((tgtdrivesize-3600))
volgroup os --pesize=4096 pv.64
logvol /var --fstype="ext3" --grow --percent=40 --name=varvol --vgname=os
logvol /tmp --fstype="ext3" --grow --percent=5 --name=tmpvol --vgname=os
logvol / --fstype="ext3" --grow --percent=50 --name=rootvol --vgname=os
logvol /home --fstype="ext3" --grow --percent=5 --name=homevol --vgname=os
EOF
# bootloader setting
echo "bootloader --location=mbr --driveorder=${tgtdrive} --append=' biosdevname=0 crashkernel=none'" > /tmp/bootloader.ks
%end
%post
echo -e "modprobe nf_conntrack_ipv4\nmodprobe nf_conntrack_ipv6\nmodprobe nf_conntrack_tftp\nmodprobe nf_nat_tftp" >> /etc/rc.modules
chmod +x /etc/rc.modules
echo -e "net.nf_conntrack_max=1048576" >> /etc/sysctl.conf
mkdir -p /var/log/coredump
echo -e "kernel.core_pattern=/var/log/coredump/core.%e.%p.%h.%t" >> /etc/sysctl.conf
chmod 777 /var/log/coredump
echo -e "* soft core unlimited\n* hard core unlimited" >> /etc/security/limits.conf
%end
%post --nochroot --log=/root/anaconda-post-before-chroot.log
#!/bin/sh
set -x
SOURCE="/mnt/sysimage/tmp/source"
for I in `cat /proc/cmdline`; do case "$I" in *=*) eval $I;; esac ; done
mkdir -p "${SOURCE}"
mount -o bind "/mnt/install/source" "${SOURCE}"
%end
%post --logfile /var/log/post_install.log
set -x -v
exec 1>/root/ks-post.log 2>&1
function save_nic_cfg() {
scrFile="/etc/sysconfig/network-scripts/ifcfg-$1"
sed -i -e 's#^\(HOSTNAME=\).*$#\1'"$hostname"'#' /etc/sysconfig/network
grep -q "^\s*$2\s+$hostname" /etc/hosts || echo "$2 $hostname" >> /etc/hosts
echo DEVICE=$1> $scrFile
echo ONBOOT=yes >> $scrFile
echo NM_CONTROLLED=no >> $scrFile
echo HWADDR=$4 >> $scrFile
echo USERCTL=no >> $scrFile
echo PEERDNS=no >> $scrFile
echo BOOTPROTO=static >> $scrFile
echo IPADDR=$2 >> $scrFile
echo NETMASK=$3 >> $scrFile
}
function save_gateway() {
if [[ -z $external_gw ]]; then
echo GATEWAY=$gw >> /etc/sysconfig/network
else
echo GATEWAY=$external_gw >> /etc/sysconfig/network
fi
search="domain $domain\nsearch $domain"
echo -e "${search}\nnameserver 127.0.0.1" > /etc/resolv.conf
[ $dns1 ] && echo -e "${search}\nnameserver $dns1" > /etc/resolv.conf
[ $dns1 ] && echo -e "${search}\nnameserver $dns1" > /etc/dnsmasq.upstream
[ $dns2 ] && echo "nameserver $dns2" >> /etc/resolv.conf
[ $dns2 ] && echo "nameserver $dns2" >> /etc/dnsmasq.upstream
if [[ -z "$dns1" && -z "$dns2" ]]; then
if [[ -z $external_gw ]]; then
echo "nameserver $gw" >> /etc/resolv.conf
else
echo "nameserver $external_gw" >> /etc/resolv.conf
fi
fi
}
# Default FQDN
hostname="compass"
for I in `cat /proc/cmdline`; do case "$I" in *=*) eval $I;; esac ; done
domain=$hostname
gw=$gw
ex_gw=$external_gw
install_ip=$install_ip
install_netmask=$install_netmask
install_intf="eth1"
#install_hwaddr=`ifconfig $install_intf | grep -i hwaddr | sed -e 's#^.*hwaddr[[:space:]]*##I'`
save_nic_cfg $install_intf $install_ip $install_netmask $install_hwaddr
mgmt_ip=$mgmt_ip
mgmt_netmask=$mgmt_netmask
mgmt_intf="eth0"
#mgmt_hwaddr=`ifconfig $mgmt_intf | grep -i hwaddr | sed -e 's#^.*hwaddr[[:space:]]*##I'`
save_nic_cfg $mgmt_intf $mgmt_ip $mgmt_netmask $mgmt_hwaddr
external_ip=$external_ip
external_netmask=$external_mask
external_intf="eth2"
#external_hwaddr=`ifconfig $external_intf | grep -i hwaddr | sed -e 's#^.*hwaddr[[:space:]]*##I'`
save_nic_cfg $external_intf $external_ip $external_netmask $external_hwaddr
save_gateway
SOURCE=/tmp/source
FS=/tmp/fs
mkdir -p ${SOURCE}
mkdir -p ${FS}
repodir="/var/lib/install_iso"
# Copying Centos files
mkdir -p ${repodir}
cp -rf ${SOURCE} ${repodir}/source
rm -rf ${repodir}/source/bootstrap/ \
${repodir}/source/compass/ \
${repodir}/source/guestimg/ \
${repodir}/source/pip/ \
${repodir}/source/repos
mkdir -p /root/.ssh /var/www /opt/cobbler
chmod 700 /root/.ssh
cat ${SOURCE}/bootstrap/boot.rsa.pub >> /root/.ssh/authorized_keys
cp -rf ${SOURCE}/compass/* /opt
cp -rf ${SOURCE}/repos/cobbler/* /opt/cobbler/
cp -rf ${SOURCE}/ansible/* /opt
cp -rf ${SOURCE}/repos/* /opt
cp -rf ${SOURCE}/loaders.tar.gz /opt
cp -rf ${SOURCE}/pip /var/www/pip
cp -rf ${SOURCE}/pip-openstack /var/www/pip-openstack
cp -rf ${SOURCE}/guestimg /var/www/guestimg
tar -zxvf ${SOURCE}/app_packages/packages.tar.gz -C /var/www
# Prepare local repository specification
rm /etc/yum.repos.d/CentOS*.repo
cat > /etc/yum.repos.d/install_iso.repo << EOF
[install_iso]
name=local repo
baseurl=file:$repodir/source
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
sed -i 's/Defaults requiretty/#Defaults requiretty/g' /etc/sudoers
sed -i 's/^UseDNS/#UseDNS/g' /etc/ssh/sshd_config
echo "UseDNS no" >> /etc/ssh/sshd_config
# End post_install_network_config generated code
%end
%packages --nobase
@core
%end
|