Fix version output when missing.
[plcapi.git] / db-config.d / 001-admin_user
1 # -*-python-*-
2 # $Id$
3 # $URL$
4 #################### 
5 # Create/update the default administrator account (should be person_id 2).
6
7 admin = { 'person_id': 2,
8           'first_name': "Default",
9           'last_name': "Administrator",
10           'email': plc['root_user'],
11           'password': plc['root_password'] }
12 persons = GetPersons([admin['person_id']])
13 if not persons:
14     person_id = AddPerson(admin)
15     if person_id != admin['person_id']:
16         # Huh? Someone deleted the account manually from the database.
17         DeletePerson(person_id)
18         raise Exception, "Someone deleted the \"%s %s\" account from the database!" % \
19               (admin['first_name'], admin['last_name'])
20     UpdatePerson(person_id, { 'enabled': True })
21 else:
22     person_id = persons[0]['person_id']
23     UpdatePerson(person_id, admin)
24