checkin for progress
This commit is contained in:
parent
c28b4b8889
commit
a60d4780ba
14
TODO
14
TODO
@ -1,13 +1,11 @@
|
|||||||
- config layout
|
- config layout
|
||||||
-- need to apply defaults and annotate/document
|
-- need to apply defaults and annotate/document
|
||||||
|
|
||||||
find out where to run aif-pre.sh (runs on host) (rename to aif-pre.script)
|
SCRATCH: find out where to run aif-pre.sh (runs on host) (rename to aif-pre.script)
|
||||||
and get a way to insert that and aif-post(.script) from the kernel params, etc.
|
and get a way to insert that and aif-post(.script) from the kernel params, etc.
|
||||||
remember to uncomment the functions in main() when ready to test
|
remember to uncomment the functions in main() when ready to test
|
||||||
|
INSTEAD: scripts['setup']?
|
||||||
|
|
||||||
- use sgdisk? scripting (generated by python) for disk partitioning (part types listed at http://www.rodsbooks.com/gdisk/walkthrough.html )
|
|
||||||
-- actually, might want to use parted --script instead? then we can do percentages. https://www.gnu.org/software/parted/manual/parted.html
|
|
||||||
https://unix.stackexchange.com/questions/200582/scripteable-gpt-partitions-using-parted
|
|
||||||
- add mkfs-ing
|
- add mkfs-ing
|
||||||
- how to support mdadm, lvm?
|
- how to support mdadm, lvm?
|
||||||
|
|
||||||
@ -19,16 +17,12 @@ would yield the *client* sending info via URL params, e.g.
|
|||||||
|
|
||||||
parser: make sure to use https://mikeknoop.com/lxml-xxe-exploit/ fix
|
parser: make sure to use https://mikeknoop.com/lxml-xxe-exploit/ fix
|
||||||
|
|
||||||
left off at network config- i think i just have software/packages/etc. next, unless i already did that
|
|
||||||
|
|
||||||
convert use of confobj or whatever to maybe be suitable to use webFetch instead. LOTS of duplicated code there.
|
convert use of confobj or whatever to maybe be suitable to use webFetch instead. LOTS of duplicated code there.
|
||||||
|
|
||||||
need to write docs
|
need to write docs
|
||||||
|
|
||||||
make sure you call install.scripts or whatever it's called in main()
|
need to double-check aif.xsd spec for the packaging command- can i specify a single element?
|
||||||
|
finish up software/packages section
|
||||||
update aif.xsd for auth stuff in scripts
|
|
||||||
|
|
||||||
|
|
||||||
docs:
|
docs:
|
||||||
http://lxml.de/parsing.html
|
http://lxml.de/parsing.html
|
||||||
|
12
aif.xsd
12
aif.xsd
@ -114,6 +114,12 @@
|
|||||||
<xs:pattern value="(grub|systemd|syslinux)" />
|
<xs:pattern value="(grub|systemd|syslinux)" />
|
||||||
</xs:restriction>
|
</xs:restriction>
|
||||||
</xs:simpleType>
|
</xs:simpleType>
|
||||||
|
|
||||||
|
<xs:simpleType name="authselect">
|
||||||
|
<xs:restriction base="xs:token">
|
||||||
|
<xs:pattern value="(basic|digest)" />
|
||||||
|
</xs:restriction>
|
||||||
|
</xs:simpleType>
|
||||||
|
|
||||||
<!-- ROOT -->
|
<!-- ROOT -->
|
||||||
<xs:element name="aif">
|
<xs:element name="aif">
|
||||||
@ -262,6 +268,7 @@
|
|||||||
<xs:element name="pacman" maxOccurs="1" minOccurs="1">
|
<xs:element name="pacman" maxOccurs="1" minOccurs="1">
|
||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
<xs:sequence>
|
<xs:sequence>
|
||||||
|
<xs:element name="command" maxOccurs="1" minOccurs="0" />
|
||||||
<xs:element name="repos" maxOccurs="1" minOccurs="1">
|
<xs:element name="repos" maxOccurs="1" minOccurs="1">
|
||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
<xs:sequence>
|
<xs:sequence>
|
||||||
@ -319,9 +326,12 @@
|
|||||||
<xs:element name="script" minOccurs="1" maxOccurs="unbounded">
|
<xs:element name="script" minOccurs="1" maxOccurs="unbounded">
|
||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
<xs:attribute name="uri" type="scripturi" use="required" />
|
<xs:attribute name="uri" type="scripturi" use="required" />
|
||||||
<xs:attribute name="lang" type="devlang" />
|
|
||||||
<xs:attribute name="order" type="xs:integer" use="required" />
|
<xs:attribute name="order" type="xs:integer" use="required" />
|
||||||
<xs:attribute name="bootstrap" type="xs:boolean" use="required" />
|
<xs:attribute name="bootstrap" type="xs:boolean" use="required" />
|
||||||
|
<xs:attribute name="user" type="xs:string" />
|
||||||
|
<xs:attribute name="password" type="xs:string" />
|
||||||
|
<xs:attribute name="realm" type="xs:string" />
|
||||||
|
<xs:attribute name="authtype" type="authselect" />
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
</xs:sequence>
|
</xs:sequence>
|
||||||
|
86
aifclient.py
86
aifclient.py
@ -717,57 +717,77 @@ class archInstall(object):
|
|||||||
return(bootcmds)
|
return(bootcmds)
|
||||||
|
|
||||||
def scriptcmds(self):
|
def scriptcmds(self):
|
||||||
if xmlobj.find('scripts') is not None:
|
if xmlobj.find('scripts') is not None:
|
||||||
self.scripts['pre'] = []
|
self.scripts['pre'] = []
|
||||||
self.scripts['post'] = []
|
self.scripts['post'] = []
|
||||||
tempscriptdict = {'pre': {}, 'post': {}}
|
tempscriptdict = {'pre': {}, 'post': {}}
|
||||||
for x in xmlobj.find('scripts'):
|
for x in xmlobj.find('scripts'):
|
||||||
if all(keyname in list(x.attrib.keys()) for keyname in ('user', 'password')):
|
if all(keyname in list(x.attrib.keys()) for keyname in ('user', 'password')):
|
||||||
auth = {}
|
auth = {}
|
||||||
auth['user'] = x.attrib['user']
|
auth['user'] = x.attrib['user']
|
||||||
auth['password'] = x.attrib['password']
|
auth['password'] = x.attrib['password']
|
||||||
if 'realm' in x.attrib.keys():
|
if 'realm' in x.attrib.keys():
|
||||||
auth['realm'] = x.attrib['realm']
|
auth['realm'] = x.attrib['realm']
|
||||||
if 'authtype' in x.attrib.keys():
|
if 'authtype' in x.attrib.keys():
|
||||||
auth['type'] = x.attrib['authtype']
|
auth['type'] = x.attrib['authtype']
|
||||||
scriptcontents = self.webFetch(x.attrib['uri']).decode('utf-8')
|
scriptcontents = self.webFetch(x.attrib['uri'], auth).decode('utf-8')
|
||||||
else:
|
else:
|
||||||
scriptcontents = self.webFetch(x.attrib['uri']).decode('utf-8')
|
scriptcontents = self.webFetch(x.attrib['uri']).decode('utf-8')
|
||||||
if x.attrib['bootstrap'].lower() in ('true', '1'):
|
if x.attrib['bootstrap'].lower() in ('true', '1'):
|
||||||
tempscriptdict['pre'][x.attrib['order']] = scriptcontents
|
tempscriptdict['pre'][x.attrib['order']] = scriptcontents
|
||||||
else:
|
else:
|
||||||
tempscriptdict['post'][x.attrib['order']] = scriptcontents
|
tempscriptdict['post'][x.attrib['order']] = scriptcontents
|
||||||
for d in ('pre', 'post'):
|
for d in ('pre', 'post'):
|
||||||
keylst = list(tempscriptdict[d].keys())
|
keylst = list(tempscriptdict[d].keys())
|
||||||
keylst.sort()
|
keylst.sort()
|
||||||
for s in keylst:
|
for s in keylst:
|
||||||
aifdict['scripts'][d].append(tempscriptdict[d][s])
|
self.scripts[d].append(tempscriptdict[d][s])
|
||||||
|
|
||||||
def chroot(self, chrootcmds = False, bootcmds = False):
|
def packagecmds(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def chroot(self, chrootcmds = False, bootcmds = False, scriptcmds = False):
|
||||||
if not chrootcmds:
|
if not chrootcmds:
|
||||||
chrootcmds = self.setup()
|
chrootcmds = self.setup()
|
||||||
if not bootcmds:
|
if not bootcmds:
|
||||||
bootcmds = self.bootloader()
|
bootcmds = self.bootloader()
|
||||||
|
if not scriptcmds:
|
||||||
|
scriptcmds = self.scripts
|
||||||
# We don't need this currently, but we might down the road.
|
# We don't need this currently, but we might down the road.
|
||||||
#chrootscript = '#!/bin/bash\n# https://aif.square-r00t.net/\n\n'
|
#chrootscript = '#!/bin/bash\n# https://aif.square-r00t.net/\n\n'
|
||||||
#with open('{0}/root/aif.sh'.format(self.system['chrootpath']), 'w') as f:
|
#with open('{0}/root/aif.sh'.format(self.system['chrootpath']), 'w') as f:
|
||||||
# f.write(chrootscript)
|
# f.write(chrootscript)
|
||||||
#os.chmod('{0}/root/aif.sh'.format(self.system['chrootpath']), 0o700)
|
#os.chmod('{0}/root/aif.sh'.format(self.system['chrootpath']), 0o700)
|
||||||
with open('{0}/root/aif-pre.sh'.format(self.system['chrootpath']), 'w') as f:
|
for t in self.scripts.keys():
|
||||||
f.write(self.scripts['pre'])
|
os.makedirs('{0}/root/scripts/{1}'.format(self.system['chrootpath'], t), exist_ok = True)
|
||||||
with open('{0}/root/aif-post.sh'.format(self.system['chrootpath']), 'w') as f:
|
cnt = 0
|
||||||
f.write(self.scripts['post'])
|
for s in self.scripts[t]:
|
||||||
|
with open('{0}/root/scripts/{1}/{2}'.format(self.system['chrootpath'],
|
||||||
|
t,
|
||||||
|
cnt), 'w') as f:
|
||||||
|
f.write(self.scripts[t][cnt])
|
||||||
|
os.chmod('{0}/root/scripts/{1}/{2}'.format(self.system['chrootpath'],
|
||||||
|
t,
|
||||||
|
cnt), 0o700)
|
||||||
|
cnt += 1
|
||||||
real_root = os.open("/", os.O_RDONLY)
|
real_root = os.open("/", os.O_RDONLY)
|
||||||
os.chroot(self.system['chrootpath'])
|
os.chroot(self.system['chrootpath'])
|
||||||
# Does this even work with an os.chroot()? Let's hope so!
|
# Does this even work with an os.chroot()? Let's hope so!
|
||||||
with open(os.devnull, 'w') as DEVNULL:
|
with open(os.devnull, 'w') as DEVNULL:
|
||||||
|
if scriptcmds['pre']:
|
||||||
|
for s in len(scriptcmds['pre']):
|
||||||
|
script = '/root/scripts/pre/{0}'.format(s - 1)
|
||||||
|
subprocess.call(script, stdout = DEVNULL, stderr = subprocess.STDOUT)
|
||||||
for c in chrootcmds:
|
for c in chrootcmds:
|
||||||
subprocess.call(c, stdout = DEVNULL, stderr = subprocess.STDOUT)
|
subprocess.call(c, stdout = DEVNULL, stderr = subprocess.STDOUT)
|
||||||
for b in bootcmds:
|
for b in bootcmds:
|
||||||
subprocess.call(b, stdout = DEVNULL, stderr = subprocess.STDOUT)
|
subprocess.call(b, stdout = DEVNULL, stderr = subprocess.STDOUT)
|
||||||
os.system('{0}/root/aif-pre.sh'.format(self.system['chrootpath']))
|
if scriptcmds['post']:
|
||||||
#os.system('{0}/root/aif.sh'.format(self.system['chrootpath']))
|
for s in len(scriptcmds['post']):
|
||||||
os.system('{0}/root/aif-post.sh'.format(self.system['chrootpath']))
|
script = '/root/scripts/post/{0}'.format(s - 1)
|
||||||
|
subprocess.call(script, stdout = DEVNULL, stderr = subprocess.STDOUT)
|
||||||
|
#os.system('{0}/root/aif-pre.sh'.format(self.system['chrootpath']))
|
||||||
|
#os.system('{0}/root/aif-post.sh'.format(self.system['chrootpath']))
|
||||||
os.fchdir(real_root)
|
os.fchdir(real_root)
|
||||||
os.chroot('.')
|
os.chroot('.')
|
||||||
os.close(real_root)
|
os.close(real_root)
|
||||||
|
Loading…
Reference in New Issue
Block a user