introduce hostname stage
this stage will set /etc/hostname in the image. it uses systemd-firstboot to perform the change
This commit is contained in:
parent
4c91a23e98
commit
c27cdd5928
1 changed files with 25 additions and 0 deletions
25
stages/org.osbuild.hostname
Executable file
25
stages/org.osbuild.hostname
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def main(tree, options):
|
||||
hostname = options["hostname"]
|
||||
try:
|
||||
os.remove(f"{tree}/etc/hostname")
|
||||
print("/etc/hostname already exists. Replacing.")
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
subprocess.run(["systemd-firstboot", f"--root={tree}", f"--hostname={hostname}"], check=True)
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = json.load(sys.stdin)
|
||||
r = main(args["tree"], args["options"])
|
||||
sys.exit(r)
|
||||
Loading…
Add table
Add a link
Reference in a new issue