1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/matterbridge_ynh.git synced 2024-09-03 19:36:24 +02:00

Merge pull request #35 from YunoHost-Apps/testing

Testing - Packagingv2
This commit is contained in:
Salamandar 2024-02-14 11:22:49 +01:00 committed by GitHub
commit 54b37d9c44
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 111 additions and 478 deletions

View file

@ -1,140 +0,0 @@
#!/bin/bash
#=================================================
# PACKAGE UPDATING HELPER
#=================================================
# This script is meant to be run by GitHub Actions
# The YunoHost-Apps organisation offers a template Action to run this script periodically
# Since each app is different, maintainers can adapt its contents so as to perform
# automatic actions when a new upstream release is detected.
# Remove this exit command when you are ready to run this Action
#exit 1
#=================================================
# FETCHING LATEST RELEASE AND ITS ASSETS
#=================================================
# Fetching information
current_version=$(cat manifest.json | jq -j '.version|split("~")[0]')
repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]')
# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions)
version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1)
assets=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'"))
# Later down the script, we assume the version has only digits and dots
# Sometimes the release name starts with a "v", so let's filter it out.
# You may need more tweaks here if the upstream repository has different naming conventions.
if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then
version=${version:1}
fi
# Setting up the environment variables
echo "Current version: $current_version"
echo "Latest release from upstream: $version"
echo "VERSION=$version" >> $GITHUB_ENV
echo "REPO=$repo" >> $GITHUB_ENV
# For the time being, let's assume the script will fail
echo "PROCEED=false" >> $GITHUB_ENV
# Proceed only if the retrieved version is greater than the current one
if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then
echo "::warning ::No new version available"
exit 0
# Proceed only if a PR for this new version does not already exist
elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then
echo "::warning ::A branch already exists for this update"
exit 0
fi
# Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.)
echo "${#assets[@]} available asset(s)"
#=================================================
# UPDATE SOURCE FILES
#=================================================
# Here we use the $assets variable to get the resources published in the upstream release.
# Here is an example for Grav, it has to be adapted in accordance with how the upstream releases look like.
# Let's loop over the array of assets URLs
for asset_url in ${assets[@]}; do
echo "Handling asset at $asset_url"
# Assign the asset to a source file in conf/ directory
# Here we base the source file name upon a unique keyword in the assets url (admin vs. update)
# Leave $src empty to ignore the asset
case $asset_url in
"matterbridge-"*"-linux-64bit")
src="amd64"
;;
"matterbridge-"*"-linux-arm64")
src="arm64"
;;
"matterbridge-"*"-linux-armv7")
src="armhf"
;;
*)
src=""
;;
esac
# If $src is not empty, let's process the asset
if [ ! -z "$src" ]; then
# Create the temporary directory
tempdir="$(mktemp -d)"
# Download sources and calculate checksum
filename=${asset_url##*/}
curl --silent -4 -L $asset_url -o "$tempdir/$filename"
checksum=$(sha256sum "$tempdir/$filename" | head -c 64)
# Delete temporary directory
rm -rf $tempdir
# Get extension
if [[ $filename == *.tar.gz ]]; then
extension=tar.gz
else
extension=${filename##*.}
fi
# Rewrite source file
cat <<EOT > conf/$src.src
SOURCE_URL=$asset_url
SOURCE_SUM=$checksum
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=$extension
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
EOT
echo "... conf/$src.src updated"
else
echo "... asset ignored"
fi
done
#=================================================
# SPECIFIC UPDATE STEPS
#=================================================
# Any action on the app's source code can be done.
# The GitHub Action workflow takes care of committing all changes after this script ends.
#=================================================
# GENERIC FINALIZATION
#=================================================
# Replace new version in manifest
echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json
# No need to update the README, yunohost-bot takes care of it
# The Action will proceed only if the PROCEED environment variable is set to true
echo "PROCEED=true" >> $GITHUB_ENV
exit 0

View file

@ -1,50 +0,0 @@
# This workflow allows GitHub Actions to automagically update your app whenever a new upstream release is detected.
# You need to enable Actions in your repository settings, and fetch this Action from the YunoHost-Apps organization.
# This file should be enough by itself, but feel free to tune it to your needs.
# It calls updater.sh, which is where you should put the app-specific update steps.
name: Check for new upstream releases
on:
# Allow to manually trigger the workflow
workflow_dispatch:
# Run it every day at 6:00 UTC
schedule:
- cron: '0 6 * * *'
jobs:
updater:
runs-on: ubuntu-latest
steps:
- name: Fetch the source code
uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run the updater script
id: run_updater
run: |
# Setting up Git user
git config --global user.name 'yunohost-bot'
git config --global user.email 'yunohost-bot@users.noreply.github.com'
# Run the updater script
/bin/bash .github/workflows/updater.sh
- name: Commit changes
id: commit
if: ${{ env.PROCEED == 'true' }}
run: |
git commit -am "Upgrade to v$VERSION"
- name: Create Pull Request
id: cpr
if: ${{ env.PROCEED == 'true' }}
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update to version ${{ env.VERSION }}
committer: 'yunohost-bot <yunohost-bot@users.noreply.github.com>'
author: 'yunohost-bot <yunohost-bot@users.noreply.github.com>'
signoff: false
base: testing
branch: ci-auto-update-v${{ env.VERSION }}
delete-branch: true
title: 'Upgrade to version ${{ env.VERSION }}'
body: |
Upgrade to v${{ env.VERSION }}
[See upstream release page](https://github.com/${{ env.REPO }}/releases/tag/v${{ env.VERSION }})
draft: false

View file

@ -16,15 +16,12 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
## Overview ## Overview
Multi-protocols bridge for online communications A simple chat bridge between a growing number of protocols:
Discord, Gitter, IRC, Keybase, Matrix, Mattermost, MSTeams, Rocket.Chat, Slack, Telegram, Twitch, WhatsApp, XMPP, Zulip, And more...
**Shipped version:** 1.26.0~ynh1 **Shipped version:** 1.26.0~ynh1
## Disclaimers / important information
## Configuration
How to configure this app: a plain file with SSH `/opt/yunohost/matterbridge/matterbridge.toml`. You can follow this [doc](https://github.com/42wim/matterbridge/wiki/How-to-create-your-config) on how to create your config.
## Documentation and resources ## Documentation and resources
* Official admin documentation: <https://github.com/42wim/matterbridge/wiki> * Official admin documentation: <https://github.com/42wim/matterbridge/wiki>

View file

@ -16,15 +16,12 @@ Si vous navez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po
## Vue densemble ## Vue densemble
Connecteur entre une série de protocoles de discussion Un connecteur de messagerie simple entre un nombre croissant de protocoles :
Discord, Gitter, IRC, Keybase, Matrix, Mattermost, MSTeams, Rocket.Chat, Slack, Telegram, Twitch, WhatsApp, XMPP, Zulip, Et plus...
**Version incluse :** 1.26.0~ynh1 **Version incluse :** 1.26.0~ynh1
## Avertissements / informations importantes
## Configuration
Comment configurer cette application : un fichier brut en SSH `/opt/yunohost/matterbridge/matterbridge.toml`. Vous pouvez suivre cette [documentation](https://github.com/42wim/matterbridge/wiki/How-to-create-your-config) sur la façon de créer votre config.
## Documentations et ressources ## Documentations et ressources
* Documentation officielle de ladmin : <https://github.com/42wim/matterbridge/wiki> * Documentation officielle de ladmin : <https://github.com/42wim/matterbridge/wiki>

View file

@ -1,21 +0,0 @@
;; Test complet
; Manifest
; Checks
pkg_linter=1
setup_sub_dir=0
setup_root=0
setup_nourl=1
setup_private=0
setup_public=0
upgrade=1
upgrade=1 from_commit=58cf8e614d7b4396816b4073f58af75c5c4b075f
backup_restore=1
multi_instance=0
;;; Options
Email=
Notification=none
;;; Upgrade options
; commit=58cf8e614d7b4396816b4073f58af75c5c4b075f
name=Merge pull request #5 from YunoHost-Apps/testing
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&

View file

@ -1,6 +0,0 @@
SOURCE_URL=https://github.com/42wim/matterbridge/releases/download/v1.26.0/matterbridge-1.26.0-linux-64bit
SOURCE_SUM=7f5a74b9b7cbf395b8873f3f3f418d90c61197e3cc677882e70b7faeef4c35b0
SOURCE_SUM_PRG=sha256sum
SOURCE_IN_SUBDIR=false
SOURCE_FILENAME=matterbridge
SOURCE_EXTRACT=false

View file

@ -1,6 +0,0 @@
SOURCE_URL=https://github.com/42wim/matterbridge/releases/download/v1.26.0/matterbridge-1.26.0-linux-arm64
SOURCE_SUM=3d922187ce3e792f9cf896e209c828d3466e3b2453f3a133f7f610f9d6937587
SOURCE_SUM_PRG=sha256sum
SOURCE_IN_SUBDIR=false
SOURCE_FILENAME=matterbridge
SOURCE_EXTRACT=false

View file

@ -1,6 +0,0 @@
SOURCE_URL=https://github.com/42wim/matterbridge/releases/download/v1.26.0/matterbridge-1.26.0-linux-armv6
SOURCE_SUM=fee25dc50c96508147c88c0da05c6143681f8c88bdbef1c42a91bf9388aa13f9
SOURCE_SUM_PRG=sha256sum
SOURCE_IN_SUBDIR=false
SOURCE_FILENAME=matterbridge
SOURCE_EXTRACT=false

View file

@ -6,9 +6,9 @@ After=network.target
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
UMask=000 UMask=000
ExecStart=__FINALPATH__/matterbridge -conf __FINALPATH__/matterbridge.toml ExecStart=__INSTALL_DIR__/matterbridge -conf __INSTALL_DIR__/matterbridge.toml
RestartSec=30 RestartSec=30
Restart=always Restart=always

3
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1,3 @@
A simple chat bridge between a growing number of protocols:
Discord, Gitter, IRC, Keybase, Matrix, Mattermost, MSTeams, Rocket.Chat, Slack, Telegram, Twitch, WhatsApp, XMPP, Zulip, And more...

3
doc/DESCRIPTION_fr.md Normal file
View file

@ -0,0 +1,3 @@
Un connecteur de messagerie simple entre un nombre croissant de protocoles :
Discord, Gitter, IRC, Keybase, Matrix, Mattermost, MSTeams, Rocket.Chat, Slack, Telegram, Twitch, WhatsApp, XMPP, Zulip, Et plus...

View file

@ -1,30 +0,0 @@
{
"name": "Matterbridge",
"id": "matterbridge",
"packaging_format": 1,
"description": {
"en": "Multi-protocols bridge for online communications",
"fr": "Connecteur entre une série de protocoles de discussion"
},
"version": "1.26.0~ynh1",
"url": "https://github.com/42wim/matterbridge",
"upstream": {
"license": "Apache-2.0",
"admindoc": "https://github.com/42wim/matterbridge/wiki",
"code": "https://github.com/42wim/matterbridge"
},
"license": "Apache-2.0",
"maintainer": {
"name": "liberodark",
"email": "liberodark@gmail.com"
},
"requirements": {
"yunohost": ">= 11.0.9"
},
"multi_instance": false,
"services": [],
"arguments": {
"install" : [
]
}
}

51
manifest.toml Normal file
View file

@ -0,0 +1,51 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
packaging_format = 2
id = "matterbridge"
name = "Matterbridge"
description.en = "Multi-protocols bridge for online communications"
description.fr = "Connecteur entre une série de protocoles de discussion"
version = "1.26.0~ynh1"
maintainers = []
[upstream]
license = "Apache-2.0"
admindoc = "https://github.com/42wim/matterbridge/wiki"
code = "https://github.com/42wim/matterbridge"
[integration]
yunohost = ">= 11.0.9"
architectures = ["amd64", "arm64", "armhf"]
multi_instance = false
ldap = "not_relevant"
sso = "not_relevant"
disk = "60M"
ram.build = "50M"
ram.runtime = "50M"
[install]
[resources]
[resources.sources.main]
in_subdir = false
amd64.url = "https://github.com/42wim/matterbridge/releases/download/v1.26.0/matterbridge-1.26.0-linux-64bit"
amd64.sha256 = "7f5a74b9b7cbf395b8873f3f3f418d90c61197e3cc677882e70b7faeef4c35b0"
arm64.url = "https://github.com/42wim/matterbridge/releases/download/v1.26.0/matterbridge-1.26.0-linux-arm64"
arm64.sha256 = "3d922187ce3e792f9cf896e209c828d3466e3b2453f3a133f7f610f9d6937587"
armhf.url = "https://github.com/42wim/matterbridge/releases/download/v1.26.0/matterbridge-1.26.0-linux-armv6"
armhf.sha256 = "fee25dc50c96508147c88c0da05c6143681f8c88bdbef1c42a91bf9388aa13f9"
extract = false
rename = "matterbridge"
autoupdate.strategy = "latest_github_release"
autoupdate.asset.amd64 = "matterbridge-.*-linux-64bit"
autoupdate.asset.arm64 = "matterbridge-.*-linux-arm64"
autoupdate.asset.armhf = "matterbridge-.*-linux-armv6"
[resources.system_user]
[resources.install_dir]

View file

@ -10,22 +10,6 @@
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# 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
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # DECLARE DATA AND CONF FILES TO BACKUP
#================================================= #=================================================
@ -35,7 +19,7 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup --src_path="$final_path" ynh_backup --src_path="$install_dir"
#================================================= #=================================================
# BACKUP SYSTEMD # BACKUP SYSTEMD

View file

@ -9,78 +9,40 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
# Retrieve arguments
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1
final_path=/opt/yunohost/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=5
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=1 ynh_script_progression --message="Setting up source files..." --weight=1
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" --source_id=$YNH_ARCH ynh_setup_source --dest_dir="$install_dir"
chmod +x "$install_dir/matterbridge"
chmod 750 "$final_path" chmod -R o-rwX "$install_dir"
chmod -R o-rwx "$final_path" chown -R "$app:www-data" "$install_dir"
chown -R $app:www-data "$final_path"
chmod +x $final_path/matterbridge
#================================================= #=================================================
# MODIFY A CONFIG FILE # MODIFY A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1 ynh_script_progression --message="Adding a configuration file..." --weight=1
ynh_add_config --template="../conf/matterbridge.toml" --destination="$final_path/matterbridge.toml" ynh_add_config --template="matterbridge.toml" --destination="$install_dir/matterbridge.toml"
#================================================= #=================================================
# SETUP SYSTEMD # SYSTEM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1 ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
yunohost service add "$app" --description="Multi-protocols bridge for online communications" --log="/var/log/$app/$app.log"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="Multi-protocols bridge for online communications" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_script_progression --message="Starting a systemd service..." --weight=1
# Reload services ynh_systemd_action --service_name="$app" --action=start --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name=$app --action=start --log_path="/var/log/$app/$app.log"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -10,53 +10,18 @@ source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # REMOVE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) # 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 if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then
then yunohost service remove "$app"
ynh_script_progression --message="Removing $app service integration..." --weight=1
yunohost service remove $app
fi fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=2
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_remove_systemd_config ynh_remove_systemd_config
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..." --weight=1
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=2
# Delete a system user
ynh_system_user_delete --username=$app
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -9,65 +9,32 @@
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=4
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$install_dir"
#=================================================
# RESTORE USER RIGHTS
#=================================================
# Restore permissions on app files # Restore permissions on app files
chmod +x $final_path/$app chmod -R o-rwX "$install_dir"
chown -R $app: $final_path chown -R "$app:www-data" "$install_dir"
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
ynh_restore_file --origin_path="/etc/systemd/system/$app.service" ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet systemctl enable "$app.service" --quiet
yunohost service add "$app" --description="Multi-protocols bridge for online communications" --log="/var/log/$app/$app.log"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="Multi-protocols bridge for online communications" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action=start --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name="$app" --action=start --log_path="/var/log/$app/$app.log"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -9,21 +9,6 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
#================================================= #=================================================
@ -31,68 +16,35 @@ upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action=stop --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name="$app" --action=stop --log_path="/var/log/$app/$app.log"
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=4
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Upgrading source files..." --weight=2
if [ "$upgrade_type" == "UPGRADE_APP" ] # Download, check integrity, uncompress and patch the source from app.src
then ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep="matterbridge.toml"
ynh_script_progression --message="Upgrading source files..." --weight=2 chmod +x "$install_dir/matterbridge"
# Download, check integrity, uncompress and patch the source from app.src chmod -R o-rwX "$install_dir"
ynh_setup_source --dest_dir="$final_path" --source_id=$YNH_ARCH --keep="matterbridge.toml" chown -R "$app:www-data" "$install_dir"
fi
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
chmod +x $final_path/matterbridge
#================================================= #=================================================
# SETUP SYSTEMD # REAPPLY SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
yunohost service add "$app" --description="Multi-protocols bridge for online communications" --log="/var/log/$app/$app.log"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="Multi-protocols bridge for online communications" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=2 ynh_script_progression --message="Starting a systemd service..." --weight=2
ynh_systemd_action --service_name=$app --action=start --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name="$app" --action=start --log_path="/var/log/$app/$app.log"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

11
tests.toml Normal file
View file

@ -0,0 +1,11 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json
test_format = 1.0
[default]
# ------------
# Tests to run
# ------------
test_upgrade_from.58cf8e614d7b4396816b4073f58af75c5c4b075f.name = "Merge pull request #5 from YunoHost-Apps/testing"