|
Lines 1-6
Link Here
|
| 1 |
#!/bin/sh |
1 |
#!/usr/bin/python2.7 |
| 2 |
samba4_addmachine=$(/usr/sbin/univention-config-registry get "samba4/addmachine") |
2 |
# -*- coding: utf-8 -*- |
| 3 |
/usr/bin/test "$samba4_addmachine" = "deny" && exit 2 |
3 |
# |
| 4 |
/usr/sbin/umc-command "$@" || exit 1 |
4 |
# Copyright 2016 Univention GmbH |
| 5 |
/usr/bin/test "$samba4_addmachine" = "dummy" && exit 3 |
5 |
# |
| 6 |
exit 0 |
6 |
# http://www.univention.de/ |
|
|
7 |
# |
| 8 |
# All rights reserved. |
| 9 |
# |
| 10 |
# The source code of this program is made available |
| 11 |
# under the terms of the GNU Affero General Public License version 3 |
| 12 |
# (GNU AGPL V3) as published by the Free Software Foundation. |
| 13 |
# |
| 14 |
# Binary versions of this program provided by Univention to you as |
| 15 |
# well as other copyrighted, protected or trademarked materials like |
| 16 |
# Logos, graphics, fonts, specific documentations and configurations, |
| 17 |
# cryptographic keys etc. are subject to a license agreement between |
| 18 |
# you and Univention and not subject to the GNU AGPL V3. |
| 19 |
# |
| 20 |
# In the case you use this program under the terms of the GNU AGPL V3, |
| 21 |
# the program is provided in the hope that it will be useful, |
| 22 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 23 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 24 |
# GNU Affero General Public License for more details. |
| 25 |
# |
| 26 |
# You should have received a copy of the GNU Affero General Public |
| 27 |
# License with the Debian GNU/Linux or Univention distribution in file |
| 28 |
# /usr/share/common-licenses/AGPL-3; if not, see |
| 29 |
# <http://www.gnu.org/licenses/>. |
| 30 |
|
| 31 |
import sys |
| 32 |
from argparse import ArgumentParser |
| 33 |
|
| 34 |
import univention.config_registry |
| 35 |
from univention.lib.umc_connection import UMCConnection |
| 36 |
from ucsschool.lib.schoolldap import SchoolSearchBase |
| 37 |
|
| 38 |
ucr = univention.config_registry.ConfigRegistry() |
| 39 |
ucr.load() |
| 40 |
|
| 41 |
|
| 42 |
def main(): |
| 43 |
samba4_addmachine = ucr.get('samba4/addmachine') |
| 44 |
if samba4_addmachine == 'deny': |
| 45 |
sys.exit(2) |
| 46 |
|
| 47 |
parser = ArgumentParser() |
| 48 |
parser.add_argument('-s', dest='server') |
| 49 |
parser.add_argument('-P', dest='password') |
| 50 |
parser.add_argument('-U', dest='username') |
| 51 |
parser.add_argument('-o', action='append', dest='options') |
| 52 |
parser.add_argument('command') |
| 53 |
args = parser.parse_args() |
| 54 |
|
| 55 |
options = dict(x.split('=', 1) for x in args.options) |
| 56 |
options['school'] = SchoolSearchBase.getOU(ucr.get('ldap/hostdn', '')) or SchoolSearchBase.getOU(ucr.get('dhcpd/ldap/base', '')) |
| 57 |
connection = UMCConnection(args.server, args.username, args.password) |
| 58 |
connection.request(args.command, options) |
| 59 |
|
| 60 |
if samba4_addmachine == 'dummy': |
| 61 |
sys.exit(3) |
| 62 |
|
| 63 |
|
| 64 |
if __name__ == '__main__': |
| 65 |
main() |