~clearcorp-drivers/oerptools/trunk

« back to all changes in this revision

Viewing changes to openerp-scripts/openerp-restore-addons.sh

  • Committer: Carlos Vásquez
  • Date: 2012-02-06 22:49:10 UTC
  • Revision ID: carlos.vasquez@clearcorp.co.cr-20120206224910-3ssrb9rihvjya5zz
[FIX] bad addons linking bug
[IMP] new script to restore addons

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#       openerp-restore-addons.sh
 
2
#       
 
3
#       Copyright 2010 ClearCorp S.A. <info@clearcorp.co.cr>
 
4
#       
 
5
#       This program is free software; you can redistribute it and/or modify
 
6
#       it under the terms of the GNU General Public License as published by
 
7
#       the Free Software Foundation; either version 2 of the License, or
 
8
#       (at your option) any later version.
 
9
#       
 
10
#       This program is distributed in the hope that it will be useful,
 
11
#       but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
#       GNU General Public License for more details.
 
14
#       
 
15
#       You should have received a copy of the GNU General Public License
 
16
#       along with this program; if not, write to the Free Software
 
17
#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
18
#       MA 02110-1301, USA.
 
19
#!/bin/bash
 
20
 
 
21
if [[ ! -d $OPENERP_CCORP_DIR ]]; then
 
22
        echo "openerp-ccorp-scripts not installed."
 
23
        exit 1
 
24
fi
 
25
 
 
26
#~ Libraries import
 
27
. $OPENERP_CCORP_DIR/main-lib/checkRoot.sh
 
28
. $OPENERP_CCORP_DIR/main-lib/getDist.sh
 
29
. $OPENERP_CCORP_DIR/openerp-scripts/openerp-lib.sh
 
30
 
 
31
# Check user is root
 
32
checkRoot
 
33
 
 
34
# Init log file
 
35
INSTALL_LOG_PATH=/var/log/openerp
 
36
INSTALL_LOG_FILE=$INSTALL_LOG_PATH/install.log
 
37
 
 
38
if [[ ! -f $INSTALL_LOG_FILE ]]; then
 
39
        mkdir -p $INSTALL_LOG_PATH
 
40
        touch $INSTALL_LOG_FILE
 
41
fi
 
42
 
 
43
function log {
 
44
        echo "$(date): $1" >> $INSTALL_LOG_FILE
 
45
}
 
46
function log_echo {
 
47
        echo $1
 
48
        log "$1"
 
49
}
 
50
log ""
 
51
 
 
52
# Set distribution
 
53
dist=""
 
54
getDist dist
 
55
log_echo "Distribution: $dist"
 
56
log_echo ""
 
57
 
 
58
openerp_get_dist
 
59
 
 
60
# Print title
 
61
log_echo "OpenERP update addons script"
 
62
log_echo "----------------------------"
 
63
log_echo ""
 
64
 
 
65
# Source installation variables
 
66
if [ -d /etc/openerp/5.0 ] && [ ! -d /etc/openerp/6.0 ]; then
 
67
        branch="5"
 
68
elif [ ! -d /etc/openerp/5.0 ] && [ -d /etc/openerp/6.0 ]; then
 
69
        branch="6"
 
70
else
 
71
        branch=""
 
72
        while [[ ! $branch =~ ^[56]$ ]]; do
 
73
                read -p "You have installed versions 5 and 6, choose the version for this server instance (5/_6_): " branch
 
74
                if [[ $branch == "" ]]; then
 
75
                        branch="6"
 
76
                fi
 
77
                log_echo ""
 
78
        done
 
79
fi
 
80
 
 
81
if [[ $branch =~ ^[5]$ ]]; then
 
82
        log_echo "This server will use 5.0 branch."
 
83
        branch="5.0"
 
84
else
 
85
        log_echo "This server will use 6.0 branch."
 
86
        branch="6.0"
 
87
fi
 
88
 
 
89
. /etc/openerp/$branch/install.cfg
 
90
 
 
91
name=""
 
92
while [[ $name == "" ]]; do
 
93
        read -p "Enter the OpenERP server name: " name
 
94
        if [[ $name == "" ]]; then
 
95
                log_echo "The name cannot be blank."
 
96
        elif [[ ! -d /srv/openerp/instances/$name ]]; then
 
97
                log_echo "There isn't any instance named $name"
 
98
                name=""
 
99
        fi
 
100
done
 
101
 
 
102
log_echo "Restoring addons for $name"
 
103
mkserver_addons_rm_links
 
104
mkserver_install_addons
 
105
 
 
106
 
 
107
exit 0