/
ks.cfg
353 lines (308 loc) · 9.8 KB
/
ks.cfg
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
# Kickstart file automatically generated by anaconda.
#version=DEV
install
text
cdrom
reboot --eject
lang en_US.UTF-8
keyboard us
skipx
rootpw --iscrypted $6$JM2aZzCVfcypbj47$cxwD0WnJaJ02i9mtC8xdSddPYLxivJ/14b.MQB7ZRXIa4Wcjq7wUyvtvdTFGqbDEsXyhdeTjerRLaE5wUcerf/
authconfig --enableshadow --enablemd5
timezone Asia/Shanghai
firewall --disabled
selinux --disabled
# ignore unsupported hardware warning
unsupported_hardware
# NEVER ever place zerombr here, it breaks automated installation
%include /tmp/bootloader.ks
%include /tmp/partition.ks
# PREINSTALL SECTION
# HERE ARE COMMANDS THAT WILL BE LAUNCHED BEFORE
# INSTALLATION PROCESS ITSELF
%pre
#!/bin/sh
# hard drives
drives=""
removable_drives=""
for drv in `ls -1 /sys/block | grep "sd\|hd\|vd\|cciss"`; do
if (grep -q 0 /sys/block/${drv}/removable); then
drives="${drives} ${drv}"
else
removable_drives="${removable_drives} ${drv}"
fi
done
default_drive=`echo ${drives} ${removable_drives} | awk '{print $1}'`
installdrive="undefined"
forceformat="no"
for I in `cat /proc/cmdline`; do case "$I" in *=*) eval $I;; esac ; done
set ${drives} ${removable_drives}
numdrives=`echo $#`
tgtdrive="${installdrive}"
function confirm_format {
check_drive="$1"
local confirm_format="yes"
if [[ "$forceformat" == "yes" ]] ; then
return 0
fi
if parted -s /dev/$check_drive print &>/dev/null ; then
echo
echo "$check_drive drive contains partition table:"
parted -s /dev/$check_drive print
echo
read -t 10 -p "Are you sure you want to erase ALL data on disk $check_drive? (y/N)" confirm_format || confirm_format="y"
if [[ "$confirm_format" == "y" ]] || [[ "$confirm_format" == "Y" ]] || [[ "$forceformat" == "yes" ]]; then
return 0
else
return 1
fi
else
return 0
fi
}
format_confirmed="no"
if [ $numdrives -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
if [ ${numdrives} -gt 1 ] || [ `echo ${drives} | wc -w` -eq 0 ] ; then
exec < /dev/tty3 > /dev/tty3 2>&1
chvt 3
while [ "${tgtdrive}" = "undefined" ]; do
clear
echo
echo '********************************************************************************'
echo '* W A R N I N G *'
echo '* *'
echo '* Which of the detected hard drives do you want to be used as *'
echo '* the installation target? *'
echo '* *'
echo '********************************************************************************'
echo
echo "Possible choices"
echo "Persistent drives: ${drives}"
echo "Removable drives: ${removable_drives}"
echo
if [ `echo ${drives} | wc -w` -eq 1 ] ; then
read -t 5 -p "Choose hard drive: " tgtdrive || tgtdrive=$default_drive
else
read -t 10 -p "Choose hard drive: " tgtdrive || tgtdrive=$default_drive
fi
match="no"
for drive in ${drives[@]} ${removable_drives[@]}; do
if [[ "$drive" == "$tgtdrive" ]] && match="yes" ; then
if confirm_format $tgtdrive ; then
format_confirmed="yes"
break
else
tgtdrive="undefined"
read -p "You may select another disk. Press Enter to continue." _
fi
fi
done
if [[ "$match" == "no" ]]; then
tgtdrive="undefined"
read -p "Invalid choice. Press Enter to continue." _
fi
done
clear
chvt 1
else
tgtdrive=`echo ${drives} | sed -e "s/^\s*//" -e "s/\s*$//"`
fi
if [ "$format_confirmed" != "yes" ] ; then
exec < /dev/tty3 > /dev/tty3 2>&1
chvt 3
if ! confirm_format $tgtdrive ; then
clear
echo
echo '********************************************************************'
echo '* E R R O R *'
echo '* *'
echo '* Disk $tgtdrive contains active partition(s). *'
echo '* Installation cannot continue without confirmation. *'
echo '* *'
echo '********************************************************************'
echo
read -p "Press Enter to restart: " _
reboot
fi
chvt 1
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
# paths in /dev have "/" instead of "!" for cciss devices
tgtdrive=$(echo $tgtdrive | sed -e 's/!/\//')
# 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
hdparm -z /dev/${tgtdrive}
# partition
# This adds support for the p seperator required for cciss devices
if echo ${tgtdrive} | grep -q -e cciss ; then
bootdev=${tgtdrive}p
else
bootdev=${tgtdrive}
fi
echo > /tmp/partition.ks
echo "bootloader --location=mbr" >>/tmp/partition.ks
echo "clearpart --all --initlabel" >> /tmp/partition.ks
echo "zerombr" >> /tmp/partition.ks
echo "ignoredisk --only-use=${tgtdrive}" >> /tmp/partition.ks
echo "partition /boot --fstype="ext4" --size=200" >> /tmp/partition.ks
echo "partition swap --fstype="swap" --size=8192" >> /tmp/partition.ks
echo "partition / --fstype="ext4" --grow --size=1" >> /tmp/partition.ks
# bootloader
echo "bootloader --location=mbr --driveorder=${tgtdrive}" > /tmp/bootloader.ks
%end
%packages
@additional-devel
@base
@chinese-support
@compat-libraries
@core
@debugging
@development
@graphical-admin-tools
@java-platform
@kde-desktop
@php
@performance
@perl-runtime
@ruby-runtime
@system-management-snmp
@server-policy
@workstation-policy
@x11
libgcrypt-devel
libXinerama-devel
xorg-x11-proto-devel
startup-notification-devel
libgnomeui-devel
libbonobo-devel
libXau-devel
libXrandr-devel
popt-devel
libxslt-devel
libglade2-devel
gnutls-devel
mtools
python-dmidecode
wodim
sgpio
genisoimage
device-mapper-persistent-data
systemtap-client
python-six
jpackage-utils
perl-DBD-SQLite
httpd
net-tools
salt-master
salt-minion
%end
# POSTINSTALL SECTION
# HERE ARE COMMANDS THAT WILL BE LAUNCHED JUST AFTER
# INSTALLATION ITSELF COMPLETED
%post --log=/root/ks-post.log
#!/bin/bash
set -x
# Prepare local repository specification
rm -rf /etc/yum.repos.d/CentOS*.repo
cat <<EOF> /etc/yum.repos.d/cdh.repo
[econe]
name = cdh
baseurl = http://127.0.0.1:9090/
gpgcheck = 0
enabled = 1
EOF
# Add local yum repo
cat <<EOF> /etc/httpd/conf.d/cdh-repo.conf
Listen 9090
<VirtualHost *:9090>
DocumentRoot /var/www/cdh-repo
<Directory /ec-cloud>
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/cdh-repo>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
LogLevel warn
CustomLog logs/cdh-repo-access.log combined
</VirtualHost>
EOF
yum clean all
# Add service start on boot
chkconfig httpd on
chkconfig salt-master on
chkconfig salt-minion on
# Change Salt-master Auto-accept minion keys
sed -i 's/#auto_accept: False/auto_accept: True/g' /etc/salt/master
# Add sysadmin authenticate
cat >> /etc/salt/master << EOF
client_acl:
sysadmin:
- .*
external_auth:
pam:
sysadmin:
- .*
- '@runner'
- '@wheel'
timeout: 600
EOF
# Change Salt-master ip
sed -i 's/#master: salt/master: 127.0.0.1/g' /etc/salt/minion
# Change Controller Hostname
cat > /etc/hostname << EOF
${hostname:-seed.cdh.com}
EOF
# Change NIC name from em1 to eth0
sed -i '/quiet/s/\(.*\)/\1 biosdevname=0/' /boot/grub2/grub.conf
# Disable subscription-manager plugins
sed -i 's/^enabled.*/enabled=0/' /etc/yum/pluginconf.d/product-id.conf || :
sed -i 's/^enabled.*/enabled=0/' /etc/yum/pluginconf.d/subscription-manager.conf || :
# Disable GSSAPI in ssh server config
sed -i -e "/^\s*GSSAPICleanupCredentials yes/d" -e "/^\s*GSSAPIAuthentication yes/d" /etc/ssh/sshd_config
# Disabling splash
sed -i --follow-symlinks -e '/^\skernel/ s/rhgb//' /etc/grub2.conf
sed -i --follow-symlinks -e '/^\skernel/ s/quiet//' /etc/grub2.conf
# Change NIC name from em1 to eth0
rm -rf /etc/udev/rules.d/70-persistent-net.rules
rm -rf /etc/sysconfig/network-scripts/ifcfg-em*
%end