- split up guest.init (/etc/init.d/plc inside the chroot) into
[myplc.git] / plc.d / api
1 #!/bin/bash
2 #
3 # priority: 800
4 #
5 # Bootstrap the database
6 #
7 # Mark Huang <mlhuang@cs.princeton.edu>
8 # Copyright (C) 2006 The Trustees of Princeton University
9 #
10 # $Id: guest.init,v 1.12 2006/04/04 22:09:47 mlhuang Exp $
11 #
12
13 # Source function library and configuration
14 . /etc/plc.d/functions
15
16 case "$1" in
17     start)
18         if [ "$PLC_API_ENABLED" != "1" ] ; then
19             exit 0
20         fi
21
22         MESSAGE=$"Bootstrapping the database"
23         dialog "$MESSAGE"
24
25         # Update the maintenance account username. This can't be
26         # done through the api-config script since it uses the
27         # maintenance account to access the API. The maintenance
28         # account should be person_id 1 since it is created by the
29         # DB schema itself.
30         psql -U $PLC_DB_USER -c "UPDATE persons SET email='$PLC_API_MAINTENANCE_USER' WHERE person_id=1" $PLC_DB_NAME
31
32         # Bootstrap the DB
33         api-config
34         check
35
36         result "$MESSAGE"
37         ;;
38 esac
39
40 exit $ERRORS