reformat preseed

Change-Id: I7c86310f1788ef144442b269b91581e48f7c8fda
This commit is contained in:
xiaodongwang 2014-11-06 17:35:37 -08:00
parent 8c510ac32c
commit 4db535fd31
46 changed files with 1818 additions and 645 deletions

View File

@ -57,7 +57,7 @@ install
reboot
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstar_pre_log')
$SNIPPET('kickstart_start')
$SNIPPET('kickstart_pre_install_network_config')
$SNIPPET('kickstart_pre_partition_disks')
@ -83,17 +83,14 @@ rsyslog
%end
%post --log=/var/log/post_install.log
$SNIPPET('log_ks_post')
$SNIPPET('kickstart_post_log')
$SNIPPET('kickstart_post_install_kernel_options')
$SNIPPET('kickstart_post_install_network_config')
chkconfig iptables off
chkconfig ip6tables off
$SNIPPET('kickstart_yum.conf')
#if $getVar('local_repo', '') != ''
$SNIPPET('kickstart_local_repo')
#end if
$SNIPPET('kickstart_yum')
$SNIPPET('kickstart_ssh')
$SNIPPET('kickstart_ntp')
$SNIPPET('kickstart_limits.conf')

View File

@ -25,15 +25,14 @@ d-i console-keymaps-at/keymap select us
d-i keyboard-configuration/xkb-keymap select us
d-i preseed/early_command string \
$SNIPPET('preseed_pre_anamon') echo "processed preseed_pre_anamon" >> /tmp/preseed.log; \
$SNIPPET('preseed_pre_install_network_config') echo "processed preseed_pre_install_network_config" >> /tmp/preseed.log; \
wget -O- \
http://$http_server/cblr/svc/op/script/$what/$name/?script=preseed_early_default | /bin/sh -s
http://$http_server/cblr/svc/op/script/$what/$name/?script=preseed_early_default | /bin/sh -s; \
debconf-set-selections /tmp/pre_install_network_config
d-i partman/early_command string \
$SNIPPET('preseed_pre_partition_disks') echo "processed preseed_pre_partition_disks" >> /tmp/preseed.log; \
wget -O- \
http://$http_server/cblr/svc/op/script/$what/$name/?script=partman_early_default | /bin/sh -s
http://$http_server/cblr/svc/op/script/$what/$name/?script=partman_early_default | /bin/sh -s; \
debconf-set-selections /tmp/part-include
$SNIPPET('preseed_network_config')
$SNIPPET('preseed_partition_disks')
@ -46,7 +45,11 @@ d-i time/zone string US/Pacific
#end if
d-i clock-setup/utc boolean true
d-i clock-setup/ntp boolean true
d-i clock-setup/ntp-server string ntp.ubuntu.com
#if $getVar('ntp_server', '') == ""
d-i clock-setup/ntp-server string 0.ubuntu.pool.ntp.org
#else
d-i clock-setup/ntp-server string $ntp_server
#end if
# Setup the installation source
d-i mirror/country string manual
@ -102,18 +105,6 @@ d-i cdrom-detect/eject boolean false
# packages and run commands in the target system.
# d-i preseed/late_command string [command]
d-i preseed/late_command string \
$SNIPPET('preseed_post_install_network_config') echo "processed preseed_post_install_network_config" >> /tmp/preseed.log; \
$SNIPPET('preseed_ssh') echo "processed preseed_ssh" >> /tmp/preseed.log; \
$SNIPPET('preseed_ntp') echo "processed preseed_ntp" >> /tmp/preseed.log; \
$SNIPPET('preseed_post_apt_repo_config') echo "processed preseed_post_apt_repo_config" >> /tmp/preseed.log; \
#if $getVar('tool', '') != ''
#set $preseed_tool = "preseed_%s" % $tool
$SNIPPET($preseed_tool) echo "processed $preseed_tool" >> /tmp/preseed.log; \
#end if
$SNIPPET('preseed_limits.conf') echo "processed preseed_limits.conf" >> /tmp/preseed.log; \
$SNIPPET('preseed_sysctl.conf') echo "processed preseed_sysctl.conf" >> /tmp/preseed.log; \
$SNIPPET('preseed_rsyslog.conf') echo "processed preseed_rsyslog.conf" >> /tmp/preseed.log; \
$SNIPPET('preseed_post_anamon') echo "processed preseed_post_anamon" >> /tmp/preseed.log; \
wget -O- \
http://$http_server/cblr/svc/op/script/$what/$name/?script=preseed_late_default | \
chroot /target /bin/sh -s

View File

@ -0,0 +1,5 @@
# Start partman_early_default
# This script is not run in the chroot /target by default
$SNIPPET('preseed_pre_partition_disks')
# End partman_early_default

View File

@ -0,0 +1,7 @@
# Start preseed_early_default
# This script is not run in the chroot /target by default
$SNIPPET('kickstart_start')
$SNIPPET('preseed_pre_anamon')
echo "processed preseed_pre_anamon" >> /tmp/preseed.log
$SNIPPET('preseed_pre_install_network_config')
# End preseed_early_default

View File

@ -0,0 +1,17 @@
# Start preseed_late_default
# This script runs in the chroot /target by default
$SNIPPET('preseed_post_install_kernel_options')
$SNIPPET('preseed_post_install_network_config')
$SNIPPET('preseed_ssh')
$SNIPPET('preseed_ntp')
$SNIPPET('preseed_post_apt_repo_config')
#if $getVar('tool', '') != ''
#set $preseed_tool = "preseed_%s" % $tool
$SNIPPET($preseed_tool)
#end if
$SNIPPET('preseed_limits.conf')
$SNIPPET('preseed_sysctl.conf')
$SNIPPET('preseed_rsyslog.conf')
$SNIPPET('preseed_post_anamon')
$SNIPPET('kickstart_done')
# End preseed_late_default

View File

@ -0,0 +1,59 @@
cat << EOF > /etc/yum.repos.d/CentOS-Base.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-\\$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=\\$releasever&arch=\\$basearch&repo=os
baseurl=http://mirror.centos.org/centos/\\$releasever/os/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
skip_if_unavailable=1
#released updates
[updates]
name=CentOS-\\$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=\\$releasever&arch=\\$basearch&repo=updates
baseurl=http://mirror.centos.org/centos/\\$releasever/updates/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
skip_if_unavailable=1
#additional packages that may be useful
[extras]
name=CentOS-\\$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=\\$releasever&arch=\\$basearch&repo=extras
baseurl=http://mirror.centos.org/centos/\\$releasever/extras/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
skip_if_unavailable=1
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-\\$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=\\$releasever&arch=\\$basearch&repo=centosplus
baseurl=http://mirror.centos.org/centos/\\$releasever/centosplus/\\$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
skip_if_unavailable=1
#contrib - packages by Centos Users
[contrib]
name=CentOS-\\$releasever - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=\\$releasever&arch=\\$basearch&repo=contrib
baseurl=http://mirror.centos.org/centos/\\$releasever/contrib/\\$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
skip_if_unavailable=1
EOF

View File

@ -0,0 +1,23 @@
cat << EOF > /etc/yum.repos.d/CentOS-Debuginfo.repo
# CentOS-Debug.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# All debug packages from all the various CentOS-5 releases
# are merged into a single repo, split by BaseArch
#
# Note: packages in the debuginfo repo are currently not signed
#
[debug]
name=CentOS-6 - Debuginfo
baseurl=http://debuginfo.centos.org/6/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Debug-6
enabled=0
skip_if_unavailable=1
EOF

View File

@ -0,0 +1,213 @@
cat << EOF > /etc/yum.repos.d/CentOS-Vault.repo
# CentOS-Vault.repo
#
# CentOS Vault holds packages from previous releases within the same CentOS Version
# these are packages obsoleted by the current release and should usually not
# be used in production
#-----------------
[C6.0-base]
name=CentOS-6.0 - Base
baseurl=http://vault.centos.org/6.0/os/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
skip_if_unavailable=1
[C6.0-updates]
name=CentOS-6.0 - Updates
baseurl=http://vault.centos.org/6.0/updates/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
skip_if_unavailable=1
[C6.0-extras]
name=CentOS-6.0 - Extras
baseurl=http://vault.centos.org/6.0/extras/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
skip_if_unavailable=1
[C6.0-contrib]
name=CentOS-6.0 - Contrib
baseurl=http://vault.centos.org/6.0/contrib/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
skip_if_unavailable=1
[C6.0-centosplus]
name=CentOS-6.0 - CentOSPlus
baseurl=http://vault.centos.org/6.0/centosplus/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
skip_if_unavailable=1
#-----------------
[C6.1-base]
name=CentOS-6.1 - Base
baseurl=http://vault.centos.org/6.1/os/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
skip_if_unavailable=1
[C6.1-updates]
name=CentOS-6.1 - Updates
baseurl=http://vault.centos.org/6.1/updates/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
skip_if_unavailable=1
[C6.1-extras]
name=CentOS-6.1 - Extras
baseurl=http://vault.centos.org/6.1/extras/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
skip_if_unavailable=1
[C6.1-contrib]
name=CentOS-6.1 - Contrib
baseurl=http://vault.centos.org/6.1/contrib/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
skip_if_unavailable=1
[C6.1-centosplus]
name=CentOS-6.1 - CentOSPlus
baseurl=http://vault.centos.org/6.1/centosplus/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
skip_if_unavailable=1
#-----------------
[C6.2-base]
name=CentOS-6.2 - Base
baseurl=http://vault.centos.org/6.2/os/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
skip_if_unavailable=1
[C6.2-updates]
name=CentOS-6.2 - Updates
baseurl=http://vault.centos.org/6.2/updates/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
skip_if_unavailable=1
[C6.2-extras]
name=CentOS-6.2 - Extras
baseurl=http://vault.centos.org/6.2/extras/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
skip_if_unavailable=1
[C6.2-contrib]
name=CentOS-6.2 - Contrib
baseurl=http://vault.centos.org/6.2/contrib/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
skip_if_unavailable=1
[C6.2-centosplus]
name=CentOS-6.2 - CentOSPlus
baseurl=http://vault.centos.org/6.2/centosplus/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
skip_if_unavailable=1
#-----------------
[C6.3-base]
name=CentOS-6.3 - Base
baseurl=http://vault.centos.org/6.3/os/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
skip_if_unavailable=1
[C6.3-updates]
name=CentOS-6.3 - Updates
baseurl=http://vault.centos.org/6.3/updates/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
skip_if_unavailable=1
[C6.3-extras]
name=CentOS-6.3 - Extras
baseurl=http://vault.centos.org/6.3/extras/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
skip_if_unavailable=1
[C6.3-contrib]
name=CentOS-6.3 - Contrib
baseurl=http://vault.centos.org/6.3/contrib/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
skip_if_unavailable=1
[C6.3-centosplus]
name=CentOS-6.3 - CentOSPlus
baseurl=http://vault.centos.org/6.3/centosplus/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
skip_if_unavailable=1
#-----------------
[C6.4-base]
name=CentOS-6.4 - Base
baseurl=http://vault.centos.org/6.4/os/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
skip_if_unavailable=1
[C6.4-updates]
name=CentOS-6.4 - Updates
baseurl=http://vault.centos.org/6.4/updates/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
skip_if_unavailable=1
[C6.4-extras]
name=CentOS-6.4 - Extras
baseurl=http://vault.centos.org/6.4/extras/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
skip_if_unavailable=1
[C6.4-contrib]
name=CentOS-6.4 - Contrib
baseurl=http://vault.centos.org/6.4/contrib/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
skip_if_unavailable=1
[C6.4-centosplus]
name=CentOS-6.4 - CentOSPlus
baseurl=http://vault.centos.org/6.4/centosplus/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
skip_if_unavailable=1
EOF

View File

@ -8,5 +8,6 @@ $SNIPPET('kickstart_chef-admin.pem')
## Generate client.rb
$SNIPPET('kickstart_client.rb')
$SNIPPET('kickstart_knife.rb')
$SNIPPET('kickstart_gem_local_repo')
$SNIPPET('kickstart_chef_run.sh')
$SNIPPET('kickstart_chef_init')

View File

@ -15,12 +15,13 @@ ntpdate $ntp_server 2>&1 >> /tmp/ntp.log
service ntpd start 2>&1 >> /tmp/ntp.log
echo "new date is: `date`" 2>&1 >> /tmp/ntp.log
/etc/chef/run.sh
crontab -l > /tmp/mycron
echo "*/30 * * * * /etc/chef/run.sh" >> /tmp/mycron
echo "*/30 * * * * /etc/chef/chef_client_run.sh" >> /tmp/mycron
crontab /tmp/mycron
rm /tmp/mycron
/etc/chef/chef_client_run.sh &
chkconfig chef off
mv /etc/init.d/chef /tmp/chef
EOF

View File

@ -10,15 +10,20 @@
#end if
#end for
cat << EOF > /etc/chef/run.sh
cat << EOF > /etc/chef/chef_client_run.sh
#!/bin/bash
instances=\\$(pgrep chef_client_run.sh | wc -l)
if [ \\$instances -gt 1 ]; then
echo "there are chef-client run instances '\\$instances' running" &>> /tmp/chef.log
exit 1
fi
touch /tmp/chef.log
while true; do
echo "run chef-client on \`date\`" &>> /tmp/chef.log
clients=\\$(pgrep chef-client)
if [ "\\$?" == "0" ]; then
echo "there are chef-clients '\\$clients' running" &>> /tmp/chef.log
break
sleep 1m
else
echo "knife search nodes" &>> /tmp/chef.log
USER=root HOME=/root knife search node "name:\\$HOSTNAME.*" -i -a name &>> /tmp/chef.log
@ -78,5 +83,5 @@ EOL
fi
done
EOF
chmod +x /etc/chef/run.sh
chmod +x /etc/chef/chef_client_run.sh

View File

@ -0,0 +1,14 @@
cat << EOF > /root/.gemrc
gem: --no-ri --no-rdoc
:backtrace: false
:benchmark: false
:bulk_threshold: 1000
:sources:
## - http://gems.rubyforge.org/
#if $getVar("local_repo","") != ""
- $local_repo/gem_repo/
#end if
:update_sources: true
:verbose: true
EOF

View File

@ -1,24 +0,0 @@
mkdir -p /tmp/repo_backup
mv /etc/yum.repos.d/* /tmp/repo_backup/
cat << EOF > /etc/yum.repos.d/Compass.repo
[compass_repo]
name=Compass yum repo
baseurl=$local_repo/compass_repo/
enabled=1
gpgcheck=0
priority=1
proxy=_none_
EOF
cat << EOF > /root/.gemrc
gem: --no-ri --no-rdoc
:backtrace: false
:benchmark: false
:bulk_threshold: 1000
:sources:
- http://gems.rubyforge.org/
- $local_repo/gem_repo/
:update_sources: true
:verbose: true
EOF

View File

@ -90,7 +90,7 @@ declare -A used_physical_interfaces
#if $mac != ""
physical_interface=\${physical_mac_interface[$mac]}
logical_interface_mapping[$iname]=\$physical_interface
if [ -n "\$physical_interface" ]; then
if [ ! -z "\$physical_interface" ]; then
unset physical_interfaces[\$physical_interface]
if [ "\$physical_interface" != "$iname" ]; then
used_physical_interfaces[\$physical_interface]=\$physical_interface
@ -105,7 +105,7 @@ unset_logical_interfaces[$iname]=$iname
echo "unset logical interfaces: \${unset_logical_interfaces[@]}" >> /tmp/network_log
for logical_interface in \${unset_logical_interfaces[@]}; do
if [ -n "\${physical_interfaces[\$logical_interface]}" ]; then
if [ ! -z "\${physical_interfaces[\$logical_interface]}" ]; then
logical_interface_mapping[\$logical_interface]=\$logical_interface
unset unset_logical_interfaces[\$logical_interface]
unset physical_interfaces[\$logical_interface]
@ -179,8 +179,8 @@ echo "DEVICE=$iname" > $devfile
echo "ONBOOT=yes" >> $devfile
#if $iface_type not in ("master","bond","bridge","bonded_bridge_slave")
#if $vlanpattern.match(iname)
pass
#if $vlanpattern.match($iname)
#pass
#else
#set $interface_matched = $subinterfacepattern.match($iname)
#if $interface_matched
@ -190,14 +190,14 @@ logical_interface=$interface_name
logical_interface=$iname
#end if
physical_interface=\${logical_interface_mapping[\$logical_interface]}
if [ -n "\$physical_interface" ]; then
if [ ! -z "\$physical_interface" ]; then
physical_mac=\${physical_interface_mac[\$physical_interface]}
fi
if [ -n "\$physical_mac" ]; then
if [ ! -z "\$physical_mac" ]; then
echo "HWADDR=\$physical_mac" >> $devfile
fi
#if not $subinterfacepattern.match($iname)
if [ -f "/etc/modprobe.conf" ] && [ -n "\$physical_interface" ]; then
if [ -f "/etc/modprobe.conf" ] && [ ! -z "\$physical_interface" ]; then
grep \$physical_interface /etc/modprobe.conf | sed "s/\$physical_interface/$iname/" >> /etc/modprobe.conf.cobbler
grep -v \$physical_interface /etc/modprobe.conf >> /etc/modprobe.conf.new
rm -f /etc/modprobe.conf
@ -312,17 +312,17 @@ unset logical_interface_mapping[\$logical_interface]
for logical_interface in \${!logical_interface_mapping[@]}; do
physical_interface=\${logical_interface_mapping[\$logical_interface]}
if [ -n "\$physical_interface" ]; then
if [ ! -z "\$physical_interface" ]; then
devfile="/etc/sysconfig/network-scripts/cobbler/ifcfg-"\$logical_interface
mac=\${physical_interface_mac[\$physical_interface]}
echo "DEVICE=\$logical_interface" > \$devfile
echo "ONBOOT=yes" >> \$devfile
echo "BOOTPROTO=static" >> \$devfile
if [ -n "\$mac" ]; then
if [ ! -z "\$mac" ]; then
echo "HWADDR=\$mac" >> \$devfile
fi
echo "TYPE=Ethernet" >> \$devfile
if [ -f "/etc/modprobe.conf" ] && [ -n "\$physical_interface" ]; then
if [ -f "/etc/modprobe.conf" ] && [ ! -z "\$physical_interface" ]; then
grep \$physical_interface /etc/modprobe.conf | sed "s/\$physical_interface/\$logical_interface/" >> /etc/modprobe.conf.cobbler
grep -v \$physical_interface /etc/modprobe.conf >> /etc/modprobe.conf.new
rm -f /etc/modprobe.conf

View File

@ -0,0 +1,2 @@
set -x -v
exec 1>/root/ks-post.log 2>&1

View File

@ -1,5 +1,8 @@
#if $getVar("system_name","") != ""
# Start pre_install_network_config generated code
#if $getVar('management_nic', '') == ""
#set $management_nic=''
#end if
#raw
# generic functions to be used later for discovering NICs
mac_exists() {
@ -28,12 +31,7 @@ get_ifname() {
}
#end raw
#set ikeys = $interfaces.keys()
#import re
#set $vlanpattern = $re.compile("[a-zA-Z0-9]+[\.:][0-9]+")
#set $routepattern = $re.compile("[0-9/.]+:[0-9.]+")
##
#for $iname in $ikeys
# Start $iname
#set $idata = $interfaces[$iname]
#set $mac = $idata["mac_address"]
#set $static = $idata["static"]
@ -43,7 +41,15 @@ get_ifname() {
#set $iface_type = $idata["interface_type"]
#set $iface_master = $idata["interface_master"]
#set $static_routes = $idata["static_routes"]
#if not $management or $mac == ""
#if $management
#set $management_nic = $iname
#end if
#if $management_nic != ''
#if $iname != $management_nic
#continue
#end if
#end if
#if $mac == ""
#continue
#end if
# Configuring $iname ($mac)

View File

@ -0,0 +1,12 @@
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 &

View File

@ -10,14 +10,12 @@
#end if
declare -A disk_mapping
set \$(ls -l /dev/disk/by-path | awk '{print \$9; print \$11}')
set \$(ls -s -l /dev/disk/by-path | awk '{print \$10, \$12}')
let disk_mapping_nums=\$#/2
let disk_mapping_offset=0
echo "disk_mapping_nums: \$disk_mapping_nums" > /tmp/log
echo "disk_mapping_offset: \$disk_mapping_offset" >> /tmp/log
echo "disk_mapping: $*" >> /tmp/log
while [ \$disk_mapping_offset -lt \$disk_mapping_nums ];
do
while [ \$disk_mapping_offset -lt \$disk_mapping_nums ]; do
let found_disk_type=0
#if $getVar('disk_type_only','') != ""
if expr match "\$1" ".*-${disk_type_only}-.*"; then
@ -42,35 +40,40 @@ set \$(list-harddrives)
let disk_nums=\$#/2
let disk_offset=0
let found_disk_offset=0
while [ \$disk_offset -lt \$disk_nums ];
do
let found_disk=0
if [[ x"\${disk_mapping[\$1]}" == x"" ]]; then
echo "ignore disk \$1 since it is not in disk_mapping" >> /tmp/log
else
while [ \$disk_offset -lt \$disk_nums ]; do
let found_disk=0
disk_name=\$(basename \$1)
if [[ x"\${disk_mapping[\${disk_name}]}" == x"" ]]; then
echo "ignore disk \$1 since it is not in disk_mapping" >> /tmp/log
let disk_offset=\$disk_offset+1
shift 2
continue
fi
#if $getVar('partitions_only', '') != ""
#for $partition_only in $partitions_only.split(',')
if expr match "\$1" "$partition_only"; then
#if not $partition_only
#continue
#end if
if expr match "\${disk_name}" "$partition_only"; then
let found_disk=1
else
echo "disk \$1 does not match $partition_only" >> /tmp/log
echo "disk \${disk_name} does not match $partition_only" >> /tmp/log
fi
#end for
#else
let found_disk=1
#end if
fi
if [ \$found_disk -gt 0 ]; then
echo "add disk \$1 in partitioning list" >> /tmp/log
if [ \$found_disk -gt 0 ]; then
echo "add disk \${disk_name} in partitioning list" >> /tmp/log
#if $getVar('partition_by_path', '0') != "0"
disks[\$found_disk_offset]=/dev/disk/by-path/\${disk_mapping[\$1]}
disks[\$found_disk_offset]=/dev/disk/by-path/\${disk_mapping[\${disk_name}]}
#else
disks[\$found_disk_offset]=\$1
disks[\$found_disk_offset]=/dev/\${disk_name}
#end if
let found_disk_offset=\$found_disk_offset+1
fi
let disk_offset=\$disk_offset+1
shift 2
let found_disk_offset=\$found_disk_offset+1
fi
let disk_offset=\$disk_offset+1
shift 2
done
echo "disks \${disks[@]}" >> /tmp/log
#if $getVar('sort_disks', '0') != "0"

View File

@ -0,0 +1,8 @@
mkdir -p /tmp/repo_backup
mv /etc/yum.repos.d/* /tmp/repo_backup/
$SNIPPET('kickstart_yum.conf')
## $SNIPPET('kickstart_centos_base_repo')
## $SNIPPET('kickstart_centos_debuginfo_repo')
## $SNIPPET('kickstart_centos_vault_repo')
$SNIPPET('kickstart_yum_local_repo')

View File

@ -1,6 +1,6 @@
cat << EOF > /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
cachedir=/var/cache/yum/\$basearch/\$releasever
#if $getVar('proxy', '') != ""
proxy=$proxy
#end if

View File

@ -0,0 +1,11 @@
#if $getVar("local_repo","") != ""
cat << EOF > /etc/yum.repos.d/Compass.repo
[compass_repo]
name=Compass yum repo
baseurl=$local_repo/compass_repo/
enabled=1
gpgcheck=0
priority=1
proxy=_none_
EOF
#end if

View File

@ -5,21 +5,21 @@ d-i apt-setup/use_mirror boolean false
#set $cur=0
#set $repo_data = $getVar("repo_data",[])
#for $repo in $repo_data
#for $dist in $repo.apt_dists
#set $comps = " ".join($repo.apt_components)
#for $dist in $repo.apt_dists
#set $comps = " ".join($repo.apt_components)
d-i apt-setup/local${cur}/repository string \
#if $repo.mirror_locally
#if $repo.mirror_locally
deb http://$http_server/cobbler/repo_mirror/${repo.name} $dist $comps
#else
#else
deb ${repo.mirror} $dist $comps
#end if
#if $repo.comment != ""
#end if
#if $repo.comment != ""
d-i apt-setup/local${cur}/comment string ${repo.comment}
#end if
#if $repo.breed == "src"
#end if
#if $repo.breed == "src"
# Enable deb-src lines
d-i apt-setup/local${cur}/source boolean false
#end if
#set $cur=$cur+1
#end for
#end if
#set $cur=$cur+1
#end for
#end for

View File

@ -1,10 +1,13 @@
mkdir -p /target/etc/chef; \
mkdir -p /etc/chef
mkdir -p /var/log/chef
## Generate validation.pem
$SNIPPET('preseed_chef-validator.pem') echo "processed preseed_chef-validator.pem" >> /tmp/preseed.log; \
$SNIPPET('preseed_chef-validator.pem')
## Generate admin.pem
$SNIPPET('preseed_chef-admin.pem')
## Generate client.rb
$SNIPPET('preseed_client.rb') echo "processed preseed_client.rb" >> /tmp/preseed.log; \
## Generate chef rsyslog conf
$SNIPPET('preseed_chef_rsyslog.conf') echo "processed preseed_chef_rsyslog.conf" >> /tmp/preseed.log; \
$SNIPPET('preseed_chef_firstrun.sh') echo "processed preseed_chef_firstrun.sh" >> /tmp/preseed.log; \
$SNIPPET('preseed_chef_rerun.sh') echo "processed preseed_chef_rerun.sh" >> /tmp/preseed.log; \
$SNIPPET('preseed_chef_init') echo "processed preseed_chef_init" >> /tmp/preseed.log; \
$SNIPPET('preseed_client.rb')
$SNIPPET('preseed_knife.rb')
$SNIPPET('preseed_gem_local_repo')
$SNIPPET('preseed_chef_run.sh')
$SNIPPET('preseed_chef_init')

View File

@ -0,0 +1,8 @@
#if $getVar('chef_admin_file', '') == ""
#set chef_admin_file = '/etc/chef-server/admin.pem'
#end if
#set f = $open($chef_admin_file)
cat << EOL > /etc/chef/admin.pem
#echo $f.read()
EOL
#silent $f.close()

View File

@ -1,15 +1,8 @@
#if $getVar('chef_validation_file', '') == ""
#set chef_validation_file = '/etc/chef-server/chef-validator.pem'
#end if
#set $firstline = True
#set $f = $open($chef_validation_file)
#for $line in $f
#set $line = $line.rstrip('\n')
#if $firstline
echo "$line" > /target/etc/chef/validation.pem; \
#else
echo "$line" >> /target/etc/chef/validation.pem; \
#end if
#set $firstline = False
#end for
#set f = $open($chef_validation_file)
cat << EOL > /etc/chef/validation.pem
#echo $f.read()
EOL
#silent $f.close()

View File

@ -1,20 +0,0 @@
echo "#!/bin/bash" > /target/etc/chef/firstrun.sh; \
echo "touch /tmp/chef.log" >> /target/etc/chef/firstrun.sh; \
echo "while true; do" >> /target/etc/chef/firstrun.sh; \
echo " echo \"firstrun.sh chef-client on \`date\`\" &>> /tmp/chef.log" >> /target/etc/chef/firstrun.sh; \
echo " clients=\\$(pgrep chef-client)" >> /target/etc/chef/firstrun.sh; \
echo " if [ \"\\$?\" == \"0\" ]; then" >> /target/etc/chef/firstrun.sh; \
echo " echo \"there are chef-clients '\\$clients' running\" &>> /tmp/chef.log" >> /target/etc/chef/firstrun.sh; \
echo " sleep 1m" >> /target/etc/chef/firstrun.sh; \
echo " else" >> /target/etc/chef/firstrun.sh; \
echo " chef-client -L /var/log/chef-client.log &>> /tmp/chef.log" >> /target/etc/chef/firstrun.sh; \
echo " if [ \"\\$?\" != \"0\" ]; then" >> /target/etc/chef/firstrun.sh; \
echo " echo \"chef-client run failed\" &>> /tmp/chef.log" >> /target/etc/chef/firstrun.sh; \
echo " sleep 1m" >> /target/etc/chef/firstrun.sh; \
echo " else" >> /target/etc/chef/firstrun.sh; \
echo " echo \"chef-client run success\" &>> /tmp/chef.log" >> /target/etc/chef/firstrun.sh; \
echo " break" >> /target/etc/chef/firstrun.sh; \
echo " fi" >> /target/etc/chef/firstrun.sh; \
echo " fi" >> /target/etc/chef/firstrun.sh; \
echo "done" >> /target/etc/chef/firstrun.sh; \
chmod +x /target/etc/chef/firstrun.sh; \

View File

@ -2,20 +2,29 @@
#if $getVar('ntp_server', '') == ""
#set $ntp_server = '0.ubuntu.pool.ntp.org'
#end if
echo "#!/bin/bash" > /target/etc/init.d/chef; \
echo "echo \"old date is: \`date\`\" 2>&1 > /tmp/ntp.log" >> /target/etc/init.d/chef; \
echo "service ntp stop 2>&1 >> /tmp/ntp.log" >> /target/etc/init.d/chef; \
echo "ntpdate $ntp_server 2>&1 >> /tmp/ntp.log" >> /target/etc/init.d/chef; \
echo "service ntp start 2>&1 >> /tmp/ntp.log" >> /target/etc/init.d/chef; \
echo "echo \"new date is: \`date\`\" 2>&1 >> /tmp/ntp.log" >> /target/etc/init.d/chef; \
echo "rm -rf /var/lib/rsyslog/firstboot_log" >> /target/etc/init.d/chef; \
echo "service rsyslog restart" >> /target/etc/init.d/chef; \
echo "/etc/chef/firstrun.sh" >> /target/etc/init.d/chef; \
echo "crontab -l > /tmp/mycron" >> /target/etc/init.d/chef; \
echo "echo \"*/30 * * * * /etc/chef/rerun.sh\" >> /tmp/mycron" >> /target/etc/init.d/chef; \
echo "crontab /tmp/mycron" >> /target/etc/init.d/chef; \
echo "rm /tmp/mycron" >> /target/etc/init.d/chef; \
echo "update-rc.d -f chef remove" >> /target/etc/init.d/chef; \
echo "mv /etc/init.d/chef /tmp/chef" >> /target/etc/init.d/chef; \
chmod +x /target/etc/init.d/chef; \
chroot /target update-rc.d chef defaults 99 20; \
cat << EOF > /etc/init.d/chef
#raw
#!/bin/bash
# chkconfig: 2345 99 20
# description: Description of the script
# processname: chef-agent
#end raw
echo "old date is: `date`" 2>&1 > /tmp/ntp.log
service ntpd stop 2>&1 >> /tmp/ntp.log
ntpdate $ntp_server 2>&1 >> /tmp/ntp.log
service ntpd start 2>&1 >> /tmp/ntp.log
echo "new date is: `date`" 2>&1 >> /tmp/ntp.log
crontab -l > /tmp/mycron
echo "*/30 * * * * /etc/chef/chef_client_run.sh" >> /tmp/mycron
crontab /tmp/mycron
rm /tmp/mycron
/etc/chef/chef_client_run.sh &
update-rc.d -f chef remove
mv /etc/init.d/chef /tmp/chef
EOF
chmod +x /etc/init.d/chef
update-rc.d chef defaults 99 20

View File

@ -1,14 +0,0 @@
echo "#!/bin/bash" > /target/etc/chef/rerun.sh; \
echo "echo \"rerun chef-client on \`date\`\" &>> /tmp/chef.log" >> /target/etc/chef/rerun.sh; \
echo "clients=\\$(pgrep chef-client)" >> /target/etc/chef/rerun.sh; \
echo "if [ \"\\$?\" == \"0\" ]; then" >> /target/etc/chef/rerun.sh; \
echo " echo \"there are chef-clients '\\$clients' running\" &>> /tmp/chef.log" >> /target/etc/chef/rerun.sh; \
echo " exit 1" >> /target/etc/chef/rerun.sh; \
echo "fi" >> /target/etc/chef/rerun.sh; \
echo "chef-client &>> /tmp/chef.log" >> /target/etc/chef/rerun.sh; \
echo "if [ \"\\$?\" != \"0\" ]; then" >> /target/etc/chef/rerun.sh; \
echo " echo \"chef-client run failed\" &>> /tmp/chef.log" >> /target/etc/chef/rerun.sh; \
echo "else" >> /target/etc/chef/rerun.sh; \
echo " echo \"chef-client run success\" &>> /tmp/chef.log" >> /target/etc/chef/rerun.sh; \
echo "fi" >> /target/etc/chef/rerun.sh; \
chmod +x /target/etc/chef/rerun.sh; \

View File

@ -0,0 +1,86 @@
#set ip_address = ""
#set ikeys = $interfaces.keys()
#for $iname in $ikeys
#set $idata = $interfaces[$iname]
#set $static = $idata["static"]
#set $management = $idata["management"]
#set $ip = $idata["ip_address"]
#if $management and $ip
#set $ip_address = $ip
#end if
#end for
cat << EOF > /etc/chef/chef_client_run.sh
#!/bin/bash
instances=\\$(pgrep chef_client_run.sh | wc -l)
if [ \\$instances -gt 1 ]; then
echo "there are chef-client run instances '\\$instances' running" &>> /tmp/chef.log
exit 1
fi
touch /tmp/chef.log
while true; do
echo "run chef-client on \`date\`" &>> /tmp/chef.log
clients=\\$(pgrep chef-client)
if [ "\\$?" == "0" ]; then
echo "there are chef-clients '\\$clients' running" &>> /tmp/chef.log
sleep 1m
else
echo "knife search nodes" &>> /tmp/chef.log
USER=root HOME=/root knife search node "name:\\$HOSTNAME.*" -i -a name &>> /tmp/chef.log
nodes=\\$(USER=root HOME=/root knife search node "name:\\$HOSTNAME.*" -i -a name | grep 'name: ' | awk '{print \\$2}')
echo "found nodes \\$nodes" &>> /tmp/chef.log
all_nodes_success=1
for node in \\$nodes; do
mkdir -p /var/log/chef/\\$node
if [ ! -f /etc/chef/\\$node.json ]; then
cat << EOL > /etc/chef/\\$node.json
#if $getVar("local_repo","") != ""
{
"local_repo": "$local_repo",
"ip_address": "$ip_address"
}
#else
{
"ip_address": "$ip_address"
}
#end if
EOL
fi
if [ ! -f "/etc/chef/\\$node.pem" ]; then
cat << EOL > /etc/rsyslog.d/\\$node.conf
\\\\$ModLoad imfile
\\\\$InputFileName /var/log/chef/\\$node/chef-client.log
\\\\$InputFileReadMode 0
\\\\$InputFileTag \\$node
\\\\$InputFileStateFile chef_\\${node}_log
\\\\$InputFileSeverity notice
\\\\$InputFileFacility local3
\\\\$InputRunFileMonitor
\\\\$InputFilePollInterval 1
local3.info @$server:514
EOL
rm -rf /var/lib/rsyslog/chef_\\$node_log
service rsyslog restart
fi
if [ -f "/etc/chef/\\$node.done" ]; then
chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem &>> /tmp/chef.log
else
chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem -L /var/log/chef/\\$node/chef-client.log &>> /tmp/chef.log
fi
if [ "\\$?" != "0" ]; then
echo "chef-client --node-name \\$node run failed" &>> /tmp/chef.log
all_nodes_success=0
else
echo "chef-client --node-name \\$node run success" &>> /tmp/chef.log
touch /etc/chef/\\$node.done
fi
done
if [ \\$all_nodes_success -eq 0 ]; then
sleep 1m
else
break
fi
fi
done
EOF
chmod +x /etc/chef/chef_client_run.sh

View File

@ -1,27 +1,26 @@
echo "log_level :info" > /target/etc/chef/client.rb; \
echo "log_location '/dev/null'" >> /target/etc/chef/client.rb; \
cat << EOL > /etc/chef/client.rb
log_level :info
log_location '/dev/null'
#if $getVar('chef_url', '') != ""
echo "chef_server_url '$chef_url'" >> /target/etc/chef/client.rb; \
chef_server_url '$chef_url'
#end if
#if $getVar('proxy', '') != ""
echo "http_proxy '$proxy'" >> /target/etc/chef/client.rb; \
echo "https_proxy '$proxy'" >> /target/etc/chef/client.rb; \
echo "ENV['http_proxy'] = '$proxy'" >> /target/etc/chef/client.rb; \
echo "ENV['https_proxy'] = '$proxy'" >> /target/etc/chef/client.rb; \
echo "ENV['HTTP_PROXY'] = '$proxy'" >> /target/etc/chef/client.rb; \
echo "ENV['HTTPS_PROXY'] = '$proxy'" >> /target/etc/chef/client.rb; \
http_proxy '$proxy'
https_proxy '$proxy'
ENV['http_proxy'] = '$proxy'
ENV['https_proxy'] = '$proxy'
ENV['HTTP_PROXY'] = '$proxy'
ENV['HTTPS_PROXY'] = '$proxy'
#if $getVar('ignore_proxy', '') != ""
#set ignore_proxy = ','.join([proxy.strip() for proxy in $ignore_proxy.split(',') if proxy.strip()])
echo "no_proxy '$ignore_proxy'" >> /target/etc/chef/client.rb; \
echo "ENV['no_proxy'] = '$ignore_proxy'" >> /target/etc/chef/client.rb; \
echo "ENV['NO_PROXY'] = '$ignore_proxy'" >> /target/etc/chef/client.rb; \
no_proxy '$ignore_proxy'
ENV['no_proxy'] = '$ignore_proxy'
ENV['NO_PROXY'] = '$ignore_proxy'
#end if
#end if
#if $getVar('chef_node_name', '') != ""
echo "node_name '$chef_node_name'" >> /target/etc/chef/client.rb; \
#end if
echo "validation_client_name 'chef-validator'" >> /target/etc/chef/client.rb; \
echo "json_attribs nil" >> /target/etc/chef/client.rb; \
echo "pid_file '/var/run/chef-client.pid'" >> /target/etc/chef/client.rb; \
echo "# Using default node name (fqdn)" >> /target/etc/chef/client.rb; \
echo "no_lazy_load true" >> /target/etc/chef/client.rb; \
validation_client_name 'chef-validator'
json_attribs nil
pid_file '/var/run/chef-client.pid'
# Using default node name (fqdn)
no_lazy_load true
EOL

View File

@ -0,0 +1,14 @@
cat << EOF > /root/.gemrc
gem: --no-ri --no-rdoc
:backtrace: false
:benchmark: false
:bulk_threshold: 1000
:sources:
## - http://gems.rubyforge.org/
#if $getVar("local_repo","") != ""
- $local_repo/gem_repo/
#end if
:update_sources: true
:verbose: true
EOF

View File

@ -1,14 +1,15 @@
echo "127.0.0.1 $system_name localhost localhost.localdomain localhost4 localhost4.localdomain4" > /target/etc/hosts; \
echo "::1 $system_name localhost localhost.localdomain localhost6 localhost6.localdomain6" >> /target/etc/hosts; \
cat << EOL > /etc/hosts
127.0.0.1 $system_name localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 $system_name localhost localhost.localdomain localhost6 localhost6.localdomain6
#for $iname, $idata in $interfaces.items()
#if $hostname and $idata["management"] and $idata["static"] and $idata.get("ip_address", "") != ""
echo "$idata["ip_address"] $hostname" >> /target/etc/hosts; \
$idata["ip_address"] $hostname
#end if
#end for
#import os
#set $server_name = $os.uname[1]
echo "$server $server_name" >> /target/etc/hosts; \
$server $server_name
#if $getVar("chef_server_ip", "") != "" and $getVar("chef_server_dns", "") != ""
echo "$chef_server_ip $chef_server_dns" >> /target/etc/hosts; \
$chef_server_ip $chef_server_dns
#end if
EOL

View File

@ -0,0 +1,13 @@
mkdir -p /root/.chef
cat << EOL > /root/.chef/knife.rb
log_level :info
log_location '/dev/null'
#if $getVar('chef_url', '') != ""
chef_server_url '$chef_url'
#end if
node_name 'admin'
client_key '/etc/chef/admin.pem'
validation_client_name 'chef-validator'
validation_key '/etc/chef/validation.pem'
syntax_check_cache_path '/root/.chef/syntax_check_cache'
EOL

View File

@ -1 +1,54 @@
echo "* - nofile 100000" > /target/etc/security/limits.conf; \
cat << EOF > /etc/security/limits.conf
#raw
# /etc/security/limits.conf
#
# Each line describes a limit for a user in the form:
#
#<domain> <type> <item> <value>
#
#Where:
#<domain> can be:
# - an user name
# - a group name, with @group syntax
# - the wildcard *, for default entry
# - the wildcard %, can be also used with %group syntax,
# for maxlogin limit
#
#<type> can have the two values:
# - "soft" for enforcing the soft limits
# - "hard" for enforcing hard limits
#
#<item> can be one of the following:
# - core - limits the core file size (KB)
# - data - max data size (KB)
# - fsize - maximum filesize (KB)
# - memlock - max locked-in-memory address space (KB)
# - nofile - max number of open files
# - rss - max resident set size (KB)
# - stack - max stack size (KB)
# - cpu - max CPU time (MIN)
# - nproc - max number of processes
# - as - address space limit (KB)
# - maxlogins - max number of logins for this user
# - maxsyslogins - max number of logins on the system
# - priority - the priority to run user process with
# - locks - max number of file locks the user can hold
# - sigpending - max number of pending signals
# - msgqueue - max memory used by POSIX message queues (bytes)
# - nice - max nice priority allowed to raise to values: [-20, 19]
# - rtprio - max realtime priority
#
#<domain> <type> <item> <value>
#
#* soft core 0
#* hard rss 10000
#@student hard nproc 20
#@faculty soft nproc 20
#@faculty hard nproc 50
#ftp hard nproc 0
#@student - maxlogins 4
* - nofile 100000
# End of file
#end raw
EOF

View File

@ -1,16 +1,70 @@
#if $getVar('ntp_server', '') == ""
#set $ntp_server = '0.ubuntu.pool.ntp.org'
#end if
echo "driftfile /var/lib/ntp/ntp.drift" > /target/etc/ntp.conf; \
echo "#statsdir /var/log/ntpstats/" >> /target/etc/ntp.conf; \
echo "statistics loopstats peerstats clockstats" >> /target/etc/ntp.conf; \
echo "filegen loopstats file loopstats type day enable" >> /target/etc/ntp.conf; \
echo "filegen peerstats file peerstats type day enable" >> /target/etc/ntp.conf; \
echo "filegen clockstats file clockstats type day enable" >> /target/etc/ntp.conf; \
echo "server $ntp_server" >> /target/etc/ntp.conf; \
echo "restrict -4 default kod notrap nomodify nopeer noquery" >> /target/etc/ntp.conf; \
echo "restrict -6 default kod notrap nomodify nopeer noquery" >> /target/etc/ntp.conf; \
echo "restrict 127.0.0.1" >> /target/etc/ntp.conf; \
echo "restrict ::1" >> /target/etc/ntp.conf; \
echo "server 127.127.1.0 # local clock" >> /target/etc/ntp.conf; \
chroot /target update-rc.d ntp defaults 58 74; \
cat << EOF > /etc/ntp.conf
# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).
# Include the option tinker panic 0 at the top of your ntp.conf file.
# By default, the NTP daemon sometimes panics and exits if the underlying clock
# appears to be behaving erratically. This option causes the daemon to keep
# running instead of panicking.
tinker panic 0
driftfile /var/lib/ntp/drift
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict -6 ::1
# Hosts on local network are less restricted.
# restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
# server 0.ubuntu.pool.ntp.org
# server 1.ubuntu.pool.ntp.org
# server 2.ubuntu.pool.ntp.org
server $ntp_server
# broadcast 192.168.1.255 autokey # broadcast server
# broadcastclient # broadcast client
# broadcast 224.0.1.1 autokey # multicast server
# multicastclient 224.0.1.1 # multicast client
# manycastserver 239.255.254.254 # manycast server
# manycastclient 239.255.254.254 autokey # manycast client
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
server 127.127.1.0 # local clock
# Enable public key cryptography.
# crypto
includefile /etc/ntp/crypto/pw
# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys
# Specify the key identifiers which are trusted.
# trustedkey 4 8 42
# Specify the key identifier to use with the ntpdc utility.
# requestkey 8
# Specify the key identifier to use with the ntpq utility.
# controlkey 8
# Enable writing of statistics records.
# statistics clockstats cryptostats loopstats peerstats
EOF
update-rc.d ntp defaults 58 74

View File

@ -1,16 +1,7 @@
#set hostname=$getVar('hostname',None)
#set partition = $getVar('partition', None)
#if $hostname == None
#set $vgname = "VolGroup00"
#else
#set $vgname = $hostname.split('.')[0]
#end if
#if $getVar("system_name","") != ""
d-i partman-auto/init_automatically_partition string custom
d-i partman-auto/automatically_partition string custom
d-i partman-auto/method string lvm
d-i partman-auto/purge_lvm_from_device boolean true
d-i partman-auto-lvm/new_vg_name string $vgname
d-i partman-auto-lvm/guided_size string max
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-lvm/device_remove_lvm_span boolean true
@ -25,8 +16,5 @@ d-i partman/default_filesystem string ext3
d-i partman/mount_style select uuid
d-i partman/confirm_write_changes_to_disks_and_configure_lvm boolean true
d-i partman/choose_partition select Finish partitioning and write changes to disk
d-i partman-auto/choose_recipe select boot-root
d-i mdadm/boot_degraded boolean true
d-i partman-auto-lvm/no_boot boolean true
d-i partman-lvm/vgcreate string $vgname
#end if

View File

@ -1,13 +1,43 @@
#if $str($getVar('anamon_enabled','')) == "1"
wget -O /target/usr/local/sbin/anamon "http://$server:$http_port/cobbler/aux/anamon"; \
## A self-destruct service to boot anamon
echo "#!/bin/bash" > /target/etc/init.d/anamon.init; \
echo "cd /var/log/installer" >> /target/etc/init.d/anamon.init; \
echo "gunzip initial-status.gz" >> /target/etc/init.d/anamon.init; \
echo "/usr/local/sbin/anamon --watchfile \"/var/log/installer/syslog /var/log/installer/hardware-summary /var/log/installer/initial-status /var/log/installer/status /var/log/messages /var/log/dmesg\" --name $name --server $server --port $http_port --exit" >> /target/etc/init.d/anamon.init; \
echo "update-rc.d -f anamon remove" >> /target/etc/init.d/anamon.init; \
echo "mv /etc/init.d/anamon.init /tmp/anamon.init" >> /target/etc/init.d/anamon.init; \
chmod 755 /target/etc/init.d/anamon.init /target/usr/local/sbin/anamon; \
chroot /target update-rc.d anamon.init defaults 95 95; \
#end if
## install anamon script
wget -O /usr/local/sbin/anamon "http://$server:$http_port/cobbler/aux/anamon"
## install anamon system service
cat << EOF > /etc/init.d/anamon.init
#raw
#!/bin/bash
## BEGIN INIT INFO
# Provides: anamon.init
# Default-Start: 3 5
# Default-Stop: 0 1 2 4 6
# Required-Start:
# Should-Start: $network
# Short-Description: Starts the cobbler anamon boot notification program
# Description: anamon runs the first time a machine is booted after
# installation.
## END INIT INFO
#
# anamon.init: Starts the cobbler post-install boot notification program
#
# chkconfig: 35 95 95
#
# description: anamon runs the first time a machine is booted after
# installation.
#
#end raw
cd /var/log/installer
gunzip initial-status.gz
cd -
/usr/local/sbin/anamon --watchfile "/var/log/installer/syslog /var/log/installer/hardware-summary /var/log/installer/initial-status /var/log/installer/status /var/log/messages /var/log/dmesg" --name $name --server $server --port $http_port --exit
update-rc.d -f anamon remove
mv /etc/init.d/anamon.init /tmp/anamon.init
EOF
## adjust permissions
chmod 755 /etc/init.d/anamon.init /usr/local/sbin/anamon
test -d /selinux && restorecon /etc/init.d/anamon.init /usr/local/sbin/anamon
## enable the script
update-rc.d anamon.init defaults 95 95
#end if

View File

@ -1,19 +1,23 @@
cat << EOF > /etc/apt/apt.conf
#if $getVar('proxy', '') != ''
echo "Acquire::http::Proxy \"$proxy\";" > /target/etc/apt/apt.conf; \
Acquire::http::Proxy "$proxy"
#end if
EOF
cat << EOF > /etc/apt/sources.list
#if $getVar('os_version', '') != ''
echo "deb http://archive.ubuntu.com/ubuntu/ $os_version main restricted universe multiverse" > /target/etc/apt/sources.list; \
echo "deb http://archive.ubuntu.com/ubuntu/ ${os_version}-security main restricted universe multiverse" >> /target/etc/apt/sources.list; \
echo "deb http://archive.ubuntu.com/ubuntu/ ${os_version}-updates main restricted universe multiverse" >> /target/etc/apt/sources.list; \
echo "deb http://archive.ubuntu.com/ubuntu/ ${os_version}-proposed main restricted universe multiverse" >> /target/etc/apt/sources.list; \
echo "deb http://archive.ubuntu.com/ubuntu/ ${os_version}-backports main restricted universe multiverse" >> /target/etc/apt/sources.list; \
deb http://archive.ubuntu.com/ubuntu/ $os_version main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ ${os_version}-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ ${os_version}-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ ${os_version}-proposed main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ ${os_version}-backports main restricted universe multiverse
#end if
#set $repo_data = $getVar("repo_data",[])
#for $repo in $repo_data
#for $dist in $repo.apt_dists
#set $comps = " ".join($repo.apt_components)
#if $repo.comment != ""
echo "# ${repo.comment}" >> /target/etc/apt/sources.list; \
# ${repo.comment}
#end if
#if $repo.arch == "x86_64"
#set $rarch = "[arch=amd64]"
@ -21,9 +25,10 @@ echo "# ${repo.comment}" >> /target/etc/apt/sources.list; \
#set $rarch = "[arch=%s]" % $repo.arch
#end if
#if $repo.mirror_locally
echo "deb ${rarch} http://$http_server/cblr/repo_mirror/${repo.name} $dist $comps" >> /target/etc/apt/sources.list; \
deb ${rarch} http://$http_server/cblr/repo_mirror/${repo.name} $dist $comps
#else
echo "deb ${rarch} ${repo.mirror} $dist $comps" >> /target/etc/apt/sources.list; \
deb ${rarch} ${repo.mirror} $dist $comps
#end if
#end for
#end for
EOF

View File

@ -0,0 +1,14 @@
#if $getVar('kernel_options_post','') != ''
# Start post install kernel options update
if [ -f /etc/default/grub ]; then
TMP_GRUB=\$(gawk 'match(\$0,/^GRUB_CMDLINE_LINUX="([^"]+)"/,a) {printf("%s\n",a[1])}' /etc/default/grub)
sed -i '/^GRUB_CMDLINE_LINUX=/d' /etc/default/grub
echo "GRUB_CMDLINE_LINUX=\"\$TMP_GRUB $kernel_options_post\"" >> /etc/default/grub
grub2-mkconfig -o /boot/grub2/grub.cfg
else
/sbin/grubby --update-kernel=\$(/sbin/grubby --default-kernel) --args="$kernel_options_post"
fi
# End post install kernel options update
#end if

View File

@ -4,212 +4,361 @@
#else
#set promisc_interfaces = []
#end if
#if $getVar("system_name","") != ""
## this is being provisioned by system records, not profile records
## so we can do the more complex stuff
## get the list of interface names
#set ikeys = $interfaces.keys()
#set osversion = $getVar("os_version","")
#import re
#set $vlanpattern = $re.compile("[a-zA-Z0-9]+[\.:][0-9]+")
## Determine if we should use the MAC address to configure the interfaces first
## Only physical interfaces are required to have a MAC address
## Also determine the number of bonding devices we have, so we can set the
## max-bonds option in modprobe.conf accordingly. -- jcapel
#set $configbymac = True
#set $bridge_slaves = {}
#set $numbondingdevs = 0
#set $enableipv6 = False
## =============================================================================
#for $iname in $ikeys
## look at the interface hash data for the specific interface
#set $idata = $interfaces[$iname]
## do not configure by mac address if we don't have one AND it's not for bonding/vlans
## as opposed to a "real" physical interface
#if $idata.get("mac_address", "") == "" and not $vlanpattern.match($iname) and not $idata.get("interface_type", "").lower() in ("master","bond","bridge"):
## we have to globally turn off the config by mac feature as we can't
## use it now
#set $configbymac = False
#end if
## count the number of bonding devices we have.
#if $idata.get("interface_type", "").lower() in ("master","bond","bonded_bridge_slave")
#set $numbondingdevs += 1
#end if
## build a mapping of bridge slaves, since deb/ubuntu bridge slaves do not
## get interface entries of their own
#if $idata.get("interface_type","").lower() == "bridge_slave"
#set $this_master = $idata.get("interface_master", None)
#if $this_master and not $bridge_slaves.has_key($this_master)
#set $bridge_slaves[$this_master] = []
#end if
<% bridge_slaves[this_master].append(iname) %>
#end if
## enable IPv6 networking if we set an ipv6 address or turn on autoconfiguration
#if $idata.get("ipv6_address", "") != "" or $ipv6_autoconfiguration == True
#set $enableipv6 = True
#end if
#if $hostname != ""
# set the hostname
echo "$hostname" > /etc/hostname
/bin/hostname $hostname
#end if
$SNIPPET('preseed_hosts')
#set $num_ns_search = $len($name_servers_search)
#if $num_ns_search > 0
sed -i -e "/^search /d" /etc/resolv.conf
echo -n "search " >>/etc/resolv.conf
#for $nameserversearch in $name_servers_search
echo -n "$nameserversearch " >>/etc/resolv.conf
#end for
echo "" >>/etc/resolv.conf
#end if
#set $num_ns = $len($name_servers)
#if $num_ns > 0
sed -i -e "/^nameserver /d" /etc/resolv.conf
#for $nameserver in $name_servers
echo "nameserver $nameserver" >>/etc/resolv.conf
#end for
## end looping through the interfaces to see which ones we need to configure.
## =============================================================================
## Rewrite the interfaces file and make sure we preserve the loopback device
echo "auto lo" > /target/etc/network/interfaces; \
echo " iface lo inet loopback" >> /target/etc/network/interfaces; \
echo "" >> /target/etc/network/interfaces; \
## =============================================================================
## now create the config file for each interface
#for $iname in $ikeys
## create lots of variables to use later
#set $idata = $interfaces[$iname]
#set $mac = $idata.get("mac_address", "").upper()
#set $mtu = $idata.get("mtu", "")
#set $static = $idata.get("static", "")
#set $management = $idata.get("management", "")
#set $ip = $idata.get("ip_address", "")
#set $netmask = $idata.get("netmask", "")
#set $if_gateway = $idata.get("if_gateway", "")
#set $static_routes = $idata.get("static_routes", "")
#set $iface_type = $idata.get("interface_type", "").lower()
#set $iface_master = $idata.get("interface_master", "")
#set $bonding_opts = $idata.get("bonding_opts", "")
#set $bridge_opts = $idata.get("bridge_opts", "").split(" ")
#set $ipv6_address = $idata.get("ipv6_address", "")
#set $ipv6_secondaries = $idata.get("ipv6_secondaries", "")
#set $ipv6_mtu = $idata.get("ipv6_mtu", "")
#set $ipv6_default_gateway = $idata.get("ipv6_default_gateway", "")
#set $ipv6_static_routes = $idata.get("ipv6_static_routes", "")
#set $devfile = "/target/etc/sysconfig/network-scripts/cobbler/ifcfg-" + $iname
#set $routesfile = "/target/etc/sysconfig/network-scripts/cobbler/route-" + $iname
#set $ipv6_routesfile = "/target/etc/sysconfig/network-scripts/cobbler/route6-" + $iname
## determine if this interface is for a VLAN
#end if
echo '' > /tmp/network_log
physical_interfaces=""
for physical_interface in \$(ip -o link | cut -d: -f2 | grep -v lo); do
echo "processing physical interface \${physical_interface}" >> /tmp/network_log
if [ -z \${physical_interfaces} ]; then
physical_interfaces="\${physical_interface}"
else
physical_interfaces="\${physical_interfaces} \${physical_interface}"
fi
done
echo "physical interfaces \${physical_interfaces}" >> /tmp/network_log
for physical_interface in \${physical_interfaces}; do
mac=\$(cat /sys/class/net/\${physical_interface}/address)
mac=\$(echo \${mac} |tr 'a-z' 'A-Z' | tr ':' '_')
eval "physical_interface_mac_\${physical_interface}=\$mac"
eval "physical_mac_interface_\${mac}=\${physical_interface}"
done
for physcial_interface in \${physical_interfaces}; do
eval "mac=\\${physical_interface_mac_\${physical_interface}}"
echo "physical interface to mac: \${physcial_interface} => \${mac}" >> /tmp/network_log
done
logical_interfaces=""
#set ikeys = $interfaces.keys()
#set osversion = $getVar("os_version","")
#import re
#set $vlanpattern = $re.compile("([a-zA-Z0-9]+)[\.][0-9]+")
#set $subinterfacepattern = $re.compile("([a-zA-Z0-9]+)[:][0-9]+")
#set $numbondingdevs = 0
#for $iname in $ikeys
#set $idata = $interfaces[$iname]
#set $mac = $idata.get("mac_address", "").upper()
#set $interface_type = $idata.get("interface_type", "").lower()
#if $interface_type in ("master","bond","bonded_bridge_slave")
#set $numbondingdevs += 1
#end if
if [ -z \${logical_interfaces} ]; then
logical_interfaces="$iname"
else
logical_interfaces="\${logical_interfaces} $iname"
fi
#if $mac != ""
#set mac = $mac.replace(':', '_')
physical_interface=\${physical_mac_interface_$mac}
if [ ! -z \${physical_interface} ]; then
logical_interface_mapping_$iname=\${physical_interface}
eval "physical_interface_mapping_\${physical_interface}=$iname"
echo "set logical interface $iname map to physical interface \${physical_interface}" >> /tmp/network_log
else
logical_interface_mapping_$iname=$iname
physical_interface_mapping_$iname=$iname
echo "force set logical interface $iname to the same physical interface" >> /tmp/network_log
fi
#end if
#end for
echo "logical interfaces \${logical_interfaces}" >> /tmp/network_log
for logical_interface in \${logical_interfaces}; do
eval "physical_interface=\\${logical_interface_mapping_\${logical_interface}}"
if [ ! -z \${physical_interface} ]; then
continue
fi
eval "physical_interface_mac=\\${physical_interface_mac_\${logical_interface}}"
if [ -z \${physical_interface_mac} ]; then
continue
fi
eval "logical_interface_mapping_\${logical_interface}=\${logical_interface}"
eval "physical_interface_mapping_\${logical_interface}=\${logical_interface}"
echo "set logical interface \${logical_interface} to the same physical interface" >> /tmp/network_log
done
unset_physical_interfaces=""
for physical_interface in \${physical_interfaces}; do
eval "logical_interface=\\${physical_interface_mapping_\${physical_interface}}"
if [ ! -z \${logical_interface} ]; then
continue
fi
if [ -z \${unset_physical_interfaces} ]; then
unset_physical_interfaces="\${physical_interface}"
else
unset_physical_interfaces="\${unset_physical_interfaces} \${physical_interface}"
fi
done
echo "unset phsycial interfaces \${unset_physiccal_interfaces}" >> /tmp/network_log
unset_logical_interfaces=""
for logical_interface in \${logical_interfaces}; do
eval "physical_interface=\\${logical_interface_mapping_\${logical_interface}}"
if [ ! -z \${physical_interface} ]; then
continue
fi
if [ -z \${unset_logical_interfaces} ]; then
unset_logical_interfaces="\${logical_interface}"
else
unset_logical_interfaces="\${unset_logical_interfaces} \${logical_interface}"
fi
done
echo "unset logical interfaces \${unset_logical_interfaces}" >> /tmp/network_log
sorted_physical_interfaces=\$(printf '%s\n' \${unset_physical_interfaces} | sort)
echo "sorted unset physical interfaces \${sorted_physical_interfaces}" >> /tmp/network_log
sorted_logical_interfaces=\$(printf '%s\n' \${unset_logical_interfaces} | sort)
echo "sorted unset logical interfaces \${sorted_logical_interfaces}" >> /tmp/network_log
for logical_interface in \${sorted_logical_interfaces}; do
set \${sorted_physical_interfaces}
physical_interface_num=\$#;
if [ \${phsycial_interface_num} -gt 0 ]; then
physical_interface=\$1
shift 1
sorted_physical_interfaces="\$@"
else
physical_interface=\${logical_interface}
fi
eval "physical_interface_mapping_\${physical_interface}=\${logical_interface}"
eval "logical_interface_mapping_\${logical_interface}=\${physical_interface}"
done
for physical_interface in \${physical_interfaces}; do
eval "logical_interface=\\${physical_interface_mapping_\${physical_interface}}"
echo "physical interface \${physical_interface} map to logical interface \${logical_interface}" >> /tmp/network_log
done
for logical_interface in \${logical_interfaces}; do
eval "physical_interface=\\${logical_interface_mapping_\${logical_interface}}"
echo "logical interface \${logical_interface} map to physical interface \${physical_interface}" >> /tmp/network_log
done
#if $numbondingdevs > 0
# we have bonded interfaces, so set max_bonds
if [ -f "/etc/modprobe.conf" ]; then
echo "options bonding max_bonds=$numbondingdevs" >> /etc/modprobe.conf
fi
#end if
## =============================================================================
## Rewrite the interfaces file and make sure we preserve the loopback device
echo "auto lo" > /etc/network/interfaces
echo " iface lo inet loopback" >> /etc/network/interfaces
echo "" >> /etc/network/interfaces
#set $nameserver_set = 0
#for $iname in $ikeys
#set $idata = $interfaces[$iname]
#set $mac = $idata.get("mac_address", "").upper()
#set $iface_type = $idata.get("interface_type", "").lower()
#set $mtu = $idata.get("mtu", "")
#set $static = $idata.get("static", "")
#set $management = $idata.get("management", "")
#set $ip = $idata.get("ip_address", "")
#set $netmask = $idata.get("netmask", "")
#set $if_gateway = $idata.get("if_gateway", "")
#set $static_routes = $idata.get("static_routes", "")
#set $iface_master = $idata.get("interface_master", "")
#set $bonding_opts = $idata.get("bonding_opts", "")
#set $bridge_opts = $idata.get("bridge_opts", "")
#if $iface_type in ("slave","bond_slave","bridge_slave","bonded_bridge_slave")
#set $static = 1
#end if
## ===================================================================
## Things every interface get, no matter what
## ===================================================================
echo "auto $iname" >> /etc/network/interfaces
#if $static
#if $iface_type not in ("slave","bond_slave","bridge_slave","bonded_bridge_slave")
echo "iface $iname inet static" >> /etc/network/interfaces
#if $iname in $promisc_interfaces
echo " address 0.0.0.0" >> /etc/network/interfaces
echo " up ip link set $iname up" >> /etc/network/interfaces
echo " up ip link set $iname promisc on" >> /etc/network/interfaces
echo " down ip link set $iname promisc off" >> /etc/network/interfaces
echo " down ip link set $iname down" >> /etc/network/interfaces
#else
#if $ip != ""
echo " address $ip" >> /etc/network/interfaces
#end if
#if $if_gateway != ""
echo " gateway $if_gateway" >> /etc/network/interfaces
#end if
#if $netmask == ""
## Default to 255.255.255.0?
#set $netmask = "255.255.255.0"
#end if
echo " netmask $netmask" >> /etc/network/interfaces
#if $gateway != "" and $if_gateway == "" and $ip != ""
#import netaddr
#set interface_network = $netaddr.IPNetwork('%s/%s' % ($ip, $netmask))
#set gateway_address = $netaddr.IPAddress($gateway)
#if $gateway_address in $interface_network
echo " gateway $gateway" >> /etc/network/interfaces
#end if
#end if
#if $mtu != ""
echo " mtu $mtu" >> /etc/network/interfaces
#end if
#end if
#else
echo "iface $iname inet manual" >> /etc/network/interfaces
#end if
#else
echo "iface $iname inet dhcp" >> /etc/network/interfaces
#end if
#if $iface_type not in ("master","bond","bridge","bonded_bridge_slave")
#if $vlanpattern.match($iname)
#set $is_vlan = "true"
#pass
#else
#set $is_vlan = "false"
#end if
## slave interfaces are assumed to be static
#if $iface_type in ("slave","bond_slave","bridge_slave","bonded_bridge_slave")
#set $static = 1
#end if
## ===================================================================
## Things every interface get, no matter what
## ===================================================================
echo "auto $iname" >> /target/etc/network/interfaces; \
## ===================================================================
## Actions based on static configuration
## ===================================================================
#if $static
#if $iface_type not in ("slave","bond_slave","bridge_slave","bonded_bridge_slave")
echo "iface $iname inet static" >> /target/etc/network/interfaces; \
#if $mac != ""
echo " hwaddress $mac" >> /target/etc/network/interfaces; \
#end if
#if $iname in $promisc_interfaces
echo " address 0.0.0.0" >> /target/etc/network/interfaces; \
echo " up ifconfig $iname promisc up" >> /target/etc/network/interfaces; \
echo " down ifconfig $iname promisc down" >> /target/etc/network/interfaces; \
#else
#if $ip != ""
echo " address $ip" >> /target/etc/network/interfaces; \
#end if
#if $if_gateway != ""
echo " gateway $if_gateway" >> /target/etc/network/interfaces; \
#end if
#if $netmask == ""
## Default to 255.255.255.0?
#set $netmask = "255.255.255.0"
#end if
echo " netmask $netmask" >> /target/etc/network/interfaces; \
#end if
#if $iface_type in ("master","bond")
#set $bondslaves = ""
#for $bondiname in $ikeys
#set $bondidata = $interfaces[$bondiname]
#set $bondiface_type = $bondidata.get("interface_type", "").lower()
#set $bondiface_master = $bondidata.get("interface_master", "")
#if $bondiface_master == $iname
#set $bondslaves += $bondiname + " "
#end if
#end for
echo " bond-slaves $bondslaves" >> /target/etc/network/interfaces; \
#for $bondopts in $bonding_opts.split(" ")
#set [$bondkey, $bondvalue] = $bondopts.split("=")
echo " bond-$bondkey $bondvalue" >> /target/etc/network/interfaces; \
#end for
#end if
#if $subinterfacepattern.match($iname)
#pass
#else
echo "iface $iname inet manual" >> /target/etc/network/interfaces; \
#end if
#if $iface_type in ("slave","bond_slave") and $iface_master != ""
echo "bond-master $iface_master" >> /target/etc/network/interfaces; \
physical_interface=\${logical_interface_mapping_$iname}
if [ ! -z \${physical_interface} ]; then
eval "physical_mac=\\${physical_interface_mac_\${physical_interface}}"
fi
if [ ! -z \$physical_mac ]; then
physical_mac=\$(echo \${physical_mac} | tr '_' ':')
echo " hwaddress ether \${physical_mac}" >> /etc/network/interfaces
fi
if [ -f "/etc/modprobe.conf" ] && [ ! -z \$physical_interface ]; then
grep \${physical_interface} /etc/modprobe.conf | sed "s/\$physical_interface/$iname/" >> /etc/modprobe.conf.cobbler
grep -v \${physical_interface} /etc/modprobe.conf >> /etc/modprobe.conf.new
rm -f /etc/modprobe.conf
mv /etc/modprobe.conf.new /etc/modprobe.conf
fi
#end if
#end if
#end if
#if $iface_type in ("master","bond","bonded_bridge_slave")
## if this is a bonded interface, configure it in modprobe.conf
if [ -f "/etc/modprobe.conf" ]; then
#if $osversion == "rhel4"
echo "install $iname /sbin/modprobe bonding -o $iname $bonding_opts" >> /etc/modprobe.conf.cobbler
#else
echo "iface $iname inet dhcp" >> /target/etc/network/interfaces; \
echo "alias $iname bonding" >> /etc/modprobe.conf.cobbler
#end if
## ===================================================================
## VLAN configuration
## ===================================================================
#if $is_vlan == "true"
#pass
#end if
## ===================================================================
## Optional configuration stuff
## ===================================================================
#if $mtu != ""
echo " mtu $mtu" >> /target/etc/network/interfaces; \
#end if
## ===================================================================
## Interface route configuration
## ===================================================================
#for $route in $static_routes
#set routepattern = $re.compile("[0-9/.]+:[0-9.]+")
#if $routepattern.match($route)
#set [$network, $router] = $route.split(":")
echo " up ip route add $network via $router dev $iname || true" >> /target/etc/network/interfaces; \
#else
echo " # Warning: invalid route: $route" >> /target/etc/network/interfaces; \
fi
#set $bondslaves = ""
#for $bondiname in $ikeys
#set $bondidata = $interfaces[$bondiname]
#set $bondiface_type = $bondidata.get("interface_type", "").lower()
#set $bondiface_master = $bondidata.get("interface_master", "")
#if $bondiface_master == $iname
#set $bondslaves += $bondiname + " "
#end if
#end for
#if $enableipv6 == True
#for $route in $ipv6_static_routes
#set routepattern = $re.compile("[0-9a-fA-F:/]+,[0-9a-fA-F:]+")
#if $routepattern.match($route)
#set [$network, $router] = $route.split(",")
echo " up ip -6 route add $network via $router dev $iname || true" >> /target/etc/network/interfaces; \
#else
echo " # Warning: invalid route: $route" >> /target/etc/network/interfaces; \
#end if
echo " bond-slaves $bondslaves" >> /etc/network/interfaces
#if $bonding_opts != ""
#for $bondopts in $bonding_opts.split(" ")
#set [$bondkey, $bondvalue] = $bondopts.split("=")
echo " bond-$bondkey $bondvalue" >> /etc/network/interfaces
#end for
#end if
#if $management
#if $gateway != "" and $if_gateway == ""
echo " gateway $gateway" >> /target/etc/network/interfaces; \
#elif $iface_type in ("slave","bond_slave") and $iface_master != ""
echo " bond-master $iface_master" >> /etc/network/interfaces
#end if
#if $iface_type == "bridge"
#set $bridgeslaves = ""
#for $bridgeiname in $ikeys
#set $bridgeidata = $interfaces[$bridgeiname]
#set $bridgeiface_type = $bridgeidata.get("interface_type", "").lower()
#set $bridgeiface_master = $bridgeidata.get("interface_master", "")
#if $bridgeiface_master == $iname
#set $bridgeslaves += $bridgeiname + " "
#end if
## =============================================================================
## Configure name server search path in /target/etc/resolv.conf
#end for
echo " bridge_ports $bridgeslaves" >> /etc/network/interfaces
#if $bridge_opts != ""
#for $bridgeopts in $bridge_opts.split(" ")
#set [$bridgekey, $bridgevalue] = $bridgeopts.split("=")
echo " bridge_$bridgekey $bridgevalue" >> /etc/network/interfaces
#end for
#end if
#end if
#if not $nameserver_set
#if $iface_type not in ("slave","bond_slave","bridge_slave","bonded_bridge_slave")
#set $nameservers = ' '.join($name_servers)
#if '8.8.8.8' not in $name_servers
#set $nameservers = ' '.join(($nameservers, '8.8.8.8'))
#end if
#set $nameserver_search = ' '.join($name_servers_search)
#if $nameservers != ""
echo " dns-nameservers $nameservers" >> /target/etc/network/interfaces; \
echo " dns-nameservers $nameservers" >> /etc/network/interfaces
#end if
#if $nameserver_search != ""
echo " dns-search $nameserver_search" >> /target/etc/network/interfaces; \
echo " dns-search $nameserver_search" >> /etc/network/interfaces
#end if
#set $nameserver_set = 1
#end if
echo "" >> /target/etc/network/interfaces; \
## ===================================================================
## Done with this interface
## ===================================================================
#end for
cp /target/etc/network/interfaces /etc/network/interfaces; \
## =============================================================================
## Configure the system's primary hostname. This is also passed to anaconda, but
## anaconda doesn't seem to honour it in DHCP-setups.
#if $hostname != ""
echo "$hostname" > /target/etc/hostname; \
#end if
$SNIPPET('preseed_hosts') echo "processed preseed_hosts" >> /tmp/preseed.log; \
#end if
#for $route in $static_routes
#set routepattern = $re.compile("[0-9/.]+:[0-9.]+")
#if $routepattern.match($route)
#set [$network, $router] = $route.split(":")
echo " up ip route add $network via $router dev $iname" >> /etc/network/interfaces
#else
echo " # Warning: invalid route: $route" >> /etc/network/interfaces
#end if
#end for
echo "" >> /etc/network/interfaces
## ===================================================================
## Done with this interface
## ===================================================================
#end for
for physical_interface in \${sorted_physical_interfaces}; do
echo "auto \${physical_interface}" >> /etc/network/interfaces
echo "iface \${physical_interface} inet static" >> /etc/network/interfaces
eval "physical_mac=\\${physical_interface_mac_\${physical_interface}}"
if [ ! -z \${physical_mac} ]; then
physical_mac=\$(echo \${physical_mac} | tr '_' ':')
echo " hwaddress ether \${physical_mac}" >> /etc/network/interfaces
fi
echo "" >> /etc/network/interfaces
done
if [ -f "/etc/modprobe.conf" ]; then
cat /etc/modprobe.conf.cobbler >> /etc/modprobe.conf
rm -f /etc/modprobe.conf.cobbler
fi
if [ -f "/etc/udev/rules.d/70-persistent-net.rules" ]; then
rm -f /etc/udev/rules.d/70-persistent-net.rules
fi
## End post_install_network_config generated code

View File

@ -1,4 +1,4 @@
#if $str($getVar('anamon_enabled','')) == "1"
wget -O /tmp/anamon "http://$server:$http_port/cobbler/aux/anamon" ; \
python /tmp/anamon --name "$name" --watchfiles "/var/log/syslog /var/log/partman /var/log/hareware_summary /var/log/status /tmp/preseed.log" --server "$server" --port "$http_port"; \
wget -O /tmp/anamon "http://$server:$http_port/cobbler/aux/anamon"
## python /tmp/anamon --name "$name" --watchfiles "/var/log/syslog /var/log/partman /var/log/hareware_summary /var/log/status /tmp/preseed.log" --server "$server" --port "$http_port"
#end if

View File

@ -1,15 +1,37 @@
#if $getVar("system_name","") != ""
mac_exists() { \
ip -o link | grep -i "$1" 2>/dev/null >/dev/null; \
return $?; \
}; \
get_ifname() { \
IFNAME=\$(ip -o link | grep -i "$1" | sed -e 's/^[0-9]*: //' -e 's/:.*//'); \
}; \
#if $getVar('management_nic', '') == ""
#set $management_nic=''
#end if
echo "generate pre network config" > /tmp/network_log
# Start pre_install_network_config generated code
#raw
# generic functions to be used later for discovering NICs
mac_exists() {
if [ -f /bin/ip ]; then
ip -o link | grep -i "$1" 2>/dev/null >/dev/null
return $?
elif [ -f /bin/esxcfg-nics ]; then
esxcfg-nics -l | grep -i "$1" 2>/dev/null >/dev/null
return $?
else
ifconfig -a | grep -i "$1" 2>/dev/null >/dev/null
return $?
fi
}
get_ifname() {
if [ -f /bin/ip ]; then
IFNAME=$(ip -o link | grep -i "$1" | sed -e 's/^[0-9]*: //' -e 's/:.*//')
elif [ -f /bin/esxcfg-nics ]; then
IFNAME=$(esxcfg-nics -l | grep -i "$1" | cut -d " " -f 1)
else
IFNAME=$(ifconfig -a | grep -i "$1" | cut -d " " -f 1)
if [ -z $IFNAME ]; then
IFNAME=$(ifconfig -a | grep -i -B 2 "$1" | sed -n '/flags/s/:.*$//p')
fi
fi
}
#end raw
#set ikeys = $interfaces.keys()
#import re
#set $vlanpattern = $re.compile("[a-zA-Z0-9]+[\.:][0-9]+")
#set $routepattern = $re.compile("[0-9/.]+:[0-9.]+")
#for $iname in $ikeys
#set $idata = $interfaces[$iname]
#set $mac = $idata["mac_address"]
@ -20,22 +42,30 @@ get_ifname() { \
#set $iface_type = $idata["interface_type"]
#set $iface_master = $idata["interface_master"]
#set $static_routes = $idata["static_routes"]
#if not $management or $mac == ""
#if $management
#set $management_nic = $iname
#end if
#if $management_nic != ''
#if $iname != $management_nic
#continue
#end if
#end if
#if $mac == ""
#continue
#end if
if mac_exists $mac; then \
get_ifname $mac; \
echo "d-i netcfg/choose_interface string \$IFNAME" >> /tmp/pre_install_network_config; \
# Configuring $iname ($mac)
if mac_exists $mac; then
get_ifname $mac
echo "d-i netcfg/choose_interface string \$IFNAME" >> /tmp/pre_install_network_config
#if $static and $ip != ""
echo "d-i netcfg/get_ipaddress string $ip" >> /tmp/pre_install_network_config; \
echo "d-i netcfg/get_ipaddress string $ip" >> /tmp/pre_install_network_config
#if $netmask == ""
#set $netmask = "255.255.255.0"
#end if
echo "d-i netcfg/get_netmask string $netmask" >> /tmp/pre_install_network_config; \
echo "d-i netcfg/get_netmask string $netmask" >> /tmp/pre_install_network_config
#else
#continue
#end if
fi; \
fi
#end for
#end if
debconf-set-selections /tmp/pre_install_network_config; \

View File

@ -1,165 +1,482 @@
#set hostname=$getVar('hostname',None)
#set partition = $getVar('partition', None)
#set partition_size = $getVar('partition_size', None)
#set partition_maxsize = $getVar('partition_maxsize', None)
#if $hostname == None
#set $vgname = "VolGroup00"
#else
#set $vgname = $hostname.split('.')[0]
#end if
#if $getVar("system_name","") != ""
first_found_disk=""; \
disks_str=""; \
found_disks_str=""; \
for disk in \$(list-devices disk); do \
if [[ x"\$disk" == x"" ]]; then \
continue; \
fi; \
set \$(ls -s -l /dev/disk/by-path | tr -s '\t' ' ' | cut -d' ' -f11,13)
disk_mapping_nums=\$((\$#/2))
disk_mapping_offset=0
echo "disk_mapping_nums: \$disk_mapping_nums" >> /tmp/preseed.log
disk_mapping=""
while [ \$disk_mapping_offset -lt \$disk_mapping_nums ]; do
found_disk_type=0
#if $getVar('disk_type_only','') != ""
if expr match "\$1" ".*-${disk_type_only}-.*"; then
found_disk_type=1
fi
#else
found_disk_type=1
#end if
if [ \$found_disk_type -gt 0 ]; then
disk_name=\$(basename \$2)
if [ -z "\${disk_mapping}" ]; then
disk_mapping="\${disk_name}"
else
disk_mapping="\${disk_mapping} \${disk_name}"
fi
disk_path=\$(echo \$1 | tr '-' '_' | tr ':' '_' | tr '.' '_')
eval "disk_\${disk_name}=\${disk_path}"
eval "disk_path_\${disk_path}=/dev/\${disk_name}"
eval "disk_path_\${disk_name}=/dev/\${disk_name}"
fi
disk_mapping_offset=\$((\${disk_mapping_offset}+1))
shift 2
done
for key in \${disk_mapping}; do
eval "disk_path=\\${disk_\$key}"
echo "disk_mapping \$key => \${disk_path}" >> /tmp/preseed.log
done
partition_disks=""
disks=""
for disk in \$(list-devices disk); do
if [ -z \$disk ]; then
continue
fi
disk_name=\$(basename \$disk)
eval "disk_path=\\${disk_\${disk_name}}"
if [ -z \${disk_path} ]; then
echo "ignore disk \${disk_name} since it is not in disk_mapping" >> /tmp/preseed.log
continue
fi
found_disk=0
#if $getVar('partitions_only','') != ""
let found_disk=0; \
#for $partition_only in $partitions_only.split(',')
#if not $partition_only
#continue
#end if
if expr match "\$disk" "$partition_only"; then \
let found_disk=1; \
fi; \
if expr match "\${disk_name}" "$partition_only"; then
found_disk=1
else
echo "disk \${disk_name} does not match $partition_only" >> /tmp/preseed.log
fi
#end for
#else
let found_disk=1; \
found_disk=1
#end if
if [ \$found_disk -gt 0 ]; then \
if [ -z \$found_disks_str ]; then \
found_disks_str="\$disk"; \
first_found_disk="\$disk"; \
else \
found_disks_str="\${found_disks_str} \$disk"; \
fi; \
fi; \
if [ -z \$disks_str ]; then \
disks_str="\$disk"; \
else \
disks_str="\${disks_str} \$disk"; \
fi; \
done; \
logger "partition disks: \${found_disks_str}"; \
#if $getVar('keep_old_partitions', '0') != "0"
remove_disks_str=\${found_disks_str}; \
#if $getVar('partition_by_path', '0') != "0"
eval "disk_name=\\${disk_\${disk_name}}"
#end if
if [ \$found_disk -gt 0 ]; then
echo "add disk \${disk_name} in partitioning list" >> /tmp/preseed.log
if [ -z \$partition_disks ]; then
partition_disks="\${disk_name}"
else
partition_disks="\${partition_disks} \${disk_name}"
fi
fi
if [ -z \$disks ]; then
disks="\${disk_name}"
else
disks="\${disks} \${disk_name}"
fi
done
echo "partition disks: \${partition_disks}" >> /tmp/preseed.log
#if $getVar('sort_disks', '0') != "0"
sorted_disks=\$(printf '%s\n' \${partition_disks} | sort)
#else
remove_disks_str=\${disks_str}; \
sorted_disks=\${partition_disks}
#end if
logger "remove disks \${remove_disks_str}"; \
## vgremove -f $vgname; \
## logger "vgremove $vgname"; \
disk_partitions=\$(pvs --noheadings --rows | head -n1); \
for disk_partition in \${disk_partitions}; do \
if [[ x"\$disk_partition" == x"" ]]; then \
continue; \
fi; \
vg=\$(pvs --noheadings --separator : \${disk_partition} | cut -d: -f2); \
remove_vg=""; \
for remove_disk in \${remove_disks_str}; do \
if [[ x"\$remove_disk" == x"" ]]; then \
continue; \
fi; \
if expr match "\${disk_partition}" "\${remove_disk}.*"; then \
remove_vg="\$vg"; \
logger "partition \${disk_partition} matches \${remove_disk}.*"; \
logger "set remove_vg to \$vg"; \
else \
logger "partition \${disk_partition} does not match \${remove_disk}.*"; \
fi; \
done; \
if [[ x"\$remove_vg" != x"" ]]; then \
vgremove -f \$remove_vg; \
logger "vgremove \${remove_vg} for \${disk_partition}"; \
else \
logger "\${disk_partition} is not in vgremove list"; \
fi; \
done; \
for remove_disk in \${remove_disks_str}; do \
if [[ x"\$remove_disk" == x"" ]]; then \
continue; \
fi; \
pvremove -ff -y \${remove_disk}*; \
logger "pvremove \${remove_disk}*"; \
done; \
remove_disks=\$(echo \${remove_disks_str} | sed -e 's/ /,/g'); \
echo "d-i partman-auto/select_disks multiselect \${remove_disks}" >> /tmp/part-include; \
echo "d-i partman-auto/disk string \${found_disks_str}" >> /tmp/part-include; \
recipe="boot-root :: \
100 100 100 ext3 \
\\$primary{ } \\$bootable{ } method{ format } \
format{ } use_filesystem{ } filesystem{ ext3 } \
mountpoint{ /boot } device{ \$first_found_disk } \
. \
256 256+10% 200% linux-swap \
\\$primary{ } method{ swap } format{ } \
device{ \$first_found_disk } \
. \
#set default_percentage = 100
echo "sorted disks \${sorted_disks}" >> /tmp/preseed.log
#if $getVar('start_from_disk', '') != ""
#set $start_from_disk = $int($start_from_disk)
#if $start_from_disk > 0
#set $disk_start_offset = $start_from_disk - 1
#else
#set $disk_start_offset = 0
#end if
set \${sorted_disks}
shift $disk_start_offset
sorted_disks=\$@
echo "sorted disks begin from the $start_from_disk: \${sorted_disks}" >> /tmp/preseed.log
#end if
#if $getVar('disk_num', '') != ""
set \${sorted_disks}
sorted_disks=\$(printf '%s\n' \$@ | head -n${disk_num})
echo "sorted disks for $disk_num disks: \${sorted_disks}" >> /tmp/preseed.log
#end if
first_disk_name=""
for disk_name in \${sorted_disks}; do
if [ -z \${disk_name} ]; then
continue
fi
if [ -z \${first_disk_name} ]; then
first_disk_name=\${disk_name}
break
fi
done
echo "first disk \${first_disk_name}" >> /tmp/preseed.log
#if $getVar('keep_old_partitions', '0') != "0"
remove_disks=\${sorted_disks}
#else
remove_disks=\${disks}
#end if
echo "remove disks \${remove_disks}" >> /tmp/preseed.log
disk_partitions=\$(pvs --noheadings --separator :| cut -d: -f1)
remove_partitions=""
remove_vgs=""
for disk_partition in \${disk_partitions}; do
if [ -z \$disk_partition ]; then
continue
fi
disk_partition_name=\$(basename \${disk_partition})
vg=\$(pvs --noheadings --separator : \${disk_partition} | cut -d: -f2)
remove_vg=""
remove_partition=""
for remove_disk_name in \${remove_disks}; do
eval "remove_disk=\\${disk_path_\${remove_disk_name}}"
if [ -z \${remove_disk_name} ]; then
continue
fi
if expr match "\${disk_partition}" "\${remove_disk}.*"; then
remove_vg="\$vg"
remove_partition="\${disk_partition}"
else
echo "partition \${disk_partition} does not match \${remove_disk}.*" >> /tmp/preseed.log
fi
done
if [ ! -z \$remove_vg ]; then
if [ -z \$remove_vgs ]; then
remove_vgs="\${remove_vg}"
else
vg_removed=0
for vg in \${remove_vgs}; do
if [[ "\$vg" == "\${remove_vg}" ]]; then
vg_removed=1
fi
done
if [ \$vg_remove -eq 0 ]; then
remove_vgs="\${remove_vgs} \${remove_vg}"
fi
fi
fi
if [ ! -z \$remove_partition ]; then
if [ -z \$remove_partitions ]; then
remove_partitions="\${remove_partition}"
else
remove_partitions="\${remove_partitions} \${remove_partition}"
fi
fi
done
echo "remove partitions \${remove_partitions} from lvm" >> /tmp/preseed.log
echo "remove vgs \${remove_vgs} from lvm" >> /tmp/preseed.log
for remove_vg in \${remove_vgs}; do
vgremove -f \${remove_vg}
done
for remove_partition in \${remove_partitions}; do
pvremove -ff -y \${remove_partition}
done
select_disks=""
echo "remove disks \${remove_disks}" >> /tmp/preseed.log
for remove_disk_name in \${remove_disks}; do
eval "remove_disk=\\${disk_path_\${remove_disk_name}}"
if [ -z \$remove_disk ]; then
continue
fi
if [ -z \${select_disks} ]; then
select_disks="\${remove_disk}"
else
select_disks="\${select_disks},\${remove_disk}"
fi
done
echo "d-i partman-auto/select_disks multiselect \${select_disks}" >> /tmp/part-include
echo "select disks \${select_disks}" >> /tmp/preseed.log
partition_disks=""
for disk_name in \${sorted_disks}; do
eval "disk=\\${disk_path_\${disk_name}}"
if [ -z \$disk ]; then
continue
fi
if [ -z \${partition_disks} ]; then
partition_disks="\${disk}"
else
partition_disks="\${partition_disks} \${disk}"
fi
done
echo "d-i partman-auto/disk string \${partition_disks}" >> /tmp/part-include
echo "disks \${partition_disks}" >> /tmp/preseed.log
default_partition=$getVar('default_partition', '/')
partition_fstype=$getVar('partition_fstype', 'ext3')
echo "default partition \${default_partition}" >> /tmp/preseed.log
echo "partition fstype \${partition_fstype}" >> /tmp/preseed.log
partition_names=""
default_partition_name=""
#if $partition != None
#set vol_sizes = [part.strip() for part in $partition.split(';') if part.strip()]
#for vol_and_size in vol_sizes
#set vol, vol_size = $vol_and_size.split(' ', 1)
#set vol = $vol.strip()
#set vol_size = $vol_size.strip()
#if $vol.startswith('/')
#set volname = $vol[1:]
#else
#continue
#if $vol == '/'
#set volname = 'root'
#elif $vol == 'swap'
#set volname = 'swap'
#elif $vol.startswith('/')
#set volname = $vol[1:].replace('/', '_')
#else
#set volname = ''
# $vol is not starts with /
#end if
#set vol_min_size = 1
#set vol_percent = 0
if [ -z \$partition_names ]; then
partition_names="$volname"
else
partition_names="\$partition_names $volname"
fi
if [[ "$vol" == "\$default_partition" ]]; then
default_partition_name=$volname
fi
partition_point_$volname=$vol
#set vol_size = $vol_size.strip()
#if $vol_size.endswith('%')
#set vol_percent = $int($vol_size[:-1])
#elif $vol_size.endswith('K')
#set vol_min_size = $int($vol_size[:-1]) / 1000
#elif $vol_size.endswith('M')
#set vol_percent = $vol_size[:-1]
partition_percentage_$volname=$vol_percent
#else
#if $vol_size.endswith('K')
#set vol_min_size = $int($vol_size[:-1]) / 1000
#elif $vol_size.endswith('M')
#set vol_min_size = $int($vol_size[:-1])
#elif $vol_size.endswith('G')
#set vol_min_size = $int($vol_size[:-1]) * 1000
#elif $vol_size.endswith('T')
#set vol_min_size = $int($vol_size[:-1]) * 1000000
#else
#set vol_min_size = $int($vol_size)
#end if
partition_size_$volname=$vol_min_size
#end if
#end for
#end if
#if $partition_size != None
#set vol_sizes = [part.strip() for part in $partition_size.split(';') if part.strip()]
#for vol_and_size in $vol_sizes
#set vol, vol_size = $vol_and_size.split(' ', 1)
#set vol = $vol.strip()
#if $vol == '/'
#set volname = 'root'
#elif $vol == 'swap'
#set volname = 'swap'
#elif $vol.startswith('/')
#set volname = $vol[1:].replace('/', '_')
#else
#set volname = ''
# $vol is not starts with /
#end if
#if $vol_size.endswith('K')
#set vol_min_size = $int($vol_size[:-1]) / 1000
#elif $vol_size.endswith('M')
#set vol_min_size = $int($vol_size[:-1])
#elif $vol_size.endswith('G')
#elif $vol_size.endswith('G')
#set vol_min_size = $int($vol_size[:-1]) * 1000
#elif $vol_size.endswith('T')
#set vol_min_size = $int($vol_size[:-1]) * 1000000
#else
#set vol_min_size = $int($vol_size)
#end if
#if $vol_percent
#set factor = '%s+%s%%' % ($vol_min_size, $vol_percent)
#set default_percentage = $default_percentage - $vol_percent
#else
#set factor = $vol_min_size
#end if
${vol_min_size} ${factor} -1 ext3 \
\\$lvmok{ } method{ format } format{ } \
use_filesystem{ } filesystem{ ext3 } \
in_vg{ $vgname } lv_name{ ${volname}vol } \
mountpoint{ $vol } \
. \
partitions_size_$volname=${vol_min_size}
#end for
#end if
#set vol_min_size = 1
#if $default_percentage <= 0
#set default_percentage = 0
#end if
#if $default_percentage
#set factor = '%s+%s%%' % ($vol_min_size, $default_percentage)
#else
#set factor = $vol_min_size
#end if
${vol_min_size} ${factor} -1 ext3 \
\\$lvmok{ } method{ format } \
format{ } use_filesystem{ } filesystem{ ext3 } \
in_vg{ $vgname } lv_name{ rootvol } \
mountpoint{ / } \
. \
"; \
pv_offset=1; \
for found_disk in \${found_disks_str}; do \
recipe="\$recipe \
512 512+100% -1 ext3 \
\\$defaultignore{ } \\$primary{ } device{ \${found_disk} } \
method{ lvm } vg_name{ $vgname } \
. \
"; \
let pv_offset=\${pv_offset}+1; \
done; \
echo "d-i partman-auto/expert_recipe string \$recipe" >> /tmp/part-include; \
debconf-set-selections /tmp/part-include; \
#if $partition_maxsize != None
#set vol_sizes = [part.strip() for part in $partition_maxsize.split(';') if part.strip()]
#for vol_and_size in $vol_sizes
#set vol, vol_size = $vol_and_size.split(' ', 1)
#set vol = $vol.strip()
#if $vol == '/'
#set volname = 'root'
#elif $vol == 'swap'
#set volname = 'swap'
#elif $vol.startswith('/')
#set volname = $vol[1:].replace('/', '_')
#else
#set volname = ''
# $vol is not starts with /
#end if
#if $vol_size.endswith('K')
#set vol_max_size = $int($vol_size[:-1]) / 1000
#elif $vol_size.endswith('M')
#set vol_max_size = $int($vol_size[:-1])
#elif $vol_size.endswith('G')
#set vol_max_size = $int($vol_size[:-1]) * 1000
#elif $vol_size.endswith('T')
#set vol_max_size = $int($vol_size[:-1]) * 1000000
#else
#set vol_max_size = $int($vol_size)
#end if
partition_maxsize_$volname=${vol_max_size}
#end for
#end if
if [ -z \${default_partition_name} ]; then
default_partition_name=root
fi
default_partition_percentage=100
for key in \${partition_names}; do
if [ -z \$key ]; then
continue
fi
if [[ "\$key" == "\${default_partition_name}" ]]; then
continue
fi
if [[ "\$key" == "swap" ]]; then
continue
fi
eval "partition_percentage=\\${partition_percentage_\$key}"
if [ ! -z \${partition_percentage} ]; then
if [ \${default_partition_percentage} -gt \${partition_percentage} ]; then
default_partition_percentage=\$((\${default_partition_percentage}-\${partition_percentage}))
else
default_partition_percentage=0
fi
fi
done
eval "partition_percentage_\${default_partition_name}=\${default_partition_percentage}"
if [ -z \$partition_point_boot ]; then
partition_point_boot="/boot"
if [ -z \$partition_names ]; then
partition_names="boot"
else
partition_names="\${partition_names} boot"
fi
fi
if [ -z \$partition_size_boot ]; then
partition_size_boot=500
fi
if [ -z \$partition_maxsize_boot ]; then
partition_maxsize_boot=\$partition_size_boot
fi
eval "first_disk=\\${disk_path_\${first_disk_name}}"
if [ -z \${first_disk} ]; then
first_disk=/dev/sda
fi
partition_param_boot="\${partition_fstype} \
\\$primary{ } \\$bootable{ } method{ format } \
format{ } use_filesystem{ } filesystem{ \${partition_fstype} } \
mountpoint{ /boot } device{ \$first_disk } \
"
if [ -z \$partition_point_swap ]; then
partition_point_swap="swap"
if [ -z \$partition_names ]; then
partition_names="swap"
else
partition_names="\${partition_names} swap"
fi
fi
if [ -z \$partition_size_swap ]; then
partition_size_swap=256
fi
if [ -z \$partition_percentage_swap ]; then
partition_percentage_swap=200
fi
if [ -z \$partition_maxsize_swap ]; then
partition_maxsize_swap=10%
fi
partition_param_swap="linux-swap \
\\$primary{ } method{ swap } format{ } \
device{ \$first_disk } \
"
if [ -z \$partition_point_root ]; then
partition_point_root="/"
if [ -z \$partition_names ]; then
partition_names="root"
else
partition_names="\$partition_names root"
fi
fi
recipe="boot-root ::"
for key in \${partition_names}; do
if [ -z \$key ]; then
continue
fi
eval "partition=\\${partition_point_\$key}"
echo "partition \$partition => \$key" >> /tmp/preseed.log
eval "partition_percentage=\\${partition_percentage_\$key}"
if [ -z \$partition_percentage ]; then
partition_percentage=0
fi
echo "partition percentage \$partition => \${partition_percentage}" >> /tmp/preseed.log
eval "partition_size=\\${partition_size_\$key}"
if [ -z \$partition_size ]; then
partition_size=1
fi
echo "partition size \$partition => \${partition_size}" >> /tmp/preseed.log
if [ \${partition_percentage} -ne 0 ]; then
partition_factor="\${partition_size}+\${partition_percentage}%"
else
partition_factor="\${partition_size}"
fi
echo "partition factor \$partition => \${partition_factor}" >> /tmp/preseed.log
eval "partition_maxsize=\\${partition_maxsize_\$key}"
if [ -z \${partition_maxsize} ]; then
partition_maxsize=-1
fi
echo "partition maxsize \$partition => \${partition_maxsize}" >> /tmp/preseed.log
eval "partition_param=\\${partition_param_\$key}"
if [ -z \${partition_param} ]; then
partition_param="\${partition_fstype} \
\\$lvmok{ } method{ format } format{ } \
use_filesystem{ } filesystem{ \${partition_fstype} } \
in_vg{ $vgname } lv_name{ \${key}vol } \
mountpoint{ \$partition }"
fi
echo "partition param \$partition => \${partition_param}" >> /tmp/preseed.log
recipe="\$recipe \${partition_size} \${partition_factor} \${partition_maxsize} \${partition_param} ."
done
for disk_name in \${sorted_disks}; do
eval "disk=\\${disk_path_\${disk_name}}"
if [ -z \$disk ]; then
continue
fi
disk_param="\${partition_fstype} \
\\$defaultignore{ } \\$primary{ } device{ \${disk} } \
method{ lvm } vg_name{ $vgname }"
recipe="\$recipe 512 512+100% -1 \${disk_param} ."
echo "partition param \${disk_name} => \${disk_param}" >> /tmp/preseed.log
done
echo "d-i partman-auto/expert_recipe string \$recipe" >> /tmp/part-include
echo "d-i partman-auto/choose_recipe select boot-root" >> /tmp/part-include
echo "d-i partman-lvm/vgcreate string $vgname" >> /tmp/part-include
echo "d-i partman-auto-lvm/new_vg_name string $vgname" >> /tmp/part-include

View File

@ -1,24 +1,63 @@
echo "\\$ModLoad imuxsock # provides support for local system logging (e.g. via logger command)" > /target/etc/rsyslog.conf; \
echo "\\$ModLoad imklog # provides kernel logging support (previously done by rklogd)" >> /target/etc/rsyslog.conf; \
echo "\\$ModLoad immark # provides --MARK-- message capability" >> /target/etc/rsyslog.conf; \
echo "\\$WorkDirectory /var/spool/rsyslog" >> /target/etc/rsyslog.conf; \
echo "\\$ActionQueueType LinkedList" >> /target/etc/rsyslog.conf; \
echo "\\$ActionQueueFileName srvrfwd" >> /target/etc/rsyslog.conf; \
echo "\\$ActionResumeRetryCount -1" >> /target/etc/rsyslog.conf; \
echo "\\$ActionQueueSaveOnShutDown on" >> /target/etc/rsyslog.conf; \
echo "*.* @@$server:514" >> /target/etc/rsyslog.conf; \
echo "\\$ModLoad imudp" >> /target/etc/rsyslog.conf; \
echo "\\$UDPServerRun 514" >> /target/etc/rsyslog.conf; \
echo "\\$ModLoad imtcp" >> /target/etc/rsyslog.conf; \
echo "\\$InputTCPServerRun 514" >> /target/etc/rsyslog.conf; \
cat << EOL > /etc/rsyslog.conf
\#\#\#\# MODULES \#\#\#\##
\\$ModLoad imuxsock # provides support for local system logging (e.g. via logger command)
\\$ModLoad imfile
\\$WorkDirectory /var/lib/rsyslog
\\$ActionQueueType LinkedList
\\$ActionQueueFileName srvrfwd
\\$ActionResumeRetryCount -1
\\$ActionQueueSaveOnShutDown on
*.* @@$server:514
\# Provides UDP syslog reception
\#\\$ModLoad imudp
\#\\$UDPServerRun 514
\# Provides TCP syslog reception
\\$ModLoad imtcp
\\$InputTCPServerRun 514
#set system_name = $getVar('system_name','')
echo "\\$LocalHostName $system_name" >> /target/etc/rsyslog.conf; \
echo "\\$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat" >> /target/etc/rsyslog.conf; \
echo "\\$IncludeConfig /etc/rsyslog.d/*.conf" >> /target/etc/rsyslog.conf; \
echo "*.info;mail.none;authpriv.none;cron.none /var/log/messages" >> /target/etc/rsyslog.conf; \
echo "mail.* -/var/log/maillog" >> /target/etc/rsyslog.conf; \
echo "cron.* /var/log/cron" >> /target/etc/rsyslog.conf; \
echo "*.emerg *" >> /target/etc/rsyslog.conf; \
echo "uucp,news.crit /var/log/spooler" >> /target/etc/rsyslog.conf; \
echo "local7.* /var/log/boot.log" >> /target/etc/rsyslog.conf; \
chroot /target update-rc.d rsyslog defaults 12 88; \
\\$LocalHostName $system_name
\#\#\#\# GLOBAL DIRECTIVES \#\#\#\##
\# Use default timestamp format
\\$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
\# File syncing capability is disabled by default. This feature is usually not required,
\# not useful and an extreme performance hit
\#\\$ActionFileEnableSync on
\# Include all config files in /etc/rsyslog.d/
\\$IncludeConfig /etc/rsyslog.d/*.conf
\#\#\#\# RULES \#\#\#\##
\# Log anything (except mail) of level info or higher.
\# Don't log private authentication messages!
syslog.*,daemon.* /var/log/messages
\# The authpriv file has restricted access.
authpriv.* /var/log/secure
\# Log all the mail messages in one place.
mail.* -/var/log/maillog
\# Log cron stuff
cron.* /var/log/cron
\# Everybody gets emergency messages
*.emerg *
\# Save news errors of level crit and higher in a special file.
uucp,news.crit /var/log/spooler
\# Save boot messages also to boot.log
local7.* /var/log/boot.log
EOL
update-rc.d rsyslog defaults 12 88

View File

@ -1,6 +1,6 @@
sed -i 's/PermitRootLogin.*/PermitRootLogin yes/g' /target/etc/ssh/sshd_config; \
mkdir -p /target/root/.ssh; \
chmod 700 -R /target/root/.ssh; \
sed -i 's/PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config
mkdir -p /root/.ssh
chmod 700 -R /root/.ssh
#if $getVar("push_ssh_keys", "") != ""
#set $ssh_keys = $push_ssh_keys.split(',')
#set $firstline = True
@ -8,17 +8,18 @@ chmod 700 -R /target/root/.ssh; \
#if not $ssh_key
#continue
#end if
#set $f = open($ssh_keys)
#for $line in $f
#set $line = $line.rstrip('\n')
#if $firstline
echo "$line" > /target/root/.ssh/authorized_keys; \
#else
echo "$line" >> /target/root/.ssh/authorized_keys; \
#end if
#set $firstline = False
#end for
#set $f = open($ssh_key)
#if firstline
cat << EOF > /root/.ssh/authorized_keys
#echo $f.read()
EOF
#else
cat << EOF >> /root/.ssh/authorized_keys
#echo $f.read()
EOF
#end if
#set $firstline = False
#silent $f.close()
#end for
chmod 600 /target/root/.ssh/authorized_keys; \
chmod 600 /root/.ssh/authorized_keys
#end if

View File

@ -1,22 +1,72 @@
echo "net.ipv4.ip_forward = 0" > /target/etc/sysctl.conf; \
echo "net.ipv4.conf.default.rp_filter = 1" >> /target/etc/sysctl.conf; \
echo "net.ipv4.conf.default.accept_source_route = 1" >> /target/etc/sysctl.conf; \
echo "kernel.sysrq = 0" >> /target/etc/sysctl.conf; \
echo "kernel.core_uses_pid = 1" >> /target/etc/sysctl.conf; \
echo "net.ipv4.tcp_syncookies = 1" >> /target/etc/sysctl.conf; \
echo "kernel.msgmnb = 65536" >> /target/etc/sysctl.conf; \
echo "kernel.msgmax = 65536" >> /target/etc/sysctl.conf; \
echo "kernel.shmmax = 68719476736" >> /target/etc/sysctl.conf; \
echo "kernel.shmall = 4294967296" >> /target/etc/sysctl.conf; \
echo "net.core.rmem_max = 16777216" >> /target/etc/sysctl.conf; \
echo "net.core.wmem_max = 16777216" >> /target/etc/sysctl.conf; \
echo "net.core.netdev_max_backlog = 30000" >> /target/etc/sysctl.conf; \
echo "net.ipv4.tcp_max_syn_backlog = 4096" >> /target/etc/sysctl.conf; \
echo "net.ipv4.tcp_congestion_control=htcp" >> /target/etc/sysctl.conf; \
echo "net.ipv4.tcp_mtu_probing=1" >> /target/etc/sysctl.conf; \
echo "net.ipv4.ip_local_port_range = 15000 61000" >> /target/etc/sysctl.conf; \
echo "net.ipv4.tcp_fin_timeout=30" >> /target/etc/sysctl.conf; \
echo "net.ipv4.tcp_tw_recycle = 1" >> /target/etc/sysctl.conf; \
echo "net.ipv4.tcp_tw_reuse = 1" >> /target/etc/sysctl.conf; \
echo "net.core.somaxconn = 8192" >> /target/etc/sysctl.conf; \
echo "net.ipv4.route.flush=1" >> /target/etc/sysctl.conf; \
cat << EOF > /etc/sysctl.conf
#raw
# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and
# sysctl.conf(5) for more details.
# Controls IP packet forwarding
net.ipv4.ip_forward = 0
# Controls source route verification
net.ipv4.conf.default.rp_filter = 1
# Do not accept source routing
net.ipv4.conf.default.accept_source_route = 0
# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0
# Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
kernel.core_uses_pid = 1
# Controls the use of TCP syncookies
net.ipv4.tcp_syncookies = 1
# Controls the default maxmimum size of a mesage queue
kernel.msgmnb = 65536
# Controls the maximum size of a message, in bytes
kernel.msgmax = 65536
# Controls the maximum shared segment size, in bytes
kernel.shmmax = 68719476736
# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 4294967296
# increase TCP max buffer size settable using setsockopt()
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
# increase Linux autotuning TCP buffer limit
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
# increase the length of the processor input queue
net.core.netdev_max_backlog = 30000
net.ipv4.tcp_max_syn_backlog = 4096
# recommended default congestion control is htcp
net.ipv4.tcp_congestion_control=htcp
# recommended for hosts with jumbo frames enabled
net.ipv4.tcp_mtu_probing=1
# increase client parallel connections
net.ipv4.ip_local_port_range = 15000 61000
net.ipv4.tcp_fin_timeout=30
# fast cycling of sockets in time_wait state and re-using them
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
# increase the maximum number of requests queued to a listen socket
net.core.somaxconn = 8192
# avoid caching tcp network transfer statistics
net.ipv4.route.flush=1
#end raw
EOF
sysctl -p