libreerp_ynh/scripts/install

94 lines
2.9 KiB
Text
Raw Normal View History

2015-09-14 17:12:17 +02:00
#!/bin/bash
2015-09-14 17:18:33 +02:00
app=odoo
2015-09-14 17:12:17 +02:00
set -e
# Retrieve arguments
domain=$1
2015-09-14 18:13:54 +02:00
odoo_version=$2
admin_password=$3
2015-09-16 12:13:00 +02:00
database_password=$4
database_lang=$5
2015-09-14 17:12:17 +02:00
# Check domain/path availability
domain=${domain}"/"
sudo yunohost app checkurl $domain -a $app \
|| (echo "Path not available: $domain" && exit 1)
# Remove trailing "/" for next commands
domain=${domain%/}
sudo yunohost app setting $app domain -v $domain
2015-09-16 10:17:50 +02:00
if [ -f /usr/bin/openerp-server ]; then
echo "Odoo is already installed, switching to multi-instances"
sudo yunohost app setting $app instance -v "slave"
else
sudo yunohost app checkport 8069
if [[ ! $? -eq 0 ]]; then
exit 1
fi
echo "Installing odoo"
sudo yunohost app setting $app version -v $odoo_version
sudo yunohost app setting $app instance -v "master"
# Install Odoo
2015-09-14 17:42:46 +02:00
# Prepare installation
2015-09-14 20:27:12 +02:00
sudo apt-get -y -qq install curl
2015-09-14 17:12:17 +02:00
# Install Odoo
2015-09-14 17:42:46 +02:00
sudo curl -sS https://nightly.odoo.com/odoo.key | sudo apt-key add -
2015-09-14 18:23:11 +02:00
if [ "$odoo_version" = "8.0" ]; then
2015-09-14 18:20:51 +02:00
sudo sh -c 'echo "deb http://nightly.odoo.com/8.0/nightly/deb/ ./" > /etc/apt/sources.list.d/odoo.list'
2015-09-14 18:23:11 +02:00
else
2015-09-14 18:20:51 +02:00
sudo sh -c 'echo "deb http://nightly.odoo.com/9.0/nightly/deb/ ./" > /etc/apt/sources.list.d/odoo.list'
fi
2015-09-14 17:42:46 +02:00
sudo apt-get update
2015-09-14 20:27:12 +02:00
# Initialize installation
sudo apt-get -y -qq install postgresql
su - postgres -c "createuser -s odoo" 2> /dev/null || true
sudo apt-get -y -qq install odoo
2015-09-14 17:12:17 +02:00
2015-09-14 20:38:40 +02:00
# Install wkhtmltopdf to print PDF reports
2015-09-16 15:48:36 +02:00
sudo wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-jessie-amd64.deb
sudo dpkg -i wkhtmltox-0.12.2.1_linux-jessie-amd64.deb
sudo cp /usr/local/bin/wkhtmltopdf /usr/bin
sudo cp /usr/local/bin/wkhtmltoimage /usr/bin
2015-09-14 20:38:40 +02:00
2015-09-14 18:38:24 +02:00
# Set admin password
2015-09-14 19:10:35 +02:00
sudo sed -i "s@ADMIN_PASSWORD@$admin_password@g" ../conf/openerp-server.conf
2015-09-14 18:56:06 +02:00
sudo cp ../conf/openerp-server.conf /etc/odoo/openerp-server.conf
sudo chown odoo:odoo /etc/odoo/openerp-server.conf
2015-09-14 18:38:24 +02:00
2015-09-16 12:13:00 +02:00
# Autoinstall the LDAP auth module
2015-09-14 18:38:24 +02:00
sudo sed -i "s@'auto_install': False@'auto_install': True@g" /usr/lib/python2.7/dist-packages/openerp/addons/auth_ldap/__openerp__.py
2015-09-14 17:12:17 +02:00
2015-09-16 12:13:00 +02:00
# Install oerplib to manage databases
2015-09-20 20:36:58 +02:00
# sudo pip install oerplib
2015-09-16 12:13:00 +02:00
2015-09-14 17:42:46 +02:00
# Add services
sudo yunohost service add postgresql
sudo yunohost service add odoo
2015-09-14 17:43:17 +02:00
sudo yunohost service stop odoo
sudo yunohost service start odoo
2015-09-16 10:17:50 +02:00
fi
2015-09-20 20:36:58 +02:00
# Setup database: not working
# sudo sed -i "s@ADMIN_PASSWORD@$admin_password@g" ../conf/install_database.py
# sudo sed -i "s@DOMAIN_DATABASE@${domain//./-}@g" ../conf/install_database.py
# sudo sed -i "s@DATABASE_LANG@$database_lang@g" ../conf/install_database.py
# sudo sed -i "s@DATABASE_PASSWORD@$database_password@g" ../conf/install_database.py
# sudo python ../conf/install_database.py
2015-09-16 12:13:00 +02:00
2015-09-16 10:17:50 +02:00
# Setup LDAP: TO BE DONE
2015-09-14 20:38:40 +02:00
2015-09-14 17:12:17 +02:00
# Configure Nginx and reload
2015-09-14 18:13:54 +02:00
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
2015-09-14 17:12:17 +02:00
2015-09-14 18:13:54 +02:00
# Make Odoo public
2015-09-14 17:12:17 +02:00
sudo yunohost app setting $app skipped_uris -v "/"
sudo service nginx reload
2015-09-19 11:48:14 +02:00
echo $?