diff --git a/docs/examples/multi_profile.xml b/docs/examples/multi_profile.xml index 8730ef8..49f9162 100644 --- a/docs/examples/multi_profile.xml +++ b/docs/examples/multi_profile.xml @@ -31,16 +31,12 @@ {xpath_ref%//meta/dev/author/text()} - testpassword + testpassword testuser Test User - anothertestpassword + anothertestpassword @@ -49,16 +45,14 @@ /iso/latest {xpath_ref%../mirror/text()}{xpath_ref%../webroot/text()}/archlinux-bootstrap-*-x86_64.tar.gz {xpath_ref%../mirror/text()}{xpath_ref%../webroot/text()}/sha1sums.txt - {xpath_ref%../tarball/text()}.sig + {xpath_ref%../tarball/text()}.sig http://archlinux32.mirror.domain.tld /iso/latest {xpath_ref%../mirror/text()}/{xpath_ref%../webroot/text()}/archlinux-bootstrap-*-i686.tar.gz {xpath_ref%../mirror/text()}/{xpath_ref%../webroot/text()}/sha512sums.txt - {xpath_ref%../tarball/text()}.sig + {xpath_ref%../tarball/text()}.sig @@ -77,24 +71,49 @@ archlinux - + + {xpath_ref%build/paths/ssl/text()}/ca.crt - - {xpath_ref%build/paths/ssl/text()}/ca.key + + + {xpath_ref%build/paths/ssl/text()}/ca.key + + domain.tld + XX + Some City + Some State + Some Org, Inc. + Department Name + {xpath_ref%../../../../../../meta/names/dev/email/text()} + {xpath_ref%build/paths/ssl/text()}/{xpath_ref%//meta/names/uxname/text()}.crt - - {xpath_ref%build/paths/ssl/text()}/{xpath_ref%//meta/names/uxname/text()}.key + + {xpath_ref%build/paths/ssl/text()}/{xpath_ref%//meta/names/uxname/text()}.key + + domain.tld (client) + XX + Some City + Some State + Some Org, Inc. + Department Name + {xpath_ref%../../../../../../meta/names/dev/email/text()} + {xpath_ref%meta/dev/website/text()}/ipxe - + - - + + root /srv/http/{xpath_ref%//meta/names/uxname/text()} @@ -105,7 +124,7 @@ - + AnotherCD @@ -120,34 +139,30 @@ https://domain.tld/projname 0.0.1 - 3 + 5 atotallyinsecurepassword testuser Test User - atestpassword + testpassword - + http://archlinux.mirror.domain.tld /iso/latest - {xpath_ref%../mirror/text()}/{xpath_ref%../webroot/text()}/archlinux-bootstrap-*-x86_64.tar.gz - {xpath_ref%../mirror/text()}/{xpath_ref%../webroot/text()}/sha1sums.txt - {xpath_ref%../tarball/text()}.sig + {xpath_ref%../mirror/text()}{xpath_ref%../webroot/text()}/archlinux-bootstrap-*-x86_64.tar.gz + {xpath_ref%../mirror/text()}{xpath_ref%../webroot/text()}/sha1sums.txt + {xpath_ref%../tarball/text()}.sig http://archlinux32.mirror.domain.tld /iso/latest {xpath_ref%../mirror/text()}/{xpath_ref%../webroot/text()}/archlinux-bootstrap-*-i686.tar.gz {xpath_ref%../mirror/text()}/{xpath_ref%../webroot/text()}/sha512sums.txt - {xpath_ref%../tarball/text()}.sig + {xpath_ref%../tarball/text()}.sig @@ -166,22 +181,42 @@ archlinux - + {xpath_ref%build/paths/ssl/text()}/ca.crt - {xpath_ref%build/paths/ssl/text()}/ca.key + + {xpath_ref%build/paths/ssl/text()}/ca.key + + domain.tld + XX + Some City + Some State + Some Org, Inc. + Department Name + {xpath_ref%../../../../../../meta/names/dev/email/text()} + {xpath_ref%build/paths/ssl/text()}/{xpath_ref%//meta/names/uxname/text()}.crt - {xpath_ref%build/paths/ssl/text()}/{xpath_ref%//meta/names/uxname/text()}.key + + {xpath_ref%build/paths/ssl/text()}/{xpath_ref%//meta/names/uxname/text()}.key + + domain.tld (client) + XX + Some City + Some State + Some Org, Inc. + Department Name + {xpath_ref%../../../../../../meta/names/dev/email/text()} + {xpath_ref%meta/dev/website/text()}/ipxe - + - - + + root /srv/http/{xpath_ref%//meta/names/uxname/text()} diff --git a/docs/examples/regen_multi.py b/docs/examples/regen_multi.py new file mode 100755 index 0000000..c7a846a --- /dev/null +++ b/docs/examples/regen_multi.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python3.6 + +import copy +from lxml import etree + +with open('single_profile.xml', 'rb') as f: + xml = etree.fromstring(f.read()) + +single_profile = xml.xpath('/bdisk/profile[1]')[0] +alt_profile = copy.deepcopy(single_profile) +for c in alt_profile.xpath('//comment()'): + p = c.getparent() + p.remove(c) + +# Change the profile identifiers +alt_profile.attrib['name'] = 'alternate' +alt_profile.attrib['id'] = '2' +alt_profile.attrib['uuid'] = '2ed07c19-2071-4d66-8569-da40475ba716' + +meta_tags = {'name': 'AnotherCD', + 'uxname': 'bdisk_alt', + 'pname': '{xpath_ref%../name/text()}', + 'desc': 'Another rescue/restore live environment.', + 'author': 'Another Dev Eloper', + 'email': '{xpath_ref%//profile[@name="default"]/meta/dev/email/text()}', + 'website': '{xpath_ref%//profile[@name="default"]/meta/dev/website/text()}', + 'ver': '0.0.1'} +# Change the names +meta = alt_profile.xpath('/profile/meta')[0] +for e in meta.iter(): + if e.tag in meta_tags: + e.text = meta_tags[e.tag] + +accounts_tags = {'rootpass': 'atotallyinsecurepassword', + 'username': 'testuser', + 'name': 'Test User', + 'passowrd': 'atestpassword'} +accounts = alt_profile.xpath('/profile/accounts')[0] +for e in accounts.iter(): + if e.tag in accounts_tags: + e.text = accounts_tags[e.tag] + if e.tag == 'rootpass': + e.attrib['hashed'] = 'no' + elif e.tag == 'user': + e.attrib['sudo'] = 'no' +# Delete the second user +accounts.remove(accounts[2]) +xml.append(alt_profile) + +#print(etree.tostring(xml).decode('utf-8')) +with open('multi_profile.xml', 'wb') as f: + f.write(b'\n' + etree.tostring(xml, + pretty_print = True)) diff --git a/docs/examples/single_profile.xml b/docs/examples/single_profile.xml index eabf36c..e74e3af 100644 --- a/docs/examples/single_profile.xml +++ b/docs/examples/single_profile.xml @@ -81,6 +81,12 @@ {xpath_ref%build/paths/ssl/text()}/ca.crt + {xpath_ref%build/paths/ssl/text()}/ca.key