Author: e2jk-guest
Date: 2013-05-03 21:10:48 +0000 (Fri, 03 May 2013)
New Revision: 13476

Added:
   trunk/packages/gnuhealth/trunk/debian/database-scripts/
   trunk/packages/gnuhealth/trunk/debian/database-scripts/install/
   trunk/packages/gnuhealth/trunk/debian/database-scripts/install/pgsql
   trunk/packages/gnuhealth/trunk/debian/database-scripts/upgrade/
   trunk/packages/gnuhealth/trunk/debian/database-scripts/upgrade/pgsql
   trunk/packages/gnuhealth/trunk/debian/gnuhealth-server.install
Modified:
   trunk/packages/gnuhealth/trunk/debian/gnuhealth-server.config
   trunk/packages/gnuhealth/trunk/debian/gnuhealth-server.postinst
   trunk/packages/gnuhealth/trunk/debian/gnuhealth-server.postrm
   trunk/packages/gnuhealth/trunk/debian/gnuhealth-server.prerm
Log:
Use dbconfig-common to handle the database tasks. Create system user.


Added: trunk/packages/gnuhealth/trunk/debian/database-scripts/install/pgsql
===================================================================
--- trunk/packages/gnuhealth/trunk/debian/database-scripts/install/pgsql        
                        (rev 0)
+++ trunk/packages/gnuhealth/trunk/debian/database-scripts/install/pgsql        
2013-05-03 21:10:48 UTC (rev 13476)
@@ -0,0 +1,32 @@
+#!/bin/sh
+# database creation script for gnuhealth-server
+
+set -e
+
+# Source the config file from dbconfig-common
+. /etc/dbconfig-common/gnuhealth-server.conf
+
+GNUHEALTH_USER="gnuhealth"
+GNUHEALTH_HOMEDIR="/var/lib/gnuhealth"
+GNUHEALTH_CONFFILE="/etc/gnuhealth/gnuhealth-server.conf"
+
+# Start printing output on a new line
+echo
+
+# Create system user
+adduser --home ${GNUHEALTH_HOMEDIR} --quiet --system --group ${GNUHEALTH_USER}
+
+tf=`sudo -u ${GNUHEALTH_USER} tempfile 2>/dev/null`
+# Use the same password for the Tryton admin as for the database
+echo $dbc_dbpass > $tf
+# Initialize the gnuhealth database
+sudo -u ${GNUHEALTH_USER} TRYTONPASSFILE=$tf trytond --database=gnuhealth \
+       --init=all --config=${GNUHEALTH_CONFFILE}
+rm -f $tf
+
+# Change database owner (needs to be run as postgres user, as PostgreSQL's
+# default authentication is set to peer method)
+sudo -u postgres psql -U postgres -c 'ALTER DATABASE gnuhealth OWNER TO 
gnuhealth'
+
+exit 0
+


Property changes on: 
trunk/packages/gnuhealth/trunk/debian/database-scripts/install/pgsql
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/packages/gnuhealth/trunk/debian/database-scripts/upgrade/pgsql
===================================================================
--- trunk/packages/gnuhealth/trunk/debian/database-scripts/upgrade/pgsql        
                        (rev 0)
+++ trunk/packages/gnuhealth/trunk/debian/database-scripts/upgrade/pgsql        
2013-05-03 21:10:48 UTC (rev 13476)
@@ -0,0 +1,21 @@
+#!/bin/sh
+# database upgrade script for gnuhealth-server
+
+set -e
+
+# Source the config file from dbconfig-common
+. /etc/dbconfig-common/gnuhealth-server.conf
+
+GNUHEALTH_USER="gnuhealth"
+GNUHEALTH_CONFFILE="/etc/gnuhealth/gnuhealth-server.conf"
+
+# Start printing output on a new line
+echo
+
+#TODO: this has not yet been tested. Will be done when packaging the version
+# after 1.8.1
+# Upgrade the gnuhealth database
+sudo -u ${GNUHEALTH_USER} trytond --database=gnuhealth --update=all 
--config=${GNUHEALTH_CONFFILE}
+
+exit 0
+


Property changes on: 
trunk/packages/gnuhealth/trunk/debian/database-scripts/upgrade/pgsql
___________________________________________________________________
Added: svn:executable
   + *

Modified: trunk/packages/gnuhealth/trunk/debian/gnuhealth-server.config
===================================================================
--- trunk/packages/gnuhealth/trunk/debian/gnuhealth-server.config       
2013-05-03 21:09:10 UTC (rev 13475)
+++ trunk/packages/gnuhealth/trunk/debian/gnuhealth-server.config       
2013-05-03 21:10:48 UTC (rev 13476)
@@ -1,5 +1,5 @@
 #!/bin/sh
-# config maintainer script for gnuhealth
+# config maintainer script for gnuhealth-server
 
 set -e
 
@@ -9,6 +9,9 @@
 # source dbconfig-common shell library, and call the hook function
 if [ -f /usr/share/dbconfig-common/dpkg/config.pgsql ]; then
     . /usr/share/dbconfig-common/dpkg/config.pgsql
-    dbc_go gnuhealth $@
+       # Both the PostgreSQL role and database are to be called gnuhealth
+       dbc_dbuser="gnuhealth"
+       dbc_dbname="gnuhealth"
+    dbc_go gnuhealth-server $@
 fi
 

Added: trunk/packages/gnuhealth/trunk/debian/gnuhealth-server.install
===================================================================
--- trunk/packages/gnuhealth/trunk/debian/gnuhealth-server.install              
                (rev 0)
+++ trunk/packages/gnuhealth/trunk/debian/gnuhealth-server.install      
2013-05-03 21:10:48 UTC (rev 13476)
@@ -0,0 +1,4 @@
+debian/gnuhealth-server.conf etc/gnuhealth
+debian/database-scripts/install 
usr/share/dbconfig-common/scripts/gnuhealth-server
+debian/database-scripts/upgrade 
usr/share/dbconfig-common/scripts/gnuhealth-server
+

Modified: trunk/packages/gnuhealth/trunk/debian/gnuhealth-server.postinst
===================================================================
--- trunk/packages/gnuhealth/trunk/debian/gnuhealth-server.postinst     
2013-05-03 21:09:10 UTC (rev 13475)
+++ trunk/packages/gnuhealth/trunk/debian/gnuhealth-server.postinst     
2013-05-03 21:10:48 UTC (rev 13476)
@@ -1,19 +1,10 @@
 #!/bin/sh
-# postinst script for gnuhealth
+# postinst script for gnuhealth-server
 #
 # see: dh_installdeb(1)
 
 set -e
 
-# Source debconf library.
-. /usr/share/debconf/confmodule
-
-# source dbconfig-common shell library, and call the hook function
-if [ -f /usr/share/dbconfig-common/dpkg/postinst.pgsql ]; then
-    . /usr/share/dbconfig-common/dpkg/postinst.pgsql
-    dbc_go gnuhealth $@
-fi
-
 # summary of how this script can be called:
 #        * <postinst> `configure' <most-recently-configured-version>
 #        * <old-postinst> `abort-upgrade' <new version>
@@ -27,46 +18,30 @@
 # the debian-policy package
 
 
+# Source debconf library.
+. /usr/share/debconf/confmodule
+
+# source dbconfig-common shell library, and call the hook function
+if [ -f /usr/share/dbconfig-common/dpkg/postinst.pgsql ]; then
+    . /usr/share/dbconfig-common/dpkg/postinst.pgsql
+    dbc_go gnuhealth-server $@
+fi
+
 GNUHEALTH_USER="gnuhealth"
+GNUHEALTH_HOMEDIR="/var/lib/gnuhealth"
 GNUHEALTH_LOGDIR="/var/log/gnuhealth"
 
 case "$1" in
     configure)
-               # Creating system user
-               adduser --no-create-home --quiet --system --group 
${GNUHEALTH_USER}
+        # Create system user
+        adduser --home ${GNUHEALTH_HOMEDIR} --quiet --system --group 
${GNUHEALTH_USER}
         
-               # Creating log directory
-               mkdir -p ${GNUHEALTH_LOGDIR}
-               chown ${GNUHEALTH_USER}:adm ${GNUHEALTH_LOGDIR}
-               chmod 0750 ${GNUHEALTH_LOGDIR}
-               
-        # TODO: needs to be reworked
-        ## Check if the gnuhealth database role already exists
-        #role=`psql -U postgres -c "\du" 2>/dev/null | grep gnuhealth | wc -l`
-        #if [ $role -eq 0 ]; then
-        #    echo "not here"
-        #    # Create the PostgreSQL database role
-        #else
-        #    # Check if the gnuhealth database exists
-        #    db=`psql -U postgres -l 2>/dev/null | grep gnuhealth | wc -l`
-        #    if [ $db -eq 1 ]; then
-        #        # Update the gnuhealth database
-        #        trytond --database=gnuhealth --update=all
-        #    else
-        #        # The user has probably set up it's own database, prompt her
-        #        # to manually upgrade its database
-        #        db_reset gnuhealth/manualupgrade
-        #        db_input high gnuhealth/manualupgrade || true
-        #        db_go
-        #    fi
-        #fi
-        #
-        ## Start the Tryton server
-        #if which invoke-rc.d >/dev/null 2>&1; then
-        #    invoke-rc.d tryton-server start
-        #else
-        #    /etc/init.d/tryton-server start
-        #fi
+               # Create log directory
+        if [ ! -d ${GNUHEALTH_LOGDIR} ]; then
+                   mkdir -p ${GNUHEALTH_LOGDIR}
+                   chown ${GNUHEALTH_USER}:adm ${GNUHEALTH_LOGDIR}
+                   chmod 0750 ${GNUHEALTH_LOGDIR}
+               fi
     ;;
 
     abort-upgrade|abort-remove|abort-deconfigure)
@@ -84,3 +59,4 @@
 #DEBHELPER#
 
 exit 0
+

Modified: trunk/packages/gnuhealth/trunk/debian/gnuhealth-server.postrm
===================================================================
--- trunk/packages/gnuhealth/trunk/debian/gnuhealth-server.postrm       
2013-05-03 21:09:10 UTC (rev 13475)
+++ trunk/packages/gnuhealth/trunk/debian/gnuhealth-server.postrm       
2013-05-03 21:10:48 UTC (rev 13476)
@@ -1,19 +1,10 @@
 #!/bin/sh
-# postrm script for gnuhealth
+# postrm script for gnuhealth-server
 #
 # see: dh_installdeb(1)
 
 set -e
 
-# Source debconf library.
-. /usr/share/debconf/confmodule
-
-# source dbconfig-common shell library, and call the hook function
-if [ -f /usr/share/dbconfig-common/dpkg/postrm.pgsql ]; then
-    . /usr/share/dbconfig-common/dpkg/postrm.pgsql
-    dbc_go gnuhealth $@
-fi
-
 # summary of how this script can be called:
 #        * <postrm> `remove'
 #        * <postrm> `purge'
@@ -28,28 +19,32 @@
 # the debian-policy package
 
 
+# Source debconf library.
+. /usr/share/debconf/confmodule
+
+# source dbconfig-common shell library, and call the hook function
+if [ -f /usr/share/dbconfig-common/dpkg/postrm.pgsql ]; then
+    . /usr/share/dbconfig-common/dpkg/postrm.pgsql
+    dbc_go gnuhealth-server $@
+fi
+
 GNUHEALTH_USER="gnuhealth"
+GNUHEALTH_HOMEDIR="/var/lib/gnuhealth"
 GNUHEALTH_LOGDIR="/var/log/gnuhealth"
 
 case "$1" in
     purge)
                # Remove system user
+               #TODO: maybe the system user should just be frozen? See #678099 
and #621833
                if [ -x /usr/sbin/deluser ]; then
                        deluser --quiet --system ${GNUHEALTH_USER}
                fi
 
-               # Remove log directory
-               rmdir --ignore-fail-on-non-empty ${GNUHEALTH_LOGDIR} > 
/dev/null 2>&1 || true
-               ;;
+               # Remove log directory and user's home directory
+               rm -rf ${GNUHEALTH_HOMEDIR} ${GNUHEALTH_LOGDIR} > /dev/null 
2>&1 || true
+       ;;
        
     remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
-        # TODO: needs to be reworked
-        ## Start the Tryton server
-        #if which invoke-rc.d >/dev/null 2>&1; then
-        #    invoke-rc.d tryton-server start
-        #else
-        #    /etc/init.d/tryton-server start
-        #fi
     ;;
 
     *)
@@ -64,3 +59,4 @@
 #DEBHELPER#
 
 exit 0
+

Modified: trunk/packages/gnuhealth/trunk/debian/gnuhealth-server.prerm
===================================================================
--- trunk/packages/gnuhealth/trunk/debian/gnuhealth-server.prerm        
2013-05-03 21:09:10 UTC (rev 13475)
+++ trunk/packages/gnuhealth/trunk/debian/gnuhealth-server.prerm        
2013-05-03 21:10:48 UTC (rev 13476)
@@ -1,19 +1,10 @@
 #!/bin/sh
-# prerm script for gnuhealth
+# prerm script for gnuhealth-server
 #
 # see: dh_installdeb(1)
 
 set -e
 
-# Source debconf library.
-. /usr/share/debconf/confmodule
-
-# source dbconfig-common shell library, and call the hook function
-if [ -f /usr/share/dbconfig-common/dpkg/prerm.pgsql ]; then
-    . /usr/share/dbconfig-common/dpkg/prerm.pgsql
-    dbc_go gnuhealth $@
-fi
-
 # summary of how this script can be called:
 #        * <prerm> `remove'
 #        * <old-prerm> `upgrade' <new-version>
@@ -26,15 +17,17 @@
 # the debian-policy package
 
 
+# Source debconf library.
+. /usr/share/debconf/confmodule
+
+# source dbconfig-common shell library, and call the hook function
+if [ -f /usr/share/dbconfig-common/dpkg/prerm.pgsql ]; then
+    . /usr/share/dbconfig-common/dpkg/prerm.pgsql
+    dbc_go gnuhealth-server $@
+fi
+
 case "$1" in
     remove|upgrade|deconfigure)
-        # TODO: needs to be reworked
-        ## Stop the Tryton server
-        #if which invoke-rc.d >/dev/null 2>&1; then
-        #    invoke-rc.d tryton-server stop
-        #else
-        #    /etc/init.d/tryton-server stop
-        #fi
     ;;
 
     failed-upgrade)
@@ -52,3 +45,4 @@
 #DEBHELPER#
 
 exit 0
+


_______________________________________________
debian-med-commit mailing list
debian-med-commit@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/debian-med-commit

Reply via email to