From a83c97f8d1095ff22356669ed9ef26557293fb22 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Tue, 27 Jun 2017 14:47:55 +0200 Subject: standardskriver: The standardskriver tool has now been packaged separately. We now only ship our config in itzks-systems. --- bin/standardskriver | 185 ---------------------------------------------------- 1 file changed, 185 deletions(-) delete mode 100755 bin/standardskriver (limited to 'bin') diff --git a/bin/standardskriver b/bin/standardskriver deleted file mode 100755 index 60f9f59..0000000 --- a/bin/standardskriver +++ /dev/null @@ -1,185 +0,0 @@ -#!/usr/bin/python - -# Copyright (C) 2013, John Sigurd Skogtvedt -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -# /etc/xdg/autostart/standardskriver.desktop eksempel: -# [Desktop Entry] -# Type=Application -# Exec=standardskriver -# Name=standardskriver -# StartupNotify=false - -CUSTOMER_ID_FILE = '/etc/debian-edu/itzks.school' -CFG_FILE = '/etc/standardskriver.cfg' -CFG_FILE_EXAMPLE = '''[settings] -enable = yes -order = machine groups -delete lpoptions = yes - -# MAC address or IP = printer -# hostname = printer -# hostname.domain = printer -# LTSP client IP = printer -# 10.1.0.0/16 = printer -# (globbing works) - -[machine] -00:01:02:03:04:05 = printer01 -172.16.34.64 = printer02 -hostname = printer01 -hostname.domain = printer02 - -# group name = printer -# (globbing works) - -[groups] -group1 = printer01 -group2 = printer02 -''' -from glob import glob -from fnmatch import fnmatchcase - -import sys -import os -import subprocess -import re -from socket import gethostname, getfqdn -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: - # only read first line - customer_id = c_id_f.readline() - # sanitize input... - customer_id = re.sub(r'([A-Z0-9]+)(.*\n)', r'\1', customer_id) - -macaddrs = [open(a).read().replace(':', '').strip().lower() for a in glob('/sys/class/net/*/address')] -macaddrs = [a for a in macaddrs if a] - -parser = OptionParser() -parser.add_option('-n', '--dryrun', action='store_true', help='only show what would be done') -options, args = parser.parse_args() - -if not os.path.exists(CFG_FILE): - print >>sys.stderr, 'Configuration file %s is missing.' % CFG_FILE - print >>sys.stderr, 'To create it, redirect the following example to %s and edit the file.' % CFG_FILE - print CFG_FILE_EXAMPLE - sys.exit(1) - -cfg = ConfigParser.RawConfigParser() -# hack: mac addrs contain :, which clashes with cfg syntax -cfg.OPTCRE = re.compile( - r'(?P