mirror of
https://github.com/YunoHost-Apps/pgadmin_ynh.git
synced 2024-09-03 19:56:38 +02:00
commit
5203b8df96
17 changed files with 611 additions and 295 deletions
90
README.md
90
README.md
|
@ -1,79 +1,47 @@
|
|||
pgAdmin for yunohost
|
||||
====================
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
# pgAdmin for YunoHost
|
||||
|
||||
[![Integration level](https://dash.yunohost.org/integration/pgadmin.svg)](https://dash.yunohost.org/appci/app/pgadmin) ![](https://ci-apps.yunohost.org/ci/badges/pgadmin.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/pgadmin.maintain.svg)
|
||||
[![Install pgadmin with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=pgadmin)
|
||||
[![Install pgAdmin with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=pgadmin)
|
||||
|
||||
> *This package allow you to install pgadmin quickly and simply on a YunoHost server.
|
||||
If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*
|
||||
*[Lire ce readme en français.](./README_fr.md)*
|
||||
|
||||
Overview
|
||||
--------
|
||||
> *This package allows you to install pgAdmin 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
|
||||
|
||||
pgAdmin is a feature rich Open Source administration and development platform for PostgreSQL.
|
||||
|
||||
**Shipped version:** 4-5.7
|
||||
|
||||
Screenshots
|
||||
-----------
|
||||
**Shipped version:** 4-5.7~ynh1
|
||||
|
||||
![](https://www.pgadmin.org/static/COMPILED/assets/img/screenshots/pgadmin4-welcome-light.png)
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
* Official documentation: https://www.pgadmin.org/docs/
|
||||
* YunoHost documentation: There no other documentations, feel free to contribute.
|
||||
## Screenshots
|
||||
|
||||
YunoHost specific features
|
||||
--------------------------
|
||||
![](./doc/screenshots/pgadmin4-welcome-light.png)
|
||||
|
||||
## Disclaimers / important information
|
||||
|
||||
### Multi-users support
|
||||
|
||||
This app actually don't support the SSO and don't support LDAP. After the install of the app you can create a other user. So this app is multi-users but independently of the LDAP database.
|
||||
|
||||
### Supported architectures
|
||||
## Documentation and resources
|
||||
|
||||
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/pgadmin%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/pgadmin/)
|
||||
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/pgadmin%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/pgadmin/)
|
||||
* Official app website: https://www.pgadmin.org
|
||||
* Official admin documentation: https://www.pgadmin.org/docs
|
||||
* YunoHost documentation for this app: https://yunohost.org/app_pgadmin
|
||||
* Report a bug: https://github.com/YunoHost-Apps/pgadmin_ynh/issues
|
||||
|
||||
<!--Limitations
|
||||
-----------
|
||||
## Developer info
|
||||
|
||||
* Any known limitations.-->
|
||||
|
||||
<!--Additional informations
|
||||
-----------------------
|
||||
|
||||
* Other informations you would add about this application-->
|
||||
|
||||
Links
|
||||
-----
|
||||
|
||||
* Report a bug: https://github.com/YunoHost-Apps/pgadmin_ynh/issues
|
||||
* App website: https://www.pgadmin.org/
|
||||
* YunoHost website: https://yunohost.org/
|
||||
|
||||
---
|
||||
|
||||
Install
|
||||
-------
|
||||
|
||||
From command line:
|
||||
|
||||
`sudo yunohost app install -l pgAdmin https://github.com/YunoHost-Apps/pgadmin_ynh`
|
||||
|
||||
Upgrade
|
||||
-------
|
||||
|
||||
From command line:
|
||||
|
||||
`sudo yunohost app upgrade pgadmin -u https://github.com/YunoHost-Apps/pgadmin_ynh`
|
||||
|
||||
Developers infos
|
||||
----------------
|
||||
|
||||
Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/pgadmin_ynh/tree/testing).
|
||||
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/pgadmin_ynh/tree/testing).
|
||||
|
||||
To try the testing branch, please proceed like that.
|
||||
```
|
||||
|
@ -82,12 +50,4 @@ or
|
|||
sudo yunohost app upgrade pgadmin -u https://github.com/YunoHost-Apps/pgadmin_ynh/tree/testing --debug
|
||||
```
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
pgAdmin is published under the the PostgreSQL licence : https://www.pgadmin.org/licence/
|
||||
|
||||
TODO
|
||||
----
|
||||
|
||||
- Add sso auth
|
||||
**More info regarding app packaging:** https://yunohost.org/packaging_apps
|
49
README_fr.md
Normal file
49
README_fr.md
Normal file
|
@ -0,0 +1,49 @@
|
|||
# pgAdmin pour YunoHost
|
||||
|
||||
[![Niveau d'intégration](https://dash.yunohost.org/integration/pgadmin.svg)](https://dash.yunohost.org/appci/app/pgadmin) ![](https://ci-apps.yunohost.org/ci/badges/pgadmin.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/pgadmin.maintain.svg)
|
||||
[![Installer pgAdmin avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=pgadmin)
|
||||
|
||||
*[Read this readme in english.](./README.md)*
|
||||
*[Lire ce readme en français.](./README_fr.md)*
|
||||
|
||||
> *Ce package vous permet d'installer pgAdmin 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
|
||||
|
||||
pgAdmin is a feature rich Open Source administration and development platform for PostgreSQL.
|
||||
|
||||
|
||||
**Version incluse :** 4-5.7~ynh1
|
||||
|
||||
|
||||
|
||||
## Captures d'écran
|
||||
|
||||
![](./doc/screenshots/pgadmin4-welcome-light.png)
|
||||
|
||||
## Avertissements / informations importantes
|
||||
|
||||
### Multi-users support
|
||||
|
||||
This app actually don't support the SSO and don't support LDAP. After the install of the app you can create a other user. So this app is multi-users but independently of the LDAP database.
|
||||
|
||||
## Documentations et ressources
|
||||
|
||||
* Site officiel de l'app : https://www.pgadmin.org
|
||||
* Documentation officielle de l'admin : https://www.pgadmin.org/docs
|
||||
* Documentation YunoHost pour cette app : https://yunohost.org/app_pgadmin
|
||||
* Signaler un bug : https://github.com/YunoHost-Apps/pgadmin_ynh/issues
|
||||
|
||||
## Informations pour les développeurs
|
||||
|
||||
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/pgadmin_ynh/tree/testing).
|
||||
|
||||
Pour essayer la branche testing, procédez comme suit.
|
||||
```
|
||||
sudo yunohost app install https://github.com/YunoHost-Apps/pgadmin_ynh/tree/testing --debug
|
||||
ou
|
||||
sudo yunohost app upgrade pgadmin -u https://github.com/YunoHost-Apps/pgadmin_ynh/tree/testing --debug
|
||||
```
|
||||
|
||||
**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps
|
|
@ -1,9 +1,9 @@
|
|||
;; Test complet
|
||||
; Manifest
|
||||
domain="domain.tld" (DOMAIN)
|
||||
path="/path" (PATH)
|
||||
admin="john" (USER)
|
||||
admin_password="Sup3rS3cr3t" (PASSWORD)
|
||||
domain="domain.tld"
|
||||
path="/path"
|
||||
admin="john"
|
||||
password="1Strong-Password"
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_sub_dir=1
|
||||
|
@ -12,13 +12,11 @@
|
|||
setup_private=0
|
||||
setup_public=0
|
||||
upgrade=1
|
||||
# upgrade=1 from_commit=CommitHash
|
||||
backup_restore=1
|
||||
multi_instance=0
|
||||
incorrect_path=1
|
||||
port_already_use=0
|
||||
change_url=1
|
||||
;;; Levels
|
||||
Level 5=auto
|
||||
;;; Options
|
||||
Email=
|
||||
Notification=none
|
||||
|
|
0
doc/.gitkeep
Normal file
0
doc/.gitkeep
Normal file
1
doc/DESCRIPTION.md
Normal file
1
doc/DESCRIPTION.md
Normal file
|
@ -0,0 +1 @@
|
|||
pgAdmin is a feature rich Open Source administration and development platform for PostgreSQL.
|
3
doc/DISCLAIMER.md
Normal file
3
doc/DISCLAIMER.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
### Multi-users support
|
||||
|
||||
This app actually don't support the SSO and don't support LDAP. After the install of the app you can create a other user. So this app is multi-users but independently of the LDAP database.
|
0
doc/screenshots/.gitkeep
Normal file
0
doc/screenshots/.gitkeep
Normal file
BIN
doc/screenshots/pgadmin4-welcome-light.png
Normal file
BIN
doc/screenshots/pgadmin4-welcome-light.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 174 KiB |
|
@ -8,13 +8,18 @@
|
|||
},
|
||||
"version": "4-5.7~ynh1",
|
||||
"url": "https://www.pgadmin.org",
|
||||
"upstream": {
|
||||
"license": "PostgreSQL",
|
||||
"website": "https://www.pgadmin.org",
|
||||
"admindoc": "https://www.pgadmin.org/docs"
|
||||
},
|
||||
"license": "PostgreSQL",
|
||||
"maintainer": {
|
||||
"name": "Josué Tille",
|
||||
"email": "josue@tille.ch"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 4.0.0.0"
|
||||
"yunohost": ">= 4.3.0"
|
||||
},
|
||||
"multi_instance": false,
|
||||
"services": [
|
||||
|
@ -25,40 +30,21 @@
|
|||
"install" : [
|
||||
{
|
||||
"name": "domain",
|
||||
"type": "domain",
|
||||
"ask": {
|
||||
"en": "Choose a domain for pgAdmin",
|
||||
"fr": "Choisissez un domaine pour pgAdmin"
|
||||
},
|
||||
"example": "domain.org"
|
||||
"type": "domain"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"type": "path",
|
||||
"ask": {
|
||||
"en": "Choose a path for pgAdmin",
|
||||
"fr": "Choisissez un chemin pour pgAdmin"
|
||||
},
|
||||
"example": "/pgadmin",
|
||||
"default": "/pgadmin"
|
||||
},
|
||||
{
|
||||
"name": "admin",
|
||||
"type": "user",
|
||||
"ask": {
|
||||
"en": "Choose the only allowed admin user",
|
||||
"fr": "Choisissez l'unique utilisateur autorisé"
|
||||
},
|
||||
"example": "johndoe"
|
||||
"type": "user"
|
||||
},
|
||||
{
|
||||
"name": "admin_password",
|
||||
"type": "password",
|
||||
"ask": {
|
||||
"en": "Enter a password for the administrator",
|
||||
"fr": "Entrez un mot de passe pour l'administrateur"
|
||||
},
|
||||
"example": "**Sup3rS3cr3t**"
|
||||
"name": "password",
|
||||
"type": "password"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
# SET ALL CONSTANTS
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
final_path=/opt/yunohost/$app
|
||||
pgadmin_user="$app"
|
||||
python_version="$(python3 -V | cut -d' ' -f2 | cut -d. -f1-2)"
|
||||
dependances="python3-pip build-essential python3-dev python3-venv postgresql uwsgi uwsgi-plugin-python3 expect libpq-dev libkrb5-dev"
|
||||
|
||||
# dependencies used by the app
|
||||
pkg_dependencies="python3-pip build-essential python3-dev python3-venv postgresql uwsgi uwsgi-plugin-python3 expect libpq-dev libkrb5-dev"
|
||||
|
||||
#=================================================
|
||||
# DEFINE ALL COMMON FONCTIONS
|
||||
|
@ -61,6 +60,7 @@ install_source() {
|
|||
set -$u_arg;
|
||||
pip3 install --upgrade pip
|
||||
pip3 install --upgrade 'Werkzeug<1.0'
|
||||
pip3 install --upgrade 'markupsafe==2.0.1'
|
||||
pip3 install --upgrade pgadmin$app_main_version==$app_sub_version
|
||||
set +$u_arg;
|
||||
deactivate
|
||||
|
@ -72,6 +72,7 @@ set_permission() {
|
|||
# Set permission
|
||||
chown $pgadmin_user:root -R $final_path
|
||||
chown $pgadmin_user:root -R /var/lib/pgadmin
|
||||
mkdir -p /var/log/pgadmin
|
||||
chown $pgadmin_user:root -R /var/log/pgadmin
|
||||
chown $pgadmin_user:root /var/log/uwsgi/$app
|
||||
chown $pgadmin_user:root /etc/uwsgi/apps-available/$app.ini
|
||||
|
|
|
@ -3,45 +3,69 @@
|
|||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# Import common cmd
|
||||
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||
source ../settings/scripts/experimental_helper.sh
|
||||
source ../settings/scripts/_common.sh
|
||||
|
||||
# IMPORT GENERIC HELPERS
|
||||
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..."
|
||||
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)
|
||||
app_version=$(ynh_app_upstream_version)
|
||||
app_main_version=$(echo $app_version | cut -d'-' -f1)
|
||||
app_sub_version=$(echo $app_version | cut -d'-' -f2)
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
|
||||
#=================================================
|
||||
# STANDARD BACKUP STEPS
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
#=================================================
|
||||
ynh_print_info --message="Declaring files to be backed up..."
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
ynh_print_info --message="Backing up the main app directory..."
|
||||
ynh_backup --src_path "$final_path"
|
||||
#=================================================
|
||||
|
||||
# Backup config
|
||||
ynh_print_info --message="Backing configuration..."
|
||||
ynh_backup --src_path "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_backup --src_path "/etc/uwsgi/apps-available/$app.ini"
|
||||
ynh_backup --src_path="$final_path"
|
||||
|
||||
# Backup Data and LOG
|
||||
ynh_print_info --message="Backing up data..."
|
||||
ynh_backup --src_path "/var/lib/pgadmin"
|
||||
ynh_print_info --message="Backing up log..."
|
||||
ynh_backup --src_path "/var/log/pgadmin"
|
||||
ynh_backup --src_path "/var/log/uwsgi/$app"
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
#=================================================
|
||||
# BACKUP LOGROTATE
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP VARIOUS FILES
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/uwsgi/apps-available/$app.ini"
|
||||
|
||||
ynh_backup --src_path="/var/lib/pgadmin"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
|
||||
|
|
|
@ -1,50 +1,139 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# Import common cmd
|
||||
source ./experimental_helper.sh
|
||||
source ./_common.sh
|
||||
|
||||
# Source YunoHost helpers
|
||||
source experimental_helper.sh
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Stop script if errors
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
old_domain=$YNH_APP_OLD_DOMAIN
|
||||
old_path=$YNH_APP_OLD_PATH
|
||||
|
||||
new_domain=$YNH_APP_NEW_DOMAIN
|
||||
new_path=$YNH_APP_NEW_PATH
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
# Needed for helper "ynh_add_nginx_config"
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
# Add settings here as needed by your application
|
||||
pgadmin_user="$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..."
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
ynh_clean_check_starting
|
||||
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
|
||||
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
|
||||
# Restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
# Retrive arguments
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
old_domain=$YNH_APP_OLD_DOMAIN
|
||||
domain=$YNH_APP_NEW_DOMAIN
|
||||
path_url=$(ynh_normalize_url_path --path_url $YNH_APP_NEW_PATH)
|
||||
#=================================================
|
||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||
#=================================================
|
||||
|
||||
change_domain=0
|
||||
if [ "$old_domain" != "$new_domain" ]
|
||||
then
|
||||
change_domain=1
|
||||
fi
|
||||
|
||||
change_path=0
|
||||
if [ "$old_path" != "$new_path" ]
|
||||
then
|
||||
change_path=1
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Updating configuration..."
|
||||
# Update nginx config
|
||||
if [ "$old_domain" != "$domain" ]
|
||||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating NGINX web server configuration..."
|
||||
|
||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||
|
||||
# Change the path in the NGINX config file
|
||||
if [ $change_path -eq 1 ]
|
||||
then
|
||||
# Delete file checksum for the old conf file location
|
||||
ynh_delete_file_checksum --file "/etc/nginx/conf.d/$old_domain.d/$app.conf"
|
||||
|
||||
mv "/etc/nginx/conf.d/$old_domain.d/$app.conf" "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
# Store file checksum for the new config file location
|
||||
ynh_store_file_checksum --file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
# Make a backup of the original NGINX config file if modified
|
||||
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
||||
# Set global variables for NGINX helper
|
||||
domain="$old_domain"
|
||||
path_url="$new_path"
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
fi
|
||||
ynh_add_nginx_config
|
||||
|
||||
# Change the domain for NGINX
|
||||
if [ $change_domain -eq 1 ]
|
||||
then
|
||||
# Delete file checksum for the old conf file location
|
||||
ynh_delete_file_checksum --file="$nginx_conf_path"
|
||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||
# Store file checksum for the new config file location
|
||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC MODIFICATIONS
|
||||
#=================================================
|
||||
# UPDATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating configuration..."
|
||||
|
||||
domain=$new_domain
|
||||
path_url=$new_path
|
||||
|
||||
# Update UWSGI Config
|
||||
ynh_add_uwsgi_service 'pgadmin_user python_version'
|
||||
|
||||
# Reload services
|
||||
ynh_script_progression --message="Restarting $app services..." --weight=3
|
||||
ynh_systemd_action --service_name "uwsgi-app@$app.service" --action restart \
|
||||
--line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log"
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=3
|
||||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="restart" --line_match="WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path="/var/log/uwsgi/$app/$app.log"
|
||||
sleep 10
|
||||
|
||||
#=================================================
|
||||
# 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="Change of URL completed for $app" --last
|
||||
|
|
|
@ -131,6 +131,12 @@ ynh_remove_uwsgi_service () {
|
|||
ynh_restore_uwsgi_service () {
|
||||
ynh_check_global_uwsgi_config
|
||||
systemctl enable "uwsgi-app@$app" --quiet
|
||||
|
||||
# make sure the folder for logs exists and set authorizations
|
||||
mkdir -p /var/log/uwsgi/$app
|
||||
chown $app:root /var/log/uwsgi/$app
|
||||
chmod -R u=rwX,g=rX,o= /var/log/uwsgi/$app
|
||||
|
||||
yunohost service add "uwsgi-app@$app" --log "/var/log/uwsgi/$app/$app.log"
|
||||
}
|
||||
|
||||
|
|
142
scripts/install
142
scripts/install
|
@ -3,34 +3,52 @@
|
|||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
|
||||
# Import common cmd
|
||||
source ./experimental_helper.sh
|
||||
source ./_common.sh
|
||||
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source experimental_helper.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
|
||||
|
||||
ynh_script_progression --message="Validating installation parameters..."
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||
#=================================================
|
||||
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path_url=$YNH_APP_ARG_PATH
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
admin_pwd=$YNH_APP_ARG_PASSWORD
|
||||
|
||||
db_user="pgadmin"
|
||||
admin_pwd=$YNH_APP_ARG_ADMIN_PASSWORD
|
||||
db_pwd=$(ynh_string_random --length 30)
|
||||
app_version=$(ynh_app_upstream_version)
|
||||
app_main_version=$(echo $app_version | cut -d'-' -f1)
|
||||
app_sub_version=$(echo $app_version | cut -d'-' -f2)
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
pgadmin_user="$app"
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
test ! -e "$final_path" || ynh_die --message "This path already contains a folder"
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating installation parameters..."
|
||||
|
||||
final_path=/opt/yunohost/$app
|
||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||
|
||||
# Register (book) web path
|
||||
ynh_webpath_register --app $app --domain $domain --path_url $path_url
|
||||
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||
|
||||
# Get user email and check that the user exist
|
||||
email=$(ynh_user_get_info --username $admin --key 'mail')
|
||||
|
@ -39,37 +57,60 @@ then
|
|||
ynh_die --message "Can't get user email, check that the user exist or that the user have an email"
|
||||
fi
|
||||
|
||||
# Build user password
|
||||
ynh_script_progression --message="Defining db password..."
|
||||
db_pwd=$(ynh_string_random --length 30)
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Storing installation settings..."
|
||||
ynh_app_setting_set --app $app --key domain --value $domain
|
||||
ynh_app_setting_set --app $app --key path --value $path_url
|
||||
ynh_app_setting_set --app $app --key admin --value $admin
|
||||
ynh_app_setting_set --app $app --key db_user --value "$db_user"
|
||||
ynh_app_setting_set --app $app --key final_path --value $final_path
|
||||
ynh_app_setting_set --app $app --key admin_pwd --value "$admin_pwd"
|
||||
ynh_app_setting_set --app $app --key db_pwd --value "$db_pwd"
|
||||
|
||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
||||
ynh_app_setting_set --app=$app --key=admin_pwd --value="$admin_pwd"
|
||||
ynh_app_setting_set --app=$app --key=db_user --value="$db_user"
|
||||
ynh_app_setting_set --app=$app --key=db_pwd --value="$db_pwd"
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
|
||||
# Install dependance
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing dependencies..." --weight=7
|
||||
ynh_install_app_dependencies $dependances
|
||||
|
||||
# Create user
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring system user..."
|
||||
ynh_system_user_create --username $pgadmin_user --home_dir $final_path
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create --username=$pgadmin_user --home_dir=$final_path
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
ynh_script_progression --message="Installing sources files..." --weight=10
|
||||
setup_dir
|
||||
install_source
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring NGINX web server..."
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# ...
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Configuring application..."
|
||||
|
||||
# CONFIGURE PGADMIN
|
||||
|
@ -78,9 +119,6 @@ config_pgadmin
|
|||
# Config uwsgi
|
||||
ynh_add_uwsgi_service 'pgadmin_user python_version'
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
||||
ynh_script_progression --message="Configuring sqlite database..."
|
||||
|
||||
# initialisation sqlite database for pgadmin
|
||||
|
@ -104,26 +142,44 @@ set +u;
|
|||
deactivate
|
||||
set -u;
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
||||
# Set permission after initialisation
|
||||
ynh_script_progression --message="Protecting directory"
|
||||
set_permission
|
||||
|
||||
# Restrict access to admin only
|
||||
ynh_script_progression --message="Configuring permissions"
|
||||
ynh_permission_update --permission="main" --remove="all_users" --add=$admin
|
||||
|
||||
# Configuration de logrotate
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring log rotation..."
|
||||
ynh_use_logrotate --logfile /var/log/pgadmin
|
||||
|
||||
# reload uwsgi
|
||||
ynh_script_progression --message="Starting $app services..." --weight=3
|
||||
ynh_systemd_action --service_name "uwsgi-app@$app.service" \
|
||||
--line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log"
|
||||
ynh_use_logrotate --logfile="/var/log/pgadmin"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=3
|
||||
|
||||
ynh_systemd_action --service_name "uwsgi-app@$app.service" --action="restart" --line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log"
|
||||
sleep 10
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring permissions..."
|
||||
|
||||
# Restrict access to admin only
|
||||
ynh_permission_update --permission="main" --remove="all_users" --add=$admin
|
||||
|
||||
#=================================================
|
||||
# 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" --last
|
||||
|
|
113
scripts/remove
113
scripts/remove
|
@ -3,19 +3,23 @@
|
|||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# Import common cmd
|
||||
source ./experimental_helper.sh
|
||||
source ./_common.sh
|
||||
|
||||
# Source YunoHost helpers
|
||||
source experimental_helper.sh
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
domain=$(ynh_app_setting_get --app $app --key domain)
|
||||
db_name=$(ynh_app_setting_get --app $app --key db_name)
|
||||
db_user="$app"
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
db_user=$(ynh_app_setting_get --app=$app --key=db_user)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
|
@ -24,38 +28,73 @@ db_user="$app"
|
|||
# Stop service
|
||||
ynh_systemd_action --service_name "uwsgi-app@$app.service" --action stop
|
||||
|
||||
# Remove db user
|
||||
ynh_script_progression --message="Cleaning the PostgreSQL database..."
|
||||
ynh_psql_drop_user $db_user
|
||||
|
||||
# Remove depandance
|
||||
ynh_script_progression --message="Removing dependencies..." --weight=10
|
||||
ynh_remove_app_dependencies || true
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_script_progression --message="Removing app main directory..." --weight=4
|
||||
ynh_secure_remove --file="$final_path"
|
||||
|
||||
# Remove app data
|
||||
ynh_secure_remove --file=/var/lib/$app
|
||||
|
||||
# Remove logrotate
|
||||
ynh_script_progression --message="Removing logrotate configuration..."
|
||||
ynh_remove_logrotate
|
||||
|
||||
# Remove logs
|
||||
ynh_script_progression --message="Removing logs..."
|
||||
ynh_secure_remove --file=/var/log/$app
|
||||
|
||||
# Remove the dedicated nginx config
|
||||
ynh_script_progression --message="Removing configuration..."
|
||||
ynh_remove_nginx_config
|
||||
|
||||
# Remove uwsgi config
|
||||
ynh_remove_uwsgi_service
|
||||
|
||||
# Delete a system user
|
||||
#=================================================
|
||||
# REMOVE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing logrotate configuration..."
|
||||
|
||||
# Remove the app-specific logrotate config
|
||||
ynh_remove_logrotate
|
||||
|
||||
#=================================================
|
||||
# REMOVE DB_USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Cleaning the PostgreSQL database..."
|
||||
|
||||
ynh_psql_drop_user $db_user
|
||||
|
||||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing app main directory..." --weight=4
|
||||
|
||||
# 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..." --weight=10
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies || true
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC REMOVE
|
||||
#=================================================
|
||||
# REMOVE VARIOUS FILES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing various files..."
|
||||
|
||||
# Remove app data
|
||||
ynh_secure_remove --file="/var/lib/$app"
|
||||
|
||||
# Remove the log files
|
||||
ynh_secure_remove --file="/var/log/$app"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the dedicated system user..."
|
||||
ynh_system_user_delete $app
|
||||
|
||||
# Delete a system user
|
||||
ynh_system_user_delete --username=$app
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed" --last
|
||||
|
|
120
scripts/restore
120
scripts/restore
|
@ -3,45 +3,77 @@
|
|||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# Import common cmd
|
||||
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||
source ../settings/scripts/experimental_helper.sh
|
||||
source ../settings/scripts/_common.sh
|
||||
|
||||
# IMPORT GENERIC HELPERS
|
||||
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 settings..."
|
||||
domain=$(ynh_app_setting_get --app $app --key domain)
|
||||
path_url=$(ynh_app_setting_get --app $app --key path)
|
||||
admin=$(ynh_app_setting_get --app $app --key admin)
|
||||
final_path=$(ynh_app_setting_get --app $app --key final_path)
|
||||
db_name=$(ynh_app_setting_get --app $app --key db_name)
|
||||
db_user=$(ynh_app_setting_get --app $app --key db_user)
|
||||
db_pwd=$(ynh_app_setting_get --app $app --key db_pwd)
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
db_user=$(ynh_app_setting_get --app=$app --key=db_user)
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||
|
||||
app_version=$(ynh_app_upstream_version)
|
||||
app_main_version=$(echo $app_version | cut -d'-' -f1)
|
||||
app_sub_version=$(echo $app_version | cut -d'-' -f2)
|
||||
|
||||
pgadmin_user="$app"
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
#=================================================
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the NGINX web server configuration..."
|
||||
|
||||
# Install dependance
|
||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=5
|
||||
ynh_install_app_dependencies $dependances
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
# Create user
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Recreating the dedicated system user..."
|
||||
ynh_system_user_create --username $pgadmin_user --home_dir $final_path
|
||||
|
||||
# Restore all config and data
|
||||
ynh_script_progression --message="Restoring files..." --weight=5
|
||||
ynh_restore
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$pgadmin_user --home_dir=$final_path
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..." --weight=5
|
||||
|
||||
ynh_restore_file --origin_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=5
|
||||
|
||||
# Define and install dependencies
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
# Check that the good python version is installed
|
||||
# If not upgrade the source
|
||||
|
@ -50,34 +82,50 @@ install_source
|
|||
# POPULATE THE DATABASE
|
||||
ynh_script_progression --message="Reconfiguring Postgresql database..."
|
||||
ynh_psql_test_if_first_run
|
||||
ynh_psql_execute_as_root \
|
||||
--sql "CREATE USER ${db_user} WITH PASSWORD '${db_pwd}' SUPERUSER CREATEDB CREATEROLE REPLICATION"
|
||||
ynh_psql_execute_as_root --sql "CREATE USER ${db_user} WITH PASSWORD '${db_pwd}' SUPERUSER CREATEDB CREATEROLE REPLICATION"
|
||||
|
||||
#=================================================
|
||||
# RESTORE VARIOUS FILES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring various files..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/uwsgi/apps-available/$app.ini"
|
||||
ynh_restore_file --origin_path="/var/lib/pgadmin"
|
||||
|
||||
# Restore systemd configuration
|
||||
ynh_script_progression --message="Reconfiguring application..."
|
||||
ynh_restore_uwsgi_service
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
||||
# Set the permission
|
||||
ynh_script_progression --message="Protecting directory..."
|
||||
set_permission
|
||||
|
||||
# Restrict access to admin only
|
||||
ynh_script_progression --message="Configuring permissions"
|
||||
ynh_permission_update --permission="main" --remove="all_users" --add=$admin
|
||||
#=================================================
|
||||
# RESTORE THE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the logrotate configuration..."
|
||||
|
||||
# Configuration de logrotate
|
||||
ynh_script_progression --message="Configuring log rotation..."
|
||||
ynh_use_logrotate --logfile /var/log/pgadmin
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
|
||||
# reload uwsgi and nginx
|
||||
ynh_script_progression --message="Starting pgadmin services..." --weight=3
|
||||
ynh_systemd_action --service_name "uwsgi-app@$app.service" \
|
||||
--line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log"
|
||||
systemctl reload nginx
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=3
|
||||
|
||||
ynh_systemd_action --service_name "uwsgi-app@$app.service" --action="restart" --line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
sleep 10
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Restoration completed for $app" --last
|
||||
|
|
116
scripts/upgrade
116
scripts/upgrade
|
@ -3,48 +3,92 @@
|
|||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
|
||||
# Import common cmd
|
||||
source ./experimental_helper.sh
|
||||
source ./_common.sh
|
||||
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source experimental_helper.sh
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
domain=$(ynh_app_setting_get --app $app --key domain)
|
||||
path_url=$(ynh_normalize_url_path --path_url $(ynh_app_setting_get --app $app --key path))
|
||||
admin=$(ynh_app_setting_get --app $app --key admin)
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
app_version=$(ynh_app_upstream_version)
|
||||
app_main_version=$(echo $app_version | cut -d'-' -f1)
|
||||
app_sub_version=$(echo $app_version | cut -d'-' -f2)
|
||||
|
||||
pgadmin_user="$app"
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Checking version..."
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=10
|
||||
ynh_backup_before_upgrade # Backup the current version of the app
|
||||
#=================================================
|
||||
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 () {
|
||||
ynh_restore_upgradebackup # 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..."
|
||||
|
||||
test -e /etc/uwsgi/apps-available/$app.ini && \
|
||||
ynh_systemd_action --service_name "uwsgi-app@$app.service" --action stop
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..."
|
||||
|
||||
if ! grep -q "$final_path" /etc/passwd; then
|
||||
sed --in-place -r "s@$app\:x\:([[:digit:]]+\:[[:digit:]]+)\:\:/.*/$app\:/usr/sbin/nologin@$app\:x\:\1\:\:$final_path\:/usr/sbin/nologin@g" /etc/passwd
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading NGINX web server configuration..."
|
||||
|
||||
# Install dependance
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..."
|
||||
ynh_install_app_dependencies $dependances
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# ...
|
||||
#=================================================
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=6
|
||||
install_source
|
||||
|
@ -56,28 +100,40 @@ config_pgadmin
|
|||
# Config uwsgi
|
||||
ynh_add_uwsgi_service 'pgadmin_user python_version'
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
||||
# Clean old uwsgi config
|
||||
ynh_secure_remove /etc/uwsgi/apps-enabled/pgadmin.ini
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
||||
# Set permission after initialisation
|
||||
ynh_script_progression --message="Protecting directory..."
|
||||
set_permission
|
||||
|
||||
# Configuration de logrotate
|
||||
ynh_script_progression --message="Configuring log rotation..."
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading logrotate configuration..."
|
||||
|
||||
# Use logrotate to manage app-specific logfile(s)
|
||||
ynh_use_logrotate --logfile /var/log/pgadmin --nonappend
|
||||
|
||||
# reload uwsgi
|
||||
ynh_script_progression --message="Restarting $app services..." --weight=3
|
||||
ynh_systemd_action --service_name "uwsgi-app@$app.service" \
|
||||
--line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log"
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=3
|
||||
|
||||
ynh_systemd_action --service_name "uwsgi-app@$app.service" --action="restart" --line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log"
|
||||
sleep 10
|
||||
|
||||
#=================================================
|
||||
# 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" --last
|
||||
|
|
Loading…
Reference in a new issue