AutoYaST
From openSUSE
| Revision as of 23:43, 5 February 2008 Marlierian (Talk | contribs) � Previous diff |
Revision as of 14:54, 16 June 2009 Fsundermeyer (Talk | contribs) Content check Next diff → |
||
| Line 95: | Line 95: | ||
| + | {{Contentcheck|[[User:Fsundermeyer|Fsundermeyer]] 14:54, 16 June 2009 (UTC)}} | ||
| [[Category:YaST]] | [[Category:YaST]] | ||
Revision as of 14:54, 16 June 2009
See also YaST Autoinstallation
Contents |
AutoYaST Script examples
I've seen some neat things done in autoyast scripts, so I thought it would be a good idea to capture them all in one place and this looks like a good place.
Detect if your client is a vmware VM
This script detects if your autoyasting client is a VMware virtual machine. Originally designed to run as a custom rule, but easily changed to run as a pre-script. [Originally posted by Mike Marion of qualcom.com on the mailing list opensuse-autoinstall@opensuse.org
<rule>
<custom1>
<script>
<![CDATA[
#!/bin/sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin
if [ -n "`ifconfig | awk '/HWaddr/{print $NF}' | egrep -i '^00:0C:29'`"
]
then
echo vmware
else
echo default
fi
]]>
</script>
<match>*</match>
<match_type>exact</match_type>
</custom1>
</rule>
Detecting a xen VM is similar; replace "00:0C:29" above with "00:16:3E"
Copy answers from ask scripts to the newly installed system
The ask directive [1] is great for getting user input during the install, but what if you don't need to do anything with that until post install ? Well, the following script will take the answers written by the ask directive to a permanent file in the installed system.
In my ask statements I write all the answers to /tmp/answer_* as in this example
<ask-list config:type="list"> <ask> <question>Enter the user for this machine</question> <default></default> <help>Enter your novell userID</help> <title>userID</title> <file>/tmp/answer_user</file> <stage>initial</stage> <path>general,ask-list,3,default</path> </ask> </ask-list>
And the following script would then copy all of those answers and write them into the installed system. It runs as a "non-chrooted, chroot script" [2] The script also creates a single file containing all the answers in shell var=value format.
#!/bin/bash mkdir /mnt/var/adm/autoinstall/answers
for FILE in /tmp/answer*
do
cp $FILE /mnt/var/adm/autoinstall/answers/.
ANSWER=`cat $FILE`
QUESTION=${FILE##*/}
echo ${QUESTION##*_}=$ANSWER >> /mnt/var/adm/autoinstall/answers/all_answers
done
Using classes with opensuse 10.3
I had some trouble getting classes to work correctly in opensuse 10.3, due to differences in the XML document definitions between the profile itself and the included class file. In the end, I found that this worked.
In the profile, include the class by using
<?xml version="1.0"?> <!DOCTYPE profile SYSTEM "/usr/share/autoinstall/dtd/profile.dtd"> <profile xmlns="http://www.suse.com/1.0/yast2ns" xmlns:config="http://www.suse.com/1.0/configns"> <classes config:type="list"> <class> <class_name>10.3</class_name> <configuration>default.xml</configuration> </class> </classes> . . . </profile>
This will cause autoyast to look for the class file at classes/10.3/default.xml of the directory where your profiles are stored. If you're pulling from an http source, for example, you might point to a profile at nfs://instserver.example.com/autoyast/sampleprofile.xml; the class file included within that profile would then be sought at nfs://instserver.example.com/autoyast/classes/10.3/default.xml
The file classes/10.3/default.xml has a slightly different XML definition at the top. This one works (others may as well, but this one is known to):
<?xml version="1.0"?> <profile xmlns="http://www.suse.com/1.0/yast2ns" xmlns:config="http://www.suse.com/1.0/configns"> <section1> </section1> . . . </profile>
Passed QA check: Fsundermeyer 14:54, 16 June 2009 (UTC)

