Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pi.id file creation on startup.py #19

Open
yeyeto2788 opened this issue Oct 16, 2018 · 2 comments
Open

pi.id file creation on startup.py #19

yeyeto2788 opened this issue Oct 16, 2018 · 2 comments

Comments

@yeyeto2788
Copy link
Contributor

Hello @schollz,

I have noticed that on first try, the startup.py script tries to find a pi.id file that if it is not on the directory it will create it with and random generated key and then expands the filesystem.

There are 2 things that caught my mind:

1 - Why expanding the filesystem if the file is not present? Is there a reason why the filesystem should be expanded if the file is not on the directory?

2 - If the idea of the of the id_generator() method is to create a unique, let's say, serial number maybe we can use the information on the board itself to get the unique id directly from hardware Something like this:

def id_generator():
  # Extract serial from cpuinfo file
  cpuserial = "0000000000000000"
  try:
    f = open('/proc/cpuinfo','r')
    for line in f:
      if line[0:6]=='Serial':
        cpuserial = line[10:26]
    f.close()
  except:
    cpuserial = "ERROR000000000"

  return cpuserial

We can even have a mix that if the try block fails we can generate it by the method you have implemented, so on the first blocks it will return the real unique serial number and in the second block it will generate it as it is generating it until now.

Best regards.

@ilirb
Copy link
Contributor

ilirb commented Dec 6, 2018

  1. IMO I don't think it is of such importance for the ID to really be unique as it is used only to get the IP and that's it. Of course serial number could work too but I consider it overkill considering the id_generator already exists.

@yeyeto2788
Copy link
Contributor Author

@ilirb thanks for your comment, just wanted to help on this project and I thought maybe it was necessary to have real unique identifier. If this is not important then we can dismiss the changes.

Regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants