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

Merge pull request #44 from yalh76/2.98

full upgrade
This commit is contained in:
Alexandre Aubin 2019-08-02 21:03:36 +02:00 committed by GitHub
commit 8051074e2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 368 additions and 314 deletions

View file

@ -3,13 +3,13 @@
[![Integration level](https://dash.yunohost.org/integration/wekan.svg)](https://dash.yunohost.org/appci/app/wekan)
[![Install Wekan with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=wekan)
> *This package allow you to install wekan quickly and simply on a YunoHost server.
> *This package allow you to install Wekan 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.*
## Overview
Wekan is an open-source kanban board (task manager and organizer)
**Shipped version:** 2.56
**Shipped version:** 2.98
## Screenshots
@ -17,7 +17,7 @@ Wekan is an open-source kanban board (task manager and organizer)
## Status
- This app **only works on x86, 64bits architecture** ! In particular, it won't work on 32 bit machines or ARM. See the discussion [here](https://github.com/YunoHost-Apps/wekan_ynh/issues/1#issuecomment-401612500). On the long term, [support for ARM64 might happen](https://blog.wekan.team/2018/01/wekan-progress-on-x64-and-arm/index.html)...
- This app **only works on x86, 64bits architecture** ! In particular, it won't work on 32 bit machines or ARM. See the discussion [here](https://github.com/YunoHost-Apps/wekan_ynh/issues/1#issuecomment-401612500).
- There is currently **no SSO integration** though it might be integrated at some point in the app, now that it's supported in Meteor/Wekan. In the meantime, users can create accounts (in fact, they can create infinite number of accounts) manually, and need to login manually specifically in Wekan.
@ -26,16 +26,14 @@ Wekan is an open-source kanban board (task manager and organizer)
**Package by:** ljf & Aleks
**Categories:** Productivity, Task
**Upgrade this package:**
`sudo yunohost app upgrade --verbose wekan -u https://github.com/YunoHost-Apps/wekan_ynh`
**Multi-user:** Yes.
**Private/Public mode:** In private mode, only authorized YunoHost members can access to the wekan.
## Configuration
First registered user will be admin, and next ones normal users. If you want other admins too, you can change their permission to admin at Wekan Admin Panel.
As LDAP authentification is enable by default, wekan admins are the members of the YunoHost LDAP admin group.
To add an account in the YunoHost, you must first install [phpLDAPadmin](https://github.com/YunoHost-Apps/phpldapadmin_ynh) , connect to the interface and in the left panel go on `dc=yunohost,dc=org`, `ou=groups`, `cn=admins`. In the right panel, in the memberUid category, click on modify group members, add the account in the group, save changes and update object
If you have disable ldap authentication, first registered user will be admin, and next ones normal users. If you want other admins too, you can change their permission to admin at Wekan Admin Panel.
**Private/Public mode:** In private mode, only authorized YunoHost members can access to the wekan.
## Documentation
@ -46,17 +44,18 @@ First registered user will be admin, and next ones normal users. If you want oth
#### Multi-users support
LDAP is supported but HTTP auth is still not supported
#### Supported architectures
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/wekan%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/wekan/)
* ARMv8-A - Not supported
* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/wekan%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/wekan/)
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/wekan%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/wekan/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/wekan%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/wekan/)
* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/wekan%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/wekan/)
## Links
* Report a bug: https://github.com/YunoHost-Apps/wekan_ynh/issues
* App website: https://wekan.github.io/
* Github App website: https://github.com/wekan/wekan
* Upstream app repository: https://github.com/wekan/wekan
* YunoHost website: https://yunohost.org/
---
@ -64,7 +63,6 @@ LDAP is supported but HTTP auth is still not supported
Developers info
----------------
**Only if you want to use a testing branch for coding, instead of merging directly into master.**
Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/wekan_ynh/tree/testing).
To try the testing branch, please proceed like that.

View file

@ -14,23 +14,13 @@
upgrade=1 from_commit=4fe78843712dc1adc189830d2dde5f78bb17d747
backup_restore=1
multi_instance=1
incorrect_path=1
# This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version.
# incorrect_path=1
port_already_use=0
change_url=1
;;; Levels
Level 1=auto
Level 2=auto
Level 3=auto
# Level 4: If the app supports LDAP and SSOwat, turn level 4 to '1' and add a link to an issue or a part of your code to show it.
# If the app does not use LDAP nor SSOwat, and can't use them, turn level 4 to 'na' and explain as well.
#LDAP Implemented but not SSOwat
Level 4=0
# If the level 5 (Package linter) is forced to 1. Please add justifications here.
Level 5=auto
Level 6=auto
Level 7=auto
Level 8=0
Level 9=0
Level 10=0
;;; Options
Email=ljf+ynh-wekan@reflexlibre.net
Notification=down

View file

@ -1,8 +0,0 @@
# This is on YunoHost server just to avoid the file from disappearing
# Original source is https://releases.wekan.team/
SOURCE_URL=https://build.yunohost.org/apps/wekan-2.56.tar.gz
SOURCE_SUM=bf4c8a6d958be7c66c2a3f31462646681a325890003f8c140a853901d5b5f8de
SOURCE_SUM_PRG=sha256sum
ARCH_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=wekan-2.56.tar.gz

8
conf/arm64.src Normal file
View file

@ -0,0 +1,8 @@
# This is on YunoHost server just to avoid the file from disappearing
# Original source is https://releases.wekan.team/raspi3/wekan-2.94-arm64-bundle.tar.gz
SOURCE_URL=https://build.yunohost.org/apps/wekan-2.94-arm64-bundle.tar.gz
SOURCE_SUM=f23d57238e5e7702c9e7a93226f2d6dcaf996671a6b22a6639b99b5ec2ab2c7f
SOURCE_SUM_PRG=sha256sum
ARCH_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=wekan-2.94-arm64-bundle.tar.gz

View file

@ -1,5 +1,5 @@
location __PATH__
{
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
}

8
conf/x86-64.src Normal file
View file

@ -0,0 +1,8 @@
# This is on YunoHost server just to avoid the file from disappearing
# Original source is https://releases.wekan.team/wekan-2.98-meteor1.8-x64.tar.gz
SOURCE_URL=https://build.yunohost.org/apps/wekan-2.98-meteor1.8-x64.tar.gz
SOURCE_SUM=0f851e74eb35ef34415701c212f2953e55028d7cded5f427a161b20318e36885
SOURCE_SUM_PRG=sha256sum
ARCH_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=wekan-2.98-meteor1.8-x64.tar.gz

View file

@ -6,7 +6,7 @@
"en": "Trello-like kanban",
"fr": "Un kanban similaire à Trello"
},
"version": "2.56~ynh2",
"version": "2.98~ynh1",
"url": "https://wekan.io",
"license": "MIT",
"maintainer": [
@ -19,7 +19,7 @@
"name": "ljf"
}],
"requirements": {
"yunohost": ">= 3.4"
"yunohost": ">= 3.5"
},
"multi_instance": true,
"services": [

18
pull_request_template.md Normal file
View file

@ -0,0 +1,18 @@
## Problem
- *Description of why you made this PR*
## Solution
- *And how do you fix that problem*
## PR Status
- [ ] Code finished.
- [ ] Tested with Package_check.
- [ ] Fix or enhancement tested.
- [ ] Upgrade from last version tested.
- [ ] Can be reviewed and tested.
## Package_check results
---
*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results*
[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/wekan_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/wekan_ynh%20PR-NUM-%20(USERNAME)/)

View file

@ -14,40 +14,50 @@ 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_print_info "Loading installation settings..."
ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get $app final_path)
domain=$(ynh_app_setting_get $app domain)
db_name=$(ynh_app_setting_get $app db_name)
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)
#=================================================
# STANDARD BACKUP STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Stopping $app service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_print_info "Backing up the main app directory..."
ynh_print_info --message="Backing up the main app directory..."
ynh_backup "$final_path"
ynh_backup --src_path="$final_path"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_print_info "Backing up nginx web server configuration..."
ynh_print_info --message="Backing up nginx web server configuration..."
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP THE MONGODB DATABASE
#=================================================
ynh_print_info "Backing up the MongoDB database..."
ynh_print_info --message="Backing up the MongoDB database..."
mongodump --db "$db_name" -o "./dump"
@ -56,12 +66,20 @@ mongodump --db "$db_name" -o "./dump"
#=================================================
# BACKUP SYSTEMD
#=================================================
ynh_print_info "Backing up systemd configuration..."
ynh_print_info --message="Backing up systemd configuration..."
ynh_backup "/etc/systemd/system/$app.service"
ynh_backup --src_path="/etc/systemd/system/$app.service"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Starting $app service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started Wekan, task board"
sleep 30
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Backup script completed for $app. (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

@ -7,7 +7,6 @@
#=================================================
source _common.sh
source ynh_systemd_action
source /usr/share/yunohost/helpers
#=================================================
@ -25,14 +24,14 @@ app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading installation settings..."
ynh_print_info --message="Loading installation settings..."
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get $app final_path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# Add settings here as needed by your application
port=$(ynh_app_setting_get $app port)
port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
@ -52,10 +51,17 @@ fi
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Stopping $app service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_print_info "Updating nginx web server configuration..."
ynh_print_info --message="Updating nginx web server configuration..."
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
@ -63,7 +69,7 @@ nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
if [ $change_path -eq 1 ]
then
# Make a backup of the original nginx config file if modified
ynh_backup_if_checksum_is_different "$nginx_conf_path"
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for nginx helper
domain="$old_domain"
path_url="$new_path"
@ -75,10 +81,10 @@ fi
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
ynh_delete_file_checksum "$nginx_conf_path"
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 "/etc/nginx/conf.d/$new_domain.d/$app.conf"
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
#=================================================
@ -86,24 +92,29 @@ fi
#=================================================
# MODIFY URL IN .ENV
#=================================================
ynh_print_info "Updating .env configuration..."
ynh_print_info --message="Updating .env configuration..."
ynh_systemd_action --action=stop --service_name=$app --log_path="systemd"
ynh_replace_string "$old_domain$old_path" "$new_domain$new_path" "$final_path/.env"
ynh_systemd_action --action=start --service_name=$app --log_path="systemd" --line_match="Kadira: completed instrumenting the app"
sleep 10
ynh_replace_string --match_string="$old_domain$old_path" --replace_string="$new_domain$new_path" --target_file="$final_path/.env"
#=================================================
# GENERIC FINALISATION
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Starting $app service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started Wekan, task board"
sleep 30
#=================================================
# RELOAD NGINX
#=================================================
ynh_print_info "Reloading nginx web server..."
ynh_print_info --message="Reloading nginx web server..."
systemctl reload nginx
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Change of URL completed for $app"
ynh_print_info --message="Change of URL completed for $app"

View file

@ -7,13 +7,16 @@
#=================================================
source _common.sh
source ynh_systemd_action
source ynh_detect_arch__2
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
@ -30,43 +33,47 @@ app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_print_info "Validating installation parameters..."
ynh_print_info --message="Validating installation parameters..."
architecture=$(ynh_detect_arch)
# Check machine architecture (in particular, we don't support ARM and 32bit machines)
[[ $(uname -m) == "x86_64" ]] || ynh_die "Sorry, but this app can only be installed on a x86, 64 bits machine :("
if [ $architecture == "x86_64" ] || [ $architecture == "arm" ]
then
ynh_die --message="Sorry, but this app can only be installed on a x86, 64 bits machine :("
fi
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder"
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Register (book) web path
ynh_webpath_register $app $domain $path_url
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_print_info "Storing installation settings..."
ynh_print_info --message="Storing installation settings..."
ynh_app_setting_set $app domain $domain
ynh_app_setting_set $app path $path_url
ynh_app_setting_set $app is_public $is_public
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=is_public --value=$is_public
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_print_info "Configuring firewall..."
ynh_print_info --message="Configuring firewall..."
# Find a free port
port=$(ynh_find_port 8095)
ynh_app_setting_set $app port $port
port=$(ynh_find_port --port=8095)
ynh_app_setting_set --app=$app --key=port --value=$port
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_print_info "Installing dependencies..."
ynh_print_info --message="Installing dependencies..."
ynh_install_nodejs 8.15.1
ynh_install_nodejs --nodejs_version="8.16.0"
ynh_use_nodejs
ynh_install_app_dependencies $pkg_dependencies
@ -74,29 +81,29 @@ ynh_install_app_dependencies $pkg_dependencies
#=================================================
# START MONGODB
#=================================================
ynh_print_info "Starting mongodb ..."
ynh_print_info --message="Starting mongodb ..."
# Start mongodb
systemctl enable mongodb
systemctl start mongodb
# Registering db name
db_name=$(ynh_sanitize_dbid $app)
ynh_app_setting_set $app db_name $db_name
db_name=$(ynh_sanitize_dbid --db_name=$app)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_print_info "Setting up source files..."
ynh_print_info --message="Setting up source files..."
ynh_app_setting_set $app final_path $final_path
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path"
ynh_setup_source --dest_dir="$final_path" --source_id="$architecture"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_print_info "Configuring nginx web server..."
ynh_print_info --message="Configuring nginx web server..."
# Create a dedicated nginx config
ynh_add_nginx_config
@ -104,46 +111,47 @@ ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_print_info "Configuring system user..."
ynh_print_info --message="Configuring system user..."
# Create a system user
ynh_system_user_create $app "$final_path"
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# SPECIFIC SETUP
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_print_info "Configuring a systemd service..."
ynh_print_info --message="Configuring a systemd service..."
# Create a dedicated systemd config
ynh_replace_string "__NODEJS_PATH__" "$nodejs_path" "../conf/systemd.service"
ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service"
ynh_add_systemd_config
#=================================================
# MODIFY A CONFIG FILE
#=================================================
cp "../conf/.env" "$final_path/.env"
config_file="$final_path/.env"
cp "../conf/.env" $config_file
ynh_replace_string "__NODEJS_PATH__" "$nodejs_path" "$final_path/.env"
ynh_replace_string "__DB_NAME__" "$db_name" "$final_path/.env"
ynh_replace_string "__DOMAIN_URI__" "$domain$path_url" "$final_path/.env"
ynh_replace_string "__PORT__" "$port" "$final_path/.env"
ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="$config_file"
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config_file"
ynh_replace_string --match_string="__DOMAIN_URI__" --replace_string="$domain$path_url" --target_file="$config_file"
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config_file"
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$final_path/.env"
ynh_store_file_checksum --file="$config_file"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_print_info "Configuring file permissions ..."
ynh_print_info --message="Configuring file permissions ..."
# Set strong right permissions to app files
chown -R $app: "$final_path"
@ -157,35 +165,36 @@ find "$final_path" -type d -print0 | xargs -0 chmod 750
yunohost service add mongodb --log "/var/log/mongodb/mongodb.log"
yunohost service add $app
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Starting $app service..."
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Meteor APM: completed instrumenting the app"
sleep 30
#=================================================
# SETUP SSOWAT
#=================================================
ynh_print_info "Configuring SSOwat..."
ynh_print_info --message="Configuring SSOwat..."
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set $app unprotected_uris "/"
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_print_info "Reloading nginx web server..."
ynh_print_info --message="Reloading nginx web server..."
systemctl reload nginx
#=================================================
# START SERVICE
#=================================================
ynh_print_info "Now starting Wekan service..."
ynh_systemd_action --action=start --service_name=$app --log_path="systemd" --line_match="Kadira: completed instrumenting the app"
sleep 10
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Installation of $app completed"
ynh_print_info --message="Installation of $app completed"

View file

@ -12,15 +12,15 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading installation settings..."
ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
port=$(ynh_app_setting_get $app port)
db_name=$(ynh_app_setting_get $app db_name)
domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
final_path=$(ynh_app_setting_get $app final_path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# STANDARD REMOVE
@ -29,16 +29,16 @@ final_path=$(ynh_app_setting_get $app final_path)
#=================================================
# Remove a service from the admin panel, added by `yunohost service add`
if yunohost service status $app >/dev/null 2>&1
if ynh_exec_warn_less yunohost service status $app >/dev/null
then
ynh_print_info "Removing $app service"
ynh_print_info --message="Removing $app service..."
yunohost service remove $app
fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_print_info "Stopping and removing the systemd service"
ynh_print_info --message="Stopping and removing the systemd service..."
# Remove the dedicated systemd config
ynh_remove_systemd_config
@ -46,7 +46,7 @@ ynh_remove_systemd_config
#=================================================
# REMOVE THE MONGODB DATABASE
#=================================================
ynh_print_info "Removing the MongoDB database"
ynh_print_info --message="Removing the MongoDB database..."
# Remove a database if it exists, along with the associated user
mongo $db_name --eval "db.dropDatabase()"
@ -54,30 +54,24 @@ mongo $db_name --eval "db.dropDatabase()"
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_print_info "Removing dependencies"
ynh_print_info --message="Removing dependencies..."
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# REMOVE NODEJS
#=================================================
ynh_print_info "Removing nodejs"
ynh_remove_nodejs
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_print_info "Removing app main directory"
ynh_print_info --message="Removing app main directory"
# Remove the app directory securely
ynh_secure_remove "$final_path"
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_print_info "Removing nginx web server configuration"
ynh_print_info --message="Removing nginx web server configuration..."
# Remove the dedicated nginx config
ynh_remove_nginx_config
@ -87,13 +81,13 @@ ynh_remove_nginx_config
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_print_info "Removing the dedicated system user"
ynh_print_info --message="Removing the dedicated system user..."
# Delete a system user
ynh_system_user_delete $app
ynh_system_user_delete --username=$app
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Removal of $app completed"
ynh_print_info --message="Removal of $app completed"

View file

@ -14,30 +14,33 @@ 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_print_info "Loading settings..."
ynh_print_info --message="Loading settings..."
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path)
final_path=$(ynh_app_setting_get $app final_path)
db_name=$(ynh_app_setting_get $app db_name)
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_print_info "Validating restoration parameters..."
ynh_print_info --message="Validating restoration parameters..."
ynh_webpath_available $domain $path_url \
|| ynh_die "Path not available: ${domain}${path_url}"
ynh_webpath_available --domain=$domain --path_url=$path_url \
|| ynh_die --message="Path not available: ${domain}${path_url}"
test ! -d $final_path \
|| ynh_die "There is already a directory: $final_path "
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
@ -45,22 +48,22 @@ test ! -d $final_path \
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_print_info "Restoring the app main directory..."
ynh_print_info --message="Restoring the app main directory..."
ynh_restore_file "$final_path"
ynh_restore_file --origin_path="$final_path"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_print_info "Recreating the dedicated system user..."
ynh_print_info --message="Recreating the dedicated system user..."
# Create the dedicated user (if not existing)
ynh_system_user_create $app "$final_path"
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# RESTORE USER RIGHTS
@ -76,10 +79,10 @@ find "$final_path" -type d -print0 | xargs -0 chmod 750
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_print_info "Reinstalling dependencies..."
ynh_print_info --message="Reinstalling dependencies..."
# Define and install dependencies
ynh_install_nodejs 8.15.1
ynh_install_nodejs --nodejs_version="8.16.0"
ynh_use_nodejs
ynh_install_app_dependencies $pkg_dependencies
@ -87,7 +90,7 @@ ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE THE MONGODB DATABASE
#=================================================
ynh_print_info "Restoring the MongoDB database..."
ynh_print_info --message="Restoring the MongoDB database..."
# Start mongodb
systemctl enable mongodb
@ -97,10 +100,9 @@ mongorestore --db $db_name ./dump/$db_name
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_print_info "Restoring the systemd configuration..."
ynh_print_info --message="Restoring the systemd configuration..."
ynh_restore_file "/etc/systemd/system/$app.service"
systemctl daemon-reload
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service
#=================================================
@ -110,25 +112,25 @@ systemctl enable $app.service
yunohost service add mongodb --log "/var/log/mongodb/mongodb.log"
yunohost service add $app
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Starting $app service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started Wekan, task board"
sleep 30
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
#=================================================
ynh_print_info "Reloading nginx web server..."
ynh_print_info --message="Reloading nginx web server..."
systemctl reload nginx
#=================================================
# START SERVICE
#=================================================
ynh_print_info "Now starting Wekan service..."
ynh_systemd_action --action=start --service_name=$app --log_path="systemd" --line_match="Kadira: completed instrumenting the app"
sleep 10
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Restoration completed for $app"
ynh_print_info --message="Restoration completed for $app"

View file

@ -8,34 +8,44 @@
source _common.sh
source ynh_package_version
source ynh_systemd_action
source ynh_detect_arch__2
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading installation settings..."
ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path)
is_public=$(ynh_app_setting_get $app is_public)
final_path=$(ynh_app_setting_get $app final_path)
db_name=$(ynh_app_setting_get $app db_name)
port=$(ynh_app_setting_get $app port)
# Previous versions of the app did not have the db_name setting
if [ -z "$db_name" ]
then
db_name=$app
ynh_app_setting_set "$app" db_name "$db_name"
fi
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_print_info --message="Ensuring downward compatibility..."
# If db_name doesn't exist, create it
if [ -z "$db_name" ]; then
db_name=$(ynh_sanitize_dbid --db_name=$app)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
fi
#=================================================
# CHECK VERSION NUMBER
#=================================================
abort_if_up_to_date
# previous function is what defines 'version', more precisely the 'previous version'
previous_version="${version}"
@ -43,7 +53,7 @@ previous_version="${version}"
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_print_info "Backing up the app before upgrading (may take a while)..."
ynh_print_info --message="Backing up the app before upgrading (may take a while)..."
# Backup the current version of the app
ynh_backup_before_upgrade
@ -55,12 +65,12 @@ ynh_clean_setup () {
ynh_abort_if_errors
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
# MANAGE UPGRADE FROM PREVIOUS VERSION
#=================================================
ynh_print_info "Ensuring downward compatibility..."
ynh_print_info --message="Managing upgrade from previous version..."
if ynh_version_gt "0.45-2" "${previous_version}" ; then
ynh_replace_string "Environment=ROOT_URL=http://127.0.0.1:$port$path_url" "Environment=ROOT_URL=https://$domain$path_url/" "/etc/systemd/system/$app.service"
ynh_replace_string --match_string="Environment=ROOT_URL=http://127.0.0.1:$port$path_url" --replace_string="Environment=ROOT_URL=https://$domain$path_url/" --target_file="/etc/systemd/system/$app.service"
systemctl daemon-reload
fi
@ -69,14 +79,16 @@ if ynh_version_gt "0.45-3" "${previous_version}" ; then
fi
if ynh_version_gt "0.77-2" "${previous_version}" ; then
ynh_install_nodejs 8.9.3
ynh_install_nodejs --nodejs_version="8.9.3"
ynh_use_nodejs
# Create a dedicated systemd config
ynh_replace_string "__NODEJS__" "$nodejs_use_version" "../conf/systemd.service"
ynh_replace_string "__ENV_PATH__" "$PATH" "../conf/systemd.service"
ynh_replace_string "__DB_NAME__" "$app" "../conf/systemd.service"
ynh_replace_string "__URI__" "$path_url/" "../conf/systemd.service"
ynh_replace_string "__PORT__" "$port" "../conf/systemd.service"
ynh_replace_string "__DOMAIN__" "$domain" "../conf/systemd.service"
ynh_replace_string --match_string="__NODEJS__" --replace_string="$nodejs_use_version" --target_file="../conf/systemd.service"
ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service"
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$app" --target_file="../conf/systemd.service"
ynh_replace_string --match_string="__URI__" --replace_string="$path_url/" --target_file="../conf/systemd.service"
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/systemd.service"
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/systemd.service"
ynh_add_systemd_config
fi
@ -92,28 +104,32 @@ if ynh_version_gt "1.07~ynh2" "${previous_version}" ; then
# Gotta regen the systemd config because mongodb service name changed
ynh_use_nodejs
ynh_replace_string "__ENV_PATH__" "$nodejs_path" "../conf/systemd.service"
ynh_replace_string "__DB_NAME__" "$db_name" "../conf/systemd.service"
ynh_replace_string "__DOMAIN_URI__" "$domain$path_url" "../conf/systemd.service"
ynh_replace_string "__PORT__" "$port" "../conf/systemd.service"
ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service"
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/systemd.service"
ynh_replace_string --match_string="__DOMAIN_URI__" --replace_string="$domain$path_url" --target_file="../conf/systemd.service"
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/systemd.service"
ynh_add_systemd_config
fi
if ynh_version_gt "2.48~ynh1" "${previous_version}" ; then
# Install dependencies
ynh_remove_nodejs
ynh_install_nodejs 8.15.1
ynh_install_nodejs --nodejs_version="8.16.0"
ynh_use_nodejs
# Create a dedicated systemd config
ynh_replace_string "__NODEJS_PATH__" "$nodejs_path" "../conf/systemd.service"
ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service"
ynh_add_systemd_config
# Create a dedicated .env config
ynh_backup_if_checksum_is_different "$final_path/.env"
cp "../conf/.env" "$final_path/.env"
ynh_replace_string "__NODEJS_PATH__" "$nodejs_path" "$final_path/.env"
ynh_replace_string "__DB_NAME__" "$db_name" "$final_path/.env"
ynh_replace_string "__DOMAIN_URI__" "$domain$path_url" "$final_path/.env"
ynh_replace_string "__PORT__" "$port" "$final_path/.env"
ynh_store_file_checksum "$final_path/.env"
config_file="$final_path/.env"
ynh_backup_if_checksum_is_different --file="$config_file"
cp "../conf/.env" "$config_file"
ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file"$config_file"
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file"$config_file"
ynh_replace_string --match_string="__DOMAIN_URI__" --replace_string="$domain$path_url" --target_file"$config_file"
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file"$config_file"
ynh_store_file_checksum "$config_file"
fi
#=================================================
@ -121,25 +137,79 @@ fi
#=================================================
# Normalize the URL path syntax
path_url=$(ynh_normalize_url_path $path_url)
path_url=$(ynh_normalize_url_path --path_url=$path_url)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Stopping $app service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_print_info "Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path"
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_print_info --message="Upgrading source files..."
# Create a temporary directory
tmpdir="$(mktemp -d)"
# Backup the env file in the temp dir
cp -a "$final_path/.env" "$tmpdir/.env"
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
architecture=$(ynh_detect_arch)
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" --source_id="$architecture"
#Copy the admin saved settings from tmp directory to final path
cp -a "$tmpdir/.env" "$final_path/.env"
# Remove the tmp directory securely
ynh_secure_remove --file="$tmpdir"
fi
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_print_info --message="Upgrading nginx web server configuration..."
# Create a dedicated nginx config
ynh_add_nginx_config
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_print_info --message="Upgrading dependencies..."
ynh_install_nodejs --nodejs_version="8.16.0"
ynh_use_nodejs
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_print_info "Making sure dedicated system user exists..."
ynh_print_info --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing)
ynh_system_user_create $app
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_print_info --message="Upgrading systemd configuration..."
# Create a dedicated systemd config
ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service"
ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
@ -155,32 +225,32 @@ find "$final_path" -type d -print0 | xargs -0 chmod 750
#=================================================
# SETUP SSOWAT
#=================================================
ynh_print_info "Upgrading SSOwat configuration..."
ynh_print_info --message="Upgrading SSOwat configuration..."
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# unprotected_uris allows SSO credentials to be passed anyway
ynh_app_setting_set $app unprotected_uris "/"
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
fi
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started Wekan, task board"
sleep 30
#=================================================
# RELOAD NGINX
#=================================================
ynh_print_info "Reloading nginx web server..."
ynh_print_info --message="Reloading nginx web server..."
systemctl reload nginx
#=================================================
# START SERVICE
#=================================================
ynh_print_info "Now restarting Wekan service..."
ynh_systemd_action --action=restart --service_name=$app --log_path="systemd" --line_match="Kadira: completed instrumenting the app"
sleep 10
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Upgrade of $app completed"
ynh_print_info --message="Upgrade of $app completed"

View file

@ -0,0 +1,25 @@
#!/bin/bash
# Check the architecture
#
# example: architecture=$(ynh_detect_arch)
#
# usage: ynh_detect_arch
#
# Requires YunoHost version 2.2.4 or higher.
ynh_detect_arch(){
local architecture
if [ -n "$(uname -m | grep arm64)" ] || [ -n "$(uname -m | grep aarch64)" ]; then
architecture="arm64"
elif [ -n "$(uname -m | grep 64)" ]; then
architecture="x86-64"
elif [ -n "$(uname -m | grep 86)" ]; then
architecture="i386"
elif [ -n "$(uname -m | grep arm)" ]; then
architecture="arm"
else
architecture="unknown"
fi
echo $architecture
}

View file

@ -1,89 +0,0 @@
#!/bin/bash
# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started
#
# usage: ynh_systemd_action [-n service_name] [-a action] [ [-l "line to match"] [-p log_path] [-t timeout] [-e length] ]
# | arg: -n, --service_name= - Name of the service to reload. Default : $app
# | arg: -a, --action= - Action to perform with systemctl. Default: start
# | arg: -l, --line_match= - Line to match - The line to find in the log to attest the service have finished to boot.
# If not defined it don't wait until the service is completely started.
# | arg: -p, --log_path= - Log file - Path to the log file. Default : /var/log/$app/$app.log
# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds.
# | arg: -e, --length= - Length of the error log : Default : 20
ynh_systemd_action() {
# Declare an array to define the options of this helper.
declare -Ar args_array=( [n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length= )
local service_name
local action
local line_match
local length
local log_path
local timeout
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
local service_name="${service_name:-$app}"
local action=${action:-start}
local log_path="${log_path:-/var/log/$service_name/$service_name.log}"
local length=${length:-20}
local timeout=${timeout:-300}
# Start to read the log
if [[ -n "${line_match:-}" ]]
then
local templog="$(mktemp)"
# Following the starting of the app in its log
if [ "$log_path" == "systemd" ] ; then
# Read the systemd journal
journalctl -u $service_name -f --since=-45 > "$templog" &
else
# Read the specified log file
tail -F -n0 "$log_path" > "$templog" &
fi
# Get the PID of the tail command
local pid_tail=$!
fi
echo "${action^} the service $service_name" >&2
systemctl $action $service_name \
|| ( journalctl --lines=$length -u $service_name >&2 \
; test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 \
; false )
# Start the timeout and try to find line_match
if [[ -n "${line_match:-}" ]]
then
local i=0
for i in $(seq 1 $timeout)
do
# Read the log until the sentence is found, that means the app finished to start. Or run until the timeout
if grep --quiet "$line_match" "$templog"
then
echo "The service $service_name has correctly started." >&2
break
fi
echo -n "." >&2
sleep 1
done
if [ $i -eq $timeout ]
then
echo "The service $service_name didn't fully started before the timeout." >&2
journalctl --lines=$length -u $service_name >&2
test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2
fi
echo ""
ynh_clean_check_starting
fi
}
# Clean temporary process and file used by ynh_check_starting
# (usually used in ynh_clean_setup scripts)
#
# usage: ynh_clean_check_starting
ynh_clean_check_starting () {
# Stop the execution of tail.
kill -s 15 $pid_tail 2>&1
ynh_secure_remove "$templog" 2>&1
}

View file