1 |
# System authorization information |
# System authorization information |
2 |
auth --enableshadow --passalgo=sha512 |
auth --enableshadow --passalgo=sha512 |
3 |
|
|
4 |
# Use CDROM installation media |
# We do not want SELinux |
|
#cdrom #what about usb stick |
|
|
|
|
|
# we do not want Selinux |
|
5 |
selinux --disabled |
selinux --disabled |
6 |
|
|
7 |
# services to activate |
# Services to activate |
8 |
services --disabled=lm_sensors |
services --disabled=lm_sensors |
9 |
|
|
10 |
# default root pass, willbe changed in post-install process anyway |
# Default root pass, will be changed in post-install process anyway |
11 |
rootpw --lock |
rootpw --lock |
12 |
|
user --name=installer --uid=9999 |
13 |
|
|
14 |
# Accept eula |
# Accept EULA |
15 |
eula --agreed |
eula --agreed |
16 |
|
|
17 |
# include the partitioning logic from the pre section. |
# Partitioning from pre section |
18 |
%include /tmp/part-include |
%include /tmp/part-include |
19 |
|
|
20 |
# disable kdump |
# Disable kdump |
21 |
%addon com_redhat_kdump --disable |
%addon com_redhat_kdump --disable |
22 |
%end |
%end |
23 |
|
|
24 |
|
|
25 |
%pre |
# Add netinstall repos |
26 |
# pre section |
#this one gives curl 6 errors on netinstall while added manually works from time to time |
27 |
#----- partitioning logic below-------------- |
#url --mirrorlist https://mirrorlist.koozali.org/mirrorlist/smeos-10-x86_64 |
28 |
# pick the first drive that is not removable and is over MINSIZE |
#repo --name=smeupdates --mirrorlist https://mirrorlist.koozali.org/mirrorlist/smeupdates-10-x86_64 |
29 |
DIR="/sys/block" |
#repo --name=smeos --baseurl http://distro.ibiblio.org/pub/linux/distributions/smeserver/releases/10/smeos/x86_64/ |
30 |
|
#repo --name=smeupdates --baseurl http://distro.ibiblio.org/pub/linux/distributions/smeserver/releases/10/smeupdates/x86_64/ |
31 |
|
repo --name=smeos --mirrorlist https://mirrorlist.koozali.org/mirrorlist/smeos-10-x86_64 |
32 |
|
repo --name=smeupdates --mirrorlist https://mirrorlist.koozali.org/mirrorlist/smeupdates-10-x86_64 |
33 |
|
|
34 |
# minimum size of hard drive needed specified in GIGABYTES |
# Packages to install |
35 |
MINSIZE=5 |
%packages |
36 |
|
@^minimal |
37 |
|
@base |
38 |
|
@core |
39 |
|
-chrony |
40 |
|
-kexec-tools |
41 |
|
%end |
42 |
|
|
43 |
|
|
44 |
# Number of detected drives |
# Partitioning in pre-install |
45 |
|
%pre --interpreter=/bin/bash --log=/var/log/sme-partitioning.log |
46 |
|
|
47 |
|
# Read command line arguments |
48 |
|
if grep nolvm "/proc/cmdline" ; then NOLVM=true ; fi |
49 |
|
if grep noraid "/proc/cmdline" ; then NORAID=true ; fi |
50 |
|
if grep noxfs "/proc/cmdline" ; then FSTYPE="ext4" ; else FSTYPE="xfs" ; fi |
51 |
|
echo "Command line arguments:" |
52 |
|
cat /proc/cmdline |
53 |
|
|
54 |
|
# Minimum size of hard drive needed specified in MB |
55 |
|
MINSIZE=5000 |
56 |
|
|
57 |
|
# Number of detected drives and first disk size |
58 |
NDEV=0 |
NDEV=0 |
59 |
|
BASESIZE=0 |
60 |
|
SIZEDIFF=0 |
61 |
|
|
62 |
for DEV in $(lsblk -nl | grep disk | cut -d' ' -f1); do |
# Loop through block devices, keep those over MINSIZE and ensure additional drives for RAID are within 100MB of the first |
63 |
if [ -d /sys/block/$DEV ]; then |
for DEV in $(lsblk -nl | grep disk | cut -d' ' -f1) ; do |
64 |
|
if [ -d /sys/block/$DEV ] ; then |
65 |
REMOVABLE=`cat /sys/block/$DEV/removable` |
REMOVABLE=`cat /sys/block/$DEV/removable` |
66 |
if (( $REMOVABLE == 0 )); then |
if (( $REMOVABLE == 0 )) ; then |
67 |
SIZE=`cat /sys/block/$DEV/size` |
SIZE=`cat /sys/block/$DEV/size` |
68 |
GB=$(($SIZE/2**21)) |
MB=$(($SIZE/2**11)) |
69 |
if [ $GB -gt $MINSIZE ]; then |
if [ $MB -gt $MINSIZE ] ; then |
70 |
DRIVES[$NDEV]=$DEV |
if [ $NDEV == 0 ] ; then |
71 |
((NDEV++)) |
echo "First drive found: $DEV with size $MB MB" |
72 |
|
DRIVES[$NDEV]=$DEV |
73 |
|
BASESIZE=$MB |
74 |
|
((NDEV++)) |
75 |
|
else |
76 |
|
SIZEDIFF=$(($MB-$BASESIZE)) |
77 |
|
if [ $SIZEDIFF -gt 100 ] || [ $SIZEDIFF -lt -100 ] ; then |
78 |
|
echo "Drive found but size of $MB MB doesn't match $BASESIZE MB - ignoring" |
79 |
|
else |
80 |
|
echo "Additional drive found: $DEV with size $MB MB" |
81 |
|
DRIVES[$NDEV]=$DEV |
82 |
|
((NDEV++)) |
83 |
|
fi |
84 |
|
fi |
85 |
fi |
fi |
86 |
fi |
fi |
87 |
fi |
fi |
88 |
done |
done |
89 |
|
echo "Total disks found: $NDEV" |
90 |
|
|
91 |
# For now keep things simple and just use the first one |
# Calculate recommended swap size for RAID + nolvm case |
92 |
# TODO: |
if [ -d /sys/firmware/efi ] ; then |
93 |
# * Create software RAID depending on the number of detected drives |
DISKSPARE=$(($BASESIZE-200-500-3000)) |
94 |
# * Allow non LVM install |
else |
95 |
|
DISKSPARE=$(($BASESIZE-1-500-3000)) |
96 |
ROOTDRIVE=${DRIVES[0]} |
fi |
97 |
if [ $ROOTDRIVE == "" ] ; then |
MEMSIZE=$(awk '/^MemTotal:/{print $2}' /proc/meminfo) |
98 |
echo "No drive suitable for installation found! Please proceed manually." |
MEMSIZEMB=$(($MEMSIZE/2**10)) |
|
# first in case detection fails... |
|
|
cat << EOF > /tmp/part-include |
|
|
# Clear the Master Boot Record |
|
|
zerombr |
|
|
# System bootloader configuration |
|
|
clearpart --all --initlabel |
|
|
# Automatically create partitions, no LVM |
|
|
autopart --lvm |
|
99 |
|
|
100 |
|
if [ $MEMSIZEMB -lt 2000 ] ; then |
101 |
|
SWAPSIZE=$((2*$MEMSIZEMB)) |
102 |
|
elif [ $MEMSIZEMB -lt 8000 ] ; then |
103 |
|
SWAPSIZE=$MEMSIZEMB |
104 |
|
else |
105 |
|
SWAPSIZE=8000 |
106 |
|
fi |
107 |
|
if [ $SWAPSIZE -gt $DISKSPARE ] ; then SWAPSIZE=$DISKSPARE ; fi |
108 |
|
|
109 |
|
# Declare useful variables |
110 |
|
printf -v DRIVELIST ",%s" "${DRIVES[@]}" |
111 |
|
if [ $NORAID ] ; then |
112 |
|
DRIVELIST=${DRIVES[0]} |
113 |
|
else |
114 |
|
DRIVELIST=${DRIVELIST:1} |
115 |
|
fi |
116 |
|
|
117 |
|
echo "Final drive list: $DRIVELIST" |
118 |
|
LEVEL=1 |
119 |
|
SPARE=0 |
120 |
|
|
121 |
|
|
122 |
|
# Error if detection has failed and fall back |
123 |
|
if [ ${#DRIVES[@]} == 0 ] ; then |
124 |
|
echo "No drive suitable for installation found! Reverting to Anaconda defaults." |
125 |
|
|
126 |
|
cat > /tmp/part-include <<EOF |
127 |
|
# Clear the Master Boot Record |
128 |
|
zerombr |
129 |
|
|
130 |
|
# Clear current partitions |
131 |
|
clearpart --all --initlabel |
132 |
|
|
133 |
|
# Automatically create partitions using LVM |
134 |
|
autopart --lvm --nohome |
135 |
EOF |
EOF |
136 |
|
|
137 |
|
# Otherwise clear detected devices and set up bootloader |
138 |
else |
else |
139 |
cat <<_EOF > /tmp/part-include |
cat > /tmp/part-include <<EOF |
140 |
zerombr |
# Clear the Master Boot Record |
141 |
clearpart --all --drives=$ROOTDRIVE --initlabel |
zerombr |
142 |
bootloader --boot-drive=$ROOTDRIVE |
|
143 |
part /boot --fstype xfs --size=500 --ondisk=$ROOTDRIVE --label=BOOT |
# Clear current partitions and install bootloader |
144 |
part pv.01 --size=4500 --grow --ondisk=$ROOTDRIVE |
clearpart --all --drives=$DRIVELIST --initlabel |
145 |
volgroup main pv.01 |
ignoredisk --only-use=$DRIVELIST |
146 |
logvol / --fstype xfs --name=root --vgname=main --grow --size=3000 --label=ROOT |
bootloader --location=mbr --driveorder=$DRIVELIST |
147 |
logvol swap --fstype swap --name=swap --vgname=main --recommended --label=SWAP |
EOF |
|
_EOF |
|
148 |
|
|
149 |
fi |
# If single disk or noraid specific then set up partitioning without RAID |
150 |
|
# NOTE: From this point we're appending to part-include |
151 |
|
if [ ${#DRIVES[@]} == 1 ] || [ $NORAID ] ; then |
152 |
|
|
153 |
|
# Include the EFI or biosboot partition if necessary |
154 |
|
if [ -d /sys/firmware/efi ] ; then |
155 |
|
printf "part /boot/efi --fstype=efi --size=200 --ondisk=%s\n" "${DRIVES[0]}" >> /tmp/part-include |
156 |
|
elif [ $BASESIZE -gt 2048000 ] ; then |
157 |
|
printf "part biosboot --fstype=biosboot --size=1 --ondisk=%s\n" "${DRIVES[0]}" >> /tmp/part-include |
158 |
|
fi |
159 |
|
|
160 |
%end |
# Create boot partition |
161 |
|
printf "part /boot --fstype=%s --size=500 --label=BOOT --ondisk=%s\n" "$FSTYPE" "${DRIVES[0]}" >> /tmp/part-include |
162 |
|
|
163 |
|
# Default to LVM unless specified at command line |
164 |
|
if [ $NOLVM ] ; then |
165 |
|
cat >> /tmp/part-include <<EOF |
166 |
|
part / --fstype=$FSTYPE --grow --size=3000 --label=ROOT --ondisk=${DRIVES[0]} |
167 |
|
part swap --fstype=swap --recommended --label=SWAP --ondisk=${DRIVES[0]} |
168 |
|
EOF |
169 |
|
else |
170 |
|
cat >> /tmp/part-include <<EOF |
171 |
|
part pv.01 --size=4300 --grow --ondisk=${DRIVES[0]} |
172 |
|
volgroup main pv.01 |
173 |
|
logvol / --fstype=$FSTYPE --name=root --vgname=main --grow --size=3000 |
174 |
|
logvol swap --fstype=swap --name=swap --vgname=main --recommended |
175 |
|
EOF |
176 |
|
fi |
177 |
|
|
178 |
|
# Otherwise multiple disks - prepare for RAID |
179 |
|
else |
180 |
|
|
181 |
|
# Define EFI or biosboot and RAID partitions |
182 |
|
for i in "${!DRIVES[@]}"; do |
183 |
|
|
184 |
# packages to install |
if [ -d /sys/firmware/efi ] ; then |
185 |
%packages |
printf "part raid.%s0 --size=200 --ondisk=%s\n" "$i" "${DRIVES[$i]}" >> /tmp/part-include |
186 |
@^minimal |
elif [ $BASESIZE -gt 2048000 ] ; then |
187 |
@base |
printf "part biosboot --fstype=biosboot --size=1 --ondisk=%s\n" "${DRIVES[$i]}" >> /tmp/part-include |
188 |
@core |
fi |
189 |
-chrony |
printf "part raid.%s1 --size=500 --ondisk=%s\n" "$i" "${DRIVES[$i]}" >> /tmp/part-include |
|
-kexec-tools |
|
190 |
|
|
191 |
%end |
# Default to LVM unless specified |
192 |
|
if [ $NOLVM ] ; then |
193 |
|
printf "part raid.%s2 --size=3000 --grow --ondisk=%s\n" "$i" "${DRIVES[$i]}" >> /tmp/part-include |
194 |
|
printf "part raid.%s3 --size=%s --ondisk=%s\n" "$i" "$SWAPSIZE" "${DRIVES[$i]}" >> /tmp/part-include |
195 |
|
else |
196 |
|
printf "part raid.%s2 --size=4300 --grow --ondisk=%s\n" "$i" "${DRIVES[$i]}" >> /tmp/part-include |
197 |
|
fi |
198 |
|
|
199 |
|
done |
200 |
|
|
201 |
|
# Compute RAID level |
202 |
|
# from https://wiki.contribs.org/Raid |
203 |
|
# 2 Drives - Software RAID 1 |
204 |
|
# 3 Drives - Software RAID 1 + 1 Hot-spare |
205 |
|
# 4 Drives - Software RAID 6 |
206 |
|
# 5+ Drives - Software RAID 6 + 1 Hot-spare |
207 |
|
|
208 |
|
if [ ${#DRIVES[@]} == 2 ] ; then |
209 |
|
LEVEL=1 |
210 |
|
SPARE=0 |
211 |
|
elif [ ${#DRIVES[@]} == 3 ] ; then |
212 |
|
LEVEL=1 |
213 |
|
SPARE=1 |
214 |
|
elif [ ${#DRIVES[@]} == 4 ] ; then |
215 |
|
LEVEL=6 |
216 |
|
SPARE=0 |
217 |
|
else |
218 |
|
LEVEL=6 |
219 |
|
SPARE=1 |
220 |
|
fi |
221 |
|
|
222 |
|
# Set up RAID devices |
223 |
|
printf -v EFIDEVS "raid.%s0 " "${!DRIVES[@]}" |
224 |
|
printf -v BOOTDEVS "raid.%s1 " "${!DRIVES[@]}" |
225 |
|
printf -v ROOTDEVS "raid.%s2 " "${!DRIVES[@]}" |
226 |
|
printf -v SWAPDEVS "raid.%s3 " "${!DRIVES[@]}" |
227 |
|
|
228 |
|
# Include the EFI partition if necessary |
229 |
|
if [ -d /sys/firmware/efi ] ; then |
230 |
|
printf "raid /boot/efi --fstype=efi --level=1 --spares=0 --device=md9 %s\n" "$EFIDEVS" >> /tmp/part-include |
231 |
|
fi |
232 |
|
|
233 |
|
# Boot partition |
234 |
|
printf "raid /boot --fstype=%s --level=1 --spares=0 --device=md0 %s\n" "$FSTYPE" "$BOOTDEVS" >> /tmp/part-include |
235 |
|
|
236 |
|
# Default to LVM unless specified |
237 |
|
if [ $NOLVM ] ; then |
238 |
|
cat >> /tmp/part-include <<EOF |
239 |
|
raid / --fstype=$FSTYPE --level=$LEVEL --spares=$SPARE --device=md1 $ROOTDEVS |
240 |
|
raid swap --fstype=swap --level=$LEVEL --spares=$SPARE --device=md2 $SWAPDEVS |
241 |
|
EOF |
242 |
|
else |
243 |
|
cat >> /tmp/part-include <<EOF |
244 |
|
raid pv.01 --level=$LEVEL --spares=$SPARE --device=md1 $ROOTDEVS |
245 |
|
volgroup main pv.01 |
246 |
|
logvol / --fstype=$FSTYPE --name=root --vgname=main --grow --size=3000 |
247 |
|
logvol swap --fstype swap --name=swap --vgname=main --recommended |
248 |
|
EOF |
249 |
|
fi |
250 |
|
fi |
251 |
|
fi |
252 |
|
|
253 |
|
echo "Final part-include output:" |
254 |
|
cat /tmp/part-include |
255 |
|
|
256 |
|
%end |
257 |
|
|
258 |
|
|
259 |
|
# SME events in post-install |
260 |
%post --interpreter=/usr/bin/bash --log=/var/log/ks.post02.log |
%post --interpreter=/usr/bin/bash --log=/var/log/ks.post02.log |
261 |
# before reboot performing post-install |
userdel -r installer |
262 |
# this is for first alpha iso. we should put this in anaconda |
sleep 2 |
263 |
# and / or handle possible upgrade later |
/sbin/e-smith/signal-event post-install |
264 |
/sbin/rsyslogd; |
sleep 2 |
265 |
sleep 2; |
/sbin/e-smith/db configuration set UnsavedChanges no |
|
/sbin/e-smith/signal-event post-install; |
|
|
sleep 2; |
|
|
/sbin/e-smith/db configuration set UnsavedChanges no; |
|
266 |
touch /forcequotacheck |
touch /forcequotacheck |
|
|
|
267 |
%end |
%end |
268 |
|
|
269 |
|
|
270 |
%post --nochroot --log=/mnt/sysimage/var/log/ks.post01.log |
%post --nochroot --log=/mnt/sysimage/var/log/ks.post01.log |
271 |
#!/bin/bash |
#!/bin/bash |
272 |
sysimage="/mnt/sysimage" |
sysimage="/mnt/sysimage" |
273 |
|
cp -r /var/log/sme-partitioning.log ${sysimage}/root/ |
274 |
cp -r /tmp/anaconda.log ${sysimage}/root/ |
cp -r /tmp/anaconda.log ${sysimage}/root/ |
275 |
%end |
%end |