X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=db-config.d%2F001-admin_user;fp=db-config.d%2F001-admin_user;h=879716453b15879150d91a1a44c01d3034aa37aa;hb=50e2adc8f9e2a58efafedbad31b66b347b0ac61f;hp=0000000000000000000000000000000000000000;hpb=a1d9cfaed3cedc96f0a6b23c934b28026c2afba4;p=myplc.git diff --git a/db-config.d/001-admin_user b/db-config.d/001-admin_user new file mode 100644 index 0000000..8797164 --- /dev/null +++ b/db-config.d/001-admin_user @@ -0,0 +1,24 @@ +# -*-python-*- +# $Id$ +# $URL$ +#################### +# Create/update the default administrator account (should be person_id 2). + +admin = { 'person_id': 2, + 'first_name': "Default", + 'last_name': "Administrator", + 'email': plc['root_user'], + 'password': plc['root_password'] } +persons = GetPersons([admin['person_id']]) +if not persons: + person_id = AddPerson(admin) + if person_id != admin['person_id']: + # Huh? Someone deleted the account manually from the database. + DeletePerson(person_id) + raise Exception, "Someone deleted the \"%s %s\" account from the database!" % \ + (admin['first_name'], admin['last_name']) + UpdatePerson(person_id, { 'enabled': True }) +else: + person_id = persons[0]['person_id'] + UpdatePerson(person_id, admin) +