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

Manifestv2

This commit is contained in:
Salamandar 2023-10-03 23:43:58 +02:00
parent 747d5f92ca
commit 70afd1e5c2
15 changed files with 642 additions and 1096 deletions

View file

@ -1,29 +0,0 @@
;; Test complet (bozon=sans bdd)
auto_remove=1
; Manifest
domain="domain.tld"
path="/path"
is_public=1
admin="john"
password="super_secret_password"
; Checks
pkg_linter=1
setup_sub_dir=1
setup_root=1
setup_nourl=0
setup_private=1
setup_public=1
upgrade=1
# 2.4.18~ynh2
upgrade=1 from_commit=8fcdd9d4e05b1d5e4f98dd57ac3659c060330916
backup_restore=1
multi_instance=0
port_already_use=0
change_url=1
;;; Options
Email=
Notification=none
;;; Upgrade options
; commit=8fcdd9d4e05b1d5e4f98dd57ac3659c060330916
name=Use official helper
manifest_arg=domain=DOMAIN&path=PATH&is_public=1&language="fr"&filesize="2G"&admin=USER&password=PASSWORD&backup_core_only=1&

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://github.com/broncowdd/BoZoN/archive/ce0265e0dd13bc1e3cbbf0d96b846f65d1a17173.zip
SOURCE_SUM=42e8e81771cb3489297a75138a69cf83c82edc3e6ea5988b8d436254ac502b1b
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -2,7 +2,7 @@
location __PATH__/ {
# Path to source
alias __FINALPATH__/;
alias __INSTALL_DIR__/;
index index.php;

View file

@ -358,7 +358,7 @@ request_terminate_timeout = 1d
; Chdir to this directory at the start.
; Note: relative path can be used.
; Default Value: current directory or / when chroot
chdir = __FINALPATH__
chdir = __INSTALL_DIR__
; Redirect worker stdout and stderr into main error log. If not set, stdout and
; stderr will be redirected to /dev/null according to FastCGI specs.

View file

View file

@ -1,55 +0,0 @@
{
"name": "BoZoN",
"id": "bozon",
"packaging_format": 1,
"description": {
"en": "Minimalist Drag & drop file sharing app",
"fr": "Application minimaliste de partage de fichiers"
},
"version": "2.4.18~ynh4",
"url": "https://github.com/broncowdd/BoZoN",
"upstream": {
"license": "AGPL-3.0",
"code": "https://github.com/broncowdd/BoZoN"
},
"license": "AGPL-3.0",
"maintainer": {
"name": "ewilly",
"email": "ewilly@neuf.fr"
},
"requirements": {
"yunohost": ">= 4.3.0"
},
"multi_instance": false,
"services": [
"nginx",
"php7.4-fpm"
],
"arguments": {
"install": [
{
"name": "domain",
"type": "domain"
},
{
"name": "path",
"type": "path",
"example": "/bozon",
"default": "/bozon"
},
{
"name": "is_public",
"type": "boolean",
"default": false
},
{
"name": "admin",
"type": "user"
},
{
"name": "password",
"type": "password"
}
]
}
}

69
manifest.toml Normal file
View file

@ -0,0 +1,69 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
packaging_format = 2
id = "bozon"
name = "BoZoN"
description.en = "Minimalist Drag & drop file sharing app"
description.fr = "Application minimaliste de partage de fichiers"
version = "2.4.18~ynh4"
maintainers = ["ewilly"]
[upstream]
license = "AGPL-3.0"
code = "https://github.com/broncowdd/BoZoN"
[integration]
yunohost = ">= 4.3.0"
architectures = "all"
multi_instance = false
ldap = true
sso = "not_relevant"
disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ...
ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
[install]
[install.domain]
type = "domain"
[install.path]
type = "path"
default = "/bozon"
[install.init_main_permission]
help.en = "If public, any visitor can convert audio or video files using your server."
help.fr = "Si lapplication est publique, nimporte quel visiteur pourra utiliser votre serveur pour convertir des fichiers audio et vidéos."
type = "group"
default = "visitors"
[install.admin]
type = "user"
[install.password]
type = "password"
[resources]
[resources.sources.main]
url = "https://github.com/broncowdd/BoZoN/archive/ce0265e0dd13bc1e3cbbf0d96b846f65d1a17173.zip"
sha256 = "42e8e81771cb3489297a75138a69cf83c82edc3e6ea5988b8d436254ac502b1b"
[resources.system_user]
[resources.install_dir]
[resources.data_dir]
subdirs = ["uploads", "thumbs"]
[resources.permissions]
main.url = "/"
[resources.apt]
packages = [
"php7.4-fpm",
"php7.4-zip",
"php7.4-curl",
"php7.4-gd",
]

View file

@ -4,47 +4,19 @@
# COMMON VARIABLES
#=================================================
YNH_PHP_VERSION="7.4"
php_dependencies="php$YNH_PHP_VERSION-zip php$YNH_PHP_VERSION-curl php$YNH_PHP_VERSION-gd"
# dependencies used by the app (must be on a single line)
pkg_dependencies="$php_dependencies"
#=================================================
# PERSONAL HELPERS
#=================================================
# Check if directory/file already exists (path in argument)
myynh_check_path () {
[ -z "$1" ] && ynh_die --message="No argument supplied"
[ ! -e "$1" ] || ynh_die --message="$1 already exists"
}
# Create directory only if not already exists (path in argument)
myynh_create_dir () {
[ -z "$1" ] && ynh_die --message="No argument supplied"
[ -d "$1" ] || mkdir -p "$1"
}
# Clean & copy files needed to final folder
myynh_clean_source () {
find "$tmpdir" -type f -name ".htaccess" | xargs rm
[ -e "$tmpdir/.gitignore" ] && ynh_secure_remove "$tmpdir/.gitignore"
find "$install_dir" -type f -name ".htaccess" -delete
if [ -e "$install_dir/.gitignore" ]; then
ynh_secure_remove "$install_dir/.gitignore"
fi
}
myynh_set_permissions () {
[ $(find "$final_path" -type f | wc -l) -gt 0 ] && find "$final_path" -type f | xargs chmod 0644
[ $(find "$final_path" -type d | wc -l) -gt 0 ] && find "$final_path" -type d | xargs chmod 0755
[ $(find "$datadir" -type f | wc -l) -gt 0 ] && find "$datadir" -type f | xargs chmod 0644
[ $(find "$datadir" -type d | wc -l) -gt 0 ] && find "$datadir" -type d | xargs chmod 0755
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
chmod -R o-rwx "$datadir"
chown -R $app:www-data "$datadir"
}
#Convert --data to --data-urlencode before ynh_local_curl
# Convert --data to --data-urlencode before ynh_local_curl
myynh_urlencode() {
local data
if [[ $# != 1 ]]; then

View file

@ -10,28 +10,6 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
@ -41,13 +19,13 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="$final_path"
ynh_backup --src_path="$install_dir"
#=================================================
# BACKUP THE DATA DIR
#=================================================
ynh_backup --src_path="$datadir" --is_big
ynh_backup --src_path="$data_dir" --is_big
#=================================================
# BACKUP THE NGINX CONFIGURATION

View file

@ -9,59 +9,6 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN
new_path=$YNH_APP_NEW_PATH
app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
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
ynh_clean_setup () {
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================
change_domain=0
if [ "$old_domain" != "$new_domain" ]
then
change_domain=1
fi
change_path=0
if [ "$old_path" != "$new_path" ]
then
change_path=1
fi
#=================================================
# STANDARD MODIFICATIONS
#=================================================
@ -69,37 +16,7 @@ fi
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the path in the NGINX config file
if [ $change_path -eq 1 ]
then
# Make a backup of the original NGINX config file if modified
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for NGINX helper
domain="$old_domain"
path_url="$new_path"
# Create a dedicated NGINX config
ynh_add_nginx_config
fi
# Change the domain for NGINX
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
#=================================================
# GENERIC FINALISATION
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
ynh_change_url_nginx_config
#=================================================
# END OF SCRIPT

View file

@ -9,165 +9,42 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
admin=$YNH_APP_ARG_ADMIN
password=$YNH_APP_ARG_PASSWORD
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=/var/www/$app
datadir="/home/yunohost.app/$app"
path_url=$(ynh_normalize_url_path --path_url="$path_url")
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
## check that admin user is an existing account
ynh_user_exists --username="$admin"
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=admin_user --value=$admin
ynh_app_setting_set --app=$app --key=final_path --value="$final_path"
ynh_app_setting_set --app=$app --key=datadir --value="$datadir"
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=3
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=3
## download source
tmpdir=$(mktemp -d)
ynh_setup_source --dest_dir="$tmpdir"
## clean & copy files needed to final folder
ynh_setup_source --dest_dir="$install_dir"
myynh_clean_source
mv "$tmpdir" "$final_path"
mkdir "$install_dir/private"
ln -s "$data_dir/uploads" "$install_dir/uploads"
ln -s "$data_dir/thumbs" "$install_dir/thumbs"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
chmod 750 "$data_dir"
chmod -R o-rwx "$data_dir"
chown -R "$app:www-data" "$data_dir"
#=================================================
# PHP-FPM CONFIGURATION
# SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Configuring PHP-FPM..." --weight=1
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
if [ "$path_url" != "/" ]; then
ynh_replace_string --match_string="^#sub_path_only" --replace_string="" --target_file="../conf/nginx.conf"
fi
ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
#=================================================
# CREATE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Creating a data directory..." --weight=1
datadir=/home/yunohost.app/$app
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
mkdir -p $datadir
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
## create private & data folders
myynh_create_dir "$final_path/private"
myynh_create_dir "$datadir/uploads"
myynh_create_dir "$datadir/thumbs"
ln -s "$datadir/uploads" "$final_path/uploads"
ln -s "$datadir/thumbs" "$final_path/thumbs"
## set permissions
myynh_set_permissions
ynh_add_fpm_config
#=================================================
# SETUP APPLICATION WITH CURL
#=================================================
ynh_script_progression --message="Configuring admin user in BoZon..." --weight=2
# Set the app as temporarily public for curl call
ynh_script_progression --message="Configuring SSOwat..."
# Making the app public for curl
ynh_permission_update --permission="main" --add="visitors"
## fill the superadmin creation form (helper ynh_local_curl doesn't work due to --data vs --data-urlencode ?)
admin_url="/index.php?p=login"
admin=$(myynh_urlencode $admin)
password=$(myynh_urlencode $password)
ynh_local_curl $admin_url "creation=1" "login=$admin" "pass=$password" "confirm=$password"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring SSOwat..." --weight=1
if [ $is_public -eq 0 ]; then
# escape magic chars in vars (lua magic chars are ().%+-*?[^$ according to https://www.lua.org/pil/20.2.html)
domainluaregex=$(echo "$domain" | sed -e 's/[]().%+*?[^$[]/\%&/g' | sed -e 's/\-/\%&/g')
pathluaregex=$([ "$path_url" == "/" ] || echo "$path_url" | sed -e 's/[]().%+*?[^$[]/\%&/g' | sed -e 's/\-/\%&/g')
regexList="${domainluaregex}${pathluaregex}/index%.php$","${domainluaregex}${pathluaregex}/index%.php%?p=.*$"
ynh_app_setting_set --app="$app" --key=protected_regex --value="$regexList"
fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
ynh_local_curl "/index.php?p=login" "creation=1" "login=$admin" "pass=$password" "confirm=$password"
#=================================================
# END OF SCRIPT

View file

@ -10,71 +10,14 @@ source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
# REMOVE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#=================================================
# STANDARD REMOVE
#=================================================
# 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"
#=================================================
# REMOVE DATA DIR
#=================================================
# Remove the data directory if --purge option is used
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
then
ynh_script_progression --message="Removing app data directory..." --weight=1
ynh_secure_remove --file="$datadir"
fi
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=1
# Remove the dedicated PHP-FPM config
ynh_remove_fpm_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
# Delete a system user
ynh_system_user_delete --username=$app
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -10,92 +10,45 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_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)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
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"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
#=================================================
# RESTORE THE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Restoring the data directory..." --weight=1
ynh_restore_file --origin_path="$datadir" --not_mandatory
ynh_restore_file --origin_path="$data_dir" --not_mandatory
mkdir -p $datadir
chmod 750 "$data_dir"
chmod -R o-rwx "$data_dir"
chown -R "$app:www-data" "$data_dir"
#=================================================
# SPECIFIC RESTORATION
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#=================================================
# RESTORE THE NGINX CONFIGURATION
# GENERIC FINALIZATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE USER RIGHTS
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
myynh_set_permissions
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# GENERIC FINALIZATION
@ -104,8 +57,8 @@ myynh_set_permissions
#=================================================
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
ynh_systemd_action --service_name=nginx --action=reload
ynh_systemd_action --service_name="php$phpversion-fpm" --action=reload
ynh_systemd_action --service_name="nginx" --action=reload
#=================================================
# END OF SCRIPT

View file

@ -8,20 +8,6 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
admin_user=$(ynh_app_setting_get --app=$app --key=admin_user)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#=================================================
# CHECK VERSION
#=================================================
@ -29,20 +15,6 @@ ynh_script_progression --message="Checking version..." --weight=1
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=3
# 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
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
@ -50,78 +22,36 @@ ynh_abort_if_errors
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
# If final_path doesn't exist, create it
if [ -z "$final_path" ]; then
final_path="/var/www/$app"
ynh_app_setting_set --app="$app" --key=final_path --value="$final_path"
fi
# If datadir doesn't exist, create it
if [ -z "$datadir" ]; then
datadir="/home/yunohost.app/$app"
ynh_app_setting_set --app="$app" --key=datadir --value="$datadir"
fi
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
# download & unpack bozon
ynh_script_progression --message="Setting up source files..." --weight=2
## download source
tmpdir=$(mktemp -d)
ynh_setup_source --dest_dir="$tmpdir"
## clean & copy files needed to final folder
ynh_setup_source --dest_dir="$install_dir" --keep=config.php
myynh_clean_source
[ -e "$tmpdir/config.php" ] && ynh_secure_remove "$tmpdir/config.php"
cp -a "$tmpdir/." "$final_path"
ynh_secure_remove "$tmpdir"
fi
## set permissions
myynh_set_permissions
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
chmod 750 "$data_dir"
chmod -R o-rwx "$data_dir"
chown -R "$app:www-data" "$data_dir"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=1
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
if [ "$path_url" != "/" ]; then
ynh_replace_string --match_string="^#sub_path_only" --replace_string="" --target_file="../conf/nginx.conf"
fi
ynh_add_nginx_config
ynh_add_fpm_config
#=================================================
# SPECIFIC UPGRADE
#=================================================
@ -135,15 +65,6 @@ elif [ -d "/usr/lib/php" ]; then
[ -x /usr/lib/php/sessionclean ] && /usr/lib/php/sessionclean
fi
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================

7
tests.toml Normal file
View file

@ -0,0 +1,7 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json
test_format = 1.0
[default]
test_upgrade_from.8fcdd9d4e05b1d5e4f98dd57ac3659c060330916.name = "Use official helper"