Skip to content

Commit

Permalink
preseed get_firstboot (#45)
Browse files Browse the repository at this point in the history
* added service file

* preseed get_firstboot

* copy service file with ftp

* entrypoint executable

* change firstboot owner to root

* FTP permissions

* template in ftp network info

* preseed fix

* preseed config

* check for keys

* key check

* key check

* Update preseed.cfg.jinja2

* return type fix

* render change

* empty dict args

* None object to none test

---------

Co-authored-by: Robert Gingras <gingrm02@pfw.edu>
  • Loading branch information
r-akers and xeluior authored Feb 16, 2024
1 parent 62888ab commit 8bec794
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
9 changes: 8 additions & 1 deletion genisys/modules/preseed.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ def generate(self: Self) -> str:
if isinstance(value, bool):
self.config["users"][key] = str(value).lower()


return template.render(settings=self.config["users"], ftp=self.config["network"].get("ftp", {}))
# end generate

# end class Preseed

# Read SSH key files and store their contents as strings
ssh_keys_contents = []
ssh_keys_dir = Path("../ssh_keys") # Update this to your directory path
Expand All @@ -51,4 +57,5 @@ def generate(self: Self) -> str:

config = YAMLParser(sys.argv[1])
preseed = Preseed(config)
print(preseed.generate())
print(preseed.generate())

16 changes: 16 additions & 0 deletions genisys/templates/preseed.cfg.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,19 @@ d-i preseed/late_command string \
in-target chmod 644 /root/.ssh/authorized_keys; \
in-target chmod 700 /root/.ssh/
{% endif %}

# copy firstboot.service file to client
{% if ftp.get('ip') is not none and ftp.get('port') is not none %}
d-i preseed/late_command string ftp {{ ftp['ip'] }}:{{ ftp['port'] }}/ftp/first-boot/genisys-firstboot.service /etc/systemd/system/
{% endif %}
d-i preseed/late_command string chmod 0644 /first-boot
d-i preseed/late_command string chown root /first-boot
# enable systemd service
d-i preseed/late_command string systemctl daemon-reload
d-i preseed/late_command string systemctl enable systemd-firstboot.service
# there must be an entrypoint file
# ensure entrypoint is executable
d-i preseed/late_command string chmod +x /first-boot/entrypoint

# change firstboot owner to root
chown -R root:root /first-boot

0 comments on commit 8bec794

Please sign in to comment.