4 perl
-pne 's%(?:(COMP_CONFIGURE_HINTS|COMP_TAR_INTERNAL_PATHS)=1?)%${1}=1%' -i "$PWD/root/etc/sysconfig/bash-completion"
7 perl
-pne 's%(?:(START_GPGAGENT|START_GPGAGENT_SH)=(?:"?(no|yes)"?)?)%${1}="no"%' -i "$PWD/root/etc/sysconfig/gnupg2"
10 cat << EOF > "$PWD/root/etc/vconsole.conf"
14 cat << EOF > "$PWD/root/etc/locale.conf"
15 LANGUAGE=$LOCALE:${LOCALE_ALT}
20 cat << EOF > "$PWD/root/etc/sysconfig/network"
26 cat << EOF > "$PWD/root/etc/hostname"
31 cat << EOF > "$PWD/root/etc/machine-info"
36 #XXX: we remove mask from address
37 cat << EOF > "$PWD/root/etc/hosts"
40 ${NETADDRESS4%/*} ${NETHOSTNAME} ${NETALIAS}
41 ${NETADDRESS6%/*} ${NETHOSTNAME} ${NETALIAS}
45 perl
-pne 's%listen-on port 53 \{ .+; \};%listen-on port 53 { 127.0.0.1; };%' -i "$PWD/root/etc/named.conf"
46 perl
-pne 's%listen-on-v6 port 53 \{ .+; \};%listen-on-v6 port 53 { ::1; };%' -i "$PWD/root/etc/named.conf"
49 mkdir -p "$PWD/root/etc/systemd/network"
50 if [ ! -z "${NETCONFIG}" -a "${NETCONFIG}" = 'static' ]; then
51 cat << EOF > "$PWD/root/etc/systemd/network/${NETMAC}.network"
57 Address=${NETADDRESS4}
58 Address=${NETADDRESS6}
62 Destination=${NETGATEWAY4}
66 Gateway=${NETGATEWAY4}
69 Destination=${NETGATEWAY6}
73 Gateway=${NETGATEWAY6}
76 cat << EOF > "$PWD/root/etc/systemd/network/${NETMAC}.network"
86 cat << EOF > "$PWD/root/etc/fstab"
87 UUID=${BOOTUUID} /boot ext3 defaults,noatime 1 2
88 UUID=${DATAUUID} / btrfs subvol=/slash,defaults,relatime 1 1
89 UUID=${SWAPAUUID} none swap sw 0 0
90 UUID=${SWAPBUUID} none swap sw 0 0
91 UUID=${DATAUUID} /home btrfs subvol=/home,defaults,relatime 1 1
92 proc /proc proc defaults 0 0
96 #XXX: Don't forget to add option nofail,noauto for every devices requiring manual unlocking
97 cat << EOF > "$PWD/root/etc/crypttab"
98 ${DATANAME} UUID=${LUKSDATAUUID}
102 ln -fs "/run/systemd/resolve/resolv.conf" "$PWD/root/etc/resolv.conf"
103 #Disable LLMNR, enable localhost
104 perl
-pne 's/^#LLMNR=yes$/LLMNR=no/;s/^#DNS=/DNS=127.0.0.1/' -i "$PWD/root/etc/systemd/resolved.conf"
107 rm -f "$PWD/root/etc/resolvconf/run/enable-updates"
110 cat << EOF >> "$PWD/root/etc/mdadm.conf"
115 echo -n "$ROOTPASS" | chroot
$PWD/root passwd root
--stdin
116 chroot
$PWD/root adduser
-m "$USERLOGIN"
117 echo -n "$USERPASS" | chroot
$PWD/root passwd
"$USERLOGIN" --stdin
120 perl
-pne 's/^GRUB_TIMEOUT=[0-9]+$/GRUB_TIMEOUT=1/' -i $PWD/root
/etc
/default
/grub
123 cat << EOF >> $PWD/root/etc/shorewall/zones
126 cat << EOF >> $PWD/root/etc/shorewall/policy
131 cat << EOF >> $PWD/root/etc/shorewall/rules
134 cat << EOF > $PWD/root/etc/shorewall/rules.drakx
135 ACCEPT net fw udp 68,6700:7000 -
136 ACCEPT net fw icmp 8 -
137 ACCEPT net fw tcp 20,21,22,80,443,6700:7000 -
141 cat << EOF >> $PWD/root/etc/shorewall6/zones
144 cat << EOF >> $PWD/root/etc/shorewall6/policy
149 cat << EOF >> $PWD/root/etc/shorewall6/rules
152 cat << EOF > $PWD/root/etc/shorewall6/rules.drakx
153 ACCEPT net fw udp 546,6700:7000 -
154 ACCEPT net fw icmp 128 -
155 ACCEPT net fw tcp 20,21,22,80,443,546,6700:7000 -
158 # Disable old services
159 # Strip WantedBy=multi-user.target in [Install] section of lm_sensors.service ?
160 for s
in lm_sensors network network
-auth network
-up resolvconf smartd
; do
161 if [ -f "$PWD/root/etc/rc.d/init.d/$s" -a -x "$PWD/root/etc/rc.d/init.d/$s" ]; then
162 chroot
$PWD/root
/usr
/lib
/systemd
/systemd
-sysv-install disable
$s
164 if [ -f "$PWD/root/etc/systemd/system/multi-user.target.wants/${s}.service" ]; then
165 rm -f "$PWD/root/etc/systemd/system/multi-user.target.wants/${s}.service"
169 # Extract last kernel version
170 KVER
=`chroot $PWD/root rpm -qa | perl -pne '/kernel-server-latest/||undef $_;s%^kernel-(server)-latest-([^-]+)-(.+)$%\2-\1-\3%'`
171 #XXX: we do not regenerate initrd here, it will be generated at image build step
172 rm -f "$PWD/root/boot/initrd-${KVER}.img"
174 # Check rc.local state
175 if [ -f "$PWD/root/etc/rc.d/rc.local" ]; then
176 echo "$PWD/root/etc/rc.d/rc.local not empty"
180 # First boot startup script
181 #XXX: regenerate initrd after first successfull boot to strip from useless modules
182 touch "$PWD/root/etc/rc.d/rc.local"
183 chmod a
+x
"$PWD/root/etc/rc.d/rc.local"
184 cat << EOF > "$PWD/root/etc/rc.d/rc.local"
186 . /etc/init.d/functions
189 gprintf "Disabling lm_sensors.service: "
190 /usr/bin/systemctl disable lm_sensors.service
191 [ \$? -eq 0 ] && success || failure
193 gprintf "Stopping lm_sensors.service: "
194 /usr/bin/systemctl stop lm_sensors.service
195 [ \$? -eq 0 ] && success || failure
197 gprintf "Generating initrd: "
198 /usr/sbin/mkinitrd -f -v /boot/initrd-${KVER}.img ${KVER}
199 [ \$? -eq 0 ] && success || failure
205 echo "Usage: \$0 start" >&2
212 chroot
"$PWD/root" msec
-f webserver
215 perl
-pne "my \$m='${MAIL}'; s%^(root:[\\t\\s]+)postfix\$%\\1\$m%" -i "$PWD/root/etc/postfix/aliases"
218 chroot
"$PWD/root" /usr
/sbin
/sshd
-keygen
221 #XXX: forced because msec decides otherwise
222 perl
-pne 's%^PermitRootLogin .*%PermitRootLogin yes%' -i "$PWD/root/etc/ssh/sshd_config"
224 # Add rsa key if available
225 #XXX: dsa is unsupported anymore
226 if [ -e "$HOME/.ssh/id_rsa.pub" ]; then
227 [ ! -d "$PWD/root/root/.ssh" ] && mkdir -m 0700 "$PWD/root/root/.ssh"
228 cp -f "$HOME/.ssh/id_rsa.pub" "$PWD/root/root/.ssh/authorized_keys"
231 #TODO ntp /etc/systemd/timesyncd.conf
233 # Cleanup tmp and run
234 rm -fr $PWD/root
/tmp
/* $PWD/root
/run
/*