Initial commit
This commit is contained in:
commit
df5befa9d1
45 changed files with 2030 additions and 0 deletions
23
root-fs/usr/bin/wallaby_set_hostname.py
Executable file
23
root-fs/usr/bin/wallaby_set_hostname.py
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from subprocess import check_output, call
|
||||
|
||||
bot_id = "bot"
|
||||
|
||||
for i2c in range(4):
|
||||
bot_id += check_output("i2cget -y 0 0x50 0x4%i" % i2c, shell=True).decode()[-2]
|
||||
|
||||
new_hosts_content = ""
|
||||
|
||||
for line in open("/etc/hosts", "r").read().split("\n"):
|
||||
if line.startswith("127.0.1.1"):
|
||||
new_hosts_content += "127.0.1.1\t%s\n" % bot_id
|
||||
elif line != "":
|
||||
new_hosts_content += "%s\n" % line
|
||||
|
||||
open("/etc/hosts", "w").write(new_hosts_content)
|
||||
|
||||
call("hostnamectl set-hostname %s" % bot_id, shell=True)
|
||||
call("systemctl restart avahi-daemon", shell=True)
|
||||
|
||||
print("Hostname set: '%s'" % bot_id)
|
Reference in a new issue