2
# Copyright 2015 Canonical Ltd. This software is licensed under the
3
# GNU Affero General Public License version 3 (see the file LICENSE).
5
from __future__ import (
7
print("This utility may only be run as root.")
10
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "maas.settings")
11
sys.path.append('/usr/share/maas')
13
# Use Django 1.6 if the python-django16 package is installed: this is
14
# to get MAAS to work on vivid: vivid ships with Django 1.7 by default
15
# and MAAS isn't yet compatible with Django 1.7.
16
if os.path.exists('/usr/lib/django16'):
17
sys.path.insert(1, '/usr/lib/django16')
19
from django.core import management
22
# At present, only root should execute this.
24
raise SystemExit("This utility may only be run as root.")
28
# Ensure that we're running as the `maas` group.
30
gr_maas = grp.getgrnam("maas")
32
raise SystemExit("No such group: maas")
34
os.setegid(gr_maas.gr_gid)
38
# Prevent creation of world-readable (or writable, executable) files.
43
# Force the production MAAS Django configuration.
44
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "maas.settings")
46
# The Django configuration lives outside of sys.path.
47
sys.path.append('/usr/share/maas')
49
# Use Django 1.6 if the python-django16 package is installed: this is to
50
# get MAAS to work on vivid: vivid ships with Django 1.7 by default and
51
# MAAS isn't yet compatible with Django 1.7.
52
if os.path.exists('/usr/lib/django16'):
53
sys.path.insert(1, '/usr/lib/django16')
55
# Let Django do the rest.
56
from django.core import management
57
management.execute_from_command_line()
21
67
if __name__ == "__main__":
22
management.execute_from_command_line()