commit
19c8da52ae
22 changed files with 1145 additions and 559 deletions
17
.gitattributes
vendored
17
.gitattributes
vendored
|
@ -1,17 +0,0 @@
|
|||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
||||
|
||||
# Custom for Visual Studio
|
||||
*.cs diff=csharp
|
||||
|
||||
# Standard to msysgit
|
||||
*.doc diff=astextplain
|
||||
*.DOC diff=astextplain
|
||||
*.docx diff=astextplain
|
||||
*.DOCX diff=astextplain
|
||||
*.dot diff=astextplain
|
||||
*.DOT diff=astextplain
|
||||
*.pdf diff=astextplain
|
||||
*.PDF diff=astextplain
|
||||
*.rtf diff=astextplain
|
||||
*.RTF diff=astextplain
|
55
.github/ISSUE_TEMPLATE.md
vendored
Normal file
55
.github/ISSUE_TEMPLATE.md
vendored
Normal file
|
@ -0,0 +1,55 @@
|
|||
---
|
||||
name: Bug report
|
||||
about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently.
|
||||
|
||||
---
|
||||
|
||||
**How to post a meaningful bug report**
|
||||
1. *Read this whole template first.*
|
||||
2. *Determine if you are on the right place:*
|
||||
- *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!*
|
||||
- *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.*
|
||||
- *When in doubt, post here and we will figure it out together.*
|
||||
3. *Delete the italic comments as you write over them below, and remove this guide.*
|
||||
---
|
||||
|
||||
### Describe the bug
|
||||
|
||||
*A clear and concise description of what the bug is.*
|
||||
|
||||
### Context
|
||||
|
||||
- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...*
|
||||
- YunoHost version: x.x.x
|
||||
- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...*
|
||||
- Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: *no / yes*
|
||||
- If yes, please explain:
|
||||
- Using, or trying to install package version/branch:
|
||||
- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`*
|
||||
|
||||
### Steps to reproduce
|
||||
|
||||
- *If you performed a command from the CLI, the command itself is enough. For example:*
|
||||
```sh
|
||||
sudo yunohost app install the_app
|
||||
```
|
||||
- *If you used the webadmin, please perform the equivalent command from the CLI first.*
|
||||
- *If the error occurs in your browser, explain what you did:*
|
||||
1. *Go to '...'*
|
||||
2. *Click on '...'*
|
||||
3. *Scroll down to '...'*
|
||||
4. *See error*
|
||||
|
||||
### Expected behavior
|
||||
|
||||
*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.*
|
||||
|
||||
### Logs
|
||||
|
||||
*When an operation fails, YunoHost provides a simple way to share the logs.*
|
||||
- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.*
|
||||
- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.*
|
||||
|
||||
*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)*
|
||||
|
||||
*If applicable and useful, add screenshots to help explain your problem.*
|
16
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
16
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
## Problem
|
||||
|
||||
- *Description of why you made this PR*
|
||||
|
||||
## Solution
|
||||
|
||||
- *And how do you fix that problem*
|
||||
|
||||
## PR Status
|
||||
|
||||
- [ ] Code finished and ready to be reviewed/tested
|
||||
- [ ] The fix/enhancement were manually tested (if applicable)
|
||||
|
||||
## Automatic tests
|
||||
|
||||
Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ *after creating the PR*, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization)
|
43
.gitignore
vendored
43
.gitignore
vendored
|
@ -1,43 +0,0 @@
|
|||
# Windows image file caches
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
|
||||
# Folder config file
|
||||
Desktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
# =========================
|
||||
# Operating System Files
|
||||
# =========================
|
||||
|
||||
# OSX
|
||||
# =========================
|
||||
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear on external disk
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
57
README.md
57
README.md
|
@ -1,7 +1,19 @@
|
|||
LibreERP
|
||||
----
|
||||
[![Integration level](https://dash.yunohost.org/integration/libreerp.svg)](https://dash.yunohost.org/appci/app/libreerp)
|
||||
[![Install libreerp with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=libreerp)
|
||||
<!--
|
||||
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
|
||||
It shall NOT be edited by hand.
|
||||
-->
|
||||
|
||||
# LibreERP for YunoHost
|
||||
|
||||
[![Integration level](https://dash.yunohost.org/integration/libreerp.svg)](https://dash.yunohost.org/appci/app/libreerp) ![](https://ci-apps.yunohost.org/ci/badges/libreerp.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/libreerp.maintain.svg)
|
||||
[![Install LibreERP with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=libreerp)
|
||||
|
||||
*[Lire ce readme en français.](./README_fr.md)*
|
||||
|
||||
> *This package allows you to install LibreERP quickly and simply on a YunoHost server.
|
||||
If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
|
||||
|
||||
## Overview
|
||||
|
||||
LibreERP is a suite of web based open source business apps. LibreERP is a fork of Odoo Community Edition.
|
||||
|
||||
|
@ -9,8 +21,13 @@ The main LibreERP Apps include an Open Source CRM, Website Builder, eCommerce, P
|
|||
|
||||
LibreERP Apps can be used as stand-alone applications, but they also integrate seamlessly so you get a full-featured Open Source ERP when you install several Apps.
|
||||
|
||||
LibreERP for YunoHost
|
||||
----------------------------
|
||||
|
||||
**Shipped version:** 12.0~ynh6
|
||||
|
||||
**Demo:** https://www.odoo.com/trial
|
||||
|
||||
## Disclaimers / important information
|
||||
|
||||
**WARNING**: LibreERP is a complex app. **DO NOT USE THIS PACKAGE** to run your business unless you know what you are doing!!! If you don't, you should consider to ask for help from a professionnal!
|
||||
|
||||
**IMPORTANT:** This app MUST be installed on a domain's root!
|
||||
|
@ -20,14 +37,32 @@ https://example.com/erp/ will NOT work
|
|||
To connect on your LibreERP
|
||||
-----------
|
||||
- Go on https://YOURDOMAIN/web
|
||||
- Use your master password OR admin/admin if you use LibreERP 8.0
|
||||
|
||||
Contribute
|
||||
-----------
|
||||
See the project here : https://github.com/YunoHost-Apps/libreerp_ynh/projects/1
|
||||
- Use your master password
|
||||
|
||||
About licences
|
||||
-----------
|
||||
LibreERP 8.0 is under AGPL-3.0
|
||||
Next version are under LGPL-3.0
|
||||
LibreERP is forked from Odoo Community Edition. The name is change due to Odoo trademark policy.
|
||||
|
||||
## Documentation and resources
|
||||
|
||||
* Official app website: https://odoo.com
|
||||
* Official user documentation: https://www.odoo.com/documentation/15.0/applications.html
|
||||
* Official admin documentation: https://www.odoo.com/documentation/15.0/administration.html
|
||||
* Upstream app code repository: https://github.com/odoo/odoo
|
||||
* YunoHost documentation for this app: https://yunohost.org/app_libreerp
|
||||
* Report a bug: https://github.com/YunoHost-Apps/libreerp_ynh/issues
|
||||
|
||||
## Developer info
|
||||
|
||||
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/libreerp_ynh/tree/testing).
|
||||
|
||||
To try the testing branch, please proceed like that.
|
||||
```
|
||||
sudo yunohost app install https://github.com/YunoHost-Apps/libreerp_ynh/tree/testing --debug
|
||||
or
|
||||
sudo yunohost app upgrade libreerp -u https://github.com/YunoHost-Apps/libreerp_ynh/tree/testing --debug
|
||||
```
|
||||
|
||||
**More info regarding app packaging:** https://yunohost.org/packaging_apps
|
64
README_fr.md
Normal file
64
README_fr.md
Normal file
|
@ -0,0 +1,64 @@
|
|||
# LibreERP pour YunoHost
|
||||
|
||||
[![Niveau d'intégration](https://dash.yunohost.org/integration/libreerp.svg)](https://dash.yunohost.org/appci/app/libreerp) ![](https://ci-apps.yunohost.org/ci/badges/libreerp.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/libreerp.maintain.svg)
|
||||
[![Installer LibreERP avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=libreerp)
|
||||
|
||||
*[Read this readme in english.](./README.md)*
|
||||
*[Lire ce readme en français.](./README_fr.md)*
|
||||
|
||||
> *Ce package vous permet d'installer LibreERP rapidement et simplement sur un serveur YunoHost.
|
||||
Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.*
|
||||
|
||||
## Vue d'ensemble
|
||||
|
||||
LibreERP is a suite of web based open source business apps. LibreERP is a fork of Odoo Community Edition.
|
||||
|
||||
The main LibreERP Apps include an Open Source CRM, Website Builder, eCommerce, Project Management, Billing & Accounting, Point of Sale, Human Resources, Marketing, Manufacturing, Purchase Management, ...
|
||||
|
||||
LibreERP Apps can be used as stand-alone applications, but they also integrate seamlessly so you get a full-featured Open Source ERP when you install several Apps.
|
||||
|
||||
|
||||
**Version incluse :** 12.0~ynh6
|
||||
|
||||
**Démo :** https://www.odoo.com/trial
|
||||
|
||||
## Avertissements / informations importantes
|
||||
|
||||
**WARNING**: LibreERP is a complex app. **DO NOT USE THIS PACKAGE** to run your business unless you know what you are doing!!! If you don't, you should consider to ask for help from a professionnal!
|
||||
|
||||
**IMPORTANT:** This app MUST be installed on a domain's root!
|
||||
https://erp.example.com/ will work
|
||||
https://example.com/erp/ will NOT work
|
||||
|
||||
To connect on your LibreERP
|
||||
-----------
|
||||
- Go on https://YOURDOMAIN/web
|
||||
- Use your master password
|
||||
|
||||
About licences
|
||||
-----------
|
||||
LibreERP 8.0 is under AGPL-3.0
|
||||
Next version are under LGPL-3.0
|
||||
LibreERP is forked from Odoo Community Edition. The name is change due to Odoo trademark policy.
|
||||
|
||||
## Documentations et ressources
|
||||
|
||||
* Site officiel de l'app : https://odoo.com
|
||||
* Documentation officielle utilisateur : https://www.odoo.com/documentation/15.0/applications.html
|
||||
* Documentation officielle de l'admin : https://www.odoo.com/documentation/15.0/administration.html
|
||||
* Dépôt de code officiel de l'app : https://github.com/odoo/odoo
|
||||
* Documentation YunoHost pour cette app : https://yunohost.org/app_libreerp
|
||||
* Signaler un bug : https://github.com/YunoHost-Apps/libreerp_ynh/issues
|
||||
|
||||
## Informations pour les développeurs
|
||||
|
||||
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/libreerp_ynh/tree/testing).
|
||||
|
||||
Pour essayer la branche testing, procédez comme suit.
|
||||
```
|
||||
sudo yunohost app install https://github.com/YunoHost-Apps/libreerp_ynh/tree/testing --debug
|
||||
ou
|
||||
sudo yunohost app upgrade libreerp -u https://github.com/YunoHost-Apps/libreerp_ynh/tree/testing --debug
|
||||
```
|
||||
|
||||
**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps
|
|
@ -15,6 +15,8 @@
|
|||
setup_private=0
|
||||
setup_public=1
|
||||
upgrade=1
|
||||
# 12.0-6
|
||||
upgrade=1 from_commit=2cfdbc229faa8700873e681a01f823c32475cca8
|
||||
backup_restore=1
|
||||
multi_instance=1
|
||||
port_already_use=0
|
||||
|
|
|
@ -5,7 +5,7 @@ admin_passwd = __ADMIN_PASSWORD__
|
|||
db_host = localhost
|
||||
db_port = 5432
|
||||
db_user = __DB_NAME__
|
||||
db_password = __DB_PASS__
|
||||
db_password = __DB_PWD__
|
||||
__CONTENT__
|
||||
__CONTENT2__
|
||||
__CONTENT3__
|
0
doc/.gitkeep
Normal file
0
doc/.gitkeep
Normal file
5
doc/DESCRIPTION.md
Normal file
5
doc/DESCRIPTION.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
LibreERP is a suite of web based open source business apps. LibreERP is a fork of Odoo Community Edition.
|
||||
|
||||
The main LibreERP Apps include an Open Source CRM, Website Builder, eCommerce, Project Management, Billing & Accounting, Point of Sale, Human Resources, Marketing, Manufacturing, Purchase Management, ...
|
||||
|
||||
LibreERP Apps can be used as stand-alone applications, but they also integrate seamlessly so you get a full-featured Open Source ERP when you install several Apps.
|
16
doc/DISCLAIMER.md
Normal file
16
doc/DISCLAIMER.md
Normal file
|
@ -0,0 +1,16 @@
|
|||
**WARNING**: LibreERP is a complex app. **DO NOT USE THIS PACKAGE** to run your business unless you know what you are doing!!! If you don't, you should consider to ask for help from a professionnal!
|
||||
|
||||
**IMPORTANT:** This app MUST be installed on a domain's root!
|
||||
https://erp.example.com/ will work
|
||||
https://example.com/erp/ will NOT work
|
||||
|
||||
To connect on your LibreERP
|
||||
-----------
|
||||
- Go on https://YOURDOMAIN/web
|
||||
- Use your master password
|
||||
|
||||
About licences
|
||||
-----------
|
||||
LibreERP 8.0 is under AGPL-3.0
|
||||
Next version are under LGPL-3.0
|
||||
LibreERP is forked from Odoo Community Edition. The name is change due to Odoo trademark policy.
|
0
doc/screenshots/.gitkeep
Normal file
0
doc/screenshots/.gitkeep
Normal file
|
@ -3,9 +3,20 @@
|
|||
"id": "libreerp",
|
||||
"packaging_format": 1,
|
||||
"description": {
|
||||
"en": "LibreERP is a suite of business apps (ERP: CRM, Accounting, Point of Sale, HR, Purchases...).",
|
||||
"fr": "LibreERP est une collection d'apps de gestion d'entreprise (ERP : CRM, Comptabilité, Point de Vente, RH, Achats, ...)."
|
||||
"en": "Suite of business apps (ERP: CRM, Accounting, Point of Sale, HR, Purchases...).",
|
||||
"fr": "Une collection d'apps de gestion d'entreprise (ERP : CRM, Comptabilité, Point de Vente, RH, Achats, ...)."
|
||||
},
|
||||
"version": "12.0~ynh6",
|
||||
"url": "https://odoo.com",
|
||||
"upstream": {
|
||||
"license": "LGPL-3.0-only",
|
||||
"website": "https://odoo.com",
|
||||
"demo": "https://www.odoo.com/trial",
|
||||
"admindoc": "https://www.odoo.com/documentation/15.0/administration.html",
|
||||
"userdoc": "https://www.odoo.com/documentation/15.0/applications.html",
|
||||
"code": "https://github.com/odoo/odoo"
|
||||
},
|
||||
"license": "LGPL-3.0,AGPL-3.0",
|
||||
"maintainer": {
|
||||
"name": "ljf",
|
||||
"email": "ljf+libreerp_ynh@reflexlibre.net"
|
||||
|
@ -13,34 +24,34 @@
|
|||
"previous_maintainers": {
|
||||
"name": "scith"
|
||||
},
|
||||
"version": "12.0-6",
|
||||
"url": "https://github.com/YunoHost-Apps/libreerp_ynh",
|
||||
"license": "LGPL-3.0,AGPL-3.0",
|
||||
"requirements": {
|
||||
"yunohost": ">= 3.4.2.3"
|
||||
"yunohost": ">= 4.3.0"
|
||||
},
|
||||
"multi_instance": true,
|
||||
"services": [
|
||||
"nginx"
|
||||
],
|
||||
"arguments": {
|
||||
"install": [{
|
||||
"install": [
|
||||
{
|
||||
"name": "domain",
|
||||
"type": "domain",
|
||||
"ask": {
|
||||
"en": "Choose a domain for LibreERP (LibreERP will be installed on its root!)",
|
||||
"fr": "Choisissez un domaine pour LibreERP (LibreERP sera installé dans sa racine !)"
|
||||
"type": "domain"
|
||||
},
|
||||
"example": "erp.domain.org"
|
||||
}, {
|
||||
{
|
||||
"name": "admin",
|
||||
"type": "user"
|
||||
},
|
||||
{
|
||||
"name": "version",
|
||||
"choices": ["11", "12", "14"],
|
||||
"default": "14",
|
||||
"type": "string",
|
||||
"ask": {
|
||||
"en": "Choose the version you want",
|
||||
"fr": "Choisissez la version désirée"
|
||||
}
|
||||
}, {
|
||||
},
|
||||
"choices": ["11", "12", "14"],
|
||||
"default": "14"
|
||||
},
|
||||
{
|
||||
"name": "oca",
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
|
@ -48,28 +59,34 @@
|
|||
"en": "Do you want to setup OCA instead of LibreERP ? (not yet implemented)",
|
||||
"fr": "Désirez vous installer OCA à la place des sources de LibreERP (pas encore implémenté)"
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
"name": "admin_password",
|
||||
"type": "password",
|
||||
"ask": {
|
||||
"en": "Choose a strong master admin password",
|
||||
"fr": "Choisissez un mot de passe maître fort pour l'administration"
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
"name": "lang",
|
||||
"type": "string",
|
||||
"ask": {
|
||||
"en": "Choose a language",
|
||||
"fr": "Choisissez une langue"
|
||||
"en": "Choose the application language",
|
||||
"fr": "Choisissez la langue de l'application"
|
||||
},
|
||||
"choices": ["sq_AL", "am_ET", "ar_SY", "eu_ES", "bs_BA", "bg_BG", "my_MM", "ca_ES", "zh_CN", "zh_HK", "zh_TW", "hr_HR", "cs_CZ", "da_DK", "nl_BE", "nl_NL", "en_AU", "en_GB", "en_US", "et_EE", "fi_FI", "fr_BE", "fr_CA", "fr_CH", "fr_FR", "gl_ES", "ka_GE", "de_CH", "de_DE", "el_GR", "gu_IN", "he_IL", "hi_IN", "hu_HU", "id_ID", "it_IT", "ja_JP", "kab_DZ", "ko_KP", "ko_KR", "lo_LA", "lv_LV", "lt_LT", "mk_MK", "mn_MN", "nb_NO", "fa_IR", "pl_PL", "pt_BR", "pt_PT", "ro_RO", "ru_RU", "sr_RS", "sr@latin", "sk_SK", "sl_SI", "es_AR", "es_BO", "es_CL", "es_CO", "es_CR", "es_DO", "es_EC", "es_GT", "es_MX", "es_PA", "es_PE", "es_PY", "es_UY", "es_VE", "es_ES", "sv_SE", "te_IN", "th_TH", "tr_TR", "uk_UA", "vi_VN"],
|
||||
"default": "en_US"
|
||||
}, {
|
||||
},
|
||||
{
|
||||
"name": "tz",
|
||||
"type": "string",
|
||||
"ask": {
|
||||
"en": "Choose a timezone",
|
||||
"fr": "Choisissez un fuseau horaire"
|
||||
},
|
||||
"default": "Etc/UTC"
|
||||
}]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,20 @@
|
|||
#
|
||||
# Common variables
|
||||
#
|
||||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
|
||||
export appname="libreerp"
|
||||
export FORKNAME="odoo"
|
||||
DEPENDENCIES="curl postgresql xfonts-75dpi xfonts-base wkhtmltopdf node-less python3-dev gcc libldap2-dev libssl-dev libsasl2-dev python3-pip python3-dev python3-venv python3-wheel libxslt-dev libzip-dev python3-setuptools libjpeg-dev zlib1g-dev libfreetype6-dev libffi-dev libpq-dev"
|
||||
|
||||
swap_needed=1024
|
||||
|
||||
# dependencies used by the app
|
||||
pkg_dependencies="curl postgresql xfonts-75dpi xfonts-base wkhtmltopdf node-less python3-dev gcc libldap2-dev libssl-dev libsasl2-dev python3-pip python3-dev python3-venv python3-wheel libxslt-dev libzip-dev python3-setuptools libjpeg-dev zlib1g-dev libfreetype6-dev libffi-dev libpq-dev"
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
||||
function debranding() {
|
||||
# Remove Odoo references to avoid trademark issue
|
||||
|
@ -24,6 +34,7 @@ function debranding() {
|
|||
cp ../conf/favicon.ico $final_path/$appname/addons/web/static/src/img/favicon.ico
|
||||
|
||||
}
|
||||
|
||||
function setup_files() {
|
||||
|
||||
if [[ $oca -eq 0 ]]; then
|
||||
|
@ -33,74 +44,197 @@ function setup_files() {
|
|||
fi
|
||||
debranding
|
||||
mkdir -p $final_path/custom-addons
|
||||
chown -R $app:$app $final_path
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:$app "$final_path"
|
||||
touch /var/log/$app.log
|
||||
chown $app:$app /var/log/$app.log
|
||||
|
||||
if [ ! -f $conf_file ]; then
|
||||
ynh_configure server.conf $conf_file
|
||||
chown $app:$app $conf_file
|
||||
chmod 400 "$conf_file"
|
||||
chown $app:$app "$conf_file"
|
||||
|
||||
# Autoinstall the LDAP auth module
|
||||
if ls $final_path/$appname/$FORKNAME-bin > /dev/null ; then
|
||||
ynh_replace_string "^{$" "{'auto_install': True," ${final_path}/$appname/addons/auth_ldap/__manifest__.py
|
||||
ynh_replace_string "^{$" "{'auto_install': True," $final_path/$appname/addons/auth_ldap/__manifest__.py
|
||||
else
|
||||
ynh_replace_string "'auto_install': False" "'auto_install': True" ${final_path}/$appname/addons/auth_ldap/__openerp__.py
|
||||
ynh_replace_string "'auto_install': False" "'auto_install': True" $final_path/$appname/addons/auth_ldap/__openerp__.py
|
||||
fi
|
||||
fi
|
||||
|
||||
}
|
||||
# Install dependencies
|
||||
function install_dependencies() {
|
||||
ynh_add_swap 1024
|
||||
ynh_install_app_dependencies $DEPENDENCIES
|
||||
|
||||
if ! wkhtmltopdf --version | grep "wkhtmltopdf 0.12.4 (with patched qt)"; then
|
||||
# The debian package has a bug so we deploy a more recent version
|
||||
function setup_database() {
|
||||
export preinstall=1
|
||||
ynh_configure server.conf $conf_file
|
||||
chown $app:$app $conf_file
|
||||
# Load translation
|
||||
#param=" --without-demo True --addons-path $final_path/$appname/addons --db_user $app --db_password $db_pwd --db_host 127.0.0.1 --db_port 5432 --db-filter '^$app\$' -d $app "
|
||||
param=" -c $conf_file -d $app "
|
||||
ynh_exec_as $app $bin_file -c $conf_file --stop-after-init -i base -d $app
|
||||
ynh_exec_as $app $bin_file -c $conf_file --stop-after-init -i auth_ldap -d $app
|
||||
ynh_exec_as $app $bin_file -c $conf_file --stop-after-init --load-language $lang -d $app
|
||||
# Configure language, timezone and ldap
|
||||
ynh_exec_as $app $bin_file shell -c $conf_file -d $app <<< \
|
||||
"
|
||||
self.env['res.users'].search([['login', '=', 'admin']])[0].write({'password': '$admin_password'})
|
||||
self.env.cr.commit()
|
||||
"
|
||||
ynh_exec_as $app $bin_file shell -c $conf_file -d $app <<< \
|
||||
"
|
||||
self.write({'tz':'$tz','lang':'$lang'})
|
||||
self.env.cr.commit()
|
||||
"
|
||||
ynh_exec_as $app $bin_file shell -c $conf_file -d $app <<< \
|
||||
"
|
||||
template=env['res.users'].create({
|
||||
'login':'template',
|
||||
'password':'',
|
||||
'name':'template',
|
||||
'email':'template',
|
||||
'sel_groups_9_10':9,
|
||||
'tz':'$tz',
|
||||
'lang':'$lang'
|
||||
})
|
||||
self.env.cr.commit()
|
||||
self.company_id.ldaps.create({
|
||||
'ldap_server':'localhost',
|
||||
'ldap_server_port':389,
|
||||
'ldap_base':'ou=users, dc=yunohost,dc=org',
|
||||
'ldap_filter':'uid=%s',
|
||||
'user':template.id,
|
||||
'company':self.company_id.id
|
||||
})
|
||||
self.env.cr.commit()
|
||||
"
|
||||
export preinstall=0
|
||||
ynh_configure server.conf $conf_file
|
||||
chown $app:$app $conf_file
|
||||
}
|
||||
|
||||
ynh_configure () {
|
||||
local TEMPLATE=$1
|
||||
local DEST=$2
|
||||
content=""
|
||||
content2=""
|
||||
content3=""
|
||||
if [[ $preinstall == '1' ]]
|
||||
then
|
||||
content="dbfilter = $db_name"
|
||||
else
|
||||
content="db_name = $db_name"
|
||||
if [[ $app_version > 9 ]]
|
||||
then
|
||||
content2="dbfilter = False"
|
||||
fi
|
||||
content3="list_db = False"
|
||||
fi
|
||||
|
||||
mkdir -p "$(dirname $DEST)"
|
||||
if [ -f '../manifest.json' ] ; then
|
||||
ynh_setup_source /usr/
|
||||
ynh_add_config "${YNH_CWD}/../conf/$TEMPLATE" "$DEST"
|
||||
else
|
||||
OLD_YNH_CWD=$YNH_CWD
|
||||
YNH_CWD=$YNH_CWD/../settings/conf
|
||||
ynh_setup_source /usr/
|
||||
YNH_CWD=$OLD_YNH_CWD
|
||||
ynh_add_config "${YNH_CWD}/../settings/conf/$TEMPLATE" "$DEST"
|
||||
fi
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
||||
# Add swap
|
||||
#
|
||||
# usage: ynh_add_swap --size=SWAP in Mb
|
||||
# | arg: -s, --size= - Amount of SWAP to add in Mb.
|
||||
ynh_add_swap () {
|
||||
# Declare an array to define the options of this helper.
|
||||
declare -Ar args_array=( [s]=size= )
|
||||
local size
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
|
||||
local swap_max_size=$(( $size * 1024 ))
|
||||
|
||||
local free_space=$(df --output=avail / | sed 1d)
|
||||
# Because we don't want to fill the disk with a swap file, divide by 2 the available space.
|
||||
local usable_space=$(( $free_space / 2 ))
|
||||
|
||||
SD_CARD_CAN_SWAP=${SD_CARD_CAN_SWAP:-0}
|
||||
|
||||
# Swap on SD card only if it's is specified
|
||||
if ynh_is_main_device_a_sd_card && [ "$SD_CARD_CAN_SWAP" == "0" ]
|
||||
then
|
||||
ynh_print_warn --message="The main mountpoint of your system '/' is on an SD card, swap will not be added to prevent some damage of this one, but that can cause troubles for the app $app. If you still want activate the swap, you can relaunch the command preceded by 'SD_CARD_CAN_SWAP=1'"
|
||||
return
|
||||
fi
|
||||
pushd $final_path
|
||||
if grep "python3" $final_path/$appname/$FORKNAME-bin ; then
|
||||
python3 -m venv venv
|
||||
venv/bin/pip3 install wheel
|
||||
venv/bin/pip3 install -r $appname/requirements.txt
|
||||
|
||||
# Compare the available space with the size of the swap.
|
||||
# And set a acceptable size from the request
|
||||
if [ $usable_space -ge $swap_max_size ]
|
||||
then
|
||||
local swap_size=$swap_max_size
|
||||
elif [ $usable_space -ge $(( $swap_max_size / 2 )) ]
|
||||
then
|
||||
local swap_size=$(( $swap_max_size / 2 ))
|
||||
elif [ $usable_space -ge $(( $swap_max_size / 3 )) ]
|
||||
then
|
||||
local swap_size=$(( $swap_max_size / 3 ))
|
||||
elif [ $usable_space -ge $(( $swap_max_size / 4 )) ]
|
||||
then
|
||||
local swap_size=$(( $swap_max_size / 4 ))
|
||||
else
|
||||
virtualenv venv
|
||||
venv/bin/pip install wheel
|
||||
venv/bin/pip install -r $appname/requirements.txt
|
||||
echo "Not enough space left for a swap file" >&2
|
||||
local swap_size=0
|
||||
fi
|
||||
popd
|
||||
}
|
||||
|
||||
|
||||
# Add services
|
||||
function add_services() {
|
||||
if ! grep "^postgresql:$" /etc/yunohost/services.yml; then
|
||||
yunohost service add postgresql
|
||||
# If there's enough space for a swap, and no existing swap here
|
||||
if [ $swap_size -ne 0 ] && [ ! -e /swap_$app ]
|
||||
then
|
||||
# Preallocate space for the swap file, fallocate may sometime not be used, use dd instead in this case
|
||||
if ! fallocate -l ${swap_size}K /swap_$app
|
||||
then
|
||||
dd if=/dev/zero of=/swap_$app bs=1024 count=${swap_size}
|
||||
fi
|
||||
chmod 0600 /swap_$app
|
||||
# Create the swap
|
||||
mkswap /swap_$app
|
||||
# And activate it
|
||||
swapon /swap_$app
|
||||
# Then add an entry in fstab to load this swap at each boot.
|
||||
echo -e "/swap_$app swap swap defaults 0 0 #Swap added by $app" >> /etc/fstab
|
||||
fi
|
||||
ynh_configure app.service /etc/systemd/system/$app.service
|
||||
systemctl daemon-reload
|
||||
|
||||
yunohost service add $app --log /var/log/$app.log
|
||||
yunohost service stop $app
|
||||
yunohost service start $app
|
||||
yunohost service enable $app
|
||||
}
|
||||
|
||||
function ssowat_and_restart() {
|
||||
# Restart odoo service
|
||||
service $app restart
|
||||
|
||||
# Configure SSOWat
|
||||
ynh_sso_access "/web/database/manager"
|
||||
|
||||
# Reload services
|
||||
service nginx reload
|
||||
ynh_del_swap () {
|
||||
# If there a swap at this place
|
||||
if [ -e /swap_$app ]
|
||||
then
|
||||
# Clean the fstab
|
||||
sed -i "/#Swap added by $app/d" /etc/fstab
|
||||
# Desactive the swap file
|
||||
swapoff /swap_$app
|
||||
# And remove it
|
||||
rm /swap_$app
|
||||
fi
|
||||
}
|
||||
|
||||
# Check if the device of the main mountpoint "/" is an SD card
|
||||
#
|
||||
# [internal]
|
||||
#
|
||||
# return 0 if it's an SD card, else 1
|
||||
ynh_is_main_device_a_sd_card () {
|
||||
local main_device=$(lsblk --output PKNAME --noheadings $(findmnt / --nofsroot --uniq --output source --noheadings --first-only))
|
||||
|
||||
if echo $main_device | grep --quiet "mmc" && [ $(tail -n1 /sys/block/$main_device/queue/rotational) == "0" ]
|
||||
then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# FUTURE OFFICIAL HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -1,199 +0,0 @@
|
|||
ynh_check_var () {
|
||||
test -n "$1" || ynh_die "$2"
|
||||
}
|
||||
|
||||
ynh_export () {
|
||||
local ynh_arg=""
|
||||
for var in $@;
|
||||
do
|
||||
ynh_arg=$(echo $var | awk '{print toupper($0)}')
|
||||
ynh_arg="YNH_APP_ARG_$ynh_arg"
|
||||
export $var=${!ynh_arg}
|
||||
done
|
||||
}
|
||||
|
||||
# Save listed var in YunoHost app settings
|
||||
# usage: ynh_save_args VARNAME1 [VARNAME2 [...]]
|
||||
ynh_save_args () {
|
||||
for var in $@;
|
||||
do
|
||||
ynh_app_setting_set $app $var ${!var}
|
||||
done
|
||||
}
|
||||
|
||||
ynh_sso_access () {
|
||||
ynh_app_setting_set $app unprotected_uris "/"
|
||||
|
||||
if [[ $is_public -eq 0 ]]; then
|
||||
ynh_app_setting_set $app protected_uris "$1"
|
||||
fi
|
||||
sudo yunohost app ssowatconf
|
||||
}
|
||||
ynh_configure () {
|
||||
local TEMPLATE=$1
|
||||
local DEST=$2
|
||||
content=""
|
||||
content2=""
|
||||
content3=""
|
||||
if [[ $preinstall == '1' ]]
|
||||
then
|
||||
content="dbfilter = $db_name"
|
||||
else
|
||||
content="db_name = $db_name"
|
||||
if [[ $app_version > 9 ]]
|
||||
then
|
||||
content2="dbfilter = False"
|
||||
fi
|
||||
content3="list_db = False"
|
||||
fi
|
||||
|
||||
mkdir -p "$(dirname $DEST)"
|
||||
if [ -f '../manifest.json' ] ; then
|
||||
ynh_add_config "${YNH_CWD}/../conf/$TEMPLATE.j2" "$DEST"
|
||||
else
|
||||
ynh_add_config "${YNH_CWD}/../settings/conf/$TEMPLATE.j2" "$DEST"
|
||||
fi
|
||||
}
|
||||
|
||||
ynh_configure_nginx () {
|
||||
ynh_configure nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
sudo service nginx reload
|
||||
}
|
||||
|
||||
# Upgrade
|
||||
ynh_read_json () {
|
||||
python3 -c "import sys, json;print(json.load(open('$1'))['$2'])"
|
||||
}
|
||||
|
||||
ynh_read_manifest () {
|
||||
if [ -f '../manifest.json' ] ; then
|
||||
ynh_read_json '../manifest.json' "$1"
|
||||
else
|
||||
ynh_read_json '../settings/manifest.json' "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
is_stretch () {
|
||||
if [ "$(ynh_get_debian_release)" == "stretch" ]
|
||||
then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
is_jessie () {
|
||||
if [ "$(ynh_get_debian_release)" == "jessie" ]
|
||||
then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Argument $1 is the size of the swap in MiB
|
||||
ynh_add_swap () {
|
||||
# Declare an array to define the options of this helper.
|
||||
declare -Ar args_array=( [s]=size= )
|
||||
local size
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
|
||||
local swap_max_size=$(( $size * 1024 ))
|
||||
|
||||
local free_space=$(df --output=avail / | sed 1d)
|
||||
# Because we don't want to fill the disk with a swap file, divide by 2 the available space.
|
||||
local usable_space=$(( $free_space / 2 ))
|
||||
|
||||
# Compare the available space with the size of the swap.
|
||||
# And set a acceptable size from the request
|
||||
if [ $usable_space -ge $swap_max_size ]
|
||||
then
|
||||
local swap_size=$swap_max_size
|
||||
elif [ $usable_space -ge $(( $swap_max_size / 2 )) ]
|
||||
then
|
||||
local swap_size=$(( $swap_max_size / 2 ))
|
||||
elif [ $usable_space -ge $(( $swap_max_size / 3 )) ]
|
||||
then
|
||||
local swap_size=$(( $swap_max_size / 3 ))
|
||||
elif [ $usable_space -ge $(( $swap_max_size / 4 )) ]
|
||||
then
|
||||
local swap_size=$(( $swap_max_size / 4 ))
|
||||
else
|
||||
echo "Not enough space left for a swap file" >&2
|
||||
local swap_size=0
|
||||
fi
|
||||
|
||||
# If there's enough space for a swap, and no existing swap here
|
||||
if [ $swap_size -ne 0 ] && [ ! -e /swap ]
|
||||
then
|
||||
# Preallocate space for the swap file
|
||||
fallocate -l ${swap_size}K /swap
|
||||
chmod 0600 /swap
|
||||
# Create the swap
|
||||
mkswap /swap
|
||||
# And activate it
|
||||
swapon /swap
|
||||
# Then add an entry in fstab to load this swap at each boot.
|
||||
echo -e "/swap swap swap defaults 0 0 #Swap added by $app" >> /etc/fstab
|
||||
fi
|
||||
}
|
||||
|
||||
ynh_del_swap () {
|
||||
# If there a swap at this place
|
||||
if [ -e /swap ]
|
||||
then
|
||||
# Clean the fstab
|
||||
sed -i "/#Swap added by $app/d" /etc/fstab
|
||||
# Desactive the swap file
|
||||
swapoff /swap
|
||||
# And remove it
|
||||
rm /swap
|
||||
fi
|
||||
}
|
||||
|
||||
# Checks the app version to upgrade with the existing app version and returns:
|
||||
# - UPGRADE_APP if the upstream app version has changed
|
||||
# - UPGRADE_PACKAGE if only the YunoHost package has changed
|
||||
#
|
||||
## It stops the current script without error if the package is up-to-date
|
||||
#
|
||||
# This helper should be used to avoid an upgrade of an app, or the upstream part
|
||||
# of it, when it's not needed
|
||||
#
|
||||
# To force an upgrade, even if the package is up to date,
|
||||
# you have to set the variable YNH_FORCE_UPGRADE before.
|
||||
# example: sudo YNH_FORCE_UPGRADE=1 yunohost app upgrade MyApp
|
||||
|
||||
# usage: ynh_check_app_version_changed
|
||||
ynh_check_app_version_changed () {
|
||||
local force_upgrade=${YNH_FORCE_UPGRADE:-0}
|
||||
local package_check=${PACKAGE_CHECK_EXEC:-0}
|
||||
|
||||
# By default, upstream app version has changed
|
||||
local return_value="UPGRADE_APP"
|
||||
|
||||
local current_version=$(ynh_read_json "/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" "version" || echo 1.0)
|
||||
local current_upstream_version="${current_version/~ynh*/}"
|
||||
local update_version=$(ynh_read_manifest "version" || echo 1.0)
|
||||
local update_upstream_version="${update_version/~ynh*/}"
|
||||
|
||||
if [ "$current_version" == "$update_version" ] ; then
|
||||
# Complete versions are the same
|
||||
if [ "$force_upgrade" != "0" ]
|
||||
then
|
||||
echo "Upgrade forced by YNH_FORCE_UPGRADE." >&2
|
||||
unset YNH_FORCE_UPGRADE
|
||||
elif [ "$package_check" != "0" ]
|
||||
then
|
||||
echo "Upgrade forced for package check." >&2
|
||||
else
|
||||
ynh_die "Up-to-date, nothing to do" 0
|
||||
fi
|
||||
elif [ "$current_upstream_version" == "$update_upstream_version" ] ; then
|
||||
# Upstream versions are the same, only YunoHost package versions differ
|
||||
return_value="UPGRADE_PACKAGE"
|
||||
fi
|
||||
echo $return_value
|
||||
}
|
|
@ -1,31 +1,79 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Exit on command errors and treat unset variables as an error
|
||||
set -eu
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source /usr/share/yunohost/helpers
|
||||
#source _future.sh
|
||||
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
true
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||
conf_file=$(ynh_app_setting_get "$app" conf_file)
|
||||
|
||||
# Backup sources & data
|
||||
ynh_backup "${final_path}/$appname"
|
||||
ynh_backup "${final_path}/custom-addons"
|
||||
ynh_backup "${final_path}/.local"
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
conf_file=$(ynh_app_setting_get --app=$app --key=conf_file)
|
||||
|
||||
# Backup configuration
|
||||
ynh_backup "$conf_file"
|
||||
#=================================================
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
#=================================================
|
||||
ynh_print_info --message="Declaring files to be backed up..."
|
||||
|
||||
# Copy NGINX configuration
|
||||
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
||||
# Backup services
|
||||
ynh_backup "/etc/systemd/system/${app}.service"
|
||||
ynh_backup --src_path="$final_path/$appname"
|
||||
ynh_backup --src_path="$final_path/custom-addons"
|
||||
ynh_backup --src_path="$final_path/.local"
|
||||
|
||||
# Copy database
|
||||
sudo su -c "pg_dump $app" postgres > ./dump.sql
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
#=================================================
|
||||
# BACKUP SYSTEMD
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||
|
||||
#=================================================
|
||||
# BACKUP VARIOUS FILES
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="$conf_file"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_print_info --message="Backing up the PostgreSQL database..."
|
||||
|
||||
ynh_psql_dump_db --database="$db_name" > db.sql
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
|
|
275
scripts/install
275
scripts/install
|
@ -1,20 +1,50 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source /usr/share/yunohost/helpers
|
||||
source _future.sh
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
# Arguments from manifest
|
||||
export app=$YNH_APP_INSTANCE_NAME
|
||||
ynh_export domain oca admin_password lang tz
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||
#=================================================
|
||||
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path_url="/"
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
export app_version=$YNH_APP_ARG_VERSION
|
||||
export is_public=0
|
||||
export final_path="/var/www/$app"
|
||||
oca=$YNH_APP_ARG_OCA
|
||||
admin_password=$YNH_APP_ARG_ADMIN_PASSWORD
|
||||
lang=$YNH_APP_ARG_LANG
|
||||
tz=$YNH_APP_ARG_TZ
|
||||
|
||||
export app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
export conf_file=/etc/$app/main.conf
|
||||
export preinstall=0
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating installation parameters..."
|
||||
|
||||
export final_path=/var/www/$app
|
||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||
|
||||
export bin_file="$final_path/venv/bin/python3 $final_path/$appname/$FORKNAME-bin"
|
||||
if [ "$app_version" = "9" ]; then
|
||||
bin_file="$final_path/venv/bin/python3 $final_path/$appname/$FORKNAME.py"
|
||||
|
@ -22,79 +52,176 @@ fi
|
|||
if [ "$app_version" = "8" ]; then
|
||||
bin_file="$final_path/venv/bin/python3 $final_path/$appname/$FORKNAME.py"
|
||||
fi
|
||||
export db_name=$(ynh_sanitize_dbid $app)
|
||||
export port=$(ynh_find_port 8069)
|
||||
export port_chat=$(ynh_find_port 8072)
|
||||
export preinstall=0
|
||||
|
||||
# Register (book) web path
|
||||
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||
ynh_webpath_register $app $domain "/"
|
||||
ynh_script_progression --message="Storing installation settings..."
|
||||
|
||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||
ynh_app_setting_set --app=$app --key=app_version --value=$app_version
|
||||
ynh_app_setting_set --app=$app --key=oca --value=$oca
|
||||
ynh_app_setting_set --app=$app --key=lang --value=$lang
|
||||
ynh_app_setting_set --app=$app --key=tz --value=$tz
|
||||
ynh_app_setting_set --app=$app --key=conf_file --value=$conf_file
|
||||
|
||||
#=================================================
|
||||
# SETUP THE APP BY MODIFYING THE SYSTEM
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# FIND AND OPEN A PORT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Finding an available port..."
|
||||
|
||||
function setup_database() {
|
||||
export preinstall=1
|
||||
ynh_configure server.conf $conf_file
|
||||
chown $app:$app $conf_file
|
||||
# Load translation
|
||||
#param=" --without-demo True --addons-path $final_path/$appname/addons --db_user $app --db_password $db_pass --db_host 127.0.0.1 --db_port 5432 --db-filter '^$app\$' -d $app "
|
||||
param=" -c $conf_file -d $app "
|
||||
sudo -u $app $bin_file -c $conf_file --stop-after-init -i base -d $app
|
||||
sudo -u $app $bin_file -c $conf_file --stop-after-init -i auth_ldap -d $app
|
||||
sudo -u $app $bin_file -c $conf_file --stop-after-init --load-language $lang -d $app
|
||||
# Configure language, timezone and ldap
|
||||
sudo -u $app $bin_file shell -c $conf_file -d $app <<< \
|
||||
"
|
||||
self.env['res.users'].search([['login', '=', 'admin']])[0].write({'password': '$admin_password'})
|
||||
self.env.cr.commit()
|
||||
"
|
||||
sudo -u $app $bin_file shell -c $conf_file -d $app <<< \
|
||||
"
|
||||
self.write({'tz':'$tz','lang':'$lang'})
|
||||
self.env.cr.commit()
|
||||
"
|
||||
sudo -u $app $bin_file shell -c $conf_file -d $app <<< \
|
||||
"
|
||||
template=env['res.users'].create({
|
||||
'login':'template',
|
||||
'password':'',
|
||||
'name':'template',
|
||||
'email':'template',
|
||||
'sel_groups_9_10':9,
|
||||
'tz':'$tz',
|
||||
'lang':'$lang'
|
||||
})
|
||||
self.env.cr.commit()
|
||||
self.company_id.ldaps.create({
|
||||
'ldap_server':'localhost',
|
||||
'ldap_server_port':389,
|
||||
'ldap_base':'ou=users, dc=yunohost,dc=org',
|
||||
'ldap_filter':'uid=%s',
|
||||
'user':template.id,
|
||||
'company':self.company_id.id
|
||||
})
|
||||
self.env.cr.commit()
|
||||
"
|
||||
export preinstall=0
|
||||
ynh_configure server.conf $conf_file
|
||||
chown $app:$app $conf_file
|
||||
}
|
||||
ynh_save_args domain app_version oca lang tz final_path conf_file db_name port port_chat
|
||||
ynh_system_user_create -u $app -h $final_path
|
||||
export db_pass=$(ynh_string_random)
|
||||
setup_files
|
||||
install_dependencies
|
||||
# Find an available port
|
||||
port=$(ynh_find_port --port=8069)
|
||||
ynh_app_setting_set --app=$app --key=port --value=$port
|
||||
|
||||
# Find an available port
|
||||
port_chat=$(ynh_find_port --port=8072)
|
||||
ynh_app_setting_set --app=$app --key=port_chat --value=$port_chat
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing dependencies..."
|
||||
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring system user..."
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
|
||||
#=================================================
|
||||
# CREATE A POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating a PostgreSQL database..."
|
||||
|
||||
export db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
db_user=$db_name
|
||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
|
||||
# Make sure that postgresql is installed and running
|
||||
ynh_psql_test_if_first_run
|
||||
ynh_psql_setup_db $db_name $db_name $db_pass
|
||||
export db_pass=$(ynh_app_setting_get $app psqlpwd)
|
||||
ynh_configure_nginx
|
||||
add_services
|
||||
setup_database
|
||||
ssowat_and_restart
|
||||
|
||||
# Create the database
|
||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
|
||||
export db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||
|
||||
# Make sure that its encoding is UTF-8
|
||||
ynh_psql_execute_as_root --sql="update pg_database set encoding = pg_char_to_encoding('UTF8') where datname = '$db_name'"
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..."
|
||||
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
setup_files
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring NGINX web server..."
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# ADD SWAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding swap..."
|
||||
|
||||
ynh_add_swap --size=$swap_needed
|
||||
|
||||
#=================================================
|
||||
# BUILD APP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Building $app..."
|
||||
|
||||
if ! wkhtmltopdf --version | grep "wkhtmltopdf 0.12.4 (with patched qt)"; then
|
||||
# The debian package has a bug so we deploy a more recent version
|
||||
if [ -f '../manifest.json' ] ; then
|
||||
ynh_setup_source /usr/
|
||||
else
|
||||
OLD_YNH_CWD=$YNH_CWD
|
||||
YNH_CWD=$YNH_CWD/../settings/conf
|
||||
ynh_setup_source /usr/
|
||||
YNH_CWD=$OLD_YNH_CWD
|
||||
fi
|
||||
fi
|
||||
pushd $final_path
|
||||
if grep "python3" $final_path/$appname/$FORKNAME-bin ; then
|
||||
python3 -m venv venv
|
||||
venv/bin/pip3 install wheel
|
||||
venv/bin/pip3 install -r $appname/requirements.txt
|
||||
else
|
||||
virtualenv venv
|
||||
venv/bin/pip install wheel
|
||||
venv/bin/pip install -r $appname/requirements.txt
|
||||
fi
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring a systemd service..."
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# SETUP DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setuping the database..."
|
||||
|
||||
setup_database
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add $app --log="/var/log/$app.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app.log"
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring permissions..."
|
||||
|
||||
ynh_permission_update --permission="main" --add="visitors"
|
||||
|
||||
# Only the admin can access the admin panel of the app (if the app has an admin panel)
|
||||
ynh_permission_create --permission="admin" --url="/web/database/manager" --allowed="all_users"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Installation of $app completed"
|
||||
|
|
109
scripts/remove
109
scripts/remove
|
@ -1,29 +1,112 @@
|
|||
#!/bin/bash
|
||||
set -u
|
||||
|
||||
source /usr/share/yunohost/helpers
|
||||
source _future.sh
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
conf_file=$(ynh_app_setting_get --app=$app --key=conf_file)
|
||||
|
||||
# Retrieve app settings
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||
conf_file=$(ynh_app_setting_get "$app" conf_file)
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
||||
#=================================================
|
||||
|
||||
yunohost service stop $app
|
||||
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
||||
if ynh_exec_warn_less yunohost service status $app >/dev/null
|
||||
then
|
||||
ynh_script_progression --message="Removing $app service integration..."
|
||||
yunohost service remove $app
|
||||
ynh_psql_remove_db $app $app
|
||||
fi
|
||||
|
||||
ynh_secure_remove "$final_path"
|
||||
ynh_secure_remove "$conf_file"
|
||||
#=================================================
|
||||
# STOP AND REMOVE SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping and removing the systemd service..."
|
||||
|
||||
ynh_remove_app_dependencies
|
||||
# Remove the dedicated systemd config
|
||||
ynh_remove_systemd_config
|
||||
|
||||
ynh_system_user_delete $app
|
||||
#=================================================
|
||||
# REMOVE THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the PostgreSQL database..."
|
||||
|
||||
# Remove a database if it exists, along with the associated user
|
||||
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
|
||||
|
||||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing app main directory..."
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove --file="$final_path"
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing NGINX web server configuration..."
|
||||
|
||||
# Remove the dedicated NGINX config
|
||||
ynh_remove_nginx_config
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..."
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC REMOVE
|
||||
#=================================================
|
||||
# REMOVE VARIOUS FILES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing various files..."
|
||||
|
||||
# Remove a directory securely
|
||||
ynh_secure_remove --file="/etc/$app"
|
||||
|
||||
# Remove the log files
|
||||
ynh_secure_remove --file="/var/log/$app.log"
|
||||
|
||||
#=================================================
|
||||
# REMOVE SWAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing swap..."
|
||||
|
||||
ynh_del_swap
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the dedicated system user..."
|
||||
|
||||
# Delete a system user
|
||||
ynh_system_user_delete --username=$app
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed"
|
||||
|
|
202
scripts/restore
202
scripts/restore
|
@ -1,24 +1,43 @@
|
|||
#!/bin/bash
|
||||
set -eu
|
||||
|
||||
# Import helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
source ../settings/scripts/_future.sh
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
export app=$YNH_APP_INSTANCE_NAME
|
||||
export domain=$(ynh_app_setting_get $app domain)
|
||||
export app_version=$(ynh_app_setting_get $app app_version)
|
||||
export oca=$(ynh_app_setting_get $app oca)
|
||||
export port=$(ynh_app_setting_get $app port)
|
||||
export port_chat=$(ynh_app_setting_get $app port_chat)
|
||||
export db_name=$(ynh_app_setting_get $app db_name)
|
||||
export db_pass=$(ynh_app_setting_get $app psqlpwd)
|
||||
export final_path=$(ynh_app_setting_get $app final_path)
|
||||
export conf_file=$(ynh_app_setting_get $app conf_file)
|
||||
export is_public=0
|
||||
|
||||
export domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
export app_version=$(ynh_app_setting_get --app=$app --key=app_version)
|
||||
export oca=$(ynh_app_setting_get --app=$app --key=oca)
|
||||
export port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
export port_chat=$(ynh_app_setting_get --app=$app --key=port_chat)
|
||||
export db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
export db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||
export final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
export conf_file=$(ynh_app_setting_get --app=$app --key=conf_file)
|
||||
export bin_file="$final_path/venv/bin/python $final_path/$appname/$FORKNAME-bin"
|
||||
if [ "$app_version" = "9" ]; then
|
||||
bin_file="$final_path/venv/bin/python $final_path/$appname/$FORKNAME.py"
|
||||
|
@ -31,33 +50,148 @@ export preinstall=0
|
|||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
ynh_webpath_available "$domain" "/"
|
||||
ynh_script_progression --message="Validating restoration parameters..."
|
||||
|
||||
test ! -d $final_path \
|
||||
|| ynh_die --message="There is already a directory: $final_path "
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP BY MODIFYING THE SYSTEM
|
||||
# STANDARD RESTORATION STEPS
|
||||
#=================================================
|
||||
# Restore files
|
||||
function restore_files () {
|
||||
ynh_restore
|
||||
chown -R $app:$app $final_path
|
||||
chown $app:$app $conf_file
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the NGINX web server configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Recreating the dedicated system user..."
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..."
|
||||
|
||||
ynh_restore_file --origin_path="$final_path/$appname"
|
||||
ynh_restore_file --origin_path="$final_path/custom-addons"
|
||||
ynh_restore_file --origin_path="$final_path/.local"
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:$app "$final_path"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling dependencies..."
|
||||
|
||||
# Define and install dependencies
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# ADD SWAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding swap..."
|
||||
|
||||
ynh_add_swap --size=$swap_needed
|
||||
|
||||
#=================================================
|
||||
# BUILD APP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Building $app..."
|
||||
|
||||
if ! wkhtmltopdf --version | grep "wkhtmltopdf 0.12.4 (with patched qt)"; then
|
||||
# The debian package has a bug so we deploy a more recent version
|
||||
if [ -f '../manifest.json' ] ; then
|
||||
ynh_setup_source /usr/
|
||||
else
|
||||
OLD_YNH_CWD=$YNH_CWD
|
||||
YNH_CWD=$YNH_CWD/../settings/conf
|
||||
ynh_setup_source /usr/
|
||||
YNH_CWD=$OLD_YNH_CWD
|
||||
fi
|
||||
fi
|
||||
pushd $final_path
|
||||
if grep "python3" $final_path/$appname/$FORKNAME-bin ; then
|
||||
python3 -m venv venv
|
||||
venv/bin/pip3 install wheel
|
||||
venv/bin/pip3 install -r $appname/requirements.txt
|
||||
else
|
||||
virtualenv venv
|
||||
venv/bin/pip install wheel
|
||||
venv/bin/pip install -r $appname/requirements.txt
|
||||
fi
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the PostgreSQL database..."
|
||||
|
||||
# Make sure that postgresql is installed and running
|
||||
ynh_psql_test_if_first_run
|
||||
|
||||
# Create the database
|
||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||
|
||||
# Make sure that its encoding is UTF-8
|
||||
ynh_psql_execute_as_root --sql="update pg_database set encoding = pg_char_to_encoding('UTF8') where datname = '$db_name'"
|
||||
|
||||
# Restore the database contents
|
||||
ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
||||
|
||||
#=================================================
|
||||
# RESTORE VARIOUS FILES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring various files..."
|
||||
|
||||
ynh_restore_file --origin_path="$conf_file"
|
||||
chmod 400 "$conf_file"
|
||||
chown $app:$app "$conf_file"
|
||||
|
||||
touch /var/log/$app.log
|
||||
chown $app:$app /var/log/$app.log
|
||||
}
|
||||
|
||||
# Restore database
|
||||
function restore_database () {
|
||||
su -c "psql $app" postgres < ./dump.sql
|
||||
}
|
||||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the systemd configuration..."
|
||||
|
||||
ynh_system_user_create $app $final_path
|
||||
restore_files
|
||||
install_dependencies
|
||||
ynh_psql_test_if_first_run
|
||||
ynh_psql_setup_db $db_name $db_name $db_pass
|
||||
add_services
|
||||
restore_database
|
||||
ssowat_and_restart
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||
systemctl enable $app.service --quiet
|
||||
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add $app --log="/var/log/$app.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app.log"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Restoration completed for $app"
|
||||
|
|
151
scripts/upgrade
151
scripts/upgrade
|
@ -1,58 +1,167 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# Source YunoHost helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
source _future.sh
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
# Retrieve arguments
|
||||
export app=$YNH_APP_INSTANCE_NAME
|
||||
export domain=$(ynh_app_setting_get "$app" domain)
|
||||
export app_version=$(ynh_app_setting_get "$app" app_version)
|
||||
export oca=$(ynh_app_setting_get "$app" oca)
|
||||
export port=$(ynh_app_setting_get $app port)
|
||||
export port_chat=$(ynh_app_setting_get $app port_chat)
|
||||
export is_public=0
|
||||
export final_path=$(ynh_app_setting_get $app final_path)
|
||||
export conf_file=$(ynh_app_setting_get $app conf_file)
|
||||
|
||||
export domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
export app_version=$(ynh_app_setting_get --app=$app --key=app_version)
|
||||
export oca=$(ynh_app_setting_get --app=$app --key=oca)
|
||||
export port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
export port_chat=$(ynh_app_setting_get --app=$app --key=port_chat)
|
||||
export final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
export conf_file=$(ynh_app_setting_get --app=$app --key=conf_file)
|
||||
export preinstall=0
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Checking version..."
|
||||
|
||||
ynh_check_app_version_changed
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
# restore it if the upgrade fails
|
||||
ynh_clean_check_starting
|
||||
# Restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app.log"
|
||||
|
||||
#=================================================
|
||||
# STEP Migrations
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_system_user_create $app
|
||||
ynh_script_progression --message="Ensuring downward compatibility..."
|
||||
|
||||
# Cleaning legacy permissions
|
||||
if ynh_legacy_permissions_exists; then
|
||||
ynh_legacy_permissions_delete_all
|
||||
|
||||
ynh_app_setting_delete --app=$app --key=is_public
|
||||
fi
|
||||
|
||||
if ! ynh_permission_exists --permission="admin"; then
|
||||
# Create the required permissions
|
||||
ynh_permission_create --permission="admin" --url="/web/database/manager" --allowed="all_users"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Making sure dedicated system user exists..."
|
||||
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading source files..."
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
setup_files
|
||||
install_dependencies
|
||||
service $app restart
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..."
|
||||
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# ADD SWAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding swap..."
|
||||
|
||||
ynh_add_swap --size=$swap_needed
|
||||
|
||||
#=================================================
|
||||
# BUILD APP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Building $app..."
|
||||
|
||||
if ! wkhtmltopdf --version | grep "wkhtmltopdf 0.12.4 (with patched qt)"; then
|
||||
# The debian package has a bug so we deploy a more recent version
|
||||
if [ -f '../manifest.json' ] ; then
|
||||
ynh_setup_source /usr/
|
||||
else
|
||||
OLD_YNH_CWD=$YNH_CWD
|
||||
YNH_CWD=$YNH_CWD/../settings/conf
|
||||
ynh_setup_source /usr/
|
||||
YNH_CWD=$OLD_YNH_CWD
|
||||
fi
|
||||
fi
|
||||
pushd $final_path
|
||||
if grep "python3" $final_path/$appname/$FORKNAME-bin ; then
|
||||
python3 -m venv venv
|
||||
venv/bin/pip3 install wheel
|
||||
venv/bin/pip3 install -r $appname/requirements.txt
|
||||
else
|
||||
virtualenv venv
|
||||
venv/bin/pip install wheel
|
||||
venv/bin/pip install -r $appname/requirements.txt
|
||||
fi
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||
|
||||
yunohost service add $app --log="/var/log/$app.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app.log"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed"
|
||||
|
|
Loading…
Reference in a new issue