OpenERP> = 5.0.6一体化安装程序和更新程序在Ubuntu上使用GUI(下载最新的稳定分支从Launchpad)

OpenERP> = 5.0.6一体机安装程序和更新程序在Ubuntu上使用GUI(从Launchpad下载最新的稳定分支)

以下脚本自动化安装和更新openerp-server-5.0.x&openerp-client-5.0.x&openerp-web-5.0.x&openerp-addons-5.0.x&openerp-extra-addons-5.0.x for Ubuntu 8.04.3 LTS桌面和服务器:

  • openerp-allinone-setup-stable.sh :从launchpad.net安装或更新最新的稳定分支

目的是提供基于KISS原理的Ubuntu Desktop和Server的OpenERP图形化安装程序和更新机制

目前稳定分行为5.0.6版(2009年9月22日)。

要求:全新安装Ubuntu 8.04 LTS桌面或服务器( http://www.ubuntu.com/getubuntu/download

提示:从头开始安装Ubuntu 8.04 LTS Desktop或Server后,在虚拟机中测试此脚本。 在桥接网络中运行虚拟机:主机和客户机具有相同的子网,并且可以从LAN访问。

Ubuntu Desktop通过图形用户界面运行脚本。

  1. 解压文件
  2. 右键单击openerp-allinone-setup-stable.sh 图标
  3. 点击“属性”
  4. 点击“权限”选项卡
  5. 选择“执行:允许执行文件作为程序”
  6. 点击“关闭”
  7. 双击图标和“运行终端”或“运行”: OpenERP将在第一次执行期间安装。 如果您再次双击图标,OpenERP将从此点更新。

Ubuntu服务器(没有GUI) 只需要系统的核心,所以 安装 Ubuntu服务器时 ,不要选择“ 软件选择 ”菜单 (OpenSSH Server除外) 中的LAMP ServerPostgreSQL Server之类的软件 。 此脚本安装Apache和Postgres,并期望处理默认配置文件。 在具有X11转发的SSH会话中使用以下命令以非root方式运行脚本。

  1. ssh -X user@ubuntuserver8.04
  2. gzip -d openerp-allinone-setup-stable.sh.gz
  3. chmod + x openerp-allinone-setup-stable.sh
  4. ./openerp-allinone-setup-stable.sh
  5. 出口
  6. ssh -X user@ubuntuserver8.04
  7. ./openerp-allinone-setup-stable.sh
  8. OpenERP将在第二次执行期间安装。 如果再次执行脚本,OpenERP将从此开始更新。

安装过程可以像每个问题的“接受”一样简单。 您将需要键入您的用户密码(sudo)。

附加信息:

  1. 对于生产系统,推荐使用Ubuntu 8.04 LTS上的OpenERP
  2. OpenERP已经由Tiny和Axelor在Debian Etch和Ubuntu Hardy(8.04 LTS版本)上进行了测试,
  3. 在安装过程中,显示​​可用的IP地址以便于IP地址输入。 第一个配置的IP被标记为默认IP。
  4. / opt是下载OpenERP文件的工作目录。
  5. Apache被配置为OpenERP Web的前端,并将所有传入的HTTP流量重定向到HTTPS。 您的Web浏览器中的“无效安全证书”错误消息是正确的,因为SSL证书已创建用于测试目的。
  6. Ubuntu的防火墙设置为打开以下端口:SSH,HTTP,HTTPS,8069和8070(用于OpenERP GTK客户端的远程访问)。
  7. 添加openerp-server和openerp-web的启动/初始化脚本。
  8. 创建openerp-client和openerpweb URL的桌面图标
  9. 创建一个OpenERP-README.txt文件,其余的步骤要从OpenERP客户端(GTK或Web)完成
  10. OpenERP-updates.txt文件创建具有安装或更新的OpenERP修订版本的记录。 这对于控制您的更新非常有用。
  11. OpenERP更新程序工作 通过运行 “bzr missing”“bzr pull”

感兴趣的链接

openerp-allinone-setup-stable.sh脚本的内容:

#!/bin/bash
# BAZAAR DOC: http://doc.bazaar-vcs.org/latest/en/user-guide/index.html
# BLOG: http://opensourceconsulting.wordpress.com/
# Checking constraints...
OSREQUIREMENT=`awk '/Ubuntu 8.04.3 LTS/ {print $0}' /etc/issue`
#Ubuntu 8.04.3 LTS \n \l
if [ -z "$OSREQUIREMENT" ];
then
echo "This program must be executed on Ubuntu 8.04.3 LTS Desktop or Server"
zenity --error --text="This program must be executed on Ubuntu 8.04.3 LTS Desktop or Server"
exit 1
fi
`dpkg-query -W -f='${Status}\n' xdg-user-dirs > /tmp/dpkg-query.txt`
UBUNTUDESKTOPINSTALLED=`awk '/install ok installed/ {print $0}' /tmp/dpkg-query.txt`
if [ -z "$UBUNTUDESKTOPINSTALLED" ];
then
clear
stty erase '^?'
echo "This system seems to be Ubuntu Server... Installing zenity & xauth"
echo "If the script ends with this messange \"(zenity:5539): Gtk-WARNING **: cannot open display:\" just exit from you SSH session and try again."
echo "Remember to enable X11Forwarding with SSH"
read -p "Press any key to continue…"
sudo apt-get update
sudo apt-get install -y zenity
# Ubuntu 8.04.3 LTS Server requires xauth binary to remotely display linux applications like openerp-client:
sudo apt-get install -y xauth
MYDESKTOP=$HOME
else
MYDESKTOP=`xdg-user-dir DESKTOP`
fi


##################################################################################################################################
# FUNCTIONS
##################################################################################################################################
function installfunc()
{

if [ -x /usr/sbin/apache2 ] ; then
zenity --error --text="Apache package already installed. This script cannot be executed"
exit 0
fi

if [ -x /etc/apache2 ] ; then
zenity --error --text="/etc/apache2 already exists. This script cannot be executed"
exit 0
fi
if [ -x /var/lib/postgresql ] ; then
zenity --error --text="Postgres already installed. This script cannot be executed"
exit 0
fi
###################################################################################################################################


zenity --question --text="Would you like to install extra-addons?"
if [ $? -eq 0 ]; # 0 = ACCEPT
then
zenity --info --text="stable_5.0-extra-addons will be installed for first time"
EXTRAADDONSINSTALL=y
else
EXTRAADDONSINSTALL=n
zenity --info --text="stable_5.0-extra-addons will NOT be installed. Press OK to continue"
fi

url=$(zenity --entry \
--title="OpenERP URL" \
--text="Enter DNS name for your URL:" \
--entry-text "openerpweb.com");
if [ $? -eq 1 ]
then
zenity --warning --text="Cancel button pressed. Script execution aborted"
exit 0
fi

# Modifying /etc/hosts file
for lang in `/sbin/ifconfig | grep 'inet '| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'`;
do
array=( "${array[@]}" "$lang" )
done


element_count=${#array[@]}
# Special syntax to extract number of elements in array.
index=0
LISTOPTIONS=""
while [ "$index" -lt "$element_count" ];
do # List all the elements in the array.
LISTOPTIONS=$LISTOPTIONS"FALSE ${array[$index]} "
# ${array[index]} also works because it's within ${ ... } brackets.
let "index+=1"
done

if [ $element_count -lt 1 ];
then
zenity --error --text="No IP addresses available on your Ubuntu !! At least one IP address configured on Ubuntu is required. Script execution aborted."
#read -p "Press any key to continue…"
exit
fi
LISTOPTIONS=`echo $LISTOPTIONS | sed 's/FALSE/TRUE/i'`
ipaddrvar=$(zenity --list --text "List of IP addresses already configured on your Ubuntu system" --radiolist --column "Pick" --column "IP address" $LISTOPTIONS);
if [ $? -eq 1 ]
then
zenity --warning --text="Cancel button pressed. Script execution aborted"
exit 0
fi
passwvar=$(zenity --entry \
--title="OpenERP Database" \
--text="Please enter the Administrator Password:" \
--entry-text "openerp");
if [ $? -eq 1 ]
then
zenity --warning --text="Cancel button pressed. Script execution aborted"
exit 0
fi

#/usr/sbin/adduser --no-create-home --quiet --system openerp (ubuntu)
# SUDO issue:
CHECKSUDOPASSWORD=""
while [ -z $CHECKSUDOPASSWORD ]; do
zenity --entry --title="Adding user openerp" --text="Enter your user password (sudo):" --hide-text | sudo -S /usr/sbin/adduser --quiet --system openerp
if [ $? -ne 0 ];
then
zenity --error --text="Sorry, bad password"
else
CHECKSUDOPASSWORD="1"
fi
done

(
PATH=/usr/bin:/sbin:/bin:/usr/sbin
echo "# DON'T PRESS ACCEPT/OK !!. Downloading and installing bzr";
sudo apt-get install -y bzr
echo "# DON'T PRESS ACCEPT/OK !!. Downloading OpenERP Software from launchpad.net";
cd /opt
echo "# OpenERP Server: Downloading latest stable branch from launchpad.net";
echo "OpenERP Server: Downloading latest stable branch from launchpad.net" >> $MYDESKTOP/OpenERP-updates.txt;
sudo bzr branch lp:openobject-server/5.0 openerp-server >>$MYDESKTOP/OpenERP-updates.txt 2>&1
echo "# OpenERP Client: Downloading latest stable branch from launchpad.net";
echo "OpenERP Client: Downloading latest stable branch from launchpad.net" >> $MYDESKTOP/OpenERP-updates.txt;
sudo bzr branch lp:openobject-client/5.0 openerp-client >>$MYDESKTOP/OpenERP-updates.txt 2>&1
echo "# OpenERP Client Web: Downloading latest stable branch from launchpad.net";
echo "OpenERP Client Web: Downloading latest stable branch from launchpad.net" >> $MYDESKTOP/OpenERP-updates.txt;
sudo bzr branch lp:openobject-client-web/5.0 openerp-web >>$MYDESKTOP/OpenERP-updates.txt 2>&1
echo "# OpenERP Addons: Downloading latest stable branch from launchpad.net";
echo "OpenERP Addons: Downloading latest stable branch from launchpad.net" >> $MYDESKTOP/OpenERP-updates.txt;
sudo bzr branch lp:openobject-addons/5.0 addons >>$MYDESKTOP/OpenERP-updates.txt 2>&1

if [ "$EXTRAADDONSINSTALL" = "y" ]; then
echo "# OpenERP Extra-Addons: Downloading latest stable branch from launchpad.net";
echo "OpenERP Extra-Addons: Downloading latest stable branch from launchpad.net" >> $MYDESKTOP/OpenERP-updates.txt;
sudo bzr branch lp:~openerp-commiter/openobject-addons/stable_5.0-extra-addons extra-addons >>$MYDESKTOP/OpenERP-updates.txt 2>&1
fi

sudo apt-get update
echo "# DON'T PRESS ACCEPT/OK !!. Downloading and installing Python libraries";
sudo apt-get install -y python python-dev build-essential python-setuptools python-psycopg2 python-reportlab python-egenix-mxdatetime python-tz python-pychart python-pydot python-lxml python-libxslt1 python-vobject graphviz python-xml python-libxml2 python-imaging python-profiler;
# openerp-client requirements:
sudo apt-get install -y python-gtk2 python-glade2 xpdf;
# Matplotlib & hippocanvas still required by openerp-client (not listed as a dependency for the package):
sudo apt-get install -y python-matplotlib python-hippocanvas;
echo "# DON'T PRESS ACCEPT/OK !!. Downloading and installing Postgres Database";
sudo apt-get install -y postgresql-8.3 postgresql-client-8.3 pgadmin3;
#sudo apt-get install postgresql-8.3 postgresql-client-8.3 -y
#Postgres Database configuration:
#sudo vi /etc/postgresql/8.3/main/pg_hba.conf
#Replace the following line:
## “local” is for Unix domain socket connections only
#local all all ident sameuser
#with:
##”local” is for Unix domain socket connections only
#local all all md5
sudo sed -i 's/\(local[[:space:]]*all[[:space:]]*all[[:space:]]*\)\(ident[[:space:]]*sameuser\)/\1md5/g' /etc/postgresql/8.3/main/pg_hba.conf

#Restart Postgres:
echo "# DON'T PRESS ACCEPT/OK !!. Restarting Postgres Database";
sudo /etc/init.d/postgresql-8.3 restart
#Create a user account called openerp with password “openerp” and with privileges to create Postgres databases:
#sudo su postgres
#createuser openerp -P
# Enter password for new role: (openerp)
# Enter it again:
# Shall the new role be a superuser? (y/n) n
# Shall the new role be allowed to create databases? (y/n) y
# Shall the new role be allowed to create more new roles? (y/n) n
echo "# DON'T PRESS ACCEPT/OK !!. Creating user openerp on Postgres Database";
sudo -u postgres createuser openerp --no-superuser --createdb --no-createrole
sudo -u postgres psql template1 -U postgres -c "alter user openerp with password '$passwvar'"

echo "# DON'T PRESS ACCEPT/OK !!. Compiling and Installing OpenERP Software";
cd /opt/openerp-server
sudo python setup.py install
cd /opt/openerp-client
sudo python setup.py install
cd /opt/openerp-web
sudo easy_install -U openerp-web
cd /opt
sudo cp -r /opt/addons/ /usr/lib/python2.5/site-packages/openerp-server/
if [ "$EXTRAADDONSINSTALL" = "y" ]; then
sudo cp -r /opt/extra-addons/* /usr/lib/python2.5/site-packages/openerp-server/addons/
fi
sudo chown -R openerp.root /usr/lib/python2.5/site-packages/openerp-server/addons/

#####################
# Extending Open ERP
# To extend Open ERP you’ll need to copy modules into the addons directory. That’s in your server’s openerp-server directory (which differs between Windows,
# Mac and some of the various Linux distributions and not available at all in the Windows all-in-one installer).
# You can add modules in two main ways – through the server, or through the client.
# To add new modules through the server is a conventional systems administration task. As rootuser or other suitable user, you’d put the module in the
# addons directory and change its permissions to match those of the other modules.
# To add new modules through the client you must first change the permissions of the addonsdirectory of the server, so that it is writable by the server.
# That will enable you to install Open ERP modules using the Open ERP client (a task ultimately carried out on the application server by the server software).
#
sudo chmod 755 /usr/lib/python2.5/site-packages/openerp-server/addons/
###########################################
# Document Management Permissions: http://openobject.com/forum/topic13021.html?highlight=ftp
sudo chown openerp /usr/lib/python2.5/site-packages/openerp-server
#
echo "# DON'T PRESS ACCEPT/OK !!. Adding openerp-server and openerp-web init scripts and config files";
#####################################################################################
# openerp-server init script
#####################################################################################
cat > /tmp/openerp-server <<"EOF"
#!/bin/sh

### BEGIN INIT INFO
# Provides: openerp-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Enterprise Resource Management software
# Description: OpenERP is a complete ERP and CRM software.
### END INIT INFO

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/openerp-server
NAME=openerp-server
DESC=openerp-server
USER=openerp

test -x ${DAEMON} || exit 0

set -e

case "${1}" in
start)
echo -n "Starting ${DESC}: "

start-stop-daemon --start --quiet --pidfile /var/run/${NAME}.pid \
--chuid ${USER} --background --make-pidfile \
--exec ${DAEMON} -- --config=/etc/openerp-server.conf

echo "${NAME}."
;;

stop)
echo -n "Stopping ${DESC}: "

start-stop-daemon --stop --quiet --pidfile /var/run/${NAME}.pid \
--oknodo

echo "${NAME}."
;;

restart|force-reload)
echo -n "Restarting ${DESC}: "

start-stop-daemon --stop --quiet --pidfile /var/run/${NAME}.pid \
--oknodo

sleep 1

start-stop-daemon --start --quiet --pidfile /var/run/${NAME}.pid \
--chuid ${USER} --background --make-pidfile \
--exec ${DAEMON} -- --config=/etc/openerp-server.conf

echo "${NAME}."
;;

*)
N=/etc/init.d/${NAME}
echo "Usage: ${NAME} {start|stop|restart|force-reload}" >&2
exit 1
;;
esac

exit 0

EOF

sudo cp /tmp/openerp-server /etc/init.d/
sudo chmod +x /etc/init.d/openerp-server
#Create /var/log/openerp with proper ownership:
sudo mkdir -p /var/log/openerp
sudo touch /var/log/openerp/openerp.log
sudo chown -R openerp.root /var/log/openerp/

#####################################################################################
# openerp-server config file
#####################################################################################
cat > /tmp/openerp-server.conf <<"EOF2"
# /etc/openerp-server.conf(5) - configuration file for openerp-server(1)

[options]
# Enable the debugging mode (default False).
#verbose = True

# The file where the server pid will be stored (default False).
#pidfile = /var/run/openerp.pid

# The file where the server log will be stored (default False).
logfile = /var/log/openerp/openerp.log

# The IP address on which the server will bind.
# If empty, it will bind on all interfaces (default empty).
#interface = localhost
interface =
# The TCP port on which the server will listen (default 8069).
port = 8069

# Enable debug mode (default False).
#debug_mode = True

# Launch server over https instead of http (default False).
secure = False

# Specify the SMTP server for sending email (default localhost).
smtp_server = localhost

# Specify the SMTP user for sending email (default False).
smtp_user = False

# Specify the SMTP password for sending email (default False).
smtp_password = False

# Specify the database name.
db_name =

# Specify the database user name (default None).
db_user = openerp

# Specify the database password for db_user (default None).
db_password =

# Specify the database host (default localhost).
db_host =

# Specify the database port (default None).
db_port = 5432

EOF2

sudo cp /tmp/openerp-server.conf /etc/
sudo chown root.root /etc/openerp-server.conf
sudo chmod 644 /etc/openerp-server.conf

sudo sed -i "s/db_password =/db_password = $passwvar/g" /etc/openerp-server.conf

#####################################################################################
# openerp-web init script and openerp-web.cfg
#####################################################################################
cat > /tmp/openerp-web <<"EOF7"
#!/bin/sh

### BEGIN INIT INFO
# Provides: openerp-web
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: OpenERP Web - the Web Client of the OpenERP
# Description: OpenERP is a complete ERP and CRM software.
### END INIT INFO

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/openerp-web
NAME=openerp-web
DESC=openerp-web

# Specify the user name (Default: openerp).
USER="openerp"

# Specify an alternate config file (Default: /etc/openerp-web.cfg).
CONFIGFILE="/etc/openerp-web.cfg"

# pidfile
PIDFILE=/var/run/$NAME.pid

# Additional options that are passed to the Daemon.
DAEMON_OPTS="-c $CONFIGFILE"

[ -x $DAEMON ] || exit 0
[ -f $CONFIGFILE ] || exit 0

checkpid() {
[ -f $PIDFILE ] || return 1
pid=`cat $PIDFILE`
[ -d /proc/$pid ] && return 0
return 1
}

if [ -f /lib/lsb/init-functions ] || [ -f /etc/gentoo-release ] ; then

do_start() {
start-stop-daemon --start --quiet --pidfile $PIDFILE \
--chuid $USER --background --make-pidfile \
--exec $DAEMON -- $DAEMON_OPTS

RETVAL=$?
sleep 5 # wait for few seconds

return $RETVAL
}

do_stop() {
start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo

RETVAL=$?
sleep 2 # wait for few seconds
rm -f $PIDFILE # remove pidfile

return $RETVAL
}

do_restart() {
start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo

sleep 2 # wait for few seconds
rm -f $PIDFILE # remove pidfile

start-stop-daemon --start --quiet --pidfile $PIDFILE \
--chuid $USER --background --make-pidfile \
--exec $DAEMON -- $DAEMON_OPTS

RETVAL=$?
sleep 5 # wait for few seconds

return $RETVAL
}

else

do_start() {
$DAEMON $DAEMON_OPTS > /dev/null 2>&1 &

RETVAL=$?
sleep 5 # wait for few seconds

echo $! > $PIDFILE # create pidfile

return $RETVAL
}

do_stop() {

pid=`cat $PIDFILE`
kill -15 $pid

RETVAL=$?
sleep 2 # wait for few seconds
rm -f $PIDFILE # remove pidfile

return $RETVAL
}

do_restart() {

if [ -f $PIDFILE ]; then
do_stop
fi

do_start

return $?
}

fi

start_daemon() {

if [ -f $PIDFILE ]; then
echo "pidfile already exists: $PIDFILE"
exit 1
fi

echo -n "Starting $DESC: "

do_start

checkpid

if [ $? -eq 1 ]; then
rm -f $PIDFILE
echo "failed."
exit 1
fi

echo "done."
}

stop_daemon() {

checkpid

if [ $? -eq 1 ]; then
exit 0
fi

echo -n "Stopping $DESC: "

do_stop

if [ $? -eq 1 ]; then
echo "failed."
exit 1
fi

echo "done."
}

restart_daemon() {

echo -n "Reloading $DESC: "

do_restart

checkpid

if [ $? -eq 1 ]; then
rm -f $PIDFILE
echo "failed."
exit 1
fi

echo "done."
}

status_daemon() {

echo -n "Checking $DESC: "

checkpid

if [ $? -eq 1 ]; then
echo "stopped."
else
echo "running."
fi
}

case "$1" in
start) start_daemon ;;
stop) stop_daemon ;;
restart|force-reload) restart_daemon ;;
status) status_daemon ;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
exit 1
;;
esac

exit 0
EOF7

#sudo cp /usr/lib/python2.5/site-packages/openerp_web-5.0.1_0-py2.5.egg/scripts/openerp-web /etc/init.d/
sudo cp /tmp/openerp-web /etc/init.d/
sudo chmod +x /etc/init.d/openerp-web



cat > /tmp/openerp-web.cfg <<"EOF8"
[global]

# Some server parameters that you may want to tweak
server.socket_host = "0.0.0.0"
server.socket_port = 8080

# Sets the number of threads the server uses
server.thread_pool = 10

server.environment = "development"

# Simple code profiling
server.profile_on = False
server.profile_dir = "profile"

# if this is part of a larger site, you can set the path
# to the TurboGears instance here
#server.webpath = ""

# Set to True if you are deploying your App behind a proxy
# e.g. Apache using mod_proxy
tools.proxy.on = True

# If your proxy does not add the X-Forwarded-Host header, set
# the following to the *public* host url.
#tools.proxy.base = 'http://mydomain.com'

# logging
#log.access_file = "/var/log/openerp-web/access.log"
#log.error_file = "/var/log/openerp-web/error.log"

# OpenERP Server
[openerp]
host = 'localhost'
port = '8070'
protocol = 'socket'

# Web client settings
[openerp-web]
# filter dblists based on url pattern?
# NONE: No Filter
# EXACT: Exact Hostname
# UNDERSCORE: Hostname_
# BOTH: Exact Hostname or Hostname_

dblist.filter = 'NONE'

# whether to show Databases button on Login screen or not
dbbutton.visible = True

# will be applied on company logo
company.url = ''

# options to limit data rows in M2M/O2M lists, will be overriden
# with limit="5", min_rows="5" attributes in the tree view definitions
child.listgrid.limit = 5
child.listgrid.min_rows = 5
EOF8


#sudo cp /usr/lib/python2.5/site-packages/openerp_web-5.0.1_0-py2.5.egg/config/default.cfg /etc/openerp-web.cfg
sudo cp /tmp/openerp-web.cfg /etc/openerp-web.cfg
sudo chown root.root /etc/openerp-web.cfg
sudo chmod 644 /etc/openerp-web.cfg

#OpenERP Web configuration:
# tools.proxy.on = True
#sudo sed -i "s/^#tools\.proxy\.on.*/tools.proxy.on = True/g" /etc/openerp-web.cfg


#Create /var/log/openerp-web.log with proper ownership:
sudo mkdir -p /var/log/openerp-web
sudo touch /var/log/openerp-web/access.log
sudo touch /var/log/openerp-web/error.log
sudo chown -R openerp.root /var/log/openerp-web/

echo "# DON'T PRESS ACCEPT/OK !!. Updating RC Services";
#Now run following command to start the OpenERP Web automatically on system startup (Debian/Ubuntu):
sudo update-rc.d openerp-server start 21 2 3 4 5 . stop 21 0 1 6 .
sudo update-rc.d openerp-web start 70 2 3 4 5 . stop 20 0 1 6 .

############################################################################################
echo "# DON'T PRESS ACCEPT/OK !!. Downloading and Installing Apache";
#HTTPS and Proxy with Apache
sudo apt-get -y install apache2

############################################################################################
# /etc/apache2/sites-available/default-ssl (Available in Ubuntu9.04, but not in Ubuntu8.04)
# apache2-ssl-certificate script/package is missing in Ubuntu8.04
############################################################################################
echo "# DON'T PRESS ACCEPT/OK !!. Configuring Apache";
cat > /tmp/default <<"EOF3"
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName openerpweb.com
Redirect / https://openerpweb.com/

DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined
ServerSignature On

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

</VirtualHost>
EOF3

sudo cp /tmp/default /etc/apache2/sites-available/default
sudo chown root.root /etc/apache2/sites-available/default
sudo chmod 644 /etc/apache2/sites-available/default

cat > /tmp/default-ssl <<"EOF4"
NameVirtualHost *:443
<VirtualHost *:443>
ServerName openerpweb.com
ServerAdmin webmaster@localhost
SSLEngine on
SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyRequests Off
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/

RequestHeader set "X-Forwarded-Proto" "https"

# Fix IE problem (http error 408/409)
SetEnv proxy-nokeepalive 1

ErrorLog /var/log/apache2/error-ssl.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access-ssl.log combined
ServerSignature On
</VirtualHost>
EOF4

sudo cp /tmp/default-ssl /etc/apache2/sites-available/default-ssl
sudo chown root.root /etc/apache2/sites-available/default-ssl
sudo chmod 644 /etc/apache2/sites-available/default-ssl
echo "# DON'T PRESS ACCEPT/OK !!. Making SSL certificate for Apache";
# sudo mkdir /etc/apache2/ssl
# sudo /usr/sbin/make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/apache.pem
sudo /usr/sbin/make-ssl-cert generate-default-snakeoil --force-overwrite
# Snakeoil certificate files:
# /usr/share/ssl-cert/ssleay.cnf
# /etc/ssl/certs/ssl-cert-snakeoil.pem
# /etc/ssl/private/ssl-cert-snakeoil.key
echo "# DON'T PRESS ACCEPT/OK !!. Enabling Apache Modules";
# Apache Modules:
sudo a2enmod ssl
# We enable default-ssl site after creating "/etc/apache2/sites-available/default-ssl" file (not available in Ubuntu8.04)
sudo a2ensite default-ssl
sudo a2enmod rewrite
sudo a2enmod suexec
sudo a2enmod include
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_connect
sudo a2enmod proxy_ftp
sudo a2enmod headers
#Add your server’s IP address and URL in /etc/hosts:
# $ sudo vi /etc/hosts
#Replace
# 127.0.0.1 localhost
# 127.0.0.1 yourhostname yourhostnamealias
#With
#
# 127.0.0.1 localhost
# 192.168.x.x openerpweb.com yourhostname yourhostnamealias
sudo sed -i "s/\(^127\.0\.1\.1[[:space:]]*\)\([[:alnum:]].*\)/#\0\n$ipaddrvar $url \2/g" /etc/hosts
sudo sed -i "s/openerpweb\.com/$url/g" /etc/apache2/sites-available/default
sudo sed -i "s/openerpweb\.com/$url/g" /etc/apache2/sites-available/default-ssl
echo "# DON'T PRESS ACCEPT/OK !!. Restarting Apache";
sudo /etc/init.d/apache2 restart
echo "# DON'T PRESS ACCEPT/OK !!. Enabling Firewall settings";
# FIREWALL:
sudo ufw enable
sudo ufw allow ssh
sudo ufw allow http
sudo ufw allow https
# OpenERP port (GTK client):
sudo ufw allow 8069/tcp
# OpenERP port (GTK client):
sudo ufw allow 8070/tcp
echo "# DON'T PRESS ACCEPT/OK !!. Starting openerp-server and openerp-web services";
sudo /etc/init.d/openerp-server start
sudo /etc/init.d/openerp-web start
echo "# DON'T PRESS ACCEPT/OK !!. Making Desktop Icons for openerp-client and openerp-web URL";
#################################################################################
# This code makes links in your Desktop for openerp-client and openerpweb URL :
#################################################################################
cat > $MYDESKTOP/openerp-client.desktop <<"EOF5"
[Desktop Entry]
Version=1.0
Encoding=UTF-8
Name=openerp-client
Type=Application
Terminal=false
Name[es_ES]=openerp-client
Exec=/usr/bin/openerp-client
Comment[es_ES]=OpenERP GTK client
Comment=OpenERP GTK client
GenericName[en_US]=
EOF5
cat > $MYDESKTOP/OpenERPweb.desktop <<"EOF6"
[Desktop Entry]
Version=1.0
Encoding=UTF-8
Name=link to OpenERP Web
Type=Link
URL=http://openerpweburl
Icon=gnome-fs-bookmark
EOF6
sed -i "s/openerpweburl/$url/g" $MYDESKTOP/OpenERPweb.desktop
echo "# Installation of OpenERP Completed. PRESS ACCEPT";
clear
echo > $MYDESKTOP/OpenERP-README.txt
echo "------------------------------------------------------------------------------------------------------------------------------------------------" >> $MYDESKTOP/OpenERP-README.txt
echo " THE REMAINING STEPS CAN BE CONFIGURED FROM THE WEB INTERFACE (OPENERP WEB)" >> $MYDESKTOP/OpenERP-README.txt
echo >> $MYDESKTOP/OpenERP-README.txt
echo " 1. Register the DNS Name \"$url\" with its corresponding IP address ($ipaddrvar)." >> $MYDESKTOP/OpenERP-README.txt
echo " \"$url\" is the external URL of OpenERP Web. Make sure this URL is reachable by your Web clients (Open ERP users)" >> $MYDESKTOP/OpenERP-README.txt
echo " In Linux this can be done locally by adding the following line to /etc/hosts file:" >> $MYDESKTOP/OpenERP-README.txt
echo >> $MYDESKTOP/OpenERP-README.txt
echo " $ipaddrvar $url" >> $MYDESKTOP/OpenERP-README.txt
echo >> $MYDESKTOP/OpenERP-README.txt
echo " The hosts file is located in different locations in different operating systems and versions: \"http://en.wikipedia.org/wiki/Hosts_file\"" >> $MYDESKTOP/OpenERP-README.txt
echo " The hosts file is a computer file used to store information on where to find a node on a computer network. " >> $MYDESKTOP/OpenERP-README.txt
echo " This file maps hostnames to IP addresses. The hosts file is used as a supplement to (or a replacement of) the Domain Name System (DNS) on " >> $MYDESKTOP/OpenERP-README.txt
echo " networks of varying sizes. Unlike DNS, the hosts file is under the control of the local computer's administrator" >> $MYDESKTOP/OpenERP-README.txt
echo >> $MYDESKTOP/OpenERP-README.txt
echo " 2. Your OpenERP Web Service can now be reached with a web browser at: \"http://$url\"" >> $MYDESKTOP/OpenERP-README.txt
echo >> $MYDESKTOP/OpenERP-README.txt
echo " 3. WELCOME TO OPENERP: -> Click on \"Databases\" -> CREATE A NEW DATABASE:" >> $MYDESKTOP/OpenERP-README.txt
echo " 3.1 Super Administrator Password: admin" >> $MYDESKTOP/OpenERP-README.txt
echo " 3.2 New Name of the database: xxx " >> $MYDESKTOP/OpenERP-README.txt
echo " 3.3 Load Demo Data (y/n)" >> $MYDESKTOP/OpenERP-README.txt
echo " 3.4 Default language: ... " >> $MYDESKTOP/OpenERP-README.txt
echo " 3.5 Administrator Password: $passwvar" >> $MYDESKTOP/OpenERP-README.txt
echo " 3.6 Confirm Administrator Password: $passwvar" >> $MYDESKTOP/OpenERP-README.txt
echo >> $MYDESKTOP/OpenERP-README.txt
echo " 4. WELCOME TO OPENERP:" >> $MYDESKTOP/OpenERP-README.txt
echo " 4.1 Database: xxx " >> $MYDESKTOP/OpenERP-README.txt
echo " 4.2 Administrator Username: admin " >> $MYDESKTOP/OpenERP-README.txt
echo " 4.3 Administrator Password: $passwvar" >> $MYDESKTOP/OpenERP-README.txt
echo " 4.4 Click on \"Login\"" >> $MYDESKTOP/OpenERP-README.txt
echo >> $MYDESKTOP/OpenERP-README.txt
echo " 5. INSTALLATION & CONFIGURATION. You will now be asked to install and configure modules and users required by your Enterprise" >> $MYDESKTOP/OpenERP-README.txt
echo " 5.1 Click on \"Logout\"" >> $MYDESKTOP/OpenERP-README.txt
echo >> $MYDESKTOP/OpenERP-README.txt
echo " 6. WELCOME TO OPENERP: You can now log in with the following users" >> $MYDESKTOP/OpenERP-README.txt
echo " 6.1 User \"demo\" / Password \"demo\", in case you clicked on \"Load Demo Data\"" >> $MYDESKTOP/OpenERP-README.txt
echo " 6.2 User \"admin\" / Password \"$passwvar\"" >> $MYDESKTOP/OpenERP-README.txt
echo " 6.3 Users created by you during step #4" >> $MYDESKTOP/OpenERP-README.txt
echo "------------------------------------------------------------------------------------------------------------------------------------------------" >> $MYDESKTOP/OpenERP-README.txt
echo " Notes:" >> $MYDESKTOP/OpenERP-README.txt
echo " * OpenERP GTK Client can be run as non-root with the command \"openerp-client\"" >> $MYDESKTOP/OpenERP-README.txt
echo " (Make sure you enable X11 Forwarding on your SSH remote session)" >> $MYDESKTOP/OpenERP-README.txt
echo " * Ports 8069 & 8070 are open for remote access of OpenERP GTK clients " >> $MYDESKTOP/OpenERP-README.txt
echo " * Database backup/restore can be done with pg_dump and pg_restore (CLI) or pgAdmin3 (GUI)" >> $MYDESKTOP/OpenERP-README.txt
echo " Check http://www.postgresql.org/docs/8.3/interactive/index.html" >> $MYDESKTOP/OpenERP-README.txt
echo >> $MYDESKTOP/OpenERP-README.txt
echo " DATABASE BACKUP WITH PGADMIN:" >> $MYDESKTOP/OpenERP-README.txt
echo " pgAdmin3 : pgAdmin is the leading graphical Open Source management, development and administration tool for PostgreSQL. " >> $MYDESKTOP/OpenERP-README.txt
echo " Run \"pgAdmin3\": Applications -> System Tools -> pgAdmin III :" >> $MYDESKTOP/OpenERP-README.txt
echo " Name=XXX Database:postgres Server:localhost User:openerp Password:$passwvar" >> $MYDESKTOP/OpenERP-README.txt
echo " Run pgadmin3 locally, then connect to the database server, right click on the database name and select Backup from the contextual menu. " >> $MYDESKTOP/OpenERP-README.txt
echo " Use COMPRESS mode (native and efficient) to save the backup. Still using pgadmin3, connect on the destination server, create a new database, " >> $MYDESKTOP/OpenERP-README.txt
echo " right click on its name and select Restore." >> $MYDESKTOP/OpenERP-README.txt
echo >> $MYDESKTOP/OpenERP-README.txt
cat $MYDESKTOP/OpenERP-README.txt | zenity --title="Installation of OpenERP Completed. Content of OpenERP-README.txt" --text-info --width 1000 --height=700
) | (if $(zenity --progress \
--title="Installing OpenERP on Ubuntu" \
--text="Downloading OpenERP Software from launchpad.net" \
--pulsate);
then
echo "Installation of OpenERP Completed.";
else
# zenity's "--auto-kill" opcion does not work due to a bug. This is a workaround
kill -9 $$
fi)
}


function check4newrevisionsfunc()
{
local __newrevisionsfound=$1
local newrevisionsfound=0

local __listbranches=$2
local listbranches=""

cd /opt/openerp-server
sudo bzr missing > /tmp/check4newrevisions.txt
tail -1 /tmp/check4newrevisions.txt > /tmp/newrevisions.txt
NEWREVISIONS=`awk '/Branches are up to date/ {print $0}' /tmp/newrevisions.txt`
if [ -z "$NEWREVISIONS" ];
then
newrevisionsfound=1
listbranches=$listbranches"TRUE openerp-server "
else
listbranches=$listbranches"FALSE openerp-server "
fi
cd /opt/openerp-client
sudo bzr missing > /tmp/check4newrevisions.txt
tail -1 /tmp/check4newrevisions.txt > /tmp/newrevisions.txt
NEWREVISIONS=`awk '/Branches are up to date/ {print $0}' /tmp/newrevisions.txt`
if [ -z "$NEWREVISIONS" ];
then
newrevisionsfound=1
listbranches=$listbranches"TRUE openerp-client "
else
listbranches=$listbranches"FALSE openerp-client "
fi
cd /opt/openerp-web
sudo bzr missing > /tmp/check4newrevisions.txt
tail -1 /tmp/check4newrevisions.txt > /tmp/newrevisions.txt
NEWREVISIONS=`awk '/Branches are up to date/ {print $0}' /tmp/newrevisions.txt`
if [ -z "$NEWREVISIONS" ];
then
newrevisionsfound=1
listbranches=$listbranches"TRUE openerp-web "
else
listbranches=$listbranches"FALSE openerp-web "
fi
cd /opt/addons
sudo bzr missing > /tmp/check4newrevisions.txt
tail -1 /tmp/check4newrevisions.txt > /tmp/newrevisions.txt
NEWREVISIONS=`awk '/Branches are up to date/ {print $0}' /tmp/newrevisions.txt`
if [ -z "$NEWREVISIONS" ];
then
newrevisionsfound=1
listbranches=$listbranches"TRUE Addons "
else
listbranches=$listbranches"FALSE Addons "
fi

if [ -d /opt/extra-addons ];
then
cd /opt/extra-addons
sudo bzr missing > /tmp/check4newrevisions.txt
tail -1 /tmp/check4newrevisions.txt > /tmp/newrevisions.txt
NEWREVISIONS=`awk '/Branches are up to date/ {print $0}' /tmp/newrevisions.txt`
if [ -z "$NEWREVISIONS" ];
then
newrevisionsfound=1
listbranches=$listbranches"TRUE extra-addons "
else
listbranches=$listbranches"FALSE extra-addons "
fi
else
listbranches=$listbranches"FALSE extra-addons "
fi

eval $__newrevisionsfound="'$newrevisionsfound'"
eval $__listbranches="'$listbranches'"
}

function updatefunc()
{
# SUDO issue:
CHECKSUDOPASSWORD2=""
while [ -z $CHECKSUDOPASSWORD2 ]; do
zenity --entry --title="Superuser privileges" --text="Enter your user password (sudo):" --hide-text | sudo -S echo
if [ $? -ne 0 ];
then
zenity --error --text="Sorry, bad password"
else
CHECKSUDOPASSWORD2="1"
fi
done

# When you use pipelines with built-in commands, the shell generally spawns a subshell to execute them.
# Unfortunately any change to a subshell variable is lost when you go back to the upper shell.
# Try this:
# foo=0;
# echo $foo;
# { foo=1;echo $foo; } | cat;
# echo $foo;
# Workaround: use i/o redirection like this
# exec 3> >(zenity --progress --pulsate)
# func >&3
# exec 3>&-
# References: http://ubuntuforums.org/showthread.php?t=686757
# http://www.aero.jussieu.fr/services/INFO/documentation/mendel/HTML/io-redirection.html#FDREF
exec 3> >(if ! $(zenity --progress --title="OpenERP Updater" --text="Checking for new OpenERP revisions" --pulsate --auto-close); then kill -9 $$;fi)
check4newrevisionsfunc NEWREVISIONSFOUND LISTBRANCHES >&3
exec 3>&-

if [ $NEWREVISIONSFOUND -eq 1 ];
then
zenity --info --text="New Revisions found. Press OK to continue"
else
zenity --question --text="Your OpenERP installation is already up to date. Press OK to exit or Cancel to reinstall OpenERP"
if [ $? -eq 0 ]; # 0 = ACCEPT
then
exit
else
zenity --info --text="OpenERP will be reinstalled. Press OK"
if [ -d /opt/extra-addons ];
then
LISTBRANCHES="TRUE openerp-server TRUE openerp-client TRUE openerp-web TRUE Addons TRUE extra-addons"
else
LISTBRANCHES="TRUE openerp-server TRUE openerp-client TRUE openerp-web TRUE Addons FALSE extra-addons"
fi
fi
fi

BRANCHESTOREINSTALL=$(zenity --list --text "OpenERP Branches for updating and reinstalling" --width 300 --height=250 --checklist --column "Pick" --column "Branch" $LISTBRANCHES --separator=" ");
if [ $? -eq 1 ]
then
zenity --warning --text="Cancel button pressed. Script execution aborted"
exit 0
fi

NEWSERVERREVISIONS=`echo $BRANCHESTOREINSTALL | awk '/openerp-server/'`
if [ -n "$NEWSERVERREVISIONS" ];
then
NEWSERVERREVISIONS=1
else
NEWSERVERREVISIONS=0
fi


NEWCLIENTREVISIONS=`echo $BRANCHESTOREINSTALL | awk '/openerp-client/'`
if [ -n "$NEWCLIENTREVISIONS" ];
then
NEWCLIENTREVISIONS=1
else
NEWCLIENTREVISIONS=0
fi

NEWWEBREVISIONS=`echo $BRANCHESTOREINSTALL | awk '/openerp-web/'`
if [ -n "$NEWWEBREVISIONS" ];
then
NEWWEBREVISIONS=1
else
NEWWEBREVISIONS=0
fi

NEWADDONSREVISIONS=`echo $BRANCHESTOREINSTALL | awk '/Addons/'`
if [ -n "$NEWADDONSREVISIONS" ];
then
NEWADDONSREVISIONS=1
else
NEWADDONSREVISIONS=0
fi

NEWEXTRAADDONSREVISIONS=`echo $BRANCHESTOREINSTALL | awk '/extra-addons/'`
if [ -n "$NEWEXTRAADDONSREVISIONS" ];
then
NEWEXTRAADDONSREVISIONS=1
else
NEWEXTRAADDONSREVISIONS=0
fi

# Inside parentheses, and therefore a subshell . . .
# http://tldp.org/LDP/abs/html/subshells.html
# Variable operations inside a subshell, even to a GLOBAL variable do not affect the value of the variable outside the subshell!
(
if [ $NEWSERVERREVISIONS -eq 1 ];
then
echo "# Updating OpenERP Server with latest stable revisions from launchpad.net";
echo ">>>>> OpenERP Server: Updating latest stable revisions from launchpad.net <<<<<" | tee -a $MYDESKTOP/OpenERP-updates.txt;
cd /opt/openerp-server
sudo bzr pull >>$MYDESKTOP/OpenERP-updates.txt 2>&1
sudo bzr update /opt/openerp-server >>$MYDESKTOP/OpenERP-updates.txt 2>&1
fi
if [ $NEWCLIENTREVISIONS -eq 1 ];
then
echo "# Updating OpenERP Client with latest stable revisions from launchpad.net";
echo ">>>>> OpenERP Client: Updating latest stable revisions from launchpad.net <<<<<" | tee -a $MYDESKTOP/OpenERP-updates.txt;
cd /opt/openerp-client
sudo bzr pull >>$MYDESKTOP/OpenERP-updates.txt 2>&1
sudo bzr update /opt/openerp-client >>$MYDESKTOP/OpenERP-updates.txt 2>&1
fi
if [ $NEWWEBREVISIONS -eq 1 ];
then
echo "# Updating OpenERP Client Web with latest stable revisions from launchpad.net";
echo ">>>>> OpenERP Client Web: Updating latest stable revisions from launchpad.net <<<<<" | tee -a $MYDESKTOP/OpenERP-updates.txt;
cd /opt/openerp-web
sudo bzr pull >>$MYDESKTOP/OpenERP-updates.txt 2>&1
sudo bzr update /opt/openerp-web >>$MYDESKTOP/OpenERP-updates.txt 2>&1
fi
if [ $NEWADDONSREVISIONS -eq 1 ];
then
echo "# Updating OpenERP Addons with latest stable revisions from launchpad.net";
echo ">>>>> OpenERP Addons: Updating latest stable revisions from launchpad.net <<<<<" | tee -a $MYDESKTOP/OpenERP-updates.txt;
cd /opt/addons
sudo bzr pull >>$MYDESKTOP/OpenERP-updates.txt 2>&1
sudo bzr update /opt/addons >>$MYDESKTOP/OpenERP-updates.txt 2>&1
fi

if [ $NEWEXTRAADDONSREVISIONS -eq 1 ];
then
if [ -d /opt/extra-addons ];
then
echo "# Updating OpenERP Extra-Addons with latest stable revisions from launchpad.net";
echo ">>>>> OpenERP Extra-Addons: Updating latest stable revisions from launchpad.net <<<<<" | tee -a $MYDESKTOP/OpenERP-updates.txt;
cd /opt/extra-addons
sudo bzr pull >>$MYDESKTOP/OpenERP-updates.txt 2>&1
sudo bzr update /opt/extra-addons >>$MYDESKTOP/OpenERP-updates.txt 2>&1
else
zenity --info --text="stable_5.0-extra-addons will be installed for first time"
echo "# Downloading OpenERP Extra-Addons with latest stable revisions from launchpad.net";
echo ">>>>> OpenERP Extra-Addons: Downloading latest stable revisions from launchpad.net <<<<<" | tee -a $MYDESKTOP/OpenERP-updates.txt;
cd /opt
sudo bzr branch lp:~openerp-commiter/openobject-addons/stable_5.0-extra-addons extra-addons >>$MYDESKTOP/OpenERP-updates.txt 2>&1
sudo bzr update /opt/extra-addons >>$MYDESKTOP/OpenERP-updates.txt 2>&1
fi
fi

echo "# Stopping OpenERP Server and OpenERP Web";
sudo /etc/init.d/openerp-server stop
sudo /etc/init.d/openerp-web stop
if [ $NEWSERVERREVISIONS -eq 1 ];
then
echo "# Reinstalling OpenERP Server";
cd /opt/openerp-server
sudo python setup.py install
fi
if [ $NEWADDONSREVISIONS -eq 1 ];
then
echo "# Reinstalling OpenERP Addons";
sudo cp -r /opt/addons/ /usr/lib/python2.5/site-packages/openerp-server/
sudo chown -R openerp.root /usr/lib/python2.5/site-packages/openerp-server/addons/
sudo chmod 755 /usr/lib/python2.5/site-packages/openerp-server/addons/
fi
if [ $NEWEXTRAADDONSREVISIONS -eq 1 ];
then
echo "# Reinstalling OpenERP Extra-Addons";
sudo cp -r /opt/extra-addons/* /usr/lib/python2.5/site-packages/openerp-server/addons/
sudo chown -R openerp.root /usr/lib/python2.5/site-packages/openerp-server/addons/
sudo chmod 755 /usr/lib/python2.5/site-packages/openerp-server/addons/
fi

# UPDATES AND UPGRADES:
# http://doc.openerp.com/book/8/8_21_Implem/8_21_Implem_support.html
# http://doc.openerp.com/install/windows/server/index.html
# First time run with an upgraded version of Open ERP Server
# Execute the command with an option that updates the data structures:
# --update=all
# sudo /etc/init.d/openerp-server stop

# sudo /usr/bin/openerp-server --stop-after-init --update=all --logfile=/var/log/openerp/openerp.log --db_host=localhost --db_port=5432 -d mydb -r openerp -w openerp
# sudo /usr/bin/openerp-server --stop-after-init --update=all --logfile=/var/log/openerp/openerp.log --db_host=localhost --db_port=5432 -r openerp -w openerp
# --update=mymodule --stop-after-init --log-level=debug
echo "# Updating OpenERP Modules";
sudo /usr/bin/openerp-server --stop-after-init --update=all --logfile=/var/log/openerp/openerp.log

# UPDATE:
# - downloaded the openerp-server file and extracted it
# - python setup.py install
# - I stopped all the services and ran openerp-server --update=all
# - I updated the web client with easy_install -U openerp-web
# - Restarted all the services

# UPGRADE:
# Make a backup of the database from the old version of Open ERP
# Stop the server running the old version
# Start the script called pre.py for the versions you’re moving between.
# Start the new version of the server using the option –update=all
# Stop the server running the new version.
# Start the script called post.py for the versions you’re moving between.
# Start the new version of the server and test it.
if [ $NEWCLIENTREVISIONS -eq 1 ];
then
echo "# Reinstalling OpenERP Client";
cd /opt/openerp-client
sudo python setup.py install
fi
if [ $NEWWEBREVISIONS -eq 1 ];
then
echo "# Reinstalling OpenERP Web";
cd /opt/openerp-web
#sudo python setup.py install
sudo easy_install -U openerp-web
fi
echo "# Starting OpenERP Server and OpenERP Web";
sudo /etc/init.d/openerp-server start
sudo /etc/init.d/openerp-web start
echo "# OpenERP has been updated. Press OK to exit";
) | (if $(zenity --progress \
--title="updating OpenERP on Ubuntu" \
--text="Downloading OpenERP Software from launchpad.net" \
--pulsate);
then
echo "update of OpenERP Completed.";
else
# zenity's "--auto-kill" opcion does not work due to a bug. This is a workaround
kill -9 $$
fi)
}
########################################################################################################################
# END OF FUNCTIONS
########################################################################################################################
if [ -x /etc/init.d/openerp-web ] ; then
zenity --question --text="OpenERP already installed. Would you like to update it?"
if [ $? -eq 0 ]; # 0 = ACCEPT
then
#zenity --info --text="OpenERP will be updated"
echo "############################################################################" >>$MYDESKTOP/OpenERP-updates.txt
echo "DATE:"`date` >>$MYDESKTOP/OpenERP-updates.txt 2>&1
updatefunc
else
zenity --info --text="OpenERP will NOT be updated. Press OK to exit"
fi
else
zenity --info --text="OpenERP will be installed for first time"
echo "############################################################################" >>$MYDESKTOP/OpenERP-updates.txt
echo "DATE:"`date` >>$MYDESKTOP/OpenERP-updates.txt 2>&1
installfunc
fi
 

以前的脚本和相关内容可以在http://opensourceconsulting.wordpress.com/2009/09/15/openerp-all-in-one-installer-update-for-dummies/找到。

赞(52) 打赏
未经允许不得转载:优客志 » 系统运维
分享到:

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏