Macnamer is a combination of a Django web app and a script to run on your client Macs with the goal of setting the name of your Macs. This is a drop in replacement for MacNamer
To keep computer naming consistent. It's primarily meant for Macs, but could be used by any os.
The Mac client part of this is available here
Macnamer is divided into groups, and within each group are computers and networks.
If you set a prefix for the group, Macnamer will auto increment the number - it for example, set ABC as the prefix and your first machine will be ABC1.
If you assign a network to a group, any new request that comes from that network will be assigned the next available number (if you're using the auto naming functionality). If you don't wish Macs to be automatically added to Macnamer, don't assign any networks to a group.
You should enter the network as the LAN subnet xxx.xxx.xxx.0 (e.g. 192.168.10.0) - there isn't currently any support for subnets other than /24, although you can enter multiple subnets, nor is there any validation currently of the field, so make sure you're entering your desired subnets correctly.
The easiest way of running this is by running it in Docker or Kubernetes.
Several options, such as the timezone and admin password are customizable using environment variables.
ADMIN_PASS: The default admin's password. This is only set if there are no other superusers, so if you choose your own admin username and password later on, this won't be created.MACNAMER_TZ: The desired timezone. Defaults to Europe/London.MACNAMER_ADMINS: The admin user's details. Defaults to Docker User, docker@localhost.SECRET_KEY: The Django secret key. This key is mostly used to sign session cookies. In production you should probalby set your own. Defaults to 2&lakkwf+r78)9u+30&+1=zc3()1^s2oqrbxr5qe8z_@xm2a&4.HOST_NAME: Set the host name of your instance - might berequired if you do not have control over the load balancer or proxy in front of your instance (see the Django documentation).If you require more advanced settings, for example if you want to hide certain plugins from certain Business Units or if you have a plugin that needs settings, you can override settings.py with your own. A good starting place can be found on this image's Github repository. To use your own settings.py file, use the -v option:
-v /usr/local/macnamer_data/settings/settings.py:/home/app/macnamer/macnamer/settings.py
The directory the SQLite database lives in (/home/app/macnamer/db) is exposed. To persist your database, you should run your container with -v /host/path/somewhere/db:/home/app/macnamer/db.
There is also the option of using a postgres database instead, which will can be set up with these environment variables:
DB_HOST: The hostname for your postgresql server. Defaults to db.DB_PORT: Port the postgres server runs on. Defaults to 5432.DB_NAME: Name of the database. Required.DB_USER: Username for the database. Required.DB_PASS: Password for the database. Required.NB: Remember to back up your data before starting this!
If you are running v1.0 of this image or the original MacNamer, I recommend starting with an upgrade to v2+ of this image, as it should take care of all database migrations before the move to postgres.
Once that's done, dump your current DB to a file. This exmaple dumps the file in the same folder as the SQLite DB file:
python3 manage.py dumpdata --natural-foreign --natural-primary > db/macnamer_export.json
Next rename the current DB file so it doesn't get loaded on next startup:
mv db/macnamer.db db/macnamer_old.db
Stop the docker, set the environment variables for postgres as described above and start the docker again.
Start with a clean postgres by opening a shell:
python3 manage.py shell
And cleaning out the content types:
from django.contrib.contenttypes.models import ContentType
ContentType.objects.all().delete()
quit()
And then import your data back into the database:
python3 manage.py loaddata db/macnamer_export.json
-p 80:8000 \
-v /usr/local/macnamer_data/db:/home/app/macnamer/db \
-e ADMIN_PASS=pass \
nielshojen/macnamer
Thanks to Graham Gilbert who originally built this. I just changed a few things that i needed in my env
Content type
Image
Digest
sha256:8ab10363e…
Size
248.5 MB
Last updated
over 2 years ago
docker pull nielshojen/macnamer