1
0
forked from Git/send_ynh

Merge pull request #16 from YunoHost-Apps/upgrade

Upgrade
This commit is contained in:
yalh76 2022-07-02 18:14:20 +02:00 committed by GitHub
commit ea163e2a22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 202 additions and 121 deletions

View File

@ -19,7 +19,7 @@ A fork of Mozilla's Firefox Send. Mozilla discontinued Send, this fork is a comm
Send is a file sharing experiment which allows you to send encrypted files to other users.
**Shipped version:** 3.4.20~ynh1
**Shipped version:** 3.4.20~ynh2
**Demo:** https://send.vis.ee/

View File

@ -19,7 +19,7 @@ Un fork du Firefox Send de Mozilla. Mozilla a arrêté Send, et ce fork est un e
Send est une expérience de partage de fichiers qui permet d'envoyer des fichiers chiffrés à d'autres utilisateurs.
**Version incluse :** 3.4.20~ynh1
**Version incluse :** 3.4.20~ynh2
**Démo :** https://send.vis.ee/

View File

@ -10,13 +10,14 @@
setup_private=1
setup_public=1
upgrade=1
# 3.4.14~ynh1
upgrade=1 from_commit=6e2eba4a9b6b455b35ce9d8e558c454a001bfacf
# 3.4.18~ynh1
upgrade=1 from_commit=674f8d3211ba98b10f169deea3127a8b378c6c3c
backup_restore=1
multi_instance=1
port_already_use=0
change_url=1
;;; Options
Email=
;;; Upgrade options
; commit=6e2eba4a9b6b455b35ce9d8e558c454a001bfacf
name=3.4.14
manifest_arg=domain=DOMAIN&is_public=1&
Notification=none

View File

@ -3,3 +3,5 @@ SOURCE_SUM=d8b485383f5f2fdca98501e1abdacec158b2eb04a7a8a4dabae2a0d4f542c6e4
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View File

@ -1,8 +1,11 @@
const convict = require('convict');
const convict_format_with_validator = require('convict-format-with-validator');
const { tmpdir } = require('os');
const path = require('path');
const { randomBytes } = require('crypto');
convict.addFormats(convict_format_with_validator);
convict.addFormat({
name: 'positive-int-array',
coerce: ints => {
@ -239,6 +242,68 @@ const conf = convict({
format: String,
default: 'https://github.com/timvisee/send',
env: 'SEND_FOOTER_SOURCE_URL'
},
ui_color_primary: {
format: String,
default: '#0a84ff',
env: 'UI_COLOR_PRIMARY'
},
ui_color_accent: {
format: String,
default: '#003eaa',
env: 'UI_COLOR_ACCENT'
},
ui_custom_assets: {
android_chrome_192px: {
format: String,
default: '',
env: 'UI_CUSTOM_ASSETS_ANDROID_CHROME_192PX'
},
android_chrome_512px: {
format: String,
default: '',
env: 'UI_CUSTOM_ASSETS_ANDROID_CHROME_512PX'
},
apple_touch_icon: {
format: String,
default: '',
env: 'UI_CUSTOM_ASSETS_APPLE_TOUCH_ICON'
},
favicon_16px: {
format: String,
default: '',
env: 'UI_CUSTOM_ASSETS_FAVICON_16PX'
},
favicon_32px: {
format: String,
default: '',
env: 'UI_CUSTOM_ASSETS_FAVICON_32PX'
},
icon: {
format: String,
default: '',
env: 'UI_CUSTOM_ASSETS_ICON'
},
safari_pinned_tab: {
format: String,
default: '',
env: 'UI_CUSTOM_ASSETS_SAFARI_PINNED_TAB'
},
facebook: {
format: String,
default: '',
env: 'UI_CUSTOM_ASSETS_FACEBOOK'
},
twitter: {
format: String,
default: '',
env: 'UI_CUSTOM_ASSETS_TWITTER'
},
wordmark: {
format: String,
default: '',
env: 'UI_CUSTOM_ASSETS_WORDMARK'
}
}
});

BIN
doc/.DS_Store vendored

Binary file not shown.

View File

@ -6,7 +6,7 @@
"en": "File sharing which allows to send encrypted files",
"fr": "Partage de fichiers qui permet d'envoyer des fichiers chiffrés"
},
"version": "3.4.20~ynh1",
"version": "3.4.20~ynh2",
"url": "https://github.com/timvisee/send",
"upstream": {
"license": "MPL-2.0",
@ -26,7 +26,7 @@
"nginx"
],
"arguments": {
"install" : [
"install": [
{
"name": "domain",
"type": "domain"

View File

@ -4,7 +4,10 @@
# COMMON VARIABLES
#=================================================
nodejs_version=18
# dependencies used by the app
pkg_dependencies="redis-server"
nodejs_version=16.13
#=================================================
# PERSONAL HELPERS

View File

@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@ -14,7 +15,7 @@ source /usr/share/yunohost/helpers
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@ -46,12 +47,6 @@ ynh_backup --src_path="$final_path"
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP LOGROTATE
#=================================================
ynh_backup --src_path="/etc/logrotate.d/$app"
#=================================================
# BACKUP SYSTEMD
#=================================================

View File

@ -32,9 +32,9 @@ port=$(ynh_app_setting_get --app=$app --key=port)
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up $app before changing its URL (may take a while)..." --weight=1
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
@ -71,7 +71,7 @@ fi
#=================================================
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"
#=================================================
# MODIFY URL IN NGINX CONF
@ -102,6 +102,8 @@ then
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
# ADD A CONFIGURATION
#=================================================

View File

@ -56,7 +56,7 @@ ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_script_progression --message="Finding an available port..." --weight=2
# Find an available port
port=$(ynh_find_port --port=1443)
port=$(ynh_find_port --port=8095)
ynh_app_setting_set --app=$app --key=port --value=$port
#=================================================
@ -64,9 +64,17 @@ ynh_app_setting_set --app=$app --key=port --value=$port
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=20
# Install Nodejs
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=3
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# CREATE A REDIS DATABASE
#=================================================
@ -76,14 +84,6 @@ ynh_script_progression --message="Creating a Redis database..." --weight=5
redis_db=$(ynh_redis_get_free_db)
ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db"
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=3
# Create a system user
ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@ -91,7 +91,7 @@ ynh_script_progression --message="Setting up source files..." --weight=2
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 --dest_dir=$final_path
ynh_setup_source --dest_dir="$final_path"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
@ -106,22 +106,12 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=2
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=2
ynh_add_config --template="../conf/config.js" --destination="$final_path/server/config.js"
chmod 400 "$final_path/server/config.js"
chown $app "$final_path/server/config.js"
#=================================================
# SPECIFIC SETUP
#==============================================
# INSTALL HEDGEDOC
#==============================================
ynh_script_progression --message="Building $app... (this will take some time and resources!)" --weight=20
#=================================================
# BUILD APP
#=================================================
ynh_script_progression --message="Building app... (this will take some time and resources!)" --weight=20
pushd "$final_path"
ynh_use_nodejs
@ -129,27 +119,30 @@ pushd "$final_path"
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm run build
popd
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=2
ynh_add_config --template="../conf/config.js" --destination="$final_path/server/config.js"
chmod 400 "$final_path/server/config.js"
chown $app: "$final_path/server/config.js"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="Simple, private file sharing" --log="/var/log/$app/$app.log"
yunohost service add $app --description="Simple, private file sharing"
#=================================================
# START SYSTEMD SERVICE
@ -164,10 +157,12 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd"
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary or protect it
# Make app public if necessary
if [ $is_public -eq 1 ]
then
ynh_permission_update --permission "main" --add "visitors"
# Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors"
fi
ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true"

View File

@ -26,10 +26,10 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
# 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
then
ynh_script_progression --message="Removing $app service..." --weight=1
ynh_script_progression --message="Removing $app service integration..." --weight=1
yunohost service remove $app
fi
@ -41,21 +41,6 @@ ynh_script_progression --message="Stopping and removing the systemd service..."
# Remove the dedicated systemd config
ynh_remove_systemd_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
# Remove the app-specific logrotate config
ynh_remove_logrotate
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1
ynh_remove_nodejs
#=================================================
# REMOVE THE REDIS DATABASE
#=================================================
@ -76,9 +61,18 @@ ynh_secure_remove --file="$final_path"
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=5
# Remove the dedicated nginx config
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
ynh_remove_nodejs
#=================================================
# GENERIC FINALIZATION
#=================================================

View File

@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@ -40,13 +41,6 @@ test ! -d $final_path \
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
@ -74,9 +68,17 @@ chmod +x "$final_path/server/bin/prod.js"
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=7
# Install Nodejs
# Define and install dependencies
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE SYSTEMD
#=================================================
@ -85,19 +87,12 @@ ynh_script_progression --message="Restoring the systemd configuration..." --weig
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="Simple, private file sharing" --log="/var/log/$app/$app.log"
yunohost service add $app --description="Simple, private file sharing"
#=================================================
# START SYSTEMD SERVICE

View File

@ -20,13 +20,30 @@ 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)
port=$(ynh_app_setting_get --app=$app --key=port)
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=10
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
@ -37,18 +54,11 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Backing up $app before upgrading (may take a while)..." --weight=10
ynh_script_progression --message="Ensuring downward compatibility..."
# 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
ynh_remove_logrotate
#=================================================
# CREATE DEDICATED USER
@ -66,8 +76,23 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=10
# Create a temporary directory
tmpdir="$(mktemp -d)"
# Backup the config file in the temp dir
cp -a "$final_path/server/config.js" "$tmpdir/config.js"
# Remove the app directory securely
ynh_secure_remove --file=$final_path
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir=$final_path --keep="$final_path/server/config.js"
ynh_setup_source --dest_dir=$final_path
#Copy the admin saved settings from tmp directory to final path
cp -a "$tmpdir/config.js" "$final_path/server/config.js"
# Remove the tmp directory securely
ynh_secure_remove --file="$tmpdir"
fi
chmod 750 "$final_path"
@ -75,6 +100,14 @@ chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
chmod +x "$final_path/server/bin/prod.js"
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=18
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
#=================================================
# NGINX CONFIGURATION
#=================================================
@ -83,23 +116,15 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." -
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=18
# Install Nodejs
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
#=================================================
# SPECIFIC UPGRADE
#================================================
# INSTALL SEND
#================================================
#=================================================
# BUILD APP
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Building $app... (this will take some time and resources!)" --weight=16
ynh_script_progression --message="Building app... (this will take some time and resources!)" --weight=16
pushd "$final_path"
ynh_use_nodejs
@ -108,28 +133,32 @@ then
popd
fi
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..."
ynh_add_config --template="../conf/config.js" --destination="$final_path/server/config.js"
chmod 400 "$final_path/server/config.js"
chown $app: "$final_path/server/config.js"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=2
ynh_script_progression --message="Upgrading systemd configuration..." --weight=2
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
# GENERIC FINALIZATION
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="Simple, private file sharing" --log="/var/log/$app/$app.log"
yunohost service add $app --description="Simple, private file sharing"
#=================================================
# START SYSTEMD SERVICE