summaryrefslogtreecommitdiff
path: root/machine_profiles
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2020-11-09 11:49:21 +0100
committerAnton Khirnov <anton@khirnov.net>2020-11-09 11:49:21 +0100
commitc62885a59b5fbe40cf62a629dd2295f1161831e1 (patch)
treebb393d9fa4fa70d8aa7f10908541018246b81f97 /machine_profiles
parentdc7b00df4ba7cf2b7d7e20971fb13213b9c96e14 (diff)
install: support configuration profiles
Diffstat (limited to 'machine_profiles')
-rwxr-xr-xmachine_profiles32
1 files changed, 32 insertions, 0 deletions
diff --git a/machine_profiles b/machine_profiles
new file mode 100755
index 0000000..eb7b06d
--- /dev/null
+++ b/machine_profiles
@@ -0,0 +1,32 @@
+#!/usr/bin/python3
+
+# print a comma-separate list of tags for system
+
+import socket
+import sys
+
+tags = {
+ "desktop" : [
+ "daenerys",
+ "shion",
+ "diziet",
+ "cirno",
+ ],
+}
+
+hostname = socket.getfqdn()
+if hostname.startswith('localhost'):
+ # try gethostname, it might sometimes return a real name
+ # when FQDN is misconfigured
+ hostname = socket.gethostname()
+
+if hostname.startswith('localhost'):
+ sys.stderr.write('System hostname "%s" starts with localhost, '
+ 'that is probably wrong\n', hostname)
+
+for t, systems in tags.items():
+ for s in systems:
+ if (hostname.startswith(s) and
+ (len(s) == len(hostname) or hostname[len(s)] == '.')):
+ print(t)
+ break