Merge "add initial version of suse support" into dev/experimental

This commit is contained in:
Jenkins 2015-03-06 18:52:53 +00:00 committed by Gerrit Code Review
commit 839cde46f6
48 changed files with 2281 additions and 69 deletions

View File

@ -75,7 +75,6 @@ $SNIPPET('kickstart_pre_anamon')
%packages --nobase
@core
iproute
chef
ntp
openssh-clients
wget
@ -89,6 +88,10 @@ parted
#if $os_version == "rhel7"
net-tools
#end if
#if $getVar('tool', '') != ''
#set $kickstart_software = "kickstart_software_%s" % $tool
$SNIPPET($kickstart_software)
#end if
%end
%post --log=/var/log/post_install.log

View File

@ -79,7 +79,13 @@ $SNIPPET('preseed_apt_repo_config')
# Individual additional packages to install
# wget is REQUIRED otherwise quite a few things won't work
# later in the build (like late-command scripts)
d-i pkgsel/include string ntp ssh wget chef
#if $getVar('tool', '') != ''
#set $preseed_software = "preseed_software_%s" % $tool
$SNIPPET($preseed_software)
#else
d-i pkgsel/include string ntp ssh wget
#end if
# Whether to upgrade packages after debootstrap.
# Allowed values: none, safe-upgrade, full-upgrade
d-i pkgsel/upgrade select none

View File

@ -0,0 +1,229 @@
## Figure out if we're kickstarting a system or a profile
#if $getVar('system_name','') != ''
#set $what = "system"
#else
#set $what = "profile"
#end if
<?xml version="1.0" standalone="no"?>
<!--
Copyright (c) 2011 Novell
Uwe Gansert ug@suse.de
This software is licensed to you under the GNU General Public License,
version 2 (GPLv2). There is NO WARRANTY for this software, express or
implied, including the implied warranties of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
along with this software; if not, see
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
-->
<!DOCTYPE profile [
<!ENTITY network SYSTEM "/tmp/profile/network.xml">
<!ENTITY partition SYSTEM "/tmp/profile/partition.xml">
<!ENTITY bootloader SYSTEM "/tmp/profile/bootloader.xml">
]>
<profile xmlns="http://www.suse.com/1.0/yast2ns" xmlns:config="http://www.suse.com/1.0/configns">
<deploy_image>
<image_installation config:type="boolean">false</image_installation>
</deploy_image>
## without the next 6 lines autoyast will ask for confirmation bevore installation
<general>
<signature-handling>
<accept_unsigned_file config:type="boolean">true</accept_unsigned_file>
<accept_file_without_checksum config:type="boolean">true</accept_file_without_checksum>
<accept_verification_failed config:type="boolean">true</accept_verification_failed>
<accept_unknown_gpg_key config:type="boolean">true</accept_unknown_gpg_key>
<import_gpg_key config:type="boolean">true</import_gpg_key>
<accept_non_trusted_gpg_key config:type="boolean">true</accept_non_trusted_gpg_key>
</signature-handling>
<mode>
<confirm config:type="boolean">false</confirm>
<final_reboot config:type="boolean">true</final_reboot>
</mode>
</general>
$SNIPPET('hosts.xml')
$SNIPPET('kdump.xml')
## <keyboard>
## <keymap>english</keymap>
## </keyboard>
<language>
<language>en_US</language>
<languages></languages>
</language>
<timezone>
<hwclock>localtime</hwclock>
#if $getVar('timezone', '') != ""
<timezone>$timezone</timezone>
#else
<timezone>US/Pacific</timezone>
#end if
</timezone>
<software>
<add-on>
<add_on_products config:type="list">
$SNIPPET('repo_config.xml')
</add_on_products>
</add-on>
<patterns config:type="list">
<pattern>base</pattern>
</patterns>
<packages config:type="list">
<package>iputils</package>
<package>openssh</package>
<package>gcc</package>
<package>net-tools</package>
<package>ethtool</package>
<package>ntp</package>
<package>wget</package>
<package>rsyslog</package>
<package>iproute2</package>
<package>parted</package>
#if $getVar('tool', '') != ''
#set $suse_software = "software_%s.xml" % $tool
$SNIPPET($suse_software)
#end if
</packages>
<do_online_update config:type="boolean">true</do_online_update> <!-- since openSUSE 11.1 -->
</software>
$SNIPPET('yast_repo_config.xml')
<files config:type="list">
$SNIPPET('limits_conf.xml')
$SNIPPET('ssh.xml')
$SNIPPET('sshd.xml')
$SNIPPET('sysctl.xml')
$SNIPPET('rsyslog.xml')
</files>
<login_settings/>
<sysconfig config:type="list" >
</sysconfig>
<networking>
&amp;amp;network;
</networking>
$SNIPPET('ntp.xml')
<partitioning config:type="list">
&amp;amp;partition;
</partitioning>
<bootloader>
&amp;amp;bootloader;
</bootloader>
<runlevel>
<default>3</default>
<services config:type="list">
<service>
<service_name>sshd</service_name>
<service_status>enable</service_status>
</service>
<service>
<service_name>ntp</service_name>
<service_status>enable</service_status>
</service>
<service>
<service_name>syslog</service_name>
<service_status>enable</service_status>
</service>
<service>
<service_name>autoyast</service_name>
<service_status>enable</service_status>
</service>
</services>
</runlevel>
<sysconfig config:type="list">
<sysconfig_entry>
<sysconfig_key>SYSLOG_DAEMON</sysconfig_key>
<sysconfig_path>/etc/sysconfig/syslog</sysconfig_path>
<sysconfig_value>rsyslogd</sysconfig_value>
</sysconfig_entry>
<sysconfig_entry>
<sysconfig_key>RSYSLOGD_COMPAT_VERSION</sysconfig_key>
<sysconfig_path>/etc/sysconfig/syslog</sysconfig_path>
<sysconfig_value>4</sysconfig_value>
</sysconfig_entry>
</sysconfig>
<user_defaults>
<expire></expire>
<home>/home</home>
<inactive>-1</inactive>
<shell>/bin/bash</shell>
<skel>/etc/skel</skel>
</user_defaults>
<users config:type="list">
<user>
#if $getVar('password', '') != ""
<encrypted config:type="boolean">true</encrypted>
#else
<encrypted config:type="boolean">false</encrypted>
#end if
<fullname>root</fullname>
<gid>0</gid>
<home>/root</home>
<password_settings>
<expire></expire>
<flag></flag>
<inact></inact>
<max></max>
<min></min>
<warn></warn>
</password_settings>
<shell>/bin/bash</shell>
<uid>0</uid>
#if $getVar('password', '') != ""
<user_password>$password</user_password>
#else
<user_password>root</user_password>
#end if
<username>root</username>
</user>
</users>
<scripts>
## we have to include the pre-scripts tag to get kickstart_start included
<pre-scripts config:type="list">
<script>
<interpreter>shell</interpreter>
<filename>pre_install_script.sh</filename>
<source><![CDATA[
wget -O- http://$http_server/cblr/svc/op/script/$what/$name/?script=suse_early_default | /bin/bash
]]></source>
</script>
## SuSE has an annoying habit on ppc64 of changing the system
## boot order after installation. This makes it non-trivial to
## automatically re-install future OS.
#set global $wrappedscript = 'save_boot_device'
$SNIPPET('suse_scriptwrapper.xml')
</pre-scripts>
<post-scripts config:type="list">
<script>
<interpreter>shell</interpreter>
<network_needed config:type="boolean">true</network_needed>
<filename>post_install_script.sh</filename>
<source><![CDATA[
wget -O- http://$http_server/cblr/svc/op/script/$what/$name/?script=suse_post_default | /bin/bash
]]></source>
</script>
## This plugin wrapper provides the flexibility to call pure shell
## snippets which can be used directly on kickstart and with with
## wrapper on SuSE.
#set global $wrappedscript = 'restore_boot_device'
$SNIPPET('suse_scriptwrapper.xml')
</post-scripts>
<chroot-scripts config:type="list">
<script>
<interpreter>shell</interpreter>
<chrooted config:type="boolean">true</chrooted>
<filename>chroot_install_script.sh</filename>
<source><![CDATA[
wget -O- http://$http_server/cblr/svc/op/script/$what/$name/?script=suse_late_default | /bin/bash
]]></source>
</script>
</chroot-scripts>
<init-scripts config:type="list">
<script>
<interpreter>shell</interpreter>
<filename>init_install_script.sh</filename>
<source><![CDATA[
wget -O- http://$http_server/cblr/svc/op/script/$what/$name/?script=suse_init_default | /bin/bash
]]></source>
</script>
</init-scripts>
</scripts>
</profile>

View File

@ -0,0 +1,25 @@
# Start suse_early_default
# This script is not run in the chroot /target by default
#if $getVar('system_name','') != ''
#set $what = "system"
#else
#set $what = "profile"
#end if
$SNIPPET('suse_pre_log')
$SNIPPET('suse_pre_install_network')
$SNIPPET('suse_pre_partition_disks')
$SNIPPET('suse_pre_anamon')
wget -O- http://$http_server/cblr/svc/op/ks/$what/$name | sed -e 's/&amp;/\&/g' -e 's/&amp;/\&/g' > /tmp/profile/modified.xml
#raw
# generic functions to be used to expand xml entity
entity_expand() {
sed -i "/&$1;/ {
r /tmp/profile/$1.xml
d
}" $2
}
#end raw
entity_expand network /tmp/profile/modified.xml
entity_expand partition /tmp/profile/modified.xml
entity_expand bootloader /tmp/profile/modified.xml
# End suse_early_default

View File

@ -0,0 +1,30 @@
# Start suse_early_default
# This script is not run in the chroot /target by default
#if $getVar('system_name','') != ''
#set $what = "system"
#else
#set $what = "profile"
#end if
$SNIPPET('suse_pre_log')
$SNIPPET('suse_pre_install_network')
$SNIPPET('suse_pre_partition_disks')
$SNIPPET('suse_pre_anamon')
wget -O- http://$http_server/cblr/svc/op/ks/$what/$name | sed -e 's/&amp;/\&/g' | sed -e 's/&amp;/\&/g' > /tmp/modified.xml
cp -f /tmp/modified.xml /tmp/profile/modified.xml
cat << EOF > /tmp/expand_entity.sh
#raw
#!/bin/bash
sed -i "/&\$1;/ {
r /tmp/profile/\$1.xml
d
}" \$2
#end raw
EOF
chmod ugo+x /tmp/expand_entity.sh
/tmp/expand_entity.sh network /tmp/profile/modified.xml
/tmp/expand_entity.sh partition /tmp/profile/modified.xml
/tmp/expand_entity.sh bootloader /tmp/profile/modified.xml
while [ ! -f /tmp/break ]; do
sleep 10
done
# End suse_early_default

View File

@ -0,0 +1,7 @@
#if $getVar('system_name','') != ''
#set $what = "system"
#else
#set $what = "profile"
#end if

View File

@ -0,0 +1,17 @@
# Start suse_late_default
# This script is not run in the chroot /target by default
#if $getVar('system_name','') != ''
#set $what = "system"
#else
#set $what = "profile"
#end if
$SNIPPET('suse_post_log')
$SNIPPET('suse_post_install_network')
$SNIPPET('suse_post_partition_disks')
#if $getVar('tool', '') != ''
#set $suse_tool = "suse_%s" % $tool
$SNIPPET($suse_tool)
#end if
$SNIPPET('suse_post_anamon')
# End suse_late_default

View File

@ -0,0 +1,5 @@
#if $getVar('system_name','') != ''
#set $what = "system"
#else
#set $what = "profile"
#end if

View File

@ -10,9 +10,9 @@ cat << EOF > /etc/init.d/chef
# processname: chef-agent
#end raw
echo "old date is: `date`" 2>&1 > /tmp/ntp.log
service ntpd stop 2>&1 >> /tmp/ntp.log
service ntp stop 2>&1 >> /tmp/ntp.log
ntpdate $ntp_server 2>&1 >> /tmp/ntp.log
service ntpd start 2>&1 >> /tmp/ntp.log
service ntp start 2>&1 >> /tmp/ntp.log
echo "new date is: `date`" 2>&1 >> /tmp/ntp.log
crontab -l > /tmp/mycron

View File

@ -22,29 +22,29 @@
cat << EOF > /etc/chef/chef_client_run.sh
#!/bin/bash
touch /tmp/chef.log
touch /var/log/chef.log
PIDFILE=/tmp/chef_client_run.pid
if [ -f \\$PIDFILE ]; then
pid=\\$(cat \\$PIDFILE)
if [ -f /proc/\\$pid/exe ]; then
echo "there are chef_client_run.sh running with pid \\$pid" &>> /tmp/chef.log
echo "there are chef_client_run.sh running with pid \\$pid" &>> /var/log/chef.log
exit 1
fi
fi
echo \\$$ > \\$PIDFILE
while true; do
echo "run chef-client on \`date\`" &>> /tmp/chef.log
echo "run chef-client on \`date\`" &>> /var/log/chef.log
clients=\\$(pgrep chef-client)
if [[ "\\$?" == "0" ]]; then
echo "there are chef-clients '\\$clients' running" &>> /tmp/chef.log
echo "there are chef-clients '\\$clients' running" &>> /var/log/chef.log
break
else
echo "knife search nodes" &>> /tmp/chef.log
echo "knife search nodes" &>> /var/log/chef.log
# use knife node list here to check if node has been registered because knife search node
# doesn't work as expected.
USER=root HOME=/root knife node list |grep \\$HOSTNAME. &>> /tmp/chef.log
USER=root HOME=/root knife node list |grep \\$HOSTNAME. &>> /var/log/chef.log
nodes=\\$(USER=root HOME=/root knife node list |grep \\$HOSTNAME.)
echo "found nodes \\$nodes" &>> /tmp/chef.log
echo "found nodes \\$nodes" &>> /var/log/chef.log
let all_nodes_success=1
for node in \\$nodes; do
mkdir -p /var/log/chef/\\$node
@ -78,15 +78,15 @@ EOL
service rsyslog restart
fi
if [ -f "/etc/chef/\\$node.done" ]; then
USER=root HOME=/root chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem &>> /tmp/chef.log
USER=root HOME=/root chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem &>> /var/log/chef.log
else
USER=root HOME=/root 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
USER=root HOME=/root chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem -L /var/log/chef/\\$node/chef-client.log &>> /var/log/chef.log
fi
if [ "\\$?" != "0" ]; then
echo "chef-client --node-name \\$node run failed" &>> /tmp/chef.log
echo "chef-client --node-name \\$node run failed" &>> /var/log/chef.log
let all_nodes_success=0
else
echo "chef-client --node-name \\$node run success" &>> /tmp/chef.log
echo "chef-client --node-name \\$node run success" &>> /var/log/chef.log
touch /etc/chef/\\$node.done
fi
done

View File

@ -4,6 +4,10 @@ log_level :info
log_location '/dev/null'
#if $getVar('chef_url', '') != ""
chef_server_url '$chef_url'
#elif $getVar("compass_server","") != ""
chef_server_url 'https://$compass_server'
#else
chef_server_url 'https://$server'
#end if
validation_client_name 'chef-validator'
json_attribs nil

View File

@ -31,9 +31,9 @@ cat << EOF > /etc/init.d/anamon.init
#
#end raw
#if $getVar("compass_server","") != ""
/usr/local/sbin/anamon --watchfile "/var/log/boot.log /var/log/messages /var/log/dmesg /var/log/anaconda.log" --name $name --server $compass_server --port $http_port --exit
/usr/local/sbin/anamon --watchfile "/var/log/anaconda.log" --name $name --server $compass_server --port $http_port --exit
#else
/usr/local/sbin/anamon --watchfile "/var/log/boot.log /var/log/messages /var/log/dmesg /var/log/anaconda.log" --name $name --server $server --port $http_port --exit
/usr/local/sbin/anamon --watchfile "/var/log/anaconda.log" --name $name --server $server --port $http_port --exit
#end if
chkconfig anamon.init off
mv /etc/init.d/anamon.init /tmp/anamon.init

View File

@ -131,7 +131,7 @@ for disk in \${sorted_disks}; do
break
fi
done
echo "first disk \${first_disk}" >> /tmp/preseed.log
echo "first disk \${first_disk}" >> /tmp/log
let disk_nums=\${#sorted_disks[@]}
sorted_disks_str=""
@ -187,13 +187,13 @@ for disk_partition in \${disk_partitions}; do
remove_vg="\$vg"
remove_partition="\${disk_partition}"
else
echo "partition \${disk_partition} does not match \${remove_disk_path}.*" >> /tmp/preseed.log
echo "partition \${disk_partition} does not match \${remove_disk_path}.*" >> /tmp/log
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
echo "partition \${disk_partition} does not match \${remove_disk}.*" >> /tmp/log
fi
if [[ "\$vg" == "$vgname" ]]; then
remove_vg="\$vg"
@ -232,12 +232,12 @@ for disk_partition in \${disk_partitions}; do
fi
done
echo "remove vgs \${remove_vgs}" >> /tmp/preseed.log
echo "remove vgs \${remove_vgs}" >> /tmp/log
for remove_vg in \${remove_vgs}; do
vgremove -f \${remove_vg}
done
echo "remove partitions \${remove_partitions} from \${remove_vgs}" >> /tmp/preseed.log
echo "remove partitions \${remove_partitions} from \${remove_vgs}" >> /tmp/log
for remove_partition in \${remove_partitions}; do
pvremove -ff -y \${remove_partition}
done
@ -259,7 +259,7 @@ declare -A reserve_disks_size
#else
#set disk_size = $int($size)
#end if
reserve_disks_size[\${disk_name}]=${disk_size}
reserve_disks_size[${disk_name}]=${disk_size}
#end for
#end if
@ -293,7 +293,7 @@ declare -A max_disks_size
#else
#set disk_size = $int($size)
#end if
max_disks_size[\${disk_name}]=${disk_size}
max_disks_size[${disk_name}]=${disk_size}
#end for
#end if
@ -454,7 +454,7 @@ while [ \${disk_offset} -lt \${disk_nums} ]; do
fi
echo "partition \${disk} max size \${max_disk_size}" >> /tmp/log
if [ \${max_disk_size} -gt 0 ]; then
maxsize_param="--maxsize=\${max_disks_size[\${disk}]}"
maxsize_param="--maxsize=\${max_disk_size}"
else
maxsize_param=""
fi

View File

@ -0,0 +1 @@
chef

View File

@ -0,0 +1,61 @@
<file>
<file_path>/etc/security/limits.conf</file_path>
<file_contents>
<![CDATA[
#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
]]>
</file_contents>
<file_owner>root.root</file_owner>
<file_permissions>644</file_permissions>
</file>

16
cobbler/snippets/ntp.xml Normal file
View File

@ -0,0 +1,16 @@
#if $getVar('ntp_server', '') == ""
#set $ntp_server = '0.pool.ntp.org'
#end if
<ntp-client>
<configure_dhcp config:type="boolean">false</configure_dhcp>
<peers config:type="list">
<peer>
<address>$ntp_server</address>
<initial_sync config:type="boolean">true</initial_sync>
<options></options>
<type>server</type>
</peer>
</peers>
<start_at_boot config:type="boolean">true</start_at_boot>
<start_in_chroot config:type="boolean">true</start_in_chroot>
</ntp-client>

View File

@ -21,27 +21,27 @@
cat << EOF > /etc/chef/chef_client_run.sh
#!/bin/bash
touch /tmp/chef.log
touch /var/log/chef.log
PIDFILE=/tmp/chef_client_run.pid
if [ -f \\$PIDFILE ]; then
pid=\\$(cat \\$PIDFILE)
if [ -f /proc/\\$pid/exe ]; then
echo "there are chef_client_run.sh running with pid \\$pid" &>> /tmp/chef.log
echo "there are chef_client_run.sh running with pid \\$pid" &>> /var/log/chef.log
exit 1
fi
fi
echo \\$$ > \\$PIDFILE
while true; do
echo "run chef-client on \`date\`" &>> /tmp/chef.log
echo "run chef-client on \`date\`" &>> /var/log/chef.log
clients=\\$(pgrep chef-client)
if [[ "\\$?" == "0" ]]; then
echo "there are chef-clients '\\$clients' running" &>> /tmp/chef.log
echo "there are chef-clients '\\$clients' running" &>> /var/log/chef.log
break
else
echo "knife search nodes" &>> /tmp/chef.log
USER=root HOME=/root knife node list |grep \\$HOSTNAME. &>> /tmp/chef.log
echo "knife search nodes" &>> /var/log/chef.log
USER=root HOME=/root knife node list |grep \\$HOSTNAME. &>> /var/log/chef.log
nodes=\\$(USER=root HOME=/root knife node list |grep \\$HOSTNAME.)
echo "found nodes \\$nodes" &>> /tmp/chef.log
echo "found nodes \\$nodes" &>> /var/log/chef.log
all_nodes_success=1
for node in \\$nodes; do
mkdir -p /var/log/chef/\\$node
@ -71,15 +71,15 @@ EOL
service rsyslog restart
fi
if [ -f "/etc/chef/\\$node.done" ]; then
USER=root HOME=/root chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem &>> /tmp/chef.log
USER=root HOME=/root chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem &>> /var/log/chef.log
else
USER=root HOME=/root 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
USER=root HOME=/root chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem -L /var/log/chef/\\$node/chef-client.log &>> /var/log/chef.log
fi
if [ "\\$?" != "0" ]; then
echo "chef-client --node-name \\$node run failed" &>> /tmp/chef.log
echo "chef-client --node-name \\$node run failed" &>> /var/log/chef.log
all_nodes_success=0
else
echo "chef-client --node-name \\$node run success" &>> /tmp/chef.log
echo "chef-client --node-name \\$node run success" &>> /var/log/chef.log
touch /etc/chef/\\$node.done
fi
done

View File

@ -3,6 +3,10 @@ log_level :info
log_location '/dev/null'
#if $getVar('chef_url', '') != ""
chef_server_url '$chef_url'
#elif $getVar("compass_server","") != ""
chef_server_url 'https://$compass_server'
#else
chef_server_url 'https://$server'
#end if
validation_client_name 'chef-validator'
json_attribs nil

View File

@ -1,7 +1,11 @@
#if $str($getVar('anamon_enabled','')) == "1"
## install anamon script
#if $getVar("compass_server", "") != ""
wget -O /usr/local/sbin/anamon "http://$compass_server:$http_port/cobbler/aux/anamon"
#else
wget -O /usr/local/sbin/anamon "http://$server:$http_port/cobbler/aux/anamon"
#end if
## install anamon system service
cat << EOF > /etc/init.d/anamon.init
#raw
@ -29,7 +33,11 @@ cat << EOF > /etc/init.d/anamon.init
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
#if $getVar("compass_server","") != ""
/usr/local/sbin/anamon --watchfile "/var/log/installer/syslog /var/log/installer/hardware-summary /var/log/installer/initial-status /var/log/installer/status" --name $name --server $compass_server --port $http_port --exit
#else
/usr/local/sbin/anamon --watchfile "/var/log/installer/syslog /var/log/installer/hardware-summary /var/log/installer/initial-status /var/log/installer/status" --name $name --server $server --port $http_port --exit
#end if
update-rc.d -f anamon remove
mv /etc/init.d/anamon.init /tmp/anamon.init
EOF

View File

@ -253,8 +253,8 @@ done
echo "unset physical interfaces \${sorted_unset_physical_interfaces}" >> /tmp/network_log
echo "unset logical interfaces \${sorted_unset_logical_interfaces}" >> /tmp/network_log
# map any unmapped logical interfaces
echo "map unmapped logical interfaces" >> /tmp/network_log
# map remaining unmapped logical interfaces
echo "map remaining unmapped logical interfaces" >> /tmp/network_log
if [ ! -z "\${sorted_unset_logical_interfaces}" ]; then
# get all available logical interfaces which the same name physical interface is not used
available_logical_interfaces=""
@ -297,19 +297,6 @@ if [ ! -z "\${sorted_unset_logical_interfaces}" ]; then
done
sorted_unset_logical_interfaces=\${unset_logical_interfaces}
echo "finish mapping ramaining unmapped logical interfaces to the same name physical interface" >> /tmp/network_log
for key in \${logical_interfaces}; do
eval "physical_interface=\\${logical_interface_mapping_\${key}}"
echo "map logical interface \${key} to physical interface \${physical_interface}" >> /tmp/network_log
done
for key in \${physical_interfaces}; do
eval "logical_interface=\\${physical_interface_mapping_\${key}}"
echo "map physical interface \${key} to logical interface \${logical_interface}" >> /tmp/network_log
done
echo "unset physical interfaces \${sorted_unset_physical_interfaces}" >> /tmp/network_log
echo "unset logical interfaces \${sorted_unset_logical_interfaces}" >> /tmp/network_log
# map remain unset logical interfaces to available logical interface names
for logical_interface in \${sorted_unset_logical_interfaces}; do
for available_logical_interface in \${available_logical_interfaces}; do
@ -335,8 +322,8 @@ for key in \${physical_interfaces}; do
echo "map physical interface \${key} to logical interface \${logical_interface}" >> /tmp/network_log
done
# map any unmapped physical interfaces
echo "map unmapped physical interfaces" >> /tmp/network_log
# map remaining unmapped physical interfaces
echo "map remaining unmapped physical interfaces" >> /tmp/network_log
if [ ! -z "\${sorted_unset_physical_interfaces}" ]; then
# get all available physical interfaces which the same name logical interface is not used
available_physical_interfaces=""
@ -379,19 +366,6 @@ if [ ! -z "\${sorted_unset_physical_interfaces}" ]; then
done
sorted_unset_physical_interfaces=\${unset_physical_interfaces}
echo "finish mapping ramaining unmapped physical interfaces to the same name logical interface" >> /tmp/network_log
for key in \${logical_interfaces}; do
eval "physical_interface=\\${logical_interface_mapping_\${key}}"
echo "map logical interface \${key} to physical interface \${physical_interface}" >> /tmp/network_log
done
for key in \${physical_interfaces}; do
eval "logical_interface=\\${physical_interface_mapping_\${key}}"
echo "map physical interface \${key} to logical interface \${logical_interface}" >> /tmp/network_log
done
echo "unset physical interfaces \${sorted_unset_physical_interfaces}" >> /tmp/network_log
echo "unset logical interfaces \${sorted_unset_logical_interfaces}" >> /tmp/network_log
# map remain unset physical interfaces to logical interface name as available physical interface names
for physical_interface in \${sorted_unset_physical_interfaces}; do
for available_physical_interface in \${available_physical_interfaces}; do

View File

@ -33,6 +33,8 @@ get_ifname() {
#end raw
#set ikeys = $interfaces.keys()
#for $iname in $ikeys
#set $idata = $interfaces[$iname]
#set $management = $idata["management"]
#if $management
#set $management_nic = $iname
#end if

View File

@ -108,6 +108,7 @@ for disk in \$(list-devices disk); do
fi
done
echo "partition disks: \${partition_disks}" >> /tmp/preseed.log
echo "disks \${disks}" >> /tmp/preseed.log
#if $getVar('sort_disks', '0') != "0"
sorted_disks=\$(printf '%s\n' \${partition_disks} | sort)
@ -441,6 +442,19 @@ partition_maxsize_$volname=${vol_max_size}
#end for
#end if
echo "finish partition mapping" >> /tmp/preseed.log
for key in \${partition_names}; do
eval "mountpoint=\\${partition_point_\$key}"
echo "partition names \$key => \${mountpoint}" >> /tmp/preseed.log
eval "partition_percentage=\\${partition_percentage_\$key}"
echo "partition percentage \$key => \${partition_percentage}" >> /tmp/preseed.log
eval "partition_size=\\${partition_size_\$key}"
echo "partition size \$key => \${partition_size}" >> /tmp/preseed.log
eval "partition_max_size=\\${partition_max_size_\$key}"
echo "partition max size \$key => \${partition_max_size}" >> /tmp/preseed.log
done
if [ -z "\${default_partition_name}" ]; then
default_partition_name=root
fi
@ -505,11 +519,11 @@ if [ -z "\${partition_size_swap}" ]; then
fi
if [ -z "\${partition_percentage_swap}" ]; then
partition_percentage_swap=200
partition_percentage_swap=10
fi
if [ -z "\${partition_maxsize_swap}" ]; then
partition_maxsize_swap=10%
partition_maxsize_swap=200%
fi
partition_param_swap="linux-swap \

View File

@ -0,0 +1 @@
d-i pkgsel/include string ntp ssh wget chef

View File

@ -0,0 +1,17 @@
# Repository Config
#set $repo_data = $getVar("repo_data",[])
#for $repo in $repo_data
<listentry>
#if $repo.mirror_locally
<media_url>http://$http_server/cobbler/repo_mirror/${repo.name}</media_url>
#else
<media_url>${repo.mirror}</media_url>
#end if
<product>${repo.name}</product>
<product_dir>/</product_dir>
<ask_on_error config:type="boolean">false</ask_on_error>
<name>${repo.name}</name>
</listentry>
#end for

View File

@ -0,0 +1,71 @@
<file>
<file_path>/etc/rsyslog.conf</file_path>
<file_contents>
<![CDATA[
\#\#\#\# 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
#if $getVar("compass_server", "") != ""
*.* @@$compass_server:514
#else
*.* @@$server:514
#end if
\# Provides UDP syslog reception
\#\\$ModLoad imudp
\#\\$UDPServerRun 514
\# Provides TCP syslog reception
\\$ModLoad imtcp
\\$InputTCPServerRun 514
#set system_name = $getVar('system_name','')
\\$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
]]>
</file_contents>
<file_owner>root.root</file_owner>
<file_permissions>600</file_permissions>
</file>

View File

@ -0,0 +1,2 @@
<package>chef</package>

36
cobbler/snippets/ssh.xml Normal file
View File

@ -0,0 +1,36 @@
#set ssh_keys = $getVar("push_ssh_keys", "/root/.ssh/id_rsa.pub")
#if $ssh_keys != ""
<file>
<file_path>/root/.ssh/authorized_keys</file_path>
<file_owner>root.root</file_owner>
<file_permissions>600</file_permissions>
<file_script>
<interpreter>shell</interpreter>
<source>
<![CDATA[
\#!/bin/bash
mkdir -p /root/.ssh
chmod 700 -R /root/.ssh
#set $firstline = True
#for $ssh_key in $ssh_keys.split(',')
#if not $ssh_key
#continue
#end if
#set f = $open($ssh_key)
#if $firstline
cat << EOL > /root/.ssh/authorized_keys
#echo $f.read()
EOL
#else
cat << EOL >> /root/.ssh/authorized_keys
#echo $f.read()
EOL
#end if
#silent $f.close()
#set $firstline = False
#end for
]]>
</source>
</file_script>
</file>
#end if

142
cobbler/snippets/sshd.xml Normal file
View File

@ -0,0 +1,142 @@
<file>
<file_path>/etc/ssh/sshd_config</file_path>
<file_contents>
<![CDATA[
#raw
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
# default value.
#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
# The default requires explicit activation of protocol 1
#Protocol 2
# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 1024
# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
#LogLevel INFO
# Authentication:
#LoginGraceTime 2m
#PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
RSAAuthentication yes
PubkeyAuthentication yes
# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile .ssh/authorized_keys
#AuthorizedPrincipalsFile none
#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes
# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication yes
#PermitEmptyPasswords no
# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
# Set this to 'yes' to enable support for the deprecated 'gssapi' authentication
# mechanism to OpenSSH 3.8p1. The newer 'gssapi-with-mic' mechanism is included
# in this release. The use of 'gssapi' is deprecated due to the presence of
# potential man-in-the-middle attacks, which 'gssapi-with-mic' is not susceptible to.
#GSSAPIEnableMITMAttack no
# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes
#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
UsePrivilegeSeparation sandbox # Default for new installations.
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS yes
#PidFile /run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none
# no default banner path
#Banner none
# override default of no subsystems
Subsystem sftp /usr/lib/ssh/sftp-server
# This enables accepting locale enviroment variables LC_* LANG, see sshd_config(5).
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL
# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
# ForceCommand cvs server
#end raw
]]>
</file_contents>
<file_owner>root.root</file_owner>
<file_permissions>640</file_permissions>
</file>

View File

@ -0,0 +1,13 @@
mkdir -p /etc/chef
mkdir -p /var/log/chef
## Generate validation.pem
$SNIPPET('suse_chef-validator.pem')
## Generate admin.pem
$SNIPPET('suse_chef-admin.pem')
## Generate client.rb
$SNIPPET('suse_client.rb')
$SNIPPET('suse_knife.rb')
$SNIPPET('suse_gem_local_repo')
$SNIPPET('suse_chef_run.sh')
$SNIPPET('suse_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

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

View File

@ -0,0 +1,32 @@
## A self-destruct service to boot chef client and register cron job
#if $getVar('ntp_server', '') == ""
#set $ntp_server = '0.pool.ntp.org'
#end if
cat << EOF > /etc/init.d/chef
#raw
#!/bin/bash
# Required-Start: \$syslog \$ntp
# Default-Start: 2 3 4 5
# Default-Stop: 0 6
# Short-Description: chef client daemon (chef)
# Description: chef client daemon (chef).
#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 &
chkconfig -d chef
mv /etc/init.d/chef /tmp/chef
EOF
chmod 755 /etc/init.d/chef
chkconfig chef on

View File

@ -0,0 +1,94 @@
#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
#set $proxy_url = ""
#set $local_repo_url = ""
#if $getVar("local_repo","") != ""
#set $local_repo_url = $local_repo
#end if
#if $getVar("proxy","") != ""
#set $proxy_url = $proxy
#end if
cat << EOF > /etc/chef/chef_client_run.sh
#!/bin/bash
touch /var/log/chef.log
PIDFILE=/tmp/chef_client_run.pid
if [ -f \\$PIDFILE ]; then
pid=\\$(cat \\$PIDFILE)
if [ -f /proc/\\$pid/exe ]; then
echo "there are chef_client_run.sh running with pid \\$pid" &>> /var/log/chef.log
exit 1
fi
fi
echo \\$$ > \\$PIDFILE
while true; do
echo "run chef-client on \`date\`" &>> /var/log/chef.log
clients=\\$(pgrep chef-client)
if [[ "\\$?" == "0" ]]; then
echo "there are chef-clients '\\$clients' running" &>> /var/log/chef.log
break
else
echo "knife search nodes" &>> /var/log/chef.log
USER=root HOME=/root knife node list |grep \\$HOSTNAME. &>> /var/log/chef.log
nodes=\\$(USER=root HOME=/root knife node list |grep \\$HOSTNAME.)
echo "found nodes \\$nodes" &>> /var/log/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
{
"local_repo": "$local_repo_url",
"proxy_url": "$proxy_url",
"ip_address": "$ip_address"
}
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
USER=root HOME=/root chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem &>> /var/log/chef.log
else
USER=root HOME=/root chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem -L /var/log/chef/\\$node/chef-client.log &>> /var/log/chef.log
fi
if [ "\\$?" != "0" ]; then
echo "chef-client --node-name \\$node run failed" &>> /var/log/chef.log
all_nodes_success=0
else
echo "chef-client --node-name \\$node run success" &>> /var/log/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

@ -0,0 +1,35 @@
cat << EOL > /etc/chef/client.rb
log_level :info
log_location '/dev/null'
#if $getVar('chef_url', '') != ""
chef_server_url '$chef_url'
#elif $getVar("compass_server","") != ""
chef_server_url 'https://$compass_server'
#else
chef_server_url 'https://$server'
#end if
validation_client_name 'chef-validator'
json_attribs nil
pid_file '/var/run/chef-client.pid'
# Using default node name (fqdn)
no_lazy_load true
ssl_verify_mode :verify_none
EOL
mkdir -p /etc/chef/trusted_certs
#set certs_path = $getVar("trusted_certs_path", "/var/opt/chef-server/nginx/ca")
#if $certs_path != ""
#import os
#import os.path
#set filenames = $os.listdir($certs_path)
#for filename in $filenames
#if $filename.endswith('.crt')
#set filepath = $os.path.join($certs_path, $filename)
#set f = $open($filepath)
cat << EOF > /etc/chef/trusted_certs/$filename
#echo $f.read()
EOF
#silent $f.close()
#end if
#end for
#end if

View File

@ -0,0 +1,23 @@
cat << EOF > /root/.gemrc
#if $getVar('proxy', '') != ""
gem: --no-ri --no-rdoc --http-proxy=$proxy
#else
gem: --no-ri --no-rdoc
#end if
:backtrace: false
:benchmark: false
:bulk_threshold: 1000
:sources:
#if $getVar("local_repo","") != ""
- $local_repo/gem_repo/
#if $getVar("local_repo_only","1") == "0"
- https://rubygems.org/
#end if
#else
- https://rubygems.org/
#end if
:update_sources: true
:verbose: true
EOF
cp -f /root/.gemrc /etc/gemrc

View File

@ -0,0 +1,32 @@
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'
ssl_verify_mode :verify_none
EOL
mkdir -p /root/.chef/trusted_certs
#set certs_path = $getVar("trusted_certs_path", "/var/opt/chef-server/nginx/ca")
#if $certs_path != ""
#import os
#import os.path
#set filenames = $os.listdir($certs_path)
#for filename in $filenames
#if $filename.endswith('.crt')
#set filepath = $os.path.join($certs_path, $filename)
#set f = $open($filepath)
cat << EOF > /root/.chef/trusted_certs/$filename
#echo $f.read()
EOF
#silent $f.close()
#end if
#end for
#end if

View File

@ -0,0 +1,30 @@
#if $str($getVar('anamon_enabled','')) == "1"
#if $getVar("compass_server", "") != ""
wget -O /usr/local/sbin/anamon "http://$compass_server:$http_port/cobbler/aux/anamon"
#else
wget -O /usr/local/sbin/anamon "http://$server:$http_port/cobbler/aux/anamon"
#end if
cat << EOF > /etc/init.d/anamon.init
#raw
#!/bin/bash
## BEGIN INIT INFO
# Required-Start: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 6
# Short-Description: Starts the cobbler anamon boot notification program
# Description: anamon runs the first time a machine is booted after installation.
## END INIT INFO
#end raw
#if $getVar("compass_server","") != ""
/usr/local/sbin/anamon --watchfile "/var/log/YaST2/y2start.log /var/log/YaST2/y2log" --name $name --server $compass_server --port $http_port --exit
#else
/usr/local/sbin/anamon --watchfile "/var/log/YaST2/y2start.log /var/log/YaST2/y2log" --name $name --server $server --port $http_port --exit
#end if
chkconfig -d anamon.init
mv /etc/init.d/anamon.init /tmp/anamon.init
EOF
chmod 755 /etc/init.d/anamon.init /usr/local/sbin/anamon
chmod +x /etc/init.d/anamon.init
chkconfig anamon.init on
#end if

View File

@ -0,0 +1,10 @@
# Start post_install_network_config generated code
#if $getVar('promisc_nics', '') != ""
#set promisc_interfaces = [promisc.strip() for promisc in $promisc_nics.split(',') if promisc.strip()]
#else
#set promisc_interfaces = []
#end if
#for promisc_interface in $promisc_interfaces
echo 'LINK_OPTIONS="promisc on"' >> /etc/sysconfig/network/ifcfg-$promisc_interface
#end for

View File

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

View File

@ -0,0 +1,30 @@
set \$(lsblk -n -p -P -o NAME,TYPE,LABEL | grep 'TYPE="part"' | grep 'LABEL="reserved_.*"' | cut -d' ' -f1)
echo "list partitions: \$@" >> /tmp/post_partition.log
declare -a remove_partitions
for arg in \$@; do
eval \$arg
partition=\$NAME
partition_name=\$(basename \$partition)
echo "add \${partition_name} => \$partition into remove list" >> /tmp/post_partition.log
remove_partitions[\${partition_name}]=\$partition
done
echo "remove partitions: \${remove_partitions[@]}" >> /tmp/post_partition.log
for partition in \${remove_partitions[@]}; do
if [ -z "\$partition" ]; then
continue
fi
echo "umount \$partition" >> /tmp/post_partition.log
umount \$partition
set \$(echo \${partition} | sed -e 's/^\(.*\)\([0-9]\+\)\$/\1 \2/g')
partition_disk=\$1
partition_number=\$2
echo "remove disk \${partition_disk} partition \${partition_number}" >> /tmp/post_partition.log
if [ -z "\${partition_disk}" -o -z "\${partition_number}" ]; then
continue
fi
parted \${partition_disk} rm \${partition_number}
done
grep -v "LABEL=reserved_.*" /etc/fstab > /tmp/fstab.new
mv -f /tmp/fstab.new /etc/fstab

View File

@ -0,0 +1,9 @@
#if $str($getVar('anamon_enabled','')) == "1"
#if $getVar("compass_server", "") != ""
wget -O /tmp/anamon "http://$compass_server:$http_port/cobbler/aux/anamon"
python /tmp/anamon --watchfile "/var/log/YaST2/y2start.log /var/log/YaST2/y2log /tmp/log" --name "$name" --server "$compass_server" --port "$http_port"
#else
wget -O /tmp/anamon "http://$server:$http_port/cobbler/aux/anamon"
python /tmp/anamon --watchfile "/var/log/YaST2/y2start.log /var/log/YaST2/y2log /tmp/log" --name "$name" --server "$server" --port "$http_port"
#end if
#end if

View File

@ -0,0 +1,541 @@
# Start pre_install_network_config generated code
#if $getVar('promisc_nics', '') != ""
#set promisc_interfaces = [promisc.strip() for promisc in $promisc_nics.split(',') if promisc.strip()]
#else
#set promisc_interfaces = []
#end if
# get physical interfaces
declare -a physical_interfaces
physical_interfaces=()
set \$(ip -o link | grep -v lo | awk '{print \$2}' | sed 's/://')
let physical_interface_num=\$#;
let physical_interface_offset=0
echo "network interface numbers: \$physical_interface_num" > /tmp/network_log
echo "got network interfaces: \$@" >> /tmp/network_log
while [ \$physical_interface_offset -lt \$physical_interface_num ];
do
physical_interface=\$1
echo "record \$physical_interface_offset physical interface \${physical_interface}" >> /tmp/network_log
physical_interfaces+=(\${physical_interface})
eval "physical_interface_\${physical_interface}=\${physical_interface}"
let physical_interface_offset=\$physical_interface_offset+1
shift 1
done
echo "interfaces: \${physical_interfaces[@]}" >> /tmp/network_log
# map physical interface to mac address
declare -a mac_names
mac_names=()
for physical_interface in \${physical_interfaces[@]}; do
mac=\$(cat /sys/class/net/\${physical_interface}/address)
mac_name=\$(echo \${mac} |tr 'a-z' 'A-Z' | tr ':' '_')
mac_names+=(\$mac_name)
echo "mapping physical interface \${physical_interface} to mac \${mac}" >> /tmp/network_log
eval "physical_interface_mac_\${physical_interface}=\$mac"
eval "physical_mac_interface_\${mac_name}=\${physical_interface}"
eval "mac_name_\${mac_name}=\$mac"
done
echo "list physical interfaces to mac" >> /tmp/network_log
for physical_interface in \${physical_interfaces[@]}; do
eval "mac=\\${physical_interface_mac_\${physical_interface}}"
echo "physical interface to mac: \${physical_interface} => \${mac}" >> /tmp/network_log
done
echo "list mac to physical interface mapping" >> /tmp/network_log
for mac_name in \${mac_names[@]}; do
eval "mac=\\${mac_name_\${mac_name}}"
eval "physical_interface=\\${physical_mac_interface_\${mac_name}}"
echo "mac to physical interface: \${mac} => \${physical_interface}" >> /tmp/network_log
done
declare -a logical_interfaces
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 $interface_type in ("master","bond","bridge","bonded_bridge_slave")
#continue
#end if
#if $vlanpattern.match($iname)
#set $interface_matched = $vlanpattern.match($iname)
#set $interface_name = $interface_matched.group(1)
logical_interface=${interface_name}
#elif $subinterfacepattern.match($iname)
#set $interface_matched = $subinterfacepattern.match($iname)
#set $interface_name = $interface_matched.group(1)
logical_interface=${interface_name}
#else
logical_interface=$iname
#end if
logical_interfaces+=(\${logical_interface})
eval "logical_interface_\${logical_interface}=\${logical_interface}"
#if $mac != ""
#set mac_name = $mac.replace(':', '_')
physical_interface=\${physical_mac_interface_${mac_name}}
eval "logical_interface_mapping_\${logical_interface}=\${physical_interface}"
if [ ! -z "\$physical_interface" ]; then
eval "physical_interface_mapping_\${physical_interface}=\${logical_interface}"
fi
#else
eval "physical_interface=\\${logical_interface_mapping_\${logical_interface}}"
if [ -z "\${physical_interface}" ]; then
eval "logical_interface_mapping_\${logical_interface}="
fi
#end if
#end for
echo "logical interfaces: \${logical_interfaces[@]}" >> /tmp/network_log
echo "finish mapping logical interfaces in network config to physical interfaces" >> /tmp/network_log
for key in \${logical_interfaces[@]}; do
eval "physical_interface=\\${logical_interface_mapping_\${key}}"
echo "map logical interface \${key} to physical interface \${physical_interface}" >> /tmp/network_log
done
for key in \${physical_interfaces[@]}; do
eval "logical_interface=\\${physical_interface_mapping_\${key}}"
echo "map physical interface \${key} to logical interface \${logical_interface}" >> /tmp/network_log
done
# map unmapped logical interface to the same name physical interface
echo "mapping unmapped logical interfaces to the same name physical interfaces" >> /tmp/network_log
for logical_interface in \${logical_interfaces[@]}; do
eval "physical_interface=\\${logical_interface_mapping_\${logical_interface}}"
if [ ! -z "\${physical_interface}" ]; then
echo "ignore logical interface \${logical_interface} where its physical interface is \${physical_interface}" >> /tmp/network_log
continue
fi
# check if the same name physical interface is mapped
eval "mapped_logical_interface=\\${physical_interface_mapping_\${logical_interface}}"
if [ ! -z "\${mapped_logical_interface}" ]; then
echo "ignore logical interface \${logical_interface} since the same name physical interface is mapped by logical interface \${mapped_logical_interface}" >> /tmp/network_log
continue
fi
# check if the same name physical interface exists
eval "mapped_logical_interface=\\${physical_interface_\${logical_interface}}"
if [ -z "\${mapped_logical_interface}" ]; then
echo "ignore logical interface \${logical_interface} since the same name physical interface does not exist" >> /tmp/network_log
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
echo "finish mapping unmapped logical interfaces in network config to the same name physical interfaces" >> /tmp/network_log
for key in \${logical_interfaces[@]}; do
eval "physical_interface=\\${logical_interface_mapping_\${key}}"
echo "map logical interface \${key} to physical interface \${physical_interface}" >> /tmp/network_log
done
for key in \${physical_interfaces[@]}; do
eval "logical_interface=\\${physical_interface_mapping_\${key}}"
echo "map physical interface \${key} to logical interface \${logical_interface}" >> /tmp/network_log
done
declare -a unset_logical_interfaces
unset_logical_interfaces=()
declare -a unset_physical_interfaces
unset_physical_interfaces=()
echo "get unset logical interfaces from \${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
echo "logical interface \${logical_interface} is already set to \${physical_interface}" >> /tmp/network_log
continue
fi
unset_logical_interfaces+=(\${logical_interface})
done
echo "got unset logical interfaces: \${unset_logical_interfaces[@]}" >> /tmp/network_log
echo "get unset physical interfaces from \${physical_interfaces[@]}" >> /tmp/network_log
for physical_interface in \${physical_interfaces[@]}; do
eval "logical_interface=\\${physical_interface_mapping_\${physical_interface}}"
if [ ! -z "\${logical_interface}" ]; then
echo "physical interface \${physical_interface} is already set to \${logical_interface}" >> /tmp/network_log
continue
fi
unset_physical_interfaces+=(\${physical_interface})
eval "unset_physical_interface_\${physical_interface}=\${physical_interface}"
done
echo "got unset physical interfaces: \${unset_physical_interfaces[@]}" >> /tmp/network_log
sorted_unset_physical_interfaces=(\$(printf '%s\n' \${unset_physical_interfaces[@]} | sort))
echo "sorted unset physical interfaces: \${sorted_unset_physical_interfaces[@]}" >> /tmp/network_log
sorted_unset_logical_interfaces=(\$(printf '%s\n' \${unset_logical_interfaces[@]} | sort))
echo "sorted unset logical interfaces: \${sorted_unset_logical_interfaces[@]}" >> /tmp/network_log
# map unset logical interface to unset physical interface
echo "map unset logical interfaces \${sorted_unset_logical_interfaces[@]} to unset physical interfaces \${sorted_unset_physical_interfaces[@]}" >> /tmp/network_log
while [ \${#sorted_unset_physical_interfaces[@]} -gt 0 -a \${#sorted_unset_logical_interfaces[@]} -gt 0 ]; do
physical_interface=\${sorted_unset_physical_interfaces[0]}
logical_interface=\${sorted_unset_logical_interfaces[0]}
echo "map unset logical interface \${logical_interface} to unset physical interface \${physical_interface}" >> /tmp/network_log
unset sorted_unset_physical_interfaces[0]
unset sorted_unset_logical_interfaces[0]
echo "map unset logical interface \${logical_interface} to unset physical interface \${physical_interface}" >> /tmp/network_log
eval "physical_interface_mapping_\${physical_interface}=\${logical_interface}"
eval "logical_interface_mapping_\${logical_interface}=\${physical_interface}"
done
unset_logical_interfaces=()
unset_physical_interfaces=()
echo "finish mapping unmapped logical interfaces in network config to unmapped physical interfaces" >> /tmp/network_log
for key in \${logical_interfaces[@]}; do
eval "physical_interface=\\${logical_interface_mapping_\${key}}"
echo "map logical interface \${key} to physical interface \${physical_interface}" >> /tmp/network_log
done
for key in \${physical_interfaces[@]}; do
eval "logical_interface=\\${physical_interface_mapping_\${key}}"
echo "map physical interface \${key} to logical interface \${logical_interface}" >> /tmp/network_log
done
echo "unset logical interfaces: \${sorted_unset_logical_interfaces[@]}" >> /tmp/network_log
echo "unset physical interfaces: \${sorted_unset_physical_interfaces[@]}" >> /tmp/network_log
# map remaining unmapped logical interfaces
echo "map remaining unmapped logical interfaces" >> /tmp/network_log
if [ \${#sorted_unset_logical_interfaces[@]} -gt 0 ]; then
declare -a available_logical_interfaces
available_logical_interfaces=()
# get all available logical interfaces which the same name physical interface is not used
for logical_interface in \${logical_interfaces[@]}; do
eval "mapped_logical_interface=\\${physical_interface_mapping_\${logical_interface}}"
if [ -z "\${mapped_logical_interface}" ]; then
eval "available_logical_interface_\${logical_interface}=\${logical_interface}"
available_logical_interfaces+=(\${logical_interface})
else
echo "ignore logical interface \${logical_interface} since the same name physical interface mapped to logical interface \${mapped_logical_interface}" >> /tmp/network_log
fi
done
# add extra logical interfaces name to physical interfaces
physical_interfaces+=(\${available_logical_interfaces[@]})
echo "updated physical interfaces: \${physical_interfaces[@]}" >> /tmp/network_log
#first map logical interface to the same name physical interface if that physical interface name is not used
unset_logical_interfaces=()
for logical_interface in \${sorted_unset_logical_interfaces[@]}; do
eval "available_logical_interface=\\${available_logical_interface_\${logical_interface}}"
if [ ! -z "\${available_logical_interface}" ]; then
eval "physical_interface_mapping_\${available_logical_interface}=\${logical_interface}"
eval "logical_interface_mapping_\${logical_interface}=\${available_logical_interface}"
else
unset_logical_interfaces+=(\${logical_interface})
fi
done
sorted_unset_logical_interfaces=(\${unset_logical_interfaces[@]})
echo "finish mapping ramaining unmapped logical interfaces to the same name physical interface" >> /tmp/network_log
for key in \${logical_interfaces}; do
eval "physical_interface=\\${logical_interface_mapping_\${key}}"
echo "map logical interface \${key} to physical interface \${physical_interface}" >> /tmp/network_log
done
for key in \${physical_interfaces}; do
eval "logical_interface=\\${physical_interface_mapping_\${key}}"
echo "map physical interface \${key} to logical interface \${logical_interface}" >> /tmp/network_log
done
echo "unset physical interfaces \${sorted_unset_physical_interfaces[@]}" >> /tmp/network_log
echo "unset logical interfaces \${sorted_unset_logical_interfaces[@]}" >> /tmp/network_log
# map remain unset logical interfaces to available logical interface names
for logical_interface in \${sorted_unset_logical_interfaces[@]}; do
for available_logical_interface in \${available_logical_interfaces[@}}; do
eval "mapped_logical_interface=\\${physical_interface_mapping_\${available_logical_interface}}"
if [ -z "\${mapped_logical_interface}" ]; then
eval "physical_interface_mapping_\${available_logical_interface}=\${logical_interface}"
eval "logical_interface_mapping_\${logical_interface}=\${available_logical_interface}"
break
fi
done
done
fi
unset_logical_interfaces=()
sorted_unset_logical_interfaces=()
echo "finish mapping ramaining unmapped logical interfaces" >> /tmp/network_log
for key in \${logical_interfaces[@]}; do
eval "physical_interface=\\${logical_interface_mapping_\${key}}"
echo "map logical interface \${key} to physical interface \${physical_interface}" >> /tmp/network_log
done
for key in \${physical_interfaces[@]}; do
eval "logical_interface=\\${physical_interface_mapping_\${key}}"
echo "map physical interface \${key} to logical interface \${logical_interface}" >> /tmp/network_log
done
# map remaining unmapped physical interfaces
echo "map remaining unmapped physical interfaces" >> /tmp/network_log
if [ \${#sorted_unset_physical_interfaces[@]} -gt 0 ]; then
declare -a available_physical_interfaces
available_physical_interfaces=()
# get all available physical interfaces which the same name logical interface is not used
for physical_interface in \${physical_interfaces[@]}; do
eval "mapped_physical_interface=\\${logical_interface_mapping_\${physical_interface}}"
if [ -z "\${mapped_physical_interface}" ]; then
eval "available_physical_interface_\${physical_interface}=\${physical_interface}"
available_physical_interfaces+=(\${physical_interface})
else
echo "ignore physical interface \${physical_interface} since the same name logical interface mapped to physical interface \${mapped_physical_interface}" >> /tmp/network_log
fi
done
logical_interfaces+=(\${available_physical_interfaces[@]})
echo "updated logical interfaces: \${logical_interfaces[@]}" >> /tmp/network_log
#first map physical interface to the same name logical interface if that logical interface name is not used
unset_physical_interfaces=()
for physical_interface in \${sorted_unset_physical_interfaces[@]}; do
eval "available_physical_interface=\\${available_physical_interface_\${physical_interface}}"
if [ ! -z "\${available_physical_interface}" ]; then
eval "logical_interface_mapping_\${available_physical_interface}=\${physical_interface}"
eval "physical_interface_mapping_\${physical_interface}=\${available_physical_interface}"
else
unset_physical_interfaces+=(\${physical_interface})
fi
done
sorted_unset_physical_interfaces=(\${unset_physical_interfaces[@]})
# map remain unset physical interfaces to logical interface name as available physical interface names
for physical_interface in \${sorted_unset_physical_interfaces}; do
for available_physical_interface in \${available_physical_interfaces}; do
eval "mapped_physical_interface=\\${logical_interface_mapping_\${available_physical_interface}}"
if [ -z "\${mapped_physical_interface}" ]; then
eval "logical_interface_mapping_\${available_physical_interface}=\${physical_interface}"
eval "physical_interface_mapping_\${physical_interface}=\${available_physical_interface}"
break
fi
done
done
fi
unset_physical_interfaces=()
sorted_unset_physical_interfaces=()
echo "finish mapping ramaining unmapped physical interfaces" >> /tmp/network_log
for key in \${logical_interfaces[@]}; do
eval "physical_interface=\\${logical_interface_mapping_\${key}}"
echo "map logical interface \${key} to physical interface \${physical_interface}" >> /tmp/network_log
done
for key in \${physical_interfaces[@]}; do
eval "logical_interface=\\${physical_interface_mapping_\${key}}"
echo "map physical interface \${key} to logical interface \${logical_interface}" >> /tmp/network_log
done
echo '<keep_install_network config:type="boolean">false</keep_install_network>' > /tmp/profile/network.xml
echo '<dns>' >> /tmp/profile/network.xml
echo ' <dhcp_hostname config:type="boolean">false</dhcp_hostname>' >> /tmp/profile/network.xml
echo ' <dhcp_resolv config:type="boolean">false</dhcp_resolv>' >> /tmp/profile/network.xml
echo ' <write_hostname config:type="boolean">false</write_hostname>' >> /tmp/profile/network.xml
echo ' <resolv_conf_policy></resolv_conf_policy>' >> /tmp/profile/network.xml
#if $hostname != ""
echo ' <hostname>$hostname</hostname>' >> /tmp/profile/network.xml
#end if
#if $getVar("name_servers_search","") != ""
echo ' <searchlist config:type="list">' >> /tmp/profile/network.xml
#for $sd in $name_servers_search
echo ' <search>$sd</search>' >> /tmp/profile/network.xml
#end for
echo ' </searchlist>' >> /tmp/profile/network.xml
#end if
#if $getVar("name_servers","") != ""
echo ' <nameservers config:type="list">' >> /tmp/profile/network.xml
#for $ns in $name_servers
echo ' <nameserver>$ns</nameserver>' >> /tmp/profile/network.xml
#end for
echo ' </nameservers>' >> /tmp/profile/network.xml
#end if
#if $getVar("domain", "") != ""
echo '<domain>$domain</domain>' >> /tmp/profile/network.xml
#else
echo '<domain>site</domain>' >> /tmp/profile/network.xml
#end if
echo '</dns>' >> /tmp/profile/network.xml
echo '<interfaces config:type="list">' >> /tmp/profile/network.xml
#for $iname in $ikeys
# Start configuration for $iname
## 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 $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 $devfile = "/etc/sysconfig/network-scripts/cobbler/ifcfg-" + $iname
#set $routesfile = "/etc/sysconfig/network-scripts/cobbler/route-" + $iname
used_logical_interface_$iname=$iname
echo ' <interface>' >> /tmp/profile/network.xml
#if $iface_type in ("slave","bond_slave","bridge_slave","bonded_bridge_slave")
#set $static = 1
#end if
echo ' <device>$iname</device>' >> /tmp/profile/network.xml
echo ' <startmode>auto</startmode>' >> /tmp/profile/network.xml
echo ' <usercontrol>no</usercontrol>' >> /tmp/profile/network.xml
#if $iface_type not in ("master","bond","bridge","bonded_bridge_slave")
#if $vlanpattern.match($iname)
#pass
#else
#set $interface_matched = $subinterfacepattern.match($iname)
#if $interface_matched
#set $interface_name = $interface_matched.group(1)
logical_interface=$interface_name
#else
logical_interface=$iname
#end if
eval "physical_interface=\\${logical_interface_mapping_\${logical_interface}}"
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 'A-Z' 'a-z')
echo " <lladdr>\${physical_mac}</lladdr>" >> /tmp/profile/network.xml
fi
#end if
#end if
#if $iface_type in ("master","bond","bonded_bridge_slave")
echo ' <bonding_master>yes</bonding_master>' >> /tmp/profile/network.xml
#if $bonding_opts != ""
echo ' <bonding_module_opts>$bonding_opts.lower()</bonding_module_opts>' >> /tmp/profile/network.xml
#end if
#set $loop_ikeys = $interfaces.keys()
#set $loop_counter = 0
#for $loop_iface in $loop_ikeys
#set $loop_idata = $interfaces[$loop_iface]
#set $loop_interface_type = $loop_idata["interface_type"]
#if $loop_interface_type.lower == "bond_slave"
#if $loop_idata["interface_master"] != ""
#if $loop_idata["interface_master"].lower() == $iface.lower()
echo ' <bonding_slave$loop_counter>$loop_iface</bonding_slave$loop_counter>' >> /tmp/profile/network.xml
#set $loop_counter += 1
#end if
#end if
#end if
#end for
#end if
#if $static
echo ' <bootproto>static</bootproto>' >> /tmp/profile/network.xml
#if $iname in $promisc_interfaces
#pass
#elif $ip != ""
echo ' <ipaddr>$ip</ipaddr>' >> /tmp/profile/network.xml
#if $netmask == ""
## Default to 255.255.255.0?
#set $netmask = "255.255.255.0"
#end if
echo " <netmask>$netmask</netmask>" >> /tmp/profile/network.xml
#end if
#else
echo ' <bootproto>dhcp</bootproto>' >> /tmp/profile/network.xml
#end if
#if $mtu != ""
echo " <mtu>$mtu</mtu>" >> /tmp/profile/network.xml
#end if
echo ' </interface>' >> /tmp/profile/network.xml
#end for
for logical_interface in \${logical_interfaces[@]}; do
eval "used_logical_interface=\\${used_logical_interface_\${logical_interface}}"
if [ ! -z "\${used_logical_interface}" ]; then
# ignore logical interface that is already generated in above
echo "ignore used logical interface \${logical_interface}" >> /tmp/network_log
continue
fi
echo "add logical interface \${logical_interface} into network config since it is not set above" >> /tmp/network_log
eval "physical_interface=\\${logical_interface_mapping_\${logical_interface}}"
if [ ! -z "\${physical_interface}" ]; then
eval "mac=\\${physical_interface_mac_\${physical_interface}}"
echo " <interface>" >> /tmp/profile/network.xml
echo " <device>\${logical_interface}</device>" >> /tmp/profile/network.xml
echo " <startmode>auto</startmode>" >> /tmp/profile/network.xml
echo " <usercontrol>no</usercontrol>" >> /tmp/profile/network.xml
echo " <bootproto>static</bootproto>" >> /tmp/profile/network.xml
if [ ! -z "\$mac" ]; then
mac=\$(echo \${mac} | tr 'A-Z' 'a-z')
echo " <lladdr>\${mac}</lladdr>" >> /tmp/profile/network.xml
fi
echo " </interface>" >> /tmp/profile/network.xml
fi
done
echo '</interfaces>' >> /tmp/profile/network.xml
echo '<managed config:type="boolean">false</managed>' >> /tmp/profile/network.xml
echo '<net-udev config:type="list">' >> /tmp/profile/network.xml
for logical_interface in \${logical_interfaces[@]}; do
eval "physical_interface=\\${logical_interface_mapping_\${logical_interface}}"
if [ ! -z "\${physical_interface}" ]; then
eval "mac=\\${physical_interface_mac_\${physical_interface}}"
if [ ! -z "\$mac" ]; then
mac=\$(echo \${mac} | tr 'A-Z' 'a-z')
echo " <rule>" >> /tmp/profile/network.xml
echo " <name>\$logical_interface</name>" >> /tmp/profile/network.xml
echo " <rule>ATTR{address}</rule>" >> /tmp/profile/network.xml
echo " <value>\${mac}</value>" >> /tmp/profile/network.xml
echo " </rule>" >> /tmp/profile/network.xml
fi
fi
done
echo '</net-udev>' >> /tmp/profile/network.xml
echo '<routing>' >> /tmp/profile/network.xml
echo ' <ip_forward config:type="boolean">false</ip_forward>' >> /tmp/profile/network.xml
echo ' <routes config:type="list">' >> /tmp/profile/network.xml
#if $gateway != ""
echo ' <route>' >> /tmp/profile/network.xml
echo ' <destination>default</destination>' >> /tmp/profile/network.xml
echo ' <netmask>-</netmask>' >> /tmp/profile/network.xml
echo ' <device>-</device>' >> /tmp/profile/network.xml
echo ' <gateway>$gateway</gateway>' >> /tmp/profile/network.xml
echo ' </route>' >> /tmp/profile/network.xml
#end if
#for $iname in $ikeys
## create lots of variables to use later
#set $idata = $interfaces[$iname]
#set $static_routes = $idata.get("static_routes", "")
#for $route in $static_routes
#set routepattern = $re.compile("[0-9/.]+:[0-9.]+")
#if $routepattern.match($route)
#set $routebits = $route.split(":")
#set [$network, $router] = $route.split(":")
#import netaddr
#set interface_network = $netaddr.IPNetwork($network)
#set interface_network_ip = $str($interface_network.ip)
#set interface_network_netmask = $str($interface_network.netmask)
echo ' <route>' >> /tmp/profile/network.xml
echo ' <destination>$interface_network_ip</destination>' >> /tmp/profile/network.xml
echo ' <netmask>$interface_network_netmask</netmask>' >> /tmp/profile/network.xml
echo ' <device>$iname</device>' >> /tmp/profile/network.xml
echo ' <gateway>$router</gateway>' >> /tmp/profile/network.xml
echo ' </route>' >> /tmp/profile/network.xml
echo "$network via $router" >> $routesfile
#else
# Warning: invalid route "$route"
#end if
#end for
#end for
echo ' </routes>' >> /tmp/profile/network.xml
echo '</routing>' >> /tmp/profile/network.xml

View File

@ -0,0 +1,2 @@
set -x -v
exec 1>/tmp/yast-pre.log 2>&1

View File

@ -0,0 +1,543 @@
#set hostname=$getVar('hostname',None)
#set partition = $getVar('partition', None)
#set partition_size = $getVar('partition_size', None)
#set partition_maxsize = $getVar('partition_maxsize', None)
#set disk_reserve_size = $getVar('disk_reserve_size', None)
#set disk_max_size = $getVar('disk_max_size', None)
#set default_disk_reserve_size = $getVar('default_disk_reserve_size', '0')
#set default_disk_max_size = $getVar('default_disk_max_size', '0')
#if $hostname == None
#set $vgname = "VolGroup00"
#else
#set $vgname = $hostname.split('.')[0]
#end if
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: \$*" >> /tmp/log
declare -a disk_mapping
disk_mapping=()
declare -a disk_path_mapping
disk_path_mapping=()
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
let found_disk_type=1
fi
#else
let found_disk_type=1
#end if
path_name=\$(basename \$1)
disk_path_name=\$(echo \${path_name} | tr '-' '_' | tr ':' '_' | tr '.' '_')
disk_name=\$(basename \$2)
let disk_mapping_offset=\$disk_mapping_offset+1
shift 2
if [ \$found_disk_type -gt 0 ]; then
disk_mapping+=(\${disk_name})
disk_path_mapping+=(\${disk_path_name})
eval "disk_\${disk_name}=/dev/disk/by-path/\${path_name}"
eval "disk_\${disk_path_name}=/dev/disk/by-path/\${path_name}"
eval "disk_path_\${disk_path_name}=/dev/\${disk_name}"
eval "disk_path_\${disk_name}=/dev/\${disk_name}"
fi
done
echo "finish disk mapping" >> /tmp/log
for key in \${disk_mapping[@]}; do
eval "disk_path=\\${disk_\$key}"
echo "disk_mapping \$key => \${disk_path}" >> /tmp/log
done
for key in \${disk_path_mapping[@]}; do
eval "disk=\\${disk_path_\$key}"
echo "disk path mapping \$key => \${disk}" >> /tmp/log
done
declare -a partition_disks
partition_disks=()
declare -a disks
disks=()
set \$(lsblk -n -d -o NAME,RM,RO,SIZE | awk '\$2 == "0" && \$3 == "0" { print \$1, \$4 }')
let disk_nums=\$#/2
let disk_offset=0
while [ \$disk_offset -lt \$disk_nums ]; do
disk_name=\$1
shift 2
let disk_offset=\$disk_offset+1
eval "disk_path=\\${disk_\${disk_name}}"
if [ -z "\${disk_path}" ]; then
echo "ignore disk \${disk_name} since it is not in disk_mapping" >> /tmp/log
continue
fi
let found_disk=0
#if $getVar('partitions_only', '') != ""
#for $partition_only in $partitions_only.split(',')
#if not $partition_only
#continue
#end if
if expr match "\${disk_name}" "$partition_only"; then
let found_disk=1
else
echo "disk \${disk_name} does not match $partition_only" >> /tmp/log
fi
#end for
#else
let found_disk=1
#end if
#if $getVar('partition_by_path', '0') != "0"
eval "disk=\\${disk_\${disk_name}}"
#else
eval "disk=\\${disk_path_\${disk_name}}"
#end if
if [ \${found_disk} -gt 0 ]; then
echo "add disk \${disk_name} in partitioning list" >> /tmp/log
partition_disks+=(\$disk)
fi
disks+=(\$disk)
done
echo "partition disks: \${partition_disks[@]}" >> /tmp/log
echo "disks: \${disks[@]}" >> /tmp/log
#if $getVar('sort_disks', '0') != "0"
sorted_disks=(\$(printf '%s\n' \${partition_disks[@]} | sort))
#else
sorted_disks=(\${partition_disks[@]})
#end if
echo "sorted disks: \${sorted_disks[@]}" >> /tmp/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/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/log
#end if
first_disk=""
for disk in \${sorted_disks}; do
if [ -z "\${first_disk}" ]; then
first_disk=\${disk}
break
fi
done
echo "first disk \${first_disk}" >> /tmp/log
declare -a remove_disks
remove_disks=()
#if $getVar('keep_old_partitions', '0') != "0"
for disk in \${sorted_disks[@]}; do
dd if=/dev/zero of=\${disk} bs=512 count=1
remove_disks+=(\$disk)
done
#else
for disk in \${disks[@]}; do
dd if=/dev/zero of=\${disk} bs=512 count=1
remove_disks+=(\$disk)
done
#end if
echo "remove disks: \${remove_disks[@]}" >> /tmp/log
disk_partitions=\$(pvs --noheadings --separator :| cut -d: -f1)
remove_partitions=""
remove_vgs=""
for disk_partition in \${disk_partitions}; do
vg=\$(pvs --noheadings --separator : \${disk_partition} | cut -d: -f2)
remove_vg=""
remove_partition=""
for remove_disk in \${remove_disks[@]}; do
#if $getVar('partition_by_path', '0') != "0"
path_name=\$(basename \${remove_disk})
disk_path_name=\$(echo \${path_name} | tr '-' '_' | tr ':' '_' | tr '.' '_')
remove_disk_path=\${remove_disk}
eval "remove_disk=\\${disk_path_\${disk_path_name}}"
#else
disk_name=\$(basename \${remove_disk})
eval "remove_disk_path=\\${disk_\${disk_name}}"
#end if
if [ -z "\${remove_disk}" ]; then
continue
fi
if [ -z "\${remove_disk_path}" ]; then
continue
fi
if expr match "\${disk_partition}" "\${remove_disk_path}.*"; then
remove_vg="\$vg"
remove_partition="\${disk_partition}"
else
echo "partition \${disk_partition} does not match \${remove_disk_path}.*" >> /tmp/log
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/log
fi
if [[ "\$vg" == "$vgname" ]]; then
remove_vg="\$vg"
remove_partition="\${disk_partition}"
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_removed} -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
pv_removed=0
for pv in ${remove_partitions}; do
if [[ "\$pv" == "\${remove_partition}" ]]; then
pv_removed=1
fi
done
if [ \${pv_removed} -eq 0 ]; then
remove_partitions="\${remove_partitions} \${remove_partition}"
fi
fi
fi
done
echo "remove vgs: \${remove_vgs}" >> /tmp/log
for remove_vg in \${remove_vgs}; do
vgremove -f \${remove_vg}
done
echo "remove partitions: \${remove_partitions} from vgs \${remove_vgs}" >> /tmp/log
for remove_partition in \${remove_partitions}; do
pvremove -ff -y \${remove_partition}
done
default_partition=$getVar('default_partition', '/')
partition_fstype=$getVar('partition_fstype', 'ext3')
echo "default partition \${default_partition}" >> /tmp/log
echo "partition fstype \${partition_fstype}" >> /tmp/log
#if $disk_reserve_size != None
#set disk_sizes = [disk_size.strip() for disk_size in $disk_reserve_size.split(';') if disk_size.strip()]
#for disk_and_size in $disk_sizes
#set disk_name, size = $disk_and_size.split(' ', 1)
#set disk_name = $disk_name.strip()
reserve_disk_size_${disk_name}=${size}
#end for
#end if
default_reserve_disk_size=${default_disk_reserve_size}
#if $disk_max_size != None
#set disk_sizes = [disk_size.strip() for disk_size in $disk_max_size.split(';') if disk_size.strip()]
#for disk_and_size in $disk_sizes
#set disk_name, size = $disk_and_size.split(' ', 1)
#set disk_name = $disk_name.strip()
max_disk_size_${disk_name}=${size}
#end for
#end if
default_max_disk_size=${default_disk_max_size}
declare -a partition_names
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()
#if $vol == '/'
#set volname = 'root'
#elif $vol == 'swap'
#set volname = 'swap'
#elif $vol.startswith('/')
#set volname = $vol[1:].replace('/', '_')
#else
# $vol is not starts with /
#continue
#end if
partition_names+=($volname)
if [[ "$vol" == "\$default_partition" ]]; then
default_partition_name=$volname
fi
partition_point_$volname=$vol
#set vol_size = $vol_size.strip()
#if $vol_size.endswith('%'):
partition_percentage_$volname=$vol_size
#else
partition_size_$volname=$vol_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
# $vol is not starts with /
#continue
#end if
partitions_size_$volname=${vol_size}
#end for
#end if
#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
# $vol is not starts with /
#continue
#end if
partition_maxsize_$volname=${vol_size}
#end for
#end if
if [ -z "\${default_partition_name}" ]; then
default_partition_name=root
fi
if [ -z "\${partition_point_root}" ]; then
partition_names+=(root)
partition_point_root=/root
fi
eval "default_partition_point=\\${partition_point_\${default_partition_name}}"
if [ -z "\${default_partition_point}" ]; then
partition_names+=(\${default_partition_name})
default_partition_point="/\${default_partition_name}"
eval "partition_point_\${default_partition_name}=\${default_partition_point}"
fi
echo "finish partition mapping" >> /tmp/log
for key in \${partition_names[@]}; do
eval "mountpoint=\\${partition_point_\$key}"
echo "partition mountpoint \$key => \${mountpoint}" >> /tmp/log
eval "partition_percentage=\\${partition_percentage_\$key}"
echo "partition percentage \$key => \${partition_percentage}" >> /tmp/log
eval "partition_size=\\${partition_size_\$key}"
echo "partition size \$key => \${partition_size}" >> /tmp/log
eval "partition_max_size=\\${partition_max_size_\$key}"
echo "partition max size \$key => \${partition_max_size}" >> /tmp/log
done
if [ -z "\${first_disk}" ]; then
first_disk=/dev/sda
fi
declare -a vggroup
vggroup=()
for disk in \${sorted_disks[@]}; do
disk_name=\$(basename \$disk)
eval "used_disk_\${disk_name}=\$disk"
echo "add disk \$disk into disks" >> /tmp/log
echo '<drive>' >> /tmp/profile/partition.xml
echo " <device>\$disk</device>" >> /tmp/profile/partition.xml
echo ' <initialize config:type="boolean">true</initialize>' >> /tmp/profile/partition.xml
echo ' <use>all</use>' >> /tmp/profile/partition.xml
echo ' <disklabel>gpt</disklabel>' >> /tmp/profile/partition.xml
echo ' <partitions config:type="list">' >> /tmp/profile/partition.xml
if [[ "\$disk" == "\${first_disk}" ]]; then
percentage=\${partition_percentage_boot}
echo "got percentage \${percentage} for partition boot" >> /tmp/log
if [[ ! -z "\$percentage" ]] && [[ "\$percentage" != "0" ]]; then
size=\$percentage
else
size=\${partition_size_boot}
fi
echo "got size \$size for partition boot" >> /tmp/log
used_partition_boot="/boot"
echo "add partition /boot into disk \$disk" >> /tmp/log
echo ' <partition>' >> /tmp/profile/partition.xml
echo " <filesystem config:type=\"symbol\">\${partition_fstype}</filesystem>" >> /tmp/profile/partition.xml
echo ' <format config:type="boolean">true</format>' >> /tmp/profile/partition.xml
#if $getVar('partition_by_path', '0') != "0"
echo ' <mountby config:type="symbol">uuid</mountby>' >> /tmp/profile/partition.xml
#else
echo ' <mountby config:type="symbol">device</mountby>' >> /tmp/profile/partition.xml
#end if
echo ' <partition_type>primary</partition_type>' >> /tmp/profile/partition.xml
echo ' <mount>/boot</mount>' >> /tmp/profile/partition.xml
if [[ ! -z "\$size" ]] && [[ "$size" != "0" ]]; then
echo " <size>\${size}</size>" >> /tmp/profile/partition.xml
else
echo " <size>auto</size>" >> /tmp/profile/partition.xml
fi
echo ' </partition>' >> /tmp/profile/partition.xml
percentage=\${partition_percentage_swap}
echo "got percentage \$percentage for partition swap" >> /tmp/log
if [[ ! -z "\$percentage" ]] && [[ "\$percentage" != "0" ]]; then
size=\$percentage
else
size=\${partition_size_swap}
fi
echo "got size \$size for partition swap" >> /tmp/log
used_partition_swap=swap
echo "add partition swap into disk \$disk" >> /tmp/log
echo ' <partition>' >> /tmp/profile/partition.xml
echo " <filesystem config:type=\"symbol\">swap</filesystem>" >> /tmp/profile/partition.xml
echo ' <partition_type>primary</partition_type>' >> /tmp/profile/partition.xml
echo ' <mount>swap</mount>' >> /tmp/profile/partition.xml
if [[ ! -z "\$size" ]] && [[ "$size" != "0" ]]; then
echo " <size>\${size}</size>" >> /tmp/profile/partition.xml
else
echo " <size>auto</size>" >> /tmp/profile/partition.xml
fi
echo ' </partition>' >> /tmp/profile/partition.xml
fi
echo "add lvm partition $vgname into disk \$disk" >> /tmp/log
echo ' <partition>' >> /tmp/profile/partition.xml
echo ' <lvm_group>$vgname</lvm_group>' >> /tmp/profile/partition.xml
eval "max_disk_size=\\${max_disk_size_\${disk_name}}"
if [ -z "\${max_disk_size}" ]; then
max_disk_size=\${default_max_disk_size}
fi
echo "got max disk size \${max_disk_size} for disk \$disk" >> /tmp/log
if [[ ! -z "\${max_disk_size}" ]] && [[ "\${max_disk_size}" != "0" ]]; then
echo ' <size>${max_disk_size}</size>' >> /tmp/profile/partition.xml
else
echo " <size>max</size>" >> /tmp/profile/partition.xml
fi
echo ' </partition>' >> /tmp/profile/partition.xml
vggroup+=(\$disk)
eval "reserve_disk_size=\\${reserve_disk_size_\${disk_name}}"
if [ -z "\${reserve_disk_size}" ]; then
reserve_disk_size=\${default_reserve_disk_size}
fi
echo "reserve size \${reserve_disk_size} on \${disk}" >> /tmp/log
if [[ ! -z "\${reserve_disk_size}" ]] && [[ "\${reserve_disk_size}" != "0" ]]; then
echo "add partition /reserved_\${disk_name} into partitions" >> /tmp/log
echo ' <partition>' >> /tmp/profile/partition.xml
echo " <filesystem config:type=\"symbol\">\${partition_fstype}</filesystem>" >> /tmp/profile/partition.xml
echo ' <format config:type="boolean">true</format>' >> /tmp/profile/partition.xml
echo " <mount>/reserved_\${disk_name}</mount>" >> /tmp/profile/partition.xml
echo ' <mountby config:type="symbol">label</mountby>' >> /tmp/profile/partition.xml
echo " <label>reserved_\${disk_name}</label>" >> /tmp/profile/partition.xml
echo " <size>\${reserve_disk_size}</size>" >> /tmp/profile/partition.xml
echo ' </partition>' >> /tmp/profile/partition.xml
else
echo "no reserve space on disk \$disk" >> /tmp/log
fi
echo ' </partitions>' >> /tmp/profile/partition.xml
echo '</drive>' >> /tmp/profile/partition.xml
done
for disk in \${remove_disks[@]}; do
disk_name=\$(basename \$disk)
eval "used_disk=\\${used_disk_\${disk_name}}"
if [ ! -z "\${used_disk}" ]; then
# ignore disk that is already generated
echo "ignore disk \$disk that is already generated" >> /tmp/log
continue
fi
eval "used_disk_\${disk_name}=\$disk"
echo "add disk \$disk into disks" >> /tmp/log
echo '<drive>' >> /tmp/profile/partition.xml
echo " <device>\$disk</device>" >> /tmp/profile/partition.xml
echo ' <initialize config:type="boolean">true</initialize>' >> /tmp/profile/partition.xml
echo ' <use>all</use>' >> /tmp/profile/partition.xml
echo ' <disklabel>gpt</disklabel>' >> /tmp/profile/partition.xml
echo '</drive>' >> /tmp/profile/partition.xml
done
echo "partition disks" >> /tmp/log
if [ \${#vggroup[@]} -gt 0 ]; then
echo '<drive>' >> /tmp/profile/partition.xml
echo " <device>/dev/$vgname</device>" >> /tmp/profile/partition.xml
echo ' <type config:type="symbol">CT_LVM</type>' >> /tmp/profile/partition.xml
echo ' <is_lvm_vg config:type="boolean">true</is_lvm_vg>' >> /tmp/profile/partition.xml
echo ' <pesize>4M</pesize>' >> /tmp/profile/partition.xml
echo ' <use>all</use>' >> /tmp/profile/partition.xml
echo ' <partitions config:type="list">' >> /tmp/profile/partition.xml
for partition_name in \${partition_names[@]}; do
eval "used_partition=\\${used_partition_\${partition_name}}"
if [ ! -z "\${used_partition}" ]; then
echo "ignore partition \${used_partition} since it is already used" >> /tmp/log
continue
fi
eval "partition=\\${partition_point_\${partition_name}}"
echo "setup lvm partition name \$partition_name" >> /tmp/log
echo ' <partition>' >> /tmp/profile/partition.xml
echo ' <create config:type="boolean">true</create>' >> /tmp/profile/partition.xml
echo " <filesystem config:type=\"symbol\">\${partition_fstype}</filesystem>" >> /tmp/profile/partition.xml
echo " <lv_name>\${partition_name}vol</lv_name>" >> /tmp/profile/partition.xml
echo " <mount>\$partition</mount>" >> /tmp/profile/partition.xml
eval "percentage=\\${partition_percentage_\${partition_name}}"
echo "got percentage \${percentage} for partition \${partition_name}" >> /tmp/log
if [[ ! -z "\${percentage}" ]] && [[ "\${percentage}" != "0" ]]; then
size=\${percentage}
echo "set size \$size from percentage \$percentage for partition \${partition_name}" >> /tmp/log
else
eval "size=\\${partition_size_\${partition_name}}"
fi
echo "got size \$size for partition \${partition_name}" >> /tmp/log
if [[ ! -z "\${size}" ]] && [[ "\$size" != "0" ]]; then
echo " <size>\$size</size>" >> /tmp/profile/partition.xml
else
echo ' <size>max</size>' >> /tmp/profile/partition.xml
fi
echo ' </partition>' >> /tmp/profile/partition.xml
done
echo ' </partitions>' >> /tmp/profile/partition.xml
echo '</drive>' >> /tmp/profile/partition.xml
fi
echo '<device_map config:type="list">' >> /tmp/profile/bootloader.xml
echo ' <device_map_entry>' >> /tmp/profile/bootloader.xml
echo " <linux>\${first_disk}</linux>" >> /tmp/profile/bootloader.xml
echo ' </device_map_entry>' >> /tmp/profile/bootloader.xml
echo '</device_map>' >> /tmp/profile/bootloader.xml
echo '<global>' >> /tmp/profile/bootloader.xml
echo ' <activate>true</activate>' >> /tmp/profile/bootloader.xml
echo ' <default>SUSE</default>' >> /tmp/profile/bootloader.xml
echo ' <timeout config:type="integer">0</timeout>' >> /tmp/profile/bootloader.xml
echo ' <boot_mbr>true</boot_mbr>' >> /tmp/profile/bootloader.xml
echo ' <boot_boot>true</boot_boot>' >> /tmp/profile/bootloader.xml
echo '</global>' >> /tmp/profile/bootloader.xml

View File

@ -0,0 +1,27 @@
#set profile_name = $getVar('profile_name','')
#set os_info = $profile_name.split('-')
#set osname = $os_info[0].lower()
#set osversion = $os_info[1]
#if $getVar("local_repo", "") == "" or $getVar("local_repo_only","1") == "0"
#set repos_snippet = 'zypp.repos.d/%s/%s/autoyast_repos' % ($osname, $osversion)
$SNIPPET($repos_snippet)
#end if
#if $getVar("local_repo","") != ""
#set repo = 'zypp.repos.d/%s/%s/sles_repo' % ($osname, $osversion)
cat << EOF > /etc/zypp/repos.d/Compass.repo
[compass_repo]
name=Compass zypp repo
baseurl=$local_repo/$repo
enabled=1
autorefresh=1
path=/
type=rpm-md
keeppackages=1
EOF
#if $getVar("local_repo_only","1") != "0"
zypper -n update
#end if
#end if

View File

@ -0,0 +1,78 @@
<file>
<file_path>/etc/sysctl.conf</file_path>
<file_contents>
<![CDATA[
#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
]]>
</file_contents>
<file_owner>root.root</file_owner>
<file_permissions>644</file_permissions>
</file>

View File

@ -0,0 +1,20 @@
# Repository Config
#set $repo_data = $getVar("repo_data",[])
<add-on>
<add_on_products config:type="list">
#for $repo in $repo_data
<listentry>
#if $repo.mirror_locally
<media_url>http://$http_server/cobbler/repo_mirror/${repo.name}/</media_url>
#else
<media_url>${repo.mirror}</media_url>
#end if
<product>${repo.name}</product>
<product_dir>/</product_dir>
<ask_on_error config:type="boolean">false</ask_on_error>
<!-- available since openSUSE 11.0/SLES 11 -->
<name>${repo.name}</name> <!-- available since openSUSE 11.1/SLES11 (bnc#433981) -->
</listentry>
#end for
</add_on_products>
</add-on>