mirror of
https://github.com/YunoHost-Apps/nextcloud_ynh.git
synced 2024-09-03 19:55:57 +02:00
v2
This commit is contained in:
parent
23cfd61da4
commit
e877ce9c89
9 changed files with 253 additions and 184 deletions
|
@ -1,9 +1,9 @@
|
||||||
{
|
{
|
||||||
"system": {
|
"system": {
|
||||||
"datadirectory": "__DATADIR__",
|
"data_directory": "__DATA_DIR__",
|
||||||
"trusted_domains": [
|
"trusted_domains": [
|
||||||
"localhost",
|
"localhost",
|
||||||
"__DOMAIN__"
|
"__DOMAIN__"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ location ^~ /.well-known {
|
||||||
location ^~ __PATH__/ {
|
location ^~ __PATH__/ {
|
||||||
|
|
||||||
# Path to source
|
# Path to source
|
||||||
alias __FINALPATH__/;
|
alias __INSTALL_DIR__/;
|
||||||
|
|
||||||
# Add headers to serve security related headers
|
# Add headers to serve security related headers
|
||||||
more_set_headers "Strict-Transport-Security: max-age=15768000; includeSubDomains; preload;";
|
more_set_headers "Strict-Transport-Security: max-age=15768000; includeSubDomains; preload;";
|
||||||
|
|
69
manifest.toml
Normal file
69
manifest.toml
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
packaging_format = 2
|
||||||
|
|
||||||
|
id = "nextcloud"
|
||||||
|
name = "Nextcloud"
|
||||||
|
description.en = "Online storage, file sharing platform and various other applications"
|
||||||
|
description.fr = "Stockage en ligne, plateforme de partage de fichiers et diverses autres applications"
|
||||||
|
|
||||||
|
version = "25.0.1~ynh1"
|
||||||
|
|
||||||
|
maintainers = ["kay0u"]
|
||||||
|
|
||||||
|
[upstream]
|
||||||
|
license = "AGPL-3.0"
|
||||||
|
website = "https://nextcloud.com"
|
||||||
|
demo = "https://demo.nextcloud.com/"
|
||||||
|
admindoc = "https://docs.nextcloud.com/server/stable/admin_manual/"
|
||||||
|
userdoc = "https://docs.nextcloud.com/server/latest/user_manual/en/"
|
||||||
|
code = "https://github.com/nextcloud/server"
|
||||||
|
cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number)
|
||||||
|
fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin.
|
||||||
|
|
||||||
|
[integration]
|
||||||
|
yunohost = ">= 11.0.9"
|
||||||
|
architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64/armel), for example: ["amd64", "i386"]
|
||||||
|
multi_instance = true
|
||||||
|
ldap = "?" # FIXME: replace with true, false, or "not_relevant"
|
||||||
|
sso = "?" # FIXME: replace with true, false, or "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]
|
||||||
|
# this is a generic question - ask strings are automatically handled by Yunohost's core
|
||||||
|
type = "domain"
|
||||||
|
|
||||||
|
[install.path]
|
||||||
|
# this is a generic question - ask strings are automatically handled by Yunohost's core
|
||||||
|
type = "path"
|
||||||
|
default = "/nextcloud"
|
||||||
|
|
||||||
|
[install.admin]
|
||||||
|
# this is a generic question - ask strings are automatically handled by Yunohost's core
|
||||||
|
type = "user"
|
||||||
|
|
||||||
|
[install.init_main_permission]
|
||||||
|
help.en = "If enabled, Nextcloud will be accessible by Nextcloud Desktop and by users without a YunoHost account. This can be changed later in the webadmin."
|
||||||
|
help.fr = "Si cette case est cochée, Nextcloud sera accessible par Nextcloud Desktop et par les utilisateurs n’ayant pas de compte YunoHost. Vous pourrez changer dans la webadmin."
|
||||||
|
type = "group"
|
||||||
|
default = "visitors"
|
||||||
|
|
||||||
|
[install.user_home]
|
||||||
|
ask.en = "Access the users home folder from Nextcloud?"
|
||||||
|
ask.fr = "Accéder au dossier personnel des utilisateurs depuis Nextcloud ?"
|
||||||
|
type = "boolean"
|
||||||
|
default = false
|
||||||
|
|
||||||
|
[resources]
|
||||||
|
[resources.system_user]
|
||||||
|
|
||||||
|
[resources.install_dir]
|
||||||
|
|
||||||
|
[resources.data_dir]
|
||||||
|
|
||||||
|
[resources.permissions]
|
||||||
|
main.url = "/"
|
||||||
|
|
||||||
|
[resources.database]
|
||||||
|
type = "mysql"
|
|
@ -5,7 +5,7 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
YNH_PHP_VERSION="8.0"
|
YNH_PHP_VERSION="8.0"
|
||||||
pkg_dependencies="imagemagick libmagickcore-6.q16-6-extra acl tar smbclient at php${YNH_PHP_VERSION}-fpm php${YNH_PHP_VERSION}-bz2 php${YNH_PHP_VERSION}-imap php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-apcu php${YNH_PHP_VERSION}-redis php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-igbinary php${YNH_PHP_VERSION}-bcmath"
|
#REMOVEME? pkg_dependencies="imagemagick libmagickcore-6.q16-6-extra acl tar smbclient at php${YNH_PHP_VERSION}-fpm php${YNH_PHP_VERSION}-bz2 php${YNH_PHP_VERSION}-imap php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-apcu php${YNH_PHP_VERSION}-redis php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-igbinary php${YNH_PHP_VERSION}-bcmath"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# EXPERIMENTAL HELPERS
|
# EXPERIMENTAL HELPERS
|
||||||
|
|
|
@ -14,20 +14,20 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
#REMOVEME? ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Loading installation settings..."
|
#REMOVEME? ynh_print_info --message="Loading installation settings..."
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||||
|
@ -38,7 +38,7 @@ ynh_print_info --message="Declaring files to be backed up..."
|
||||||
# BACKUP THE APP MAIN DIR
|
# BACKUP THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="$final_path"
|
ynh_backup --src_path="$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE NGINX CONFIGURATION
|
# BACKUP THE NGINX CONFIGURATION
|
||||||
|
@ -85,7 +85,7 @@ ynh_backup --src_path="/etc/cron.d/$app"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Backing up data directory..."
|
ynh_print_info --message="Backing up data directory..."
|
||||||
|
|
||||||
ynh_backup --src_path="$datadir" --is_big
|
ynh_backup --src_path="$data_dir" --is_big
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
104
scripts/install
104
scripts/install
|
@ -14,31 +14,31 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
#REMOVEME? ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
#REMOVEME? domain=$YNH_APP_ARG_DOMAIN
|
||||||
path_url=$YNH_APP_ARG_PATH
|
#REMOVEME? path=$YNH_APP_ARG_PATH
|
||||||
admin=$YNH_APP_ARG_ADMIN
|
#REMOVEME? admin=$YNH_APP_ARG_ADMIN
|
||||||
user_home=$YNH_APP_ARG_USER_HOME
|
#REMOVEME? user_home=$YNH_APP_ARG_USER_HOME
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
phpversion=$YNH_PHP_VERSION
|
phpversion=$YNH_PHP_VERSION
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Validating installation parameters..."
|
#REMOVEME? ynh_script_progression --message="Validating installation parameters..."
|
||||||
|
|
||||||
final_path=/var/www/$app
|
#REMOVEME? install_dir=/var/www/$app
|
||||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder"
|
||||||
|
|
||||||
# Register (book) web path
|
# Register (book) web path
|
||||||
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path
|
||||||
|
|
||||||
# Check machine architecture (Seens 25.0 Nextcloud doesn't support 32bit machines)
|
# Check machine architecture (Seens 25.0 Nextcloud doesn't support 32bit machines)
|
||||||
if [ $YNH_ARCH == "i386" ];
|
if [ $YNH_ARCH == "i386" ];
|
||||||
|
@ -49,11 +49,11 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE SETTINGS FROM MANIFEST
|
# STORE SETTINGS FROM MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Storing installation settings..."
|
#REMOVEME? ynh_script_progression --message="Storing installation settings..."
|
||||||
|
|
||||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path
|
||||||
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
#REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin
|
||||||
ynh_app_setting_set --app=$app --key=user_home --value=$user_home
|
ynh_app_setting_set --app=$app --key=user_home --value=$user_home
|
||||||
|
|
||||||
maintenance_mode=0
|
maintenance_mode=0
|
||||||
|
@ -64,19 +64,19 @@ ynh_app_setting_set --app=$app --key=maintenance_mode --value=$maintenance_mode
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL DEPENDENCIES
|
# INSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing dependencies..." --weight=10
|
#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=10
|
||||||
|
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE A MYSQL DATABASE
|
# CREATE A MYSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Creating a MySQL database..." --weight=2
|
#REMOVEME? ynh_script_progression --message="Creating a MySQL database..." --weight=2
|
||||||
|
|
||||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
#REMOVEME? db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||||
db_user=$db_name
|
#REMOVEME? db_user=$db_name
|
||||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||||
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
|
#REMOVEME? ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
|
@ -95,19 +95,19 @@ SOURCE_FORMAT=tar.bz2
|
||||||
SOURCE_IN_SUBDIR=true
|
SOURCE_IN_SUBDIR=true
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
|
||||||
# Enable YunoHost patches on Nextcloud sources
|
# Enable YunoHost patches on Nextcloud sources
|
||||||
cp -a ../sources/patches_last_version/* ../sources/patches
|
cp -a ../sources/patches_last_version/* ../sources/patches
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
ynh_setup_source --dest_dir="$final_path"
|
ynh_setup_source --dest_dir="$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring system user..." --weight=3
|
#REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=3
|
||||||
|
|
||||||
# Create a system user
|
# Create a system user
|
||||||
ynh_system_user_create --username=$app
|
#REMOVEME? ynh_system_user_create --username=$app
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PHP-FPM CONFIGURATION
|
# PHP-FPM CONFIGURATION
|
||||||
|
@ -125,7 +125,7 @@ ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
|
||||||
# Create a dedicated php-fpm config
|
# Create a dedicated php-fpm config
|
||||||
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$YNH_PHP_VERSION
|
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$YNH_PHP_VERSION
|
||||||
# Used by ynh_add_nginx_config
|
# Used by ynh_add_nginx_config
|
||||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
|
@ -152,11 +152,11 @@ ynh_add_nginx_config
|
||||||
ynh_script_progression --message="Creating a data directory..." --weight=1
|
ynh_script_progression --message="Creating a data directory..." --weight=1
|
||||||
|
|
||||||
# Define app's data directory
|
# Define app's data directory
|
||||||
datadir="/home/yunohost.app/$app/data"
|
#REMOVEME? data_dir="/home/yunohost.app/$app/data"
|
||||||
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
|
#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir
|
||||||
|
|
||||||
# Create app folders
|
# Create app folders
|
||||||
mkdir -p "$datadir"
|
mkdir -p "$data_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL NEXTCLOUD
|
# INSTALL NEXTCLOUD
|
||||||
|
@ -165,12 +165,12 @@ ynh_script_progression --message="Installing Nextcloud..." --weight=30
|
||||||
|
|
||||||
# Define a function to execute commands with `occ`
|
# Define a function to execute commands with `occ`
|
||||||
exec_occ() {
|
exec_occ() {
|
||||||
(cd "$final_path" && ynh_exec_as "$app" \
|
(cd "$install_dir" && ynh_exec_as "$app" \
|
||||||
php${phpversion} --define apc.enable_cli=1 occ --no-interaction --no-ansi "$@")
|
php${phpversion} --define apc.enable_cli=1 occ --no-interaction --no-ansi "$@")
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set write access for the following commands
|
# Set write access for the following commands
|
||||||
chown -R $app: "$final_path" "$datadir"
|
chown -R $app: "$install_dir" "$data_dir"
|
||||||
|
|
||||||
# Define password in an intermediate var
|
# Define password in an intermediate var
|
||||||
# The fact that it's called _password allows it to be
|
# The fact that it's called _password allows it to be
|
||||||
|
@ -182,7 +182,7 @@ exec_occ maintenance:install \
|
||||||
--database "mysql" --database-name $db_name \
|
--database "mysql" --database-name $db_name \
|
||||||
--database-user $db_user --database-pass "$db_pwd" \
|
--database-user $db_user --database-pass "$db_pwd" \
|
||||||
--admin-user "admin" --admin-pass "$admin_password" \
|
--admin-user "admin" --admin-pass "$admin_password" \
|
||||||
--data-dir "$datadir" \
|
--data-dir "$data_dir" \
|
||||||
|| ynh_die --message="Unable to install Nextcloud"
|
|| ynh_die --message="Unable to install Nextcloud"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -198,7 +198,7 @@ exec_occ app:enable user_ldap
|
||||||
exec_occ ldap:create-empty-config
|
exec_occ ldap:create-empty-config
|
||||||
|
|
||||||
# Load the installation config file in Nextcloud
|
# Load the installation config file in Nextcloud
|
||||||
nc_conf="$final_path/config_install.json"
|
nc_conf="$install_dir/config_install.json"
|
||||||
ynh_add_config --template="../conf/config_install.json" --destination="$nc_conf"
|
ynh_add_config --template="../conf/config_install.json" --destination="$nc_conf"
|
||||||
|
|
||||||
exec_occ config:import "$nc_conf"
|
exec_occ config:import "$nc_conf"
|
||||||
|
@ -207,7 +207,7 @@ exec_occ config:import "$nc_conf"
|
||||||
ynh_secure_remove --file="$nc_conf"
|
ynh_secure_remove --file="$nc_conf"
|
||||||
|
|
||||||
# Load the additional config file (used also for upgrade)
|
# Load the additional config file (used also for upgrade)
|
||||||
nc_conf="$final_path/config.json"
|
nc_conf="$install_dir/config.json"
|
||||||
ynh_add_config --template="../conf/config.json" --destination="$nc_conf"
|
ynh_add_config --template="../conf/config.json" --destination="$nc_conf"
|
||||||
|
|
||||||
exec_occ config:import "$nc_conf"
|
exec_occ config:import "$nc_conf"
|
||||||
|
@ -230,10 +230,10 @@ exec_occ ldap:test-config '' \
|
||||||
# Define a function to add an external storage
|
# Define a function to add an external storage
|
||||||
# Create the external storage for the given folders and enable sharing
|
# Create the external storage for the given folders and enable sharing
|
||||||
create_external_storage() {
|
create_external_storage() {
|
||||||
local datadir="$1"
|
local data_dir="$1"
|
||||||
local mount_name="$2"
|
local mount_name="$2"
|
||||||
local mount_id=`exec_occ files_external:create --output=json \
|
local mount_id=`exec_occ files_external:create --output=json \
|
||||||
"$mount_name" 'local' 'null::null' -c "datadir=$datadir" || true`
|
"$mount_name" 'local' 'null::null' -c "data_dir=$data_dir" || true`
|
||||||
! [[ $mount_id =~ ^[0-9]+$ ]] \
|
! [[ $mount_id =~ ^[0-9]+$ ]] \
|
||||||
&& ynh_print_warn --message="Unable to create external storage" \
|
&& ynh_print_warn --message="Unable to create external storage" \
|
||||||
|| exec_occ files_external:option "$mount_id" enable_sharing true
|
|| exec_occ files_external:option "$mount_id" enable_sharing true
|
||||||
|
@ -262,7 +262,7 @@ exec_occ config:system:get logout_url >/dev/null 2>&1 \
|
||||||
\$main_domain = exec('cat /etc/yunohost/current_host');
|
\$main_domain = exec('cat /etc/yunohost/current_host');
|
||||||
\$CONFIG['logout_url'] = 'https://'.\$main_domain.'/yunohost/sso/?action=logout';
|
\$CONFIG['logout_url'] = 'https://'.\$main_domain.'/yunohost/sso/?action=logout';
|
||||||
//-YunoHost-
|
//-YunoHost-
|
||||||
" >> "$final_path/config/config.php"
|
" >> "$install_dir/config/config.php"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHANGE HOSTNAME FOR ACTIVITY NOTIFICATIONS
|
# CHANGE HOSTNAME FOR ACTIVITY NOTIFICATIONS
|
||||||
|
@ -285,7 +285,7 @@ exec_occ user:delete admin
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Calculate and store the config file checksum into the app settings
|
# Calculate and store the config file checksum into the app settings
|
||||||
ynh_store_file_checksum --file="$final_path/config/config.php"
|
ynh_store_file_checksum --file="$install_dir/config/config.php"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADD A CRON JOB
|
# ADD A CRON JOB
|
||||||
|
@ -327,15 +327,15 @@ ynh_multimedia_addaccess $app
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Fix app ownerships & permissions
|
# Fix app ownerships & permissions
|
||||||
chown -R $app:www-data "$final_path"
|
chown -R $app:www-data "$install_dir"
|
||||||
chown -R $app: "$datadir"
|
chown -R $app: "$data_dir"
|
||||||
find $final_path/ -type f -print0 | xargs -0 chmod 0644
|
find $install_dir/ -type f -print0 | xargs -0 chmod 0644
|
||||||
find $final_path/ -type d -print0 | xargs -0 chmod 0755
|
find $install_dir/ -type d -print0 | xargs -0 chmod 0755
|
||||||
find $datadir/ -type f -print0 | xargs -0 chmod 0640
|
find $data_dir/ -type f -print0 | xargs -0 chmod 0640
|
||||||
find $datadir/ -type d -print0 | xargs -0 chmod 0750
|
find $data_dir/ -type d -print0 | xargs -0 chmod 0750
|
||||||
chmod 640 "$final_path/config/config.php"
|
chmod 640 "$install_dir/config/config.php"
|
||||||
chmod 755 /home/yunohost.app
|
chmod 755 /home/yunohost.app
|
||||||
chmod 750 $final_path
|
chmod 750 $install_dir
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP LOGROTATE
|
# SETUP LOGROTATE
|
||||||
|
@ -343,7 +343,7 @@ chmod 750 $final_path
|
||||||
ynh_script_progression --message="Configuring log rotation..."
|
ynh_script_progression --message="Configuring log rotation..."
|
||||||
|
|
||||||
# Use logrotate to manage application logfile(s)
|
# Use logrotate to manage application logfile(s)
|
||||||
ynh_use_logrotate --logfile="$datadir/nextcloud.log"
|
ynh_use_logrotate --logfile="$data_dir/nextcloud.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP FAIL2BAN
|
# SETUP FAIL2BAN
|
||||||
|
@ -356,15 +356,15 @@ ynh_add_fail2ban_config --logpath="/home/yunohost.app/$app/data/nextcloud.log" -
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring permissions..."
|
#REMOVEME? ynh_script_progression --message="Configuring permissions..."
|
||||||
|
|
||||||
# Make app public if necessary
|
# Make app public if necessary
|
||||||
if [ $is_public -eq 1 ]
|
#REMOVEME? if [ $is_public -eq 1 ]
|
||||||
then
|
then
|
||||||
ynh_permission_update --permission="main" --add="visitors"
|
#REMOVEME? ynh_permission_update --permission="main" --add="visitors"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_permission_create --permission="api" --label="api" --url="re:$domain\/.well-known\/.*" --allowed="visitors" "all_users" --auth_header="false" --show_tile="false" --protected="true"
|
#REMOVEME? ynh_permission_create --permission="api" --label="api" --url="re:$domain\/.well-known\/.*" --allowed="visitors" "all_users" --auth_header="false" --show_tile="false" --protected="true"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
|
|
|
@ -12,41 +12,41 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..." --weight=2
|
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=2
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$db_name
|
#REMOVEME? db_user=$db_name
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# STANDARD REMOVE
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEPENDENCIES
|
# REMOVE DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing dependencies..." --weight=20
|
#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=20
|
||||||
|
|
||||||
# Remove metapackage and its dependencies
|
# Remove metapackage and its dependencies
|
||||||
ynh_remove_app_dependencies
|
#REMOVEME? ynh_remove_app_dependencies
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE THE MYSQL DATABASE
|
# REMOVE THE MYSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing the MySQL database..." --weight=5
|
#REMOVEME? ynh_script_progression --message="Removing the MySQL database..." --weight=5
|
||||||
|
|
||||||
# Remove a database if it exists, along with the associated user
|
# Remove a database if it exists, along with the associated user
|
||||||
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
|
#REMOVEME? ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE APP MAIN DIR
|
# REMOVE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing app main directory..." --weight=3
|
#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=3
|
||||||
|
|
||||||
# Remove the app directory securely
|
# Remove the app directory securely
|
||||||
ynh_secure_remove --file="$final_path"
|
#REMOVEME? ynh_secure_remove --file="$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DATA DIR
|
# REMOVE DATA DIR
|
||||||
|
@ -56,7 +56,7 @@ ynh_secure_remove --file="$final_path"
|
||||||
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
|
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Removing app data directory..." --weight=1
|
ynh_script_progression --message="Removing app data directory..." --weight=1
|
||||||
ynh_secure_remove --file="$datadir"
|
#REMOVEME? ynh_secure_remove --file="$data_dir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -116,10 +116,10 @@ done
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEDICATED USER
|
# REMOVE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing the dedicated system user..."
|
#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..."
|
||||||
|
|
||||||
# Delete a system user
|
# Delete a system user
|
||||||
ynh_system_user_delete --username=$app
|
#REMOVEME? ynh_system_user_delete --username=$app
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
|
@ -14,33 +14,33 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
#REMOVEME? ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading settings..."
|
ynh_script_progression --message="Loading settings..."
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$db_name
|
#REMOVEME? db_user=$db_name
|
||||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
|
||||||
|
|
||||||
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
|
#REMOVEME? fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
|
||||||
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
|
#REMOVEME? fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Validating restoration parameters..." --weight=4
|
#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=4
|
||||||
|
|
||||||
test ! -d $final_path \
|
#REMOVEME? test ! -d $install_dir \
|
||||||
|| ynh_die --message="There is already a directory: $final_path "
|
|| ynh_die --message="There is already a directory: $install_dir "
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD RESTORATION STEPS
|
# STANDARD RESTORATION STEPS
|
||||||
|
@ -49,34 +49,34 @@ test ! -d $final_path \
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the app main directory..."
|
ynh_script_progression --message="Restoring the app main directory..."
|
||||||
|
|
||||||
ynh_restore_file --origin_path="$final_path"
|
ynh_restore_file --origin_path="$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE MYSQL DATABASE
|
# RESTORE THE MYSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the MySQL database..." --weight=9
|
#REMOVEME? ynh_script_progression --message="Restoring the MySQL database..." --weight=9
|
||||||
|
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||||
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
#REMOVEME? ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||||
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RECREATE THE DEDICATED USER
|
# RECREATE THE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Recreating the dedicated system user..." --weight=3
|
#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=3
|
||||||
|
|
||||||
# Create the dedicated user (if not existing)
|
# Create the dedicated user (if not existing)
|
||||||
ynh_system_user_create --username=$app
|
#REMOVEME? ynh_system_user_create --username=$app
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC RESTORATION
|
# SPECIFIC RESTORATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# REINSTALL DEPENDENCIES
|
# REINSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=10
|
#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=10
|
||||||
|
|
||||||
# Define and install dependencies
|
# Define and install dependencies
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE PHP-FPM CONFIGURATION
|
# RESTORE THE PHP-FPM CONFIGURATION
|
||||||
|
@ -124,29 +124,29 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||||
ynh_script_progression --message="Restoring data directory..." --weight=2
|
ynh_script_progression --message="Restoring data directory..." --weight=2
|
||||||
|
|
||||||
# Use --not_mandatory for the data directory, because if the backup has been made with BACKUP_CORE_ONLY, there's no data into the backup.
|
# Use --not_mandatory for the data directory, because if the backup has been made with BACKUP_CORE_ONLY, there's no data into the backup.
|
||||||
ynh_restore_file --origin_path="$datadir" --not_mandatory
|
ynh_restore_file --origin_path="$data_dir" --not_mandatory
|
||||||
|
|
||||||
mkdir -p "$datadir"
|
mkdir -p "$data_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE USER RIGHTS
|
# RESTORE USER RIGHTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Fix app ownerships & permissions
|
# Fix app ownerships & permissions
|
||||||
chown -R $app:www-data "$final_path"
|
chown -R $app:www-data "$install_dir"
|
||||||
chown -R $app: "$datadir"
|
chown -R $app: "$data_dir"
|
||||||
find $final_path/ -type f -print0 | xargs -0 chmod 0644
|
find $install_dir/ -type f -print0 | xargs -0 chmod 0644
|
||||||
find $final_path/ -type d -print0 | xargs -0 chmod 0755
|
find $install_dir/ -type d -print0 | xargs -0 chmod 0755
|
||||||
find $datadir/ -type f -print0 | xargs -0 chmod 0640
|
find $data_dir/ -type f -print0 | xargs -0 chmod 0640
|
||||||
find $datadir/ -type d -print0 | xargs -0 chmod 0750
|
find $data_dir/ -type d -print0 | xargs -0 chmod 0750
|
||||||
chmod 640 "$final_path/config/config.php"
|
chmod 640 "$install_dir/config/config.php"
|
||||||
chmod 755 /home/yunohost.app
|
chmod 755 /home/yunohost.app
|
||||||
chmod 750 $final_path
|
chmod 750 $install_dir
|
||||||
|
|
||||||
# Iterate over users to extend their home folder permissions - for the external
|
# Iterate over users to extend their home folder permissions - for the external
|
||||||
# storage plugin usage - and create relevant Nextcloud directories
|
# storage plugin usage - and create relevant Nextcloud directories
|
||||||
for u in $(ynh_user_list); do
|
for u in $(ynh_user_list); do
|
||||||
mkdir -p "$datadir/$u"
|
mkdir -p "$data_dir/$u"
|
||||||
setfacl --modify g:$app:rwx "/home/$u" || true
|
setfacl --modify g:$app:rwx "/home/$u" || true
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
124
scripts/upgrade
124
scripts/upgrade
|
@ -12,21 +12,21 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..." --weight=3
|
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=3
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$db_name
|
#REMOVEME? db_user=$db_name
|
||||||
user_home=$(ynh_app_setting_get --app=$app --key=user_home)
|
#REMOVEME? user_home=$(ynh_app_setting_get --app=$app --key=user_home)
|
||||||
|
|
||||||
maintenance_mode=$(ynh_app_setting_get --app=$app --key=maintenance_mode)
|
#REMOVEME? maintenance_mode=$(ynh_app_setting_get --app=$app --key=maintenance_mode)
|
||||||
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
|
#REMOVEME? fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
|
||||||
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
|
#REMOVEME? fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
|
@ -48,19 +48,19 @@ ynh_script_progression --message="Ensuring downward compatibility..."
|
||||||
# If db_name doesn't exist, create it
|
# If db_name doesn't exist, create it
|
||||||
if [ -z "$db_name" ]; then
|
if [ -z "$db_name" ]; then
|
||||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If final_path doesn't exist, create it
|
# If install_dir doesn't exist, create it
|
||||||
if [ -z "$final_path" ]; then
|
if [ -z "$install_dir" ]; then
|
||||||
final_path=/var/www/$app
|
#REMOVEME? install_dir=/var/www/$app
|
||||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If datadir doesn't exist, create it
|
# If data_dir doesn't exist, create it
|
||||||
if [ -z "$datadir" ]; then
|
if [ -z "$data_dir" ]; then
|
||||||
datadir=/home/yunohost.app/$app
|
data_dir=/home/yunohost.app/$app
|
||||||
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
|
#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove the option backup_core_only if it's in the settings.yml file
|
# Remove the option backup_core_only if it's in the settings.yml file
|
||||||
|
@ -91,15 +91,15 @@ if [ -z "$fpm_usage" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Cleaning legacy permissions
|
# Cleaning legacy permissions
|
||||||
if ynh_legacy_permissions_exists; then
|
#REMOVEME? if ynh_legacy_permissions_exists; then
|
||||||
ynh_legacy_permissions_delete_all
|
#REMOVEME? ynh_legacy_permissions_delete_all
|
||||||
|
|
||||||
ynh_app_setting_delete --app=$app --key=is_public
|
ynh_app_setting_delete --app=$app --key=is_public
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create a permission if needed
|
# Create a permission if needed
|
||||||
if ! ynh_permission_exists --permission="api"; then
|
#REMOVEME? if ! ynh_permission_exists --permission="api"; then
|
||||||
ynh_permission_create --permission="api" --label="api" --url="re:$domain\/.well-known\/.*" --allowed="visitors" "all_users" --auth_header="false" --show_tile="false" --protected="true"
|
#REMOVEME? ynh_permission_create --permission="api" --label="api" --url="re:$domain\/.well-known\/.*" --allowed="visitors" "all_users" --auth_header="false" --show_tile="false" --protected="true"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Delete existing ini configuration file (backward compatibility)
|
# Delete existing ini configuration file (backward compatibility)
|
||||||
|
@ -110,12 +110,12 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=30
|
#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=30
|
||||||
|
|
||||||
# Made a backup only after the version 11.0.0
|
# Made a backup only after the version 11.0.0
|
||||||
# Before, the datas will be always saved.
|
# Before, the datas will be always saved.
|
||||||
# Get the current version number of nextcloud/owncloud
|
# Get the current version number of nextcloud/owncloud
|
||||||
current_version=$(grep OC_VersionString "$final_path/version.php" | cut -d\' -f2)
|
current_version=$(grep OC_VersionString "$install_dir/version.php" | cut -d\' -f2)
|
||||||
current_major_version=${current_version%%.*}
|
current_major_version=${current_version%%.*}
|
||||||
|
|
||||||
if [ $current_major_version -gt 11 ]
|
if [ $current_major_version -gt 11 ]
|
||||||
|
@ -125,42 +125,42 @@ then
|
||||||
ynh_app_setting_set --app=$app --key=backup_core_only --value=1
|
ynh_app_setting_set --app=$app --key=backup_core_only --value=1
|
||||||
|
|
||||||
# Backup the current version of the app
|
# Backup the current version of the app
|
||||||
ynh_backup_before_upgrade
|
#REMOVEME? ynh_backup_before_upgrade
|
||||||
|
|
||||||
# Remove the option backup_core_only after the backup.
|
# Remove the option backup_core_only after the backup.
|
||||||
ynh_app_setting_delete $app backup_core_only
|
ynh_app_setting_delete $app backup_core_only
|
||||||
|
|
||||||
ynh_clean_setup () {
|
#REMOVEME? ynh_clean_setup () {
|
||||||
# restore it if the upgrade fails
|
# restore it if the upgrade fails
|
||||||
ynh_restore_upgradebackup
|
#REMOVEME? ynh_restore_upgradebackup
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
#REMOVEME? ynh_abort_if_errors
|
||||||
|
|
||||||
if ynh_legacy_permissions_exists; then
|
#REMOVEME? if ynh_legacy_permissions_exists; then
|
||||||
ynh_legacy_permissions_delete_all
|
#REMOVEME? ynh_legacy_permissions_delete_all
|
||||||
|
|
||||||
ynh_permission_create --permission="api" --label="api" --url="re:$domain\/.well-known\/.*" --allowed="visitors" "all_users" --auth_header="false" --show_tile="false" --protected="true"
|
#REMOVEME? ynh_permission_create --permission="api" --label="api" --url="re:$domain\/.well-known\/.*" --allowed="visitors" "all_users" --auth_header="false" --show_tile="false" --protected="true"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPGRADE DEPENDENCIES
|
# UPGRADE DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading dependencies..." --weight=7
|
#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=7
|
||||||
|
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD UPGRADE STEPS
|
# STANDARD UPGRADE STEPS
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Making sure dedicated system user exists..."
|
#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..."
|
||||||
|
|
||||||
# Create a dedicated user (if not existing)
|
# Create a dedicated user (if not existing)
|
||||||
ynh_system_user_create --username=$app
|
#REMOVEME? ynh_system_user_create --username=$app
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PHP-FPM CONFIGURATION
|
# PHP-FPM CONFIGURATION
|
||||||
|
@ -170,7 +170,7 @@ ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2
|
||||||
# Recreate a dedicated PHP-FPM config
|
# Recreate a dedicated PHP-FPM config
|
||||||
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint
|
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint
|
||||||
|
|
||||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
|
@ -214,23 +214,23 @@ exec_occ() {
|
||||||
else
|
else
|
||||||
NEXTCLOUD_PHP_VERSION="7.0"
|
NEXTCLOUD_PHP_VERSION="7.0"
|
||||||
fi
|
fi
|
||||||
(cd "$final_path" && ynh_exec_as "$app" \
|
(cd "$install_dir" && ynh_exec_as "$app" \
|
||||||
php$NEXTCLOUD_PHP_VERSION --define apc.enable_cli=1 occ --no-interaction --no-ansi "$@")
|
php$NEXTCLOUD_PHP_VERSION --define apc.enable_cli=1 occ --no-interaction --no-ansi "$@")
|
||||||
}
|
}
|
||||||
|
|
||||||
# Define a function to add an external storage
|
# Define a function to add an external storage
|
||||||
# Create the external storage for the given folders and enable sharing
|
# Create the external storage for the given folders and enable sharing
|
||||||
create_external_storage() {
|
create_external_storage() {
|
||||||
local datadir="$1"
|
local data_dir="$1"
|
||||||
local mount_name="$2"
|
local mount_name="$2"
|
||||||
local mount_id=$(exec_occ files_external:create --output=json \
|
local mount_id=$(exec_occ files_external:create --output=json \
|
||||||
"$mount_name" 'local' 'null::null' -c "datadir=$datadir" || true)
|
"$mount_name" 'local' 'null::null' -c "data_dir=$data_dir" || true)
|
||||||
! [[ $mount_id =~ ^[0-9]+$ ]] \
|
! [[ $mount_id =~ ^[0-9]+$ ]] \
|
||||||
&& ynh_print_warn --message="Unable to create external storage" \
|
&& ynh_print_warn --message="Unable to create external storage" \
|
||||||
|| exec_occ files_external:option "$mount_id" enable_sharing true
|
|| exec_occ files_external:option "$mount_id" enable_sharing true
|
||||||
}
|
}
|
||||||
# Define app's data directory
|
# Define app's data directory
|
||||||
datadir="/home/yunohost.app/$app/data"
|
#REMOVEME? data_dir="/home/yunohost.app/$app/data"
|
||||||
|
|
||||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
then
|
then
|
||||||
|
@ -243,7 +243,7 @@ then
|
||||||
last_major_version=${last_version%%.*}
|
last_major_version=${last_version%%.*}
|
||||||
|
|
||||||
# Set write access for the following commands
|
# Set write access for the following commands
|
||||||
chown -R $app: "$final_path" "$datadir"
|
chown -R $app: "$install_dir" "$data_dir"
|
||||||
|
|
||||||
# Print the current version number of Nextcloud
|
# Print the current version number of Nextcloud
|
||||||
exec_occ -V
|
exec_occ -V
|
||||||
|
@ -306,13 +306,13 @@ EOF
|
||||||
exec_occ maintenance:mode --on
|
exec_occ maintenance:mode --on
|
||||||
|
|
||||||
# Backup the config file in the temp dir
|
# Backup the config file in the temp dir
|
||||||
cp -a "$final_path/config/config.php" "$tmpdir/config/config.php"
|
cp -a "$install_dir/config/config.php" "$tmpdir/config/config.php"
|
||||||
|
|
||||||
# Backup 3rd party applications from the current Nextcloud
|
# Backup 3rd party applications from the current Nextcloud
|
||||||
# But do not overwrite if there is any upgrade
|
# But do not overwrite if there is any upgrade
|
||||||
# (apps directory already exists in Nextcloud archive)
|
# (apps directory already exists in Nextcloud archive)
|
||||||
(
|
(
|
||||||
cd $final_path/apps
|
cd $install_dir/apps
|
||||||
for nc_app_dir in */
|
for nc_app_dir in */
|
||||||
do
|
do
|
||||||
if [ ! -d "$tmpdir/apps/$nc_app_dir" ]
|
if [ ! -d "$tmpdir/apps/$nc_app_dir" ]
|
||||||
|
@ -323,12 +323,12 @@ EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
# Replace the old nextcloud by the new one
|
# Replace the old nextcloud by the new one
|
||||||
ynh_secure_remove --file="$final_path"
|
#REMOVEME? ynh_secure_remove --file="$install_dir"
|
||||||
mv "$tmpdir" "$final_path"
|
mv "$tmpdir" "$install_dir"
|
||||||
ynh_secure_remove --file="$tmpdir"
|
ynh_secure_remove --file="$tmpdir"
|
||||||
|
|
||||||
# Set write access for the following commands
|
# Set write access for the following commands
|
||||||
chown -R $app: "$final_path" "$datadir"
|
chown -R $app: "$install_dir" "$data_dir"
|
||||||
|
|
||||||
# Upgrade Nextcloud (SUCCESS = 0, UP_TO_DATE = 3)
|
# Upgrade Nextcloud (SUCCESS = 0, UP_TO_DATE = 3)
|
||||||
exec_occ maintenance:mode --off
|
exec_occ maintenance:mode --off
|
||||||
|
@ -336,7 +336,7 @@ EOF
|
||||||
|| [ $? -eq 3 ] || ynh_die --message="Unable to upgrade Nextcloud"
|
|| [ $? -eq 3 ] || ynh_die --message="Unable to upgrade Nextcloud"
|
||||||
|
|
||||||
# Get the new current version number
|
# Get the new current version number
|
||||||
current_version=$(grep OC_VersionString "$final_path/version.php" | cut -d\' -f2)
|
current_version=$(grep OC_VersionString "$install_dir/version.php" | cut -d\' -f2)
|
||||||
current_major_version=${current_version%%.*}
|
current_major_version=${current_version%%.*}
|
||||||
|
|
||||||
# Print the current version number of nextcloud
|
# Print the current version number of nextcloud
|
||||||
|
@ -354,9 +354,9 @@ EOF
|
||||||
ynh_script_progression --message="Reconfiguring Nextcloud..." --weight=9
|
ynh_script_progression --message="Reconfiguring Nextcloud..." --weight=9
|
||||||
|
|
||||||
# Verify the checksum and backup the file if it's different
|
# Verify the checksum and backup the file if it's different
|
||||||
ynh_backup_if_checksum_is_different --file="$final_path/config/config.php"
|
ynh_backup_if_checksum_is_different --file="$install_dir/config/config.php"
|
||||||
|
|
||||||
nc_conf="${final_path}/config.json"
|
nc_conf="${install_dir}/config.json"
|
||||||
ynh_add_config --template="../conf/config.json" --destination="$nc_conf"
|
ynh_add_config --template="../conf/config.json" --destination="$nc_conf"
|
||||||
|
|
||||||
# Reneable the mail app
|
# Reneable the mail app
|
||||||
|
@ -388,7 +388,7 @@ EOF
|
||||||
\$main_domain = exec('cat /etc/yunohost/current_host');
|
\$main_domain = exec('cat /etc/yunohost/current_host');
|
||||||
\$CONFIG['logout_url'] = 'https://'.\$main_domain.'/yunohost/sso/?action=logout';
|
\$CONFIG['logout_url'] = 'https://'.\$main_domain.'/yunohost/sso/?action=logout';
|
||||||
//-YunoHost-
|
//-YunoHost-
|
||||||
" >> "$final_path/config/config.php"
|
" >> "$install_dir/config/config.php"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHANGE HOSTNAME FOR ACTIVITY NOTIFICATIONS
|
# CHANGE HOSTNAME FOR ACTIVITY NOTIFICATIONS
|
||||||
|
@ -417,7 +417,7 @@ EOF
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Calculate and store the config file checksum into the app settings
|
# Calculate and store the config file checksum into the app settings
|
||||||
ynh_store_file_checksum --file="${final_path}/config/config.php"
|
ynh_store_file_checksum --file="${install_dir}/config/config.php"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -438,15 +438,15 @@ exec_occ background:cron
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Fix app ownerships & permissions
|
# Fix app ownerships & permissions
|
||||||
chown -R $app:www-data "$final_path"
|
chown -R $app:www-data "$install_dir"
|
||||||
chown -R $app: "$datadir"
|
chown -R $app: "$data_dir"
|
||||||
find $final_path/ -type f -print0 | xargs -0 chmod 0644
|
find $install_dir/ -type f -print0 | xargs -0 chmod 0644
|
||||||
find $final_path/ -type d -print0 | xargs -0 chmod 0755
|
find $install_dir/ -type d -print0 | xargs -0 chmod 0755
|
||||||
find $datadir/ -type f -print0 | xargs -0 chmod 0640
|
find $data_dir/ -type f -print0 | xargs -0 chmod 0640
|
||||||
find $datadir/ -type d -print0 | xargs -0 chmod 0750
|
find $data_dir/ -type d -print0 | xargs -0 chmod 0750
|
||||||
chmod 640 "$final_path/config/config.php"
|
chmod 640 "$install_dir/config/config.php"
|
||||||
chmod 755 /home/yunohost.app
|
chmod 755 /home/yunohost.app
|
||||||
chmod 750 $final_path
|
chmod 750 $install_dir
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# WARNING ABOUT THIRD-PARTY APPS
|
# WARNING ABOUT THIRD-PARTY APPS
|
||||||
|
|
Loading…
Add table
Reference in a new issue