Compare commits
13 Commits
0.0.1-BETA
...
0.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a88b4347c | ||
|
|
9278cd016a | ||
|
|
0a99af21ee | ||
|
|
a28121cbab | ||
|
|
32980870b7 | ||
|
|
c64b800618 | ||
|
|
ffedfaf684 | ||
|
|
f744d7e5d4 | ||
|
|
935df2083f | ||
|
|
09d6632e3a | ||
|
|
df26d0394b | ||
|
|
517d8135cc | ||
|
|
b7ef1d5ea3 |
10
aif.xml
10
aif.xml
@@ -15,7 +15,7 @@
|
||||
<network hostname="aiftest.square-r00t.net">
|
||||
<iface device="auto" address="auto" netproto="ipv4" />
|
||||
</network>
|
||||
<system timezone="EST5EDT" locale="en_US.UTF-8" chrootpath="/mnt/aif">
|
||||
<system timezone="EST5EDT" locale="en_US.UTF-8" chrootpath="/mnt/aif" reboot="0">
|
||||
<!-- note: all password hashes below are "test"; don't waste your time trying to crack. :) -->
|
||||
<users rootpass="$6$3YPpiS.l3SQC6ELe$NQ4qMvcDpv5j1cCM6AGNc5Hyg.rsvtzCt2VWlSbuZXCGg2GB21CMUN8TMGS35tdUezZ/n9y3UFGlmLRVWXvZR.">
|
||||
<user name="aifusr"
|
||||
@@ -58,9 +58,9 @@
|
||||
</pacman>
|
||||
<bootloader type="grub" target="/boot" efi="true" />
|
||||
<scripts>
|
||||
<script uri="https://aif.square-r00t.net/sample-scripts/post/first.sh" order="1" bootstrap="0" />
|
||||
<script uri="https://aif.square-r00t.net/sample-scripts/pre/second.pl" order="2" bootstrap="1" />
|
||||
<script uri="https://aif.square-r00t.net/sample-scripts/pre/first.sh" order="1" bootstrap="1" />
|
||||
<script uri="https://aif.square-r00t.net/sample-scripts/post/second.py" order="2" bootstrap="0" />
|
||||
<script uri="https://aif.square-r00t.net/sample-scripts/post/first.sh" order="1" execution="post" />
|
||||
<script uri="https://aif.square-r00t.net/sample-scripts/pre/second.pl" order="2" execution="pre" />
|
||||
<script uri="https://aif.square-r00t.net/sample-scripts/pre/first.sh" order="1" execution="pre" />
|
||||
<script uri="https://aif.square-r00t.net/sample-scripts/post/second.py" order="2" execution="post" />
|
||||
</scripts>
|
||||
</aif>
|
||||
|
||||
1
aif.xsd
1
aif.xsd
@@ -265,6 +265,7 @@
|
||||
<xs:attribute name="locale" type="xs:string" use="required" />
|
||||
<xs:attribute name="chrootpath" type="xs:string" user="required" />
|
||||
<xs:attribute name="kbd" type="xs:token" />
|
||||
<xs:attribute name="reboot" type="xs:boolean" />
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<!-- END SYSTEM -->
|
||||
|
||||
26
aifclient.py
26
aifclient.py
@@ -16,6 +16,7 @@ try:
|
||||
except ImportError:
|
||||
import xml.etree.ElementTree as etree # https://docs.python.org/3/library/xml.etree.elementtree.html
|
||||
lxml_avail = False
|
||||
import datetime
|
||||
import shlex
|
||||
import fileinput
|
||||
import os
|
||||
@@ -31,7 +32,7 @@ import urllib.response as urlresponse
|
||||
from ftplib import FTP_TLS
|
||||
from io import StringIO
|
||||
|
||||
logfile = '/root/log'
|
||||
logfile = '/root/aif.log.{0}'.format(int(datetime.datetime.utcnow().timestamp()))
|
||||
|
||||
class aif(object):
|
||||
|
||||
@@ -285,9 +286,11 @@ class aif(object):
|
||||
aifdict['system']['locale'] = False
|
||||
aifdict['system']['kbd'] = False
|
||||
aifdict['system']['chrootpath'] = False
|
||||
for i in ('locale', 'timezone', 'kbd', 'chrootpath'):
|
||||
aifdict['system']['reboot'] = False
|
||||
for i in ('locale', 'timezone', 'kbd', 'chrootpath', 'reboot'):
|
||||
if i in xmlobj.find('system').attrib:
|
||||
aifdict['system'][i] = xmlobj.find('system').attrib[i]
|
||||
aifdict['system']['reboot'] = aifdict['system']['reboot'].lower() in ('true', '1')
|
||||
# And now services...
|
||||
if xmlobj.find('system/service') is None:
|
||||
aifdict['system']['services'] = False
|
||||
@@ -335,7 +338,8 @@ class aif(object):
|
||||
if xmlobj.find('scripts') is not None:
|
||||
aifdict['scripts']['pre'] = []
|
||||
aifdict['scripts']['post'] = []
|
||||
tempscriptdict = {'pre': {}, 'post': {}}
|
||||
aifdict['scripts']['pkg'] = []
|
||||
tempscriptdict = {'pre': {}, 'post': {}, 'pkg': {}}
|
||||
for x in xmlobj.find('scripts'):
|
||||
if all(keyname in list(x.attrib.keys()) for keyname in ('user', 'password')):
|
||||
auth = {}
|
||||
@@ -815,8 +819,8 @@ class archInstall(object):
|
||||
else:
|
||||
mirror = 'Server = {0}'.format(self.software['repos'][r]['mirror'])
|
||||
newentry = ['[{0}]\n'.format(r), '{0}\n'.format(mirror)]
|
||||
if self.software['repos'][r][siglevel] != 'default':
|
||||
newentry.append('Siglevel = {0}\n'.format(self.software['repos'][r][siglevel]))
|
||||
if self.software['repos'][r]['siglevel'] != 'default':
|
||||
newentry.append('Siglevel = {0}\n'.format(self.software['repos'][r]['siglevel']))
|
||||
if self.software['repos'][r]['enabled']:
|
||||
pass # I know, shame on me. We want this because we explicitly want it to be set as True
|
||||
else:
|
||||
@@ -849,8 +853,7 @@ class archInstall(object):
|
||||
if self.software['packages']:
|
||||
for p in self.software['packages'].keys():
|
||||
if self.software['packages'][p]['repo']:
|
||||
pkgname = '{0}/{1}'.format(self.software['packages'][p]['repo'],
|
||||
self.software['packages'][p])
|
||||
pkgname = '{0}/{1}'.format(self.software['packages'][p]['repo'], p)
|
||||
else:
|
||||
pkgname = p
|
||||
pkgr.append(pkgname)
|
||||
@@ -881,6 +884,9 @@ class archInstall(object):
|
||||
scripts = self.scripts
|
||||
if not pkgcmds:
|
||||
pkgcmds = self.packagecmds()
|
||||
# Switch in the log, and link.
|
||||
os.rename(logfile, '{0}/{1}'.format(self.system['chrootpath'], logfile))
|
||||
os.symlink('{0}/{1}'.format(self.system['chrootpath'], logfile), logfile)
|
||||
self.pacmanSetup() # This needs to be done before the chroot
|
||||
# We don't need this currently, but we might down the road.
|
||||
#chrootscript = '#!/bin/bash\n# https://aif.square-r00t.net/\n\n'
|
||||
@@ -922,6 +928,9 @@ class archInstall(object):
|
||||
def unmount(self):
|
||||
with open(logfile, 'a') as log:
|
||||
subprocess.call(['umount', '-lR', self.system['chrootpath']], stdout = log, stderr = subprocess.STDOUT)
|
||||
# We should also remove the (now dead) log symlink.
|
||||
#Note that this does NOT delete the logfile on the installed system.
|
||||
os.remove(logfile)
|
||||
return()
|
||||
|
||||
def runInstall(confdict):
|
||||
@@ -942,7 +951,8 @@ def main():
|
||||
with open(logfile, 'a') as log:
|
||||
pprint.pprint(instconf, stream = log)
|
||||
runInstall(instconf)
|
||||
subprocess.call(['reboot'])
|
||||
if instconf['system']['reboot']:
|
||||
subprocess.run(['reboot'])
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -137,6 +137,48 @@ Configure your bootloader to add the following options as necessary:
|
||||
** The same behavior applies for `aif_password`.
|
||||
* If `aif_auth` is `digest`, this is the realm we would use (we attempt to "guess" if it isn’t specified); otherwise it is ignored.
|
||||
|
||||
== Building a compatible LiveCD
|
||||
The default Arch install CD does not have AIF installed (yet... ;). You have two options of using AIF-NG.
|
||||
|
||||
=== Recommended
|
||||
The recommended option is to use https://bdisk.square-r00t.net/[BDisk^] (the author should look familiar ;) and per https://bdisk.square-r00t.net/#advanced_customization[the documentation^], you would simply create the following modifications (remember to replace *<BDisk directory>* with your actual BDisk directory):
|
||||
|
||||
. `mkdir -p *<BDisk directory>*/overlay/etc/systemd/system/multi-target.wants`
|
||||
. `ln -s /etc/systemd/system/aif.service *<BDisk directory>*/overlay/etc/systemd/system/multi-target.wants/aif.service`
|
||||
.. (NOTE: This is not a typo; the symlink will resolve to the correct place during the build)
|
||||
. `printf '[Unit]\nDescription=AIF-NG Client Service\nAfter=livecdfix.service\n\n[Service]\nType=oneshot\nExecStart=/usr/bin/aif\n\n[Install]\nWantedBy=multi-user.target\n' > *<BDisk directory>*/overlay/etc/systemd/system/aif.service`
|
||||
.. (NOTE: This is all one line.)
|
||||
.. (NOTE: We use a custom aif.service instead of the AUR package provided one because of how BDisk handles bringing up the network.)
|
||||
. `echo "aif-git" > *<BDisk directory>*/extra/pre-build.d/root/packages.both`
|
||||
. If you want automatic root login on TTY1 like the Arch install ISO (optional):
|
||||
.. `mkdir -p *<BDisk directory>*/overlay/etc/systemd/system/getty\@tty1.service.d`
|
||||
.. `printf '[Service]\nType=idle\nExecStart=\nExecStart=-/usr/bin/agetty --autologin root --noclear %%I 38400 linux\n' > *<BDisk directory>*/overlay/etc/systemd/system/getty\@tty1.service.d`
|
||||
... (NOTE: This is all one line.)
|
||||
|
||||
Remember to also create a https://bdisk.square-r00t.net/#the_code_build_ini_code_file[build.ini file^]. You can find a compatible one https://git.square-r00t.net/AIF-NG/plain/extras/bdisk.build.ini[here^] (but remember to tailor it to your particular paths and needs first!).
|
||||
|
||||
Make any further customizations as you wish, then https://bdisk.square-r00t.net/#building_a_bdisk_iso[start the build^].
|
||||
|
||||
=== Quickest
|
||||
For convenience, I've already built a LiveCD that will auto-start AIF. Note, however, that it is configured to my personal preferences (it installs https://aif.square-r00t.net/cfgs/scripts/pkg/python.sh[python3^], installs https://aif.square-r00t.net/cfgs/scripts/pkg/apacman.py[apacman^] (and configures it and pacman to my tastes), sets up a more strict https://aif.square-r00t.net/cfgs/scripts/post/sshsecure.py[SSH configuration^], and https://aif.square-r00t.net/cfgs/scripts/post/sshkeys.py[installs my SSH pubkeys^].), so you may want to use the recommended method above instead.
|
||||
|
||||
==== The full environment
|
||||
A full ISO build is https://aif.square-r00t.net/download/aif.iso[here] (GPG signatures are available in https://aif.square-r00t.net/download/aif.iso.sig[SIG] and https://aif.square-r00t.net/download/aif.iso.asc[ASC^] format; make sure you https://devblog.square-r00t.net/about/my-gpg-public-key-verification-of-identity[verify it^]).
|
||||
|
||||
It has a full GNU/Linux environment that you can use, and works on both UEFI and BIOS systems. It boots to a non-passworded root login, but AIF will be running in the background. SSH is installed and configured for key-based authentication only, but is not enabled by default.
|
||||
|
||||
==== The iPXE environment
|
||||
If you would like to boot over the network, I have an iPXE ISO https://aif.square-r00t.net/download/aif-mini.iso[here] (GPG signatures are available in https://aif.square-r00t.net/download/aif-mini.iso.sig[SIG] and https://aif.square-r00t.net/download/aif-mini.iso.asc[ASC^] format; make sure you https://devblog.square-r00t.net/about/my-gpg-public-key-verification-of-identity[verify it^]).
|
||||
|
||||
You will need at least 2GB of RAM, as it loads entirely into memory.
|
||||
|
||||
It also boots to a full GNU/Linux environment that you can use, and works on both UEFI and BIOS systems. It boots to a non-passworded root login, but AIF will be running in the background. SSH is installed and configured for key-based authentication only, but is not enabled by default.
|
||||
|
||||
|
||||
|
||||
== Logging
|
||||
Currently, only one method of logging is enabled, and is always enabled. It can be found on the host and guest at */root/aif.log._<UNIX epoch timestamp>_*. Note that after the build finishes successfully, it will remove the host's log (as it's just a broken symlink at that point). You will be able to find the full log in the guest after the install, however.
|
||||
|
||||
== Debugging
|
||||
Sometimes it's useful to get a little more information, or to start an installation from within an already-booted environment and you didn't remember (or weren't able to) change the kernel parameters. If this is the case, simply export the `DEBUG` environment variable (it can be set to anything, it doesn't matter) -- if this is done, the arguments will be read from /tmp/cmdline instead. e.g.:
|
||||
|
||||
@@ -146,7 +188,7 @@ Sometimes it's useful to get a little more information, or to start an installat
|
||||
chmod 600 /tmp/cmdline
|
||||
sed -i -e '1s/$/ aif aif_url=https:\/\/aif.square-r00t.net\/aif.xml/' /tmp/cmdline
|
||||
|
||||
It will also write the full configuration (*after* parsing) to `/root/log`.
|
||||
It will also write the full configuration (*after* parsing) to the <<logging, logfile>>.
|
||||
|
||||
= Writing an XML Configuration File
|
||||
I've included a sample `aif.xml` file with the project which is fully functional. However, it's not ideal -- namely because it will add my personal SSH pubkeys to your new install, and you probably don't want that. However, it's fairly complete so it should serve as a good example. If you want to see the full set of supported configuration elements, take a look at the most up-to-date https://aif.square-r00t.net/aif.xsd[aif.xsd^]. For explanation's sake, however, we'll go through it here. The directives are referred to in https://www.w3schools.com/xml/xml_xpath.asp[XPath^] syntax within the documentation text for easier context (but not the titles).
|
||||
@@ -349,6 +391,7 @@ The `/aif/system` element is for handling general system configuration. It conta
|
||||
^m|locale |The https://wiki.archlinux.org/index.php/Locale#Setting_the_system_locale[locale^] of the installed system (e.g. `en_US.UTF-8`); if a short version is used (e.g. `en`), then all locales starting with that prefix will be enabled (multiple explicit locale support is in the TODO)
|
||||
^m|chrootpath |The path on the host that will serve as the https://wiki.archlinux.org/index.php/Change_root[chroot^] path. This should be where your new install's / (root filesystem partition) is mounted at in <<code_mount_code, mounts>>
|
||||
^m|kbd |The https://wiki.archlinux.org/index.php/installation_guide#Set_the_keyboard_layout[keyboard layout^] (if not US)
|
||||
^m|reboot |If we should reboot the system after the install (in order to boot to the newly-installed system, assuming your boot order is set correctly). Boolean, accepts `1`/`true` or `0`/`false`.
|
||||
|======================
|
||||
|
||||
==== `<users>`
|
||||
|
||||
@@ -26,9 +26,8 @@
|
||||
DOCUMENTATION: BUG REPORTS/FEATURE REQUESTS!!!!
|
||||
|
||||
also create:
|
||||
-systemd unit to start on boot
|
||||
-mkinitcpio hooks to start from initrd environment (minimal boot env)
|
||||
-create boot media with bdisk since default arch doesn't even have python 3
|
||||
-- this is.. sort of? done. but iPXE/mini build is failing, need to investigate why
|
||||
|
||||
|
||||
docs:
|
||||
|
||||
104
extras/bdisk.build.ini
Normal file
104
extras/bdisk.build.ini
Normal file
@@ -0,0 +1,104 @@
|
||||
###########################################################
|
||||
## BUILD.CONF SAMPLE FILE ##
|
||||
###########################################################
|
||||
#
|
||||
# This file is used to define various variables/settings
|
||||
# used by the build script.
|
||||
#
|
||||
# For full (perhaps overly-verbose ;) documentation, please
|
||||
# see:
|
||||
# https://bdisk.square-r00t.net/#_the_code_build_ini_code_file
|
||||
# Or simply refer to the section titled "The build.ini File"
|
||||
# in the user manual.
|
||||
|
||||
[bdisk]
|
||||
name = AIF
|
||||
uxname = aif
|
||||
pname = AIF-NG
|
||||
ver = 1.00
|
||||
dev = r00t^2
|
||||
email = bts@square-r00t.net
|
||||
desc = See https://aif.square-r00t.net/
|
||||
uri = https://aif.square-r00t.net/
|
||||
root_password = BLANK
|
||||
user = no
|
||||
|
||||
[user]
|
||||
username = ${bdisk:uxname}
|
||||
name = Default user
|
||||
password = BLANK
|
||||
|
||||
[source_x86_64]
|
||||
mirror = mirror.us.leaseweb.net
|
||||
#mirrorproto = https
|
||||
mirrorproto = http
|
||||
mirrorpath = /archlinux/iso/latest/
|
||||
mirrorfile =
|
||||
mirrorchksum = ${mirrorpath}sha1sums.txt
|
||||
chksumtype = sha1
|
||||
mirrorgpgsig = .sig
|
||||
gpgkey = 4AA4767BBC9C4B1D18AE28B77F2D434B9741E8AC
|
||||
gpgkeyserver =
|
||||
|
||||
[source_i686]
|
||||
mirror = mirror.us.leaseweb.net
|
||||
#mirrorproto = https
|
||||
mirrorproto = http
|
||||
mirrorpath = /archlinux/iso/latest/
|
||||
mirrorfile =
|
||||
mirrorchksum = ${mirrorpath}sha1sums.txt
|
||||
chksumtype = sha1
|
||||
mirrorgpgsig = .sig
|
||||
gpgkey = 7F2D434B9741E8AC
|
||||
gpgkeyserver =
|
||||
|
||||
[build]
|
||||
gpg = yes
|
||||
dlpath = /var/tmp/${bdisk:uxname}
|
||||
chrootdir = /var/tmp/chroots
|
||||
basedir = /opt/dev/bdisk
|
||||
isodir = ${dlpath}/iso
|
||||
srcdir = ${dlpath}/src
|
||||
prepdir = ${dlpath}/temp
|
||||
archboot = ${prepdir}/${bdisk:name}
|
||||
mountpt = /mnt/${bdisk:uxname}
|
||||
multiarch = 64
|
||||
sign = yes
|
||||
ipxe = yes
|
||||
i_am_a_racecar = yes
|
||||
|
||||
[gpg]
|
||||
mygpgkey = 748231EBCBD808A14F5E85D28C004C2F93481F6B
|
||||
mygpghome = /root/.gnupg
|
||||
|
||||
[sync]
|
||||
http = yes
|
||||
tftp = yes
|
||||
git = no
|
||||
rsync = no
|
||||
|
||||
[http]
|
||||
path = ${build:dlpath}/http
|
||||
user = root
|
||||
group = root
|
||||
|
||||
[tftp]
|
||||
path = ${build:dlpath}/tftpboot
|
||||
user = root
|
||||
group = root
|
||||
|
||||
[ipxe]
|
||||
iso = yes
|
||||
uri = https://aif.square-r00t.net/boot.ipxe
|
||||
ssldir = ${build:dlpath}/ssl
|
||||
ssl_ca = ${ssldir}/ca.crt
|
||||
ssl_cakey = ${ssldir}/ca.key
|
||||
ssl_crt = ${ssldir}/main.crt
|
||||
ssl_key = ${ssldir}/main.key
|
||||
|
||||
[rsync]
|
||||
#host = 10.1.1.1
|
||||
host = bdisk.square-r00t.net
|
||||
user = root
|
||||
path = /srv/http/bdisk_ipxe
|
||||
iso = yes
|
||||
@@ -1,7 +1,7 @@
|
||||
run_hook () {
|
||||
msg ":: Starting AIF-NG..."
|
||||
/usr/bin/aifclient &
|
||||
#nohup /usr/bin/aifclient &
|
||||
/usr/bin/aif &
|
||||
#nohup /usr/bin/aif &
|
||||
#disown -h %1
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
buid() {
|
||||
add_binary "/usr/bin/python"
|
||||
add_binary "/usr/bin/aifclient"
|
||||
add_binary "/usr/bin/aif"
|
||||
|
||||
add_runscript
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ After=network.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/aifclient
|
||||
ExecStart=/usr/bin/aif
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
Reference in New Issue
Block a user