1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/biboumi_ynh.git synced 2024-09-03 18:15:58 +02:00

Merge pull request #15 from YunoHost-Apps/testing

Apply last example_ynh
This commit is contained in:
yalh76 2021-08-17 20:43:20 +02:00 committed by GitHub
commit 7c41f2b9e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 287 additions and 203 deletions

View file

@ -1,4 +1,7 @@
File containing the license of your package. This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
More information here: Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-13---indiquer-la-licence-associ%C3%A9e-au-paquet---brouillon--auto--working-
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.

View file

@ -1,47 +1,46 @@
<!--
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.
-->
# Biboumi for YunoHost # Biboumi for YunoHost
[![Integration level](https://dash.yunohost.org/integration/biboumi.svg)](https://dash.yunohost.org/appci/app/biboumi) ![](https://ci-apps.yunohost.org/ci/badges/biboumi.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/biboumi.maintain.svg) [![Integration level](https://dash.yunohost.org/integration/biboumi.svg)](https://dash.yunohost.org/appci/app/biboumi) ![](https://ci-apps.yunohost.org/ci/badges/biboumi.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/biboumi.maintain.svg)
[![Install biboumi with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=biboumi) [![Install Biboumi with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=biboumi)
*[Lire ce readme en français.](./README_fr.md)*
> *This package allows you to install Biboumi quickly and simply on a YunoHost server. > *This package allows you to install Biboumi 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.* If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
## Overview ## Overview
Biboumi is an XMPP gateway for the IRC network. XMPP gateway for the IRC network.
**Shipped version:** 8.3~ynh1
## Disclaimers / important information
Once biboumi_ynh is installed you can use any XMPP client software to join IRC channels. Any IRC channel is seen as a standard XMPP chatroom (aka MUC) with a special name. Once biboumi_ynh is installed you can use any XMPP client software to join IRC channels. Any IRC channel is seen as a standard XMPP chatroom (aka MUC) with a special name.
The the name is formatted like this: `#channelname%ircservername@biboumi.yourdomain.tld`. The the name is formatted like this: `#channelname%ircservername@biboumi.yourdomain.tld`.
For example, if you have a YunoHost server hosting domain *example.net* and you want to join the channel *#yunohost* on *irc.freenode.net* you simply need to join the MUC `#yunohost%irc.freenode.net@biboumi.example.net`. For example, if you have a YunoHost server hosting domain *example.net* and you want to join the channel *#yunohost* on *irc.freenode.net* you simply need to join the MUC `#yunohost%irc.freenode.net@biboumi.example.net`.
**Shipped version:** 8.3 * Any known limitations, constrains or stuff not working, such as (but not limited to):
## Configuration
You can configure Biboumi with the file `/etc/biboumi/biboumi.cfg`.
## Documentation
* Official documentation: https://lab.louiz.org/louiz/biboumi/blob/8.3/doc/biboumi.1.rst
#### Supported architectures
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/biboumi%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/biboumi/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/biboumi%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/biboumi/)
## Limitations
* Currently, Biboumi is only tested with one domain and it must be the main domain of your YunoHost server. * Currently, Biboumi is only tested with one domain and it must be the main domain of your YunoHost server.
## Links * Other infos that people should be aware of, such as:
* You can configure Biboumi with the file `/etc/biboumi/biboumi.cfg`.
## Documentation and resources
* Official app website: https://biboumi.louiz.org/
* Official admin documentation: Official documentation: https://lab.louiz.org/louiz/biboumi/blob/8.3/doc/biboumi.1.rst
* Upstream app code repository: https://lab.louiz.org/louiz/biboumi
* YunoHost documentation for this app: https://yunohost.org/app_biboumi
* Report a bug: https://github.com/YunoHost-Apps/biboumi_ynh/issues * Report a bug: https://github.com/YunoHost-Apps/biboumi_ynh/issues
* App website: https://biboumi.louiz.org/
* Upstream app repository: https://lab.louiz.org/louiz/biboumi/-/issues
* YunoHost website: https://yunohost.org/
---
## Developer info ## Developer info
@ -53,3 +52,5 @@ sudo yunohost app install https://github.com/YunoHost-Apps/biboumi_ynh/tree/test
or or
sudo yunohost app upgrade biboumi -u https://github.com/YunoHost-Apps/biboumi_ynh/tree/testing --debug sudo yunohost app upgrade biboumi -u https://github.com/YunoHost-Apps/biboumi_ynh/tree/testing --debug
``` ```
**More info regarding app packaging:** https://yunohost.org/packaging_apps

52
README_fr.md Normal file
View file

@ -0,0 +1,52 @@
# Biboumi pour YunoHost
[![Niveau d'intégration](https://dash.yunohost.org/integration/biboumi.svg)](https://dash.yunohost.org/appci/app/biboumi) ![](https://ci-apps.yunohost.org/ci/badges/biboumi.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/biboumi.maintain.svg)
[![Installer Biboumi avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=biboumi)
*[Read this readme in english.](./README.md)*
*[Lire ce readme en français.](./README_fr.md)*
> *Ce package vous permet d'installer Biboumi 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
Passerelle XMPP pour le réseau IRC.
**Version incluse :** 8.3~ynh1
## Avertissements / informations importantes
Once biboumi_ynh is installed you can use any XMPP client software to join IRC channels. Any IRC channel is seen as a standard XMPP chatroom (aka MUC) with a special name.
The the name is formatted like this: `#channelname%ircservername@biboumi.yourdomain.tld`.
For example, if you have a YunoHost server hosting domain *example.net* and you want to join the channel *#yunohost* on *irc.freenode.net* you simply need to join the MUC `#yunohost%irc.freenode.net@biboumi.example.net`.
* Any known limitations, constrains or stuff not working, such as (but not limited to):
* Currently, Biboumi is only tested with one domain and it must be the main domain of your YunoHost server.
* Other infos that people should be aware of, such as:
* You can configure Biboumi with the file `/etc/biboumi/biboumi.cfg`.
## Documentations et ressources
* Site officiel de l'app : https://biboumi.louiz.org/
* Documentation officielle de l'admin : Official documentation: https://lab.louiz.org/louiz/biboumi/blob/8.3/doc/biboumi.1.rst
* Dépôt de code officiel de l'app : https://lab.louiz.org/louiz/biboumi
* Documentation YunoHost pour cette app : https://yunohost.org/app_biboumi
* Signaler un bug : https://github.com/YunoHost-Apps/biboumi_ynh/issues
## Informations pour les développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/biboumi_ynh/tree/testing).
Pour essayer la branche testing, procédez comme suit.
```
sudo yunohost app install https://github.com/YunoHost-Apps/biboumi_ynh/tree/testing --debug
ou
sudo yunohost app upgrade biboumi -u https://github.com/YunoHost-Apps/biboumi_ynh/tree/testing --debug
```
**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps

View file

@ -10,6 +10,8 @@
setup_private=0 setup_private=0
setup_public=0 setup_public=0
upgrade=1 upgrade=1
# 8.3~ynh1
upgrade=1 from_commit=6596c7e12e17a2b9149b20739e916184e71fdfbd
backup_restore=1 backup_restore=1
multi_instance=0 multi_instance=0
port_already_use=1 (113) port_already_use=1 (113)
@ -17,3 +19,6 @@
;;; Options ;;; Options
Email=pitchum@gramaton.org Email=pitchum@gramaton.org
Notification=none Notification=none
;;; Upgrade options
; commit=6596c7e12e17a2b9149b20739e916184e71fdfbd
name=8.3~ynh1.

View file

@ -1,15 +1,15 @@
hostname=biboumi.__DOMAIN__ hostname=__APP__.__DOMAIN__
password=__SECRET__ password=__SHARED_SECRET__
#xmpp_server_ip=127.0.0.1 #xmpp_server_ip=127.0.0.1
#port=5347 #port=5347
db_name=/var/lib/biboumi/biboumi.sqlite db_name=/var/lib/__APP__/__APP__.sqlite
identd_port=__PORT__ identd_port=__PORT__
admin=__ADMIN_JID__ admin=__ADMIN_JID__
realname_customization=true realname_customization=true
realname_from_jid=false realname_from_jid=false
log_level=1 log_level=1
log_file=/var/log/biboumi/biboumi.log log_file=/var/log/__APP__/__APP__.log
#ca_file= #ca_file=
#outgoing_bind= #outgoing_bind=

View file

@ -1,2 +1,2 @@
Component "biboumi.__DOMAIN__" Component "__APP__.__DOMAIN__"
component_secret = "__SECRET__" component_secret = "__SHARED_SECRET__"

0
doc/.gitkeep Normal file
View file

10
doc/DISCLAIMER.md Normal file
View file

@ -0,0 +1,10 @@
Once biboumi_ynh is installed you can use any XMPP client software to join IRC channels. Any IRC channel is seen as a standard XMPP chatroom (aka MUC) with a special name.
The the name is formatted like this: `#channelname%ircservername@biboumi.yourdomain.tld`.
For example, if you have a YunoHost server hosting domain *example.net* and you want to join the channel *#yunohost* on *irc.freenode.net* you simply need to join the MUC `#yunohost%irc.freenode.net@biboumi.example.net`.
* Any known limitations, constrains or stuff not working, such as (but not limited to):
* Currently, Biboumi is only tested with one domain and it must be the main domain of your YunoHost server.
* Other infos that people should be aware of, such as:
* You can configure Biboumi with the file `/etc/biboumi/biboumi.cfg`.

0
doc/screenshots/.gitkeep Normal file
View file

View file

@ -8,6 +8,12 @@
}, },
"version": "8.3~ynh1", "version": "8.3~ynh1",
"url": "https://biboumi.louiz.org/", "url": "https://biboumi.louiz.org/",
"upstream": {
"license": "Zlib",
"website": "https://biboumi.louiz.org/",
"admindoc": "Official documentation: https://lab.louiz.org/louiz/biboumi/blob/8.3/doc/biboumi.1.rst",
"code": "https://lab.louiz.org/louiz/biboumi"
},
"license": "Zlib", "license": "Zlib",
"maintainer": { "maintainer": {
"name": "pitchum", "name": "pitchum",

View file

@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS # 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 ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -30,27 +31,24 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
#================================================= #=================================================
ynh_print_info --message="Declaring files to be backed up..." ynh_print_info --message="Declaring files to be backed up..."
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup "/etc/biboumi"
ynh_backup "/var/lib/biboumi"
#================================================= #=================================================
# BACKUP LOGROTATE # BACKUP LOGROTATE
#================================================= #=================================================
ynh_backup "/etc/logrotate.d/$app" ynh_backup --src_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# BACKUP METRONOME CONFIG # BACKUP VARIOUS FILES
#================================================= #=================================================
ynh_backup "/etc/metronome/conf.d/biboumi.cfg.lua" ynh_backup --src_path="/etc/$app"
ynh_backup --src_path="/var/lib/$app"
ynh_backup --src_path="/etc/metronome/conf.d/$app.cfg.lua"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info --message="Backup script completed for Biboumi. (YunoHost will then actually copy those files to the archive)." ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -25,9 +25,13 @@ admin=$YNH_APP_ARG_ADMIN
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
shared_secret="$(ynh_string_random 25)"
admin_jid="${admin}@$app.${domain}"
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
ynh_script_progression --message="Validating installation parameters..."
if dpkg --compare-versions "$(uname -r)" "<=" "4.0" if dpkg --compare-versions "$(uname -r)" "<=" "4.0"
then then
@ -37,101 +41,103 @@ fi
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_script_progression --message="Storing installation settings..." --weight=1 ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=shared_secret --value=$shared_secret
ynh_app_setting_set --app=$app --key=admin_jid --value=$admin_jid
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
#================================================= #=================================================
# FIND AND OPEN A PORT # FIND AND OPEN A PORT
#================================================= #=================================================
ynh_script_progression --message="Finding an available port..." --weight=2 ynh_script_progression --message="Finding an available port..."
# Find a free port # Find an available port
port=$(ynh_find_port --port=113) port=$(ynh_find_port --port=113)
ynh_app_setting_set --app=$app --key=port --value=$port ynh_app_setting_set --app=$app --key=port --value=$port
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Installing dependencies..." --weight=9 ynh_script_progression --message="Installing dependencies..."
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
#=================================================
# CONFIGURE BIBOUMI
#=================================================
# Create a secret password that will be shared by metronome and biboumi.
shared_secret="$(ynh_string_random 25)"
# Biboumi needs at least one admin JID.
admin_jid="${admin}@biboumi.${domain}"
biboumi_config_file="/etc/biboumi/biboumi.cfg"
# Create the biboumi config file.
cp ../conf/biboumi.cfg "$biboumi_config_file"
ynh_replace_string --match_string="__DOMAIN__" --replace_string="${domain}" --target_file="$biboumi_config_file"
ynh_replace_string --match_string="__SECRET__" --replace_string="${shared_secret}" --target_file="$biboumi_config_file"
ynh_replace_string --match_string="__PORT__" --replace_string="${port}" --target_file="$biboumi_config_file"
ynh_replace_string --match_string="__ADMIN_JID__" --replace_string="${admin_jid}" --target_file="$biboumi_config_file"
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$biboumi_config_file"
#================================================= #=================================================
# CONFIGURE METRONOME # CONFIGURE METRONOME
#================================================= #=================================================
ynh_script_progression --message="Configuring Metronome..."
# Add metronome component # Add metronome component
cp ../conf/biboumi.cfg.lua /etc/metronome/conf.d/ ynh_add_config --template="../conf/biboumi.cfg.lua" --destination="/etc/metronome/conf.d/$app.cfg.lua"
ynh_replace_string --match_string="__DOMAIN__" --replace_string="${domain}" --target_file="/etc/metronome/conf.d/biboumi.cfg.lua"
ynh_replace_string --match_string="__SECRET__" --replace_string="${shared_secret}" --target_file="/etc/metronome/conf.d/biboumi.cfg.lua" chown metronome:metronome "/etc/metronome/conf.d/$app.cfg.lua"
ynh_systemd_action --service_name=metronome --action="restart"
#================================================= #=================================================
# CREATE DIRECTORIES # CREATE DATA DIRECTORY
#================================================= #=================================================
ynh_script_progression --message="Creating a data directory..."
mkdir -p /var/log/biboumi /var/lib/biboumi mkdir -p /var/lib/$app
# Set permissions to app files # Set permissions to app files
chown _biboumi /var/log/biboumi /var/lib/biboumi /etc/biboumi chown -R _biboumi:_biboumi "/var/lib/$app"
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..."
ynh_add_config --template="../conf/biboumi.cfg" --destination="/etc/$app/$app.cfg"
chown -R _biboumi:_biboumi "/etc/$app/$app.cfg"
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1 ynh_script_progression --message="Configuring log rotation..."
mkdir -p /var/log/$app
chown -R _biboumi:_biboumi "/var/log/$app"
# Use logrotate to manage application logfile(s) # Use logrotate to manage application logfile(s)
ynh_use_logrotate /var/log/biboumi/ ynh_use_logrotate
#================================================= #=================================================
# ADVERTISE SERVICE IN ADMIN PANEL # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add biboumi --description="XMPP gateway for the IRC network" --log="/var/log/biboumi/biboumi.log" yunohost service add $app --description="XMPP gateway for the IRC network" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# SET THE APP AS NOT USING THE SSO # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..."
# Start a systemd service
sleep 5
ynh_systemd_action --service_name=$app --action="restart"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..."
# Prevent conflict with other apps on the same domain # Prevent conflict with other apps on the same domain
ynh_app_setting_set --app=$app --key=no_sso --value=1 ynh_app_setting_set --app=$app --key=no_sso --value=1
#=================================================
# RELOAD SERVICES
#=================================================
ynh_systemd_action --action=restart --service_name=metronome
ynh_systemd_action --action=restart --service_name=biboumi
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Installation of Biboumi completed" --last ynh_script_progression --message="Installation of $app completed"

View file

@ -12,64 +12,61 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1 ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
#================================================= #=================================================
# REMOVE SERVICE FROM ADMIN PANEL # REMOVE SERVICE INTEGRATION IN YUNOHOST
#================================================= #=================================================
# Remove a service from the admin panel, added by `yunohost service add` # Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if yunohost service status | grep -q $app if ynh_exec_warn_less yunohost service status $app >/dev/null
then then
ynh_script_progression --message="Removing $app service integration..." --weight=1 ynh_script_progression --message="Removing $app service integration..."
yunohost service remove $app yunohost service remove $app
fi fi
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=4
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing Biboumi directory..." --weight=2
# Remove the app directory securely
ynh_secure_remove "/etc/biboumi"
ynh_secure_remove "/var/lib/biboumi"
#================================================= #=================================================
# REMOVE LOGROTATE CONFIGURATION # REMOVE LOGROTATE CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=1 ynh_script_progression --message="Removing logrotate configuration..."
# Remove the app-specific logrotate config # Remove the app-specific logrotate config
ynh_remove_logrotate ynh_remove_logrotate
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..."
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#================================================= #=================================================
# SPECIFIC REMOVE # SPECIFIC REMOVE
#================================================= #=================================================
# REMOVE LOGS # REMOVE VARIOUS FILES
#================================================= #=================================================
ynh_script_progression --message="Removing various files..."
ynh_secure_remove "/var/log/biboumi" # Remove data directory
ynh_secure_remove --file="/var/lib/$app"
#================================================= # Remove a directory securely
# REMOVE METRONOME COMPONENT ynh_secure_remove --file="/etc/$app"
#=================================================
ynh_secure_remove "/etc/metronome/conf.d/biboumi.cfg.lua" # Remove the log files
ynh_secure_remove --file="/var/log/$app"
# Remove Metronome component
ynh_secure_remove --file="/etc/metronome/conf.d/$app.cfg.lua"
ynh_systemd_action --action=restart --service_name=metronome
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Removal of Biboumi completed" --last ynh_script_progression --message="Removal of $app completed"

View file

@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS # 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 ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -19,7 +20,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1 ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -28,7 +29,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1 ynh_script_progression --message="Validating restoration parameters..."
if dpkg --compare-versions "$(uname -r)" "<=" "4.0" if dpkg --compare-versions "$(uname -r)" "<=" "4.0"
then then
@ -40,55 +41,52 @@ fi
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=9 ynh_script_progression --message="Reinstalling dependencies..."
# Make sure that stretch-backports is enabled # Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE VARIOUS FILES
#================================================= #=================================================
ynh_script_progression --message="Restoring various files..."
ynh_restore_file "/etc/biboumi" ynh_restore_file --origin_path="/etc/$app"
ynh_restore_file "/var/lib/biboumi" chown -R _biboumi:_biboumi /etc/$app
#================================================= ynh_restore_file --origin_path="/var/lib/$app"
# ADVERTISE SERVICE IN ADMIN PANEL chown -R _biboumi:_biboumi /var/lib/$app
#=================================================
yunohost service add biboumi --description="XMPP gateway for the IRC network" --log="/var/log/biboumi/biboumi.log" ynh_restore_file --origin_path="/etc/metronome/conf.d/$app.cfg.lua"
chown metronome:metronome "/etc/metronome/conf.d/$app.cfg.lua"
ynh_systemd_action --service_name=metronome --action="restart"
#================================================= #=================================================
# RESTORE THE LOGROTATE CONFIGURATION # RESTORE THE LOGROTATE CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Restoring the logrotate configuration..."
mkdir -p /var/log/biboumi mkdir -p /var/log/$app
ynh_restore_file "/etc/logrotate.d/$app" chown -R _biboumi:_biboumi "/var/log/$app"
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# RESTORE USER RIGHTS # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
# Restore permissions on app files yunohost service add $app --description="XMPP gateway for the IRC network" --log="/var/log/$app/$app.log"
chown _biboumi /var/log/biboumi /var/lib/biboumi /etc/biboumi
#================================================= #=================================================
# RESTORE THE METRONOME CONFIG # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_restore_file "/etc/metronome/conf.d/biboumi.cfg.lua" ynh_systemd_action --service_name=$app --action="restart"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD SERVICES
#=================================================
ynh_systemd_action --action=restart --service_name=metronome
ynh_systemd_action --action=restart --service_name=biboumi
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Restoration completed for Biboumi" --last ynh_script_progression --message="Restoration completed for $app"

View file

@ -12,31 +12,27 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1 ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
admin=$(ynh_app_setting_get --app=$app --key=admin) admin=$(ynh_app_setting_get --app=$app --key=admin)
port=$(ynh_app_setting_get --app=$app --key=port) port=$(ynh_app_setting_get --app=$app --key=port)
shared_secret=$(ynh_app_setting_get --app=$app --key=shared_secret)
admin_jid=$(ynh_app_setting_get --app=$app --key=admin_jid)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Prevent conflict with other apps on the same domain
ynh_app_setting_set --app=$app --key=no_sso --value=1
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # 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 # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
@ -49,81 +45,93 @@ ynh_abort_if_errors
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
# Prevent conflict with other apps on the same domain
ynh_app_setting_set --app=$app --key=no_sso --value=1
if [ -z "$shared_secret" ]; then
shared_secret="$(grep password "/etc/biboumi/biboumi.cfg" | cut -d= -f2)"
ynh_app_setting_set --app=$app --key=shared_secret --value=$shared_secret
fi
if [ -z "$admin_jid" ]; then
admin_jid="${admin}@$app.${domain}"
ynh_app_setting_set --app=$app --key=admin_jid --value=$admin_jid
fi
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=9 ynh_script_progression --message="Upgrading dependencies..."
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
#=================================================
# CONFIGURE BIBOUMI
#=================================================
biboumi_config_file="/etc/biboumi/biboumi.cfg"
# Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
ynh_backup_if_checksum_is_different "$biboumi_config_file"
# Get shared_secret from the config file
shared_secret="$(grep password "$biboumi_config_file" | cut -d= -f2)"
# Biboumi needs at least one admin JID.
admin_jid="${admin}@biboumi.${domain}"
# Create the biboumi config file.
cp ../conf/biboumi.cfg /etc/biboumi/
ynh_replace_string --match_string="__DOMAIN__" --replace_string="${domain}" --target_file="$biboumi_config_file"
ynh_replace_string --match_string="__SECRET__" --replace_string="${shared_secret}" --target_file="$biboumi_config_file"
ynh_replace_string --match_string="__PORT__" --replace_string="${port}" --target_file="$biboumi_config_file"
ynh_replace_string --match_string="__ADMIN_JID__" --replace_string="${admin_jid}" --target_file="$biboumi_config_file"
# Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum "$biboumi_config_file"
#================================================= #=================================================
# UPGRADE METRONOME COMPONENT # UPGRADE METRONOME COMPONENT
#================================================= #=================================================
ynh_script_progression --message="Upgrading Metronome component..."
# Upgrade metronome component # Upgrade metronome component
cp ../conf/biboumi.cfg.lua /etc/metronome/conf.d/ ynh_add_config --template="../conf/biboumi.cfg.lua" --destination="/etc/metronome/conf.d/$app.cfg.lua"
ynh_replace_string --match_string="__DOMAIN__" --replace_string="${domain}" --target_file="/etc/metronome/conf.d/biboumi.cfg.lua"
ynh_replace_string --match_string="__SECRET__" --replace_string="${shared_secret}" --target_file="/etc/metronome/conf.d/biboumi.cfg.lua" chown metronome:metronome "/etc/metronome/conf.d/$app.cfg.lua"
ynh_systemd_action --service_name=metronome --action="restart"
#================================================= #=================================================
# SETUP LOGROTATE # CREATE DIRECTORIES
#================================================= #=================================================
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 ynh_script_progression --message="Creating a data directory..."
# Use logrotate to manage app-specific logfile(s) mkdir -p /var/lib/$app
ynh_use_logrotate /var/log/biboumi/ --non-append
# Set permissions to app files
chown -R _biboumi:_biboumi "/var/lib/$app"
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..."
ynh_add_config --template="../conf/biboumi.cfg" --destination="/etc/$app/$app.cfg"
chown -R _biboumi:_biboumi "/etc/$app/$app.cfg"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES # SETUP LOGROTATE
#================================================= #=================================================
ynh_script_progression --message="Upgrading logrotate configuration..."
# Set permissions on app files mkdir -p /var/log/$app
chown _biboumi /var/log/biboumi /var/lib/biboumi /etc/biboumi chown -R _biboumi:_biboumi "/var/log/$app"
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
#================================================= #=================================================
# ADVERTISE SERVICE IN ADMIN PANEL # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add biboumi --description="XMPP gateway for the IRC network" --log="/var/log/biboumi/biboumi.log" yunohost service add $app --description="XMPP gateway for the IRC network" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# RELOAD SERVICES # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --action=restart --service_name=metronome ynh_systemd_action --action=restart --service_name=$app
ynh_systemd_action --action=restart --service_name=biboumi
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Upgrade of Biboumi completed" --last ynh_script_progression --message="Upgrade of $app completed"