aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-06-27 12:11:16 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-06-27 12:14:24 +0200
commit3e83b2f19f913dfa86cccc76fe4f91d9cf52380e (patch)
treee73a0d43a88976e45630aba0888a1df82f3f2386
parent6c1beb764cb3911f4d6675b1fbed0c837731b50a (diff)
downloadstandardskriver-3e83b2f19f913dfa86cccc76fe4f91d9cf52380e.zip
standardskriver-3e83b2f19f913dfa86cccc76fe4f91d9cf52380e.tar.gz
standardskriver-3e83b2f19f913dfa86cccc76fe4f91d9cf52380e.tar.bz2
standardskriver: Use a generic file location for getting the site name/id from.
-rwxr-xr-xstandardskriver22
1 files changed, 11 insertions, 11 deletions
diff --git a/standardskriver b/standardskriver
index 6ce0fe9..d56f882 100755
--- a/standardskriver
+++ b/standardskriver
@@ -24,7 +24,7 @@
# Name=standardskriver
# StartupNotify=false
-CUSTOMER_ID_FILE = '/etc/debian-edu/itzks.school'
+SITE_ID_FILE = '/etc/standardskriver.site'
CFG_FILE = '/etc/standardskriver.cfg'
CFG_FILE_EXAMPLE = '''[settings]
enable = yes
@@ -63,14 +63,14 @@ import netaddr
from optparse import OptionParser
import ConfigParser
-# check whose customer system we are on...
-customer_id = None
-if os.access(CUSTOMER_ID_FILE, os.R_OK):
- with open(CUSTOMER_ID_FILE, 'r') as c_id_f:
+# if configured, check on what site location we are currently running...
+site_id = None
+if os.access(SITE_ID_FILE, os.R_OK):
+ with open(SITE_ID_FILE, 'r') as c_id_f:
# only read first line
- customer_id = c_id_f.readline()
+ site_id = c_id_f.readline()
# sanitize input...
- customer_id = re.sub(r'([A-Z0-9]+)(.*\n)', r'\1', customer_id)
+ site_id = re.sub(r'([A-Z0-9]+)(.*\n)', r'\1', site_id)
macaddrs = [open(a).read().replace(':', '').strip().lower() for a in glob('/sys/class/net/*/address')]
macaddrs = [a for a in macaddrs if a]
@@ -129,8 +129,8 @@ p.wait()
def get_group_match():
group_sections = ['groups']
- if customer_id:
- group_sections.append('groups.{customer}'.format(customer=customer_id))
+ if site_id:
+ group_sections.append('groups.{site}'.format(site=site_id))
for section in group_sections:
try:
for group, printer in cfg.items(section):
@@ -141,8 +141,8 @@ def get_group_match():
def get_machine_match():
machine_sections = ['machine']
- if customer_id:
- machine_sections.append('machine.{customer}'.format(customer=customer_id))
+ if site_id:
+ machine_sections.append('machine.{site}'.format(site=site_id))
for section in machine_sections:
try:
for machine, printer in cfg.items(section):