Email change of a developer (#503)
[openemr.git] / contrib / util / ubuntu_package_scripts / development / preinst
blob12bbd670bd48789e0bb93b12efaa4b877662afeb
1 #!/bin/bash -e
3 #This program is free software; you can redistribute it and/or modify
4 #it under the terms of the GNU General Public License as published by
5 #the Free Software Foundation; either version 2 of the License, or
6 #(at your option) any later version.
8 # Copyright 2011
9 # authors: Brady Miller <brady.g.miller@gmail.com>
10 # Amalu Obinna <amaluobinna@aol.com>
12 # Debian package pre-installation script steps:
13 # 1) Create log dir/file
14 # 2) Ensure git-OpenEMR web directory was not previously installed.
15 # 3) Create config dir/file
17 # Upgrading is not an option here, since this is for testing/evaluation
18 # of the most current unstable development version of OpenEMR.
20 # Output log file:
21 # /var/log/git-openemr/install
24 # summary of how this script can be called:
25 # * <new-preinst> `install'
26 # * <new-preinst> `install' <old-version>
27 # * <new-preinst> `upgrade' <old-version>
28 # * <old-preinst> `abort-upgrade' <new-version>
29 # for details, see http://www.debian.org/doc/debian-policy/ or
30 # the debian-policy package
32 # Source debconf library.
33 . /usr/share/debconf/confmodule
35 #constants and paths
36 LOGDIR=/var/log/git-openemr
37 LOG=$LOGDIR/install
38 CONFIGDIR=/etc/git-openemr
39 CONFIG=$CONFIGDIR/git-openemr.conf
40 WEB=/var/www
41 OPENEMR=$WEB/git-openemr
42 SITEDIR=$OPENEMR/sites/default
43 INSTALL_USER=gitopenemr
44 INSTALL_DATABASE=gitopenemr
46 #Standardized echo function to send to only log file
47 # requires one parameter (string)
48 log_only () {
49 echo "`date`: $1" >> $LOG
52 #Standardized exit function to be used when unable to install the openemr package
53 # requires one parameter (string with reason for exiting)
54 unable_exit () {
55 echo "`date`: $1" >> $LOG
56 echo "`date`: EXITING.........." >> $LOG
57 exit 1
60 #function to prompt for input
61 # 1st param is name, 2nd param is priority, 3rd param is where result gets sent back in
62 # return the input
63 prompt_input () {
64 db_set "$1" ""
65 db_fset "$1" seen false
66 db_input "$2" "$1" || true
67 db_go || true
68 db_get "$1"
69 local input_value="$RET"
70 db_set "$1" ""
71 db_fset "$1" seen false
72 local __result=$3
73 eval $__result="'$input_value'"
76 case "$1" in
77 install)
79 #create the log file directory
80 mkdir -p $LOGDIR
82 #Check for /var/www/git-openemr, if exist then exit
83 if [ -d "$OPENEMR" ]; then
84 prompt_input git-openemr/www_path_already_exists critical ret_result
85 unable_exit "OpenEMR is already installed ($OPENEMR), so can not install the OpenEMR Package."
88 #Begin the config file string
89 # this is so the postinst script can follow installation
90 # variables:
91 # process states whether installation is pending or complete
92 # plan states install
93 # pass temporarily holds the mysql root password
94 SETTING="#Optional settings\n\
95 #(currently empty, plan to use in subsequent versions if needed)\n\
96 \n\
97 #Installation settings\n\
98 # (DO NOT EDIT below!!!)\n\
99 process=pending\n\
100 plan=install"
102 #ready to install package, so create the config directory and files
103 mkdir -p $CONFIGDIR
104 echo -e $SETTING > $CONFIG
106 exit 0
109 upgrade)
111 #upgrade is not available with the git-openemr package
112 echo ""
113 log_only "Upgrading is not available with the git-openemr package"
114 log_only "This package is for testing most recent development (unstable) OpenEMR version"
115 prompt_input git-openemr/upgrade_not_supported critical ret_result
116 unable_exit "To upgrade to most recent development version, recommend removing/reinstalling package"
119 abort-upgrade)
120 echo "preinst asked to do abort-upgrade"
121 exit 0
125 echo "preinst called with unknown argument \`$1'" >&2
126 exit 1
128 esac