- set PGPORT
[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: api,v 1.1 2006/04/06 21:51:59 mlhuang Exp $
11 #
12
13 # Source function library and configuration
14 . /etc/plc.d/functions
15
16 # Export so that we do not have to specify -p to psql invocations
17 export PGPORT=$PLC_DB_PORT
18
19 case "$1" in
20     start)
21         if [ "$PLC_API_ENABLED" != "1" ] ; then
22             exit 0
23         fi
24
25         MESSAGE=$"Bootstrapping the database"
26         dialog "$MESSAGE"
27
28         # Update the maintenance account username. This can't be
29         # done through the api-config script since it uses the
30         # maintenance account to access the API. The maintenance
31         # account should be person_id 1 since it is created by the
32         # DB schema itself.
33         psql -U $PLC_DB_USER -c "UPDATE persons SET email='$PLC_API_MAINTENANCE_USER' WHERE person_id=1" $PLC_DB_NAME
34
35         # Bootstrap the DB
36         api-config
37         check
38
39         result "$MESSAGE"
40         ;;
41 esac
42
43 exit $ERRORS