mirror of
https://github.com/YunoHost-Apps/roundcube_ynh.git
synced 2024-09-03 20:16:28 +02:00
Normalization from example_ynh
This commit is contained in:
parent
338dd75c50
commit
c4412620c0
10 changed files with 256 additions and 470 deletions
|
@ -113,9 +113,9 @@ this package:
|
|||
search
|
||||
#### Supported architectures
|
||||
|
||||
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/roundcube%20%28Official%29.svg)](https://ci-apps.yunohost.org/ci/apps/roundcube/)
|
||||
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/roundcube%20%28Official%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/roundcube/)
|
||||
* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/roundcube%20%28Official%29.svg)](https://ci-stretch.nohost.me/ci/apps/roundcube/)
|
||||
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/roundcube%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/roundcube/)
|
||||
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/roundcube%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/roundcube/)
|
||||
* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/roundcube%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/roundcube/)
|
||||
|
||||
## Limitations
|
||||
|
||||
|
@ -126,6 +126,7 @@ this package:
|
|||
|
||||
* Report a bug: https://github.com/YunoHost-Apps/roundcube_ynh/issues
|
||||
* Roundcube website: https://roundcube.net/
|
||||
* Roundcube repository: https://github.com/roundcube/roundcubemail
|
||||
* YunoHost website: https://yunohost.org/
|
||||
|
||||
---
|
||||
|
|
|
@ -19,18 +19,7 @@
|
|||
port_already_use=0
|
||||
change_url=0
|
||||
;;; Levels
|
||||
Level 1=auto
|
||||
Level 2=auto
|
||||
Level 3=auto
|
||||
# https://github.com/YunoHost-Apps/roundcube_ynh/blob/master/conf/config.inc.php#L103-L118
|
||||
Level 4=1
|
||||
# https://github.com/YunoHost-Apps/roundcube_ynh/issues/10
|
||||
Level 5=1
|
||||
Level 6=auto
|
||||
Level 7=auto
|
||||
Level 8=0
|
||||
Level 9=0
|
||||
Level 10=0
|
||||
Level 5=auto
|
||||
;;; Options
|
||||
Email=
|
||||
Notification=none
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
"email": "apps@yunohost.org"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 3.2.0"
|
||||
"yunohost": ">= 3.5.0"
|
||||
},
|
||||
"multi_instance": true,
|
||||
"services": [
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
# =============================================================================
|
||||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
# =============================================================================
|
||||
#=================================================
|
||||
|
||||
# Package dependencies
|
||||
pkg_dependencies="php-cli php-common php-intl php-json php-mcrypt php-pear php-auth-sasl php-mail-mime php-patchwork-utf8 php-net-smtp php-net-socket php-net-ldap2 php-net-ldap3 php-zip php-gd php-mbstring php-curl"
|
||||
|
@ -18,43 +18,47 @@ carddav_version=3.0.3
|
|||
|
||||
# Execute a command with Composer
|
||||
#
|
||||
# usage: ynh_composer_exec [--workdir=$final_path] --commands="commands"
|
||||
# usage: ynh_composer_exec --phpversion=phpversion [--workdir=$final_path] --commands="commands"
|
||||
# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path.
|
||||
# | arg: -c, --commands - Commands to execute.
|
||||
ynh_composer_exec () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=wc
|
||||
declare -Ar args_array=( [w]=workdir= [c]=commands= )
|
||||
local legacy_args=vwc
|
||||
declare -Ar args_array=( [v]=phpversion= [w]=workdir= [c]=commands= )
|
||||
local phpversion
|
||||
local workdir
|
||||
local commands
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
workdir="${workdir:-$final_path}"
|
||||
phpversion="${phpversion:-7.0}"
|
||||
|
||||
COMPOSER_HOME="$workdir/.composer" \
|
||||
php "$workdir/composer.phar" $commands \
|
||||
php${phpversion} "$workdir/composer.phar" $commands \
|
||||
-d "$workdir" --quiet --no-interaction
|
||||
}
|
||||
|
||||
# Install and initialize Composer in the given directory
|
||||
#
|
||||
# usage: ynh_install_composer [--workdir=$final_path]
|
||||
# usage: ynh_install_composer --phpversion=phpversion [--workdir=$final_path]
|
||||
# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path.
|
||||
ynh_install_composer () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=w
|
||||
declare -Ar args_array=( [w]=workdir= )
|
||||
local legacy_args=vw
|
||||
declare -Ar args_array=( [v]=phpversion= [w]=workdir= )
|
||||
local phpversion
|
||||
local workdir
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
workdir="${workdir:-$final_path}"
|
||||
phpversion="${phpversion:-7.0}"
|
||||
|
||||
curl -sS https://getcomposer.org/installer \
|
||||
| COMPOSER_HOME="$workdir/.composer" \
|
||||
php -- --quiet --install-dir="$workdir" \
|
||||
php${phpversion} -- --quiet --install-dir="$workdir" \
|
||||
|| ynh_die "Unable to install Composer."
|
||||
|
||||
# update dependencies to create composer.lock
|
||||
ynh_composer_exec --workdir="$workdir" --commands="install --no-dev" \
|
||||
ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev" \
|
||||
|| ynh_die "Unable to update core dependencies with Composer."
|
||||
}
|
||||
|
|
|
@ -1,213 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# FIX OF YNH_HANDLE_GETOPTS_ARGS FROM UNSTABLE
|
||||
#=================================================
|
||||
|
||||
# Internal helper design to allow helpers to use getopts to manage their arguments
|
||||
#
|
||||
# [internal]
|
||||
#
|
||||
# example: function my_helper()
|
||||
# {
|
||||
# declare -Ar args_array=( [a]=arg1= [b]=arg2= [c]=arg3 )
|
||||
# local arg1
|
||||
# local arg2
|
||||
# local arg3
|
||||
# ynh_handle_getopts_args "$@"
|
||||
#
|
||||
# [...]
|
||||
# }
|
||||
# my_helper --arg1 "val1" -b val2 -c
|
||||
#
|
||||
# usage: ynh_handle_getopts_args "$@"
|
||||
# | arg: $@ - Simply "$@" to tranfert all the positionnal arguments to the function
|
||||
#
|
||||
# This helper need an array, named "args_array" with all the arguments used by the helper
|
||||
# that want to use ynh_handle_getopts_args
|
||||
# Be carreful, this array has to be an associative array, as the following example:
|
||||
# declare -Ar args_array=( [a]=arg1 [b]=arg2= [c]=arg3 )
|
||||
# Let's explain this array:
|
||||
# a, b and c are short options, -a, -b and -c
|
||||
# arg1, arg2 and arg3 are the long options associated to the previous short ones. --arg1, --arg2 and --arg3
|
||||
# For each option, a short and long version has to be defined.
|
||||
# Let's see something more significant
|
||||
# declare -Ar args_array=( [u]=user [f]=finalpath= [d]=database )
|
||||
#
|
||||
# NB: Because we're using 'declare' without -g, the array will be declared as a local variable.
|
||||
#
|
||||
# Please keep in mind that the long option will be used as a variable to store the values for this option.
|
||||
# For the previous example, that means that $finalpath will be fill with the value given as argument for this option.
|
||||
#
|
||||
# Also, in the previous example, finalpath has a '=' at the end. That means this option need a value.
|
||||
# So, the helper has to be call with --finalpath /final/path, --finalpath=/final/path or -f /final/path, the variable $finalpath will get the value /final/path
|
||||
# If there's many values for an option, -f /final /path, the value will be separated by a ';' $finalpath=/final;/path
|
||||
# For an option without value, like --user in the example, the helper can be called only with --user or -u. $user will then get the value 1.
|
||||
#
|
||||
# To keep a retrocompatibility, a package can still call a helper, using getopts, with positional arguments.
|
||||
# The "legacy mode" will manage the positional arguments and fill the variable in the same order than they are given in $args_array.
|
||||
# e.g. for `my_helper "val1" val2`, arg1 will be filled with val1, and arg2 with val2.
|
||||
ynh_handle_getopts_args () {
|
||||
# Manage arguments only if there's some provided
|
||||
set +x
|
||||
if [ $# -ne 0 ]
|
||||
then
|
||||
# Store arguments in an array to keep each argument separated
|
||||
local arguments=("$@")
|
||||
|
||||
# For each option in the array, reduce to short options for getopts (e.g. for [u]=user, --user will be -u)
|
||||
# And built parameters string for getopts
|
||||
# ${!args_array[@]} is the list of all option_flags in the array (An option_flag is 'u' in [u]=user, user is a value)
|
||||
local getopts_parameters=""
|
||||
local option_flag=""
|
||||
for option_flag in "${!args_array[@]}"
|
||||
do
|
||||
# Concatenate each option_flags of the array to build the string of arguments for getopts
|
||||
# Will looks like 'abcd' for -a -b -c -d
|
||||
# If the value of an option_flag finish by =, it's an option with additionnal values. (e.g. --user bob or -u bob)
|
||||
# Check the last character of the value associate to the option_flag
|
||||
if [ "${args_array[$option_flag]: -1}" = "=" ]
|
||||
then
|
||||
# For an option with additionnal values, add a ':' after the letter for getopts.
|
||||
getopts_parameters="${getopts_parameters}${option_flag}:"
|
||||
else
|
||||
getopts_parameters="${getopts_parameters}${option_flag}"
|
||||
fi
|
||||
# Check each argument given to the function
|
||||
local arg=""
|
||||
# ${#arguments[@]} is the size of the array
|
||||
for arg in `seq 0 $(( ${#arguments[@]} - 1 ))`
|
||||
do
|
||||
# And replace long option (value of the option_flag) by the short option, the option_flag itself
|
||||
# (e.g. for [u]=user, --user will be -u)
|
||||
# Replace long option with =
|
||||
arguments[arg]="${arguments[arg]//--${args_array[$option_flag]}/-${option_flag} }"
|
||||
# And long option without =
|
||||
arguments[arg]="${arguments[arg]//--${args_array[$option_flag]%=}/-${option_flag}}"
|
||||
done
|
||||
done
|
||||
|
||||
# Read and parse all the arguments
|
||||
# Use a function here, to use standart arguments $@ and be able to use shift.
|
||||
parse_arg () {
|
||||
# Read all arguments, until no arguments are left
|
||||
while [ $# -ne 0 ]
|
||||
do
|
||||
# Initialize the index of getopts
|
||||
OPTIND=1
|
||||
# Parse with getopts only if the argument begin by -, that means the argument is an option
|
||||
# getopts will fill $parameter with the letter of the option it has read.
|
||||
local parameter=""
|
||||
getopts ":$getopts_parameters" parameter || true
|
||||
|
||||
if [ "$parameter" = "?" ]
|
||||
then
|
||||
ynh_die --message="Invalid argument: -${OPTARG:-}"
|
||||
elif [ "$parameter" = ":" ]
|
||||
then
|
||||
ynh_die --message="-$OPTARG parameter requires an argument."
|
||||
else
|
||||
local shift_value=1
|
||||
# Use the long option, corresponding to the short option read by getopts, as a variable
|
||||
# (e.g. for [u]=user, 'user' will be used as a variable)
|
||||
# Also, remove '=' at the end of the long option
|
||||
# The variable name will be stored in 'option_var'
|
||||
local option_var="${args_array[$parameter]%=}"
|
||||
# If this option doesn't take values
|
||||
# if there's a '=' at the end of the long option name, this option takes values
|
||||
if [ "${args_array[$parameter]: -1}" != "=" ]
|
||||
then
|
||||
# 'eval ${option_var}' will use the content of 'option_var'
|
||||
eval ${option_var}=1
|
||||
else
|
||||
# Read all other arguments to find multiple value for this option.
|
||||
# Load args in a array
|
||||
local all_args=("$@")
|
||||
|
||||
# If the first argument is longer than 2 characters,
|
||||
# There's a value attached to the option, in the same array cell
|
||||
if [ ${#all_args[0]} -gt 2 ]; then
|
||||
# Remove the option and the space, so keep only the value itself.
|
||||
all_args[0]="${all_args[0]#-${parameter} }"
|
||||
# Reduce the value of shift, because the option has been removed manually
|
||||
shift_value=$(( shift_value - 1 ))
|
||||
fi
|
||||
|
||||
# Declare the content of option_var as a variable.
|
||||
eval ${option_var}=""
|
||||
# Then read the array value per value
|
||||
local i
|
||||
for i in `seq 0 $(( ${#all_args[@]} - 1 ))`
|
||||
do
|
||||
# If this argument is an option, end here.
|
||||
if [ "${all_args[$i]:0:1}" == "-" ]
|
||||
then
|
||||
# Ignore the first value of the array, which is the option itself
|
||||
if [ "$i" -ne 0 ]; then
|
||||
break
|
||||
fi
|
||||
else
|
||||
# Else, add this value to this option
|
||||
# Each value will be separated by ';'
|
||||
if [ -n "${!option_var}" ]
|
||||
then
|
||||
# If there's already another value for this option, add a ; before adding the new value
|
||||
eval ${option_var}+="\;"
|
||||
fi
|
||||
# Escape double quote to prevent any interpretation during the eval
|
||||
all_args[$i]="${all_args[$i]//\"/\\\"}"
|
||||
|
||||
eval ${option_var}+=\"${all_args[$i]}\"
|
||||
shift_value=$(( shift_value + 1 ))
|
||||
fi
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
# Shift the parameter and its argument(s)
|
||||
shift $shift_value
|
||||
done
|
||||
}
|
||||
|
||||
# LEGACY MODE
|
||||
# Check if there's getopts arguments
|
||||
if [ "${arguments[0]:0:1}" != "-" ]
|
||||
then
|
||||
# If not, enter in legacy mode and manage the arguments as positionnal ones..
|
||||
# Dot not echo, to prevent to go through a helper output. But print only in the log.
|
||||
set -x; echo "! Helper used in legacy mode !" > /dev/null; set +x
|
||||
local i
|
||||
for i in `seq 0 $(( ${#arguments[@]} -1 ))`
|
||||
do
|
||||
# Try to use legacy_args as a list of option_flag of the array args_array
|
||||
# Otherwise, fallback to getopts_parameters to get the option_flag. But an associative arrays isn't always sorted in the correct order...
|
||||
# Remove all ':' in getopts_parameters
|
||||
getopts_parameters=${legacy_args:-${getopts_parameters//:}}
|
||||
# Get the option_flag from getopts_parameters, by using the option_flag according to the position of the argument.
|
||||
option_flag=${getopts_parameters:$i:1}
|
||||
if [ -z "$option_flag" ]; then
|
||||
ynh_print_warn --message="Too many arguments ! \"${arguments[$i]}\" will be ignored."
|
||||
continue
|
||||
fi
|
||||
# Use the long option, corresponding to the option_flag, as a variable
|
||||
# (e.g. for [u]=user, 'user' will be used as a variable)
|
||||
# Also, remove '=' at the end of the long option
|
||||
# The variable name will be stored in 'option_var'
|
||||
local option_var="${args_array[$option_flag]%=}"
|
||||
|
||||
# Escape double quote to prevent any interpretation during the eval
|
||||
arguments[$i]="${arguments[$i]//\"/\\\"}"
|
||||
|
||||
# Store each value given as argument in the corresponding variable
|
||||
# The values will be stored in the same order than $args_array
|
||||
eval ${option_var}+=\"${arguments[$i]}\"
|
||||
done
|
||||
unset legacy_args
|
||||
else
|
||||
# END LEGACY MODE
|
||||
# Call parse_arg and pass the modified list of args as an array of arguments.
|
||||
parse_arg "${arguments[@]}"
|
||||
fi
|
||||
fi
|
||||
set -x
|
||||
}
|
|
@ -19,46 +19,46 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading installation settings..."
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
|
||||
#=================================================
|
||||
# STANDARD BACKUP STEPS
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_print_info "Backing up the main app directory..."
|
||||
ynh_script_progression --message="Backing up the main app directory..."
|
||||
|
||||
ynh_backup "$final_path"
|
||||
ynh_backup --src_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Backing up nginx web server configuration..."
|
||||
ynh_script_progression --message="Backing up nginx web server configuration..."
|
||||
|
||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Backing up php-fpm configuration..."
|
||||
ynh_script_progression --message="Backing up php-fpm configuration..."
|
||||
|
||||
ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf"
|
||||
ynh_backup --src_path="/etc/php/7.0/fpm/pool.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_print_info "Backing up the MySQL database..."
|
||||
ynh_script_progression --message="Backing up the MySQL database..."
|
||||
|
||||
ynh_mysql_dump_db "$db_name" > db.sql
|
||||
ynh_mysql_dump_db --database="$db_name" > db.sql
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last
|
||||
|
|
|
@ -8,9 +8,6 @@
|
|||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
# Overload the helper ynh_handle_getopts_args to have fixes from unstable.
|
||||
# Needed for composer helpers
|
||||
source _getopts_fix.sh
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
|
@ -33,58 +30,55 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
ynh_print_info "Validating installation parameters..."
|
||||
ynh_script_progression --message="Validating installation parameters..."
|
||||
|
||||
final_path=/var/www/$app
|
||||
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||
|
||||
# Normalize the url path syntax
|
||||
path_url=$(ynh_normalize_url_path $path_url)
|
||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||
|
||||
# Register (book) web path
|
||||
ynh_webpath_register $app $domain $path_url
|
||||
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_print_info "Storing installation settings..."
|
||||
ynh_script_progression --message="Storing installation settings..." --weight=2
|
||||
|
||||
ynh_app_setting_set $app domain $domain
|
||||
ynh_app_setting_set $app path $path_url
|
||||
ynh_app_setting_set $app with_carddav $with_carddav
|
||||
ynh_app_setting_set $app with_enigma $with_enigma
|
||||
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=with_carddav --value=$with_carddav
|
||||
ynh_app_setting_set --app=$app --key=with_enigma --value=$with_enigma
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_print_info "Installing dependencies..."
|
||||
ynh_script_progression --message="Installing dependencies..."5
|
||||
|
||||
ynh_install_app_dependencies "$pkg_dependencies"
|
||||
|
||||
#=================================================
|
||||
# CREATE A MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_print_info "Creating a MySQL database..."
|
||||
ynh_script_progression --message="Creating a MySQL database..."
|
||||
|
||||
db_name=$(ynh_sanitize_dbid $app)
|
||||
ynh_app_setting_set $app db_name $db_name
|
||||
ynh_mysql_setup_db $db_name $db_name
|
||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_print_info "Setting up source files..."
|
||||
ynh_script_progression --message="Setting up source files..." --weight=7
|
||||
|
||||
ynh_app_setting_set $app final_path $final_path
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source "$final_path"
|
||||
ynh_setup_source --dest_dir="$final_path"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Configuring nginx web server..."
|
||||
ynh_script_progression --message="Configuring nginx web server..."
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
@ -92,15 +86,15 @@ ynh_add_nginx_config
|
|||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_print_info "Configuring system user..."
|
||||
ynh_script_progression --message="Configuring system user..." --weight=3
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create $app
|
||||
ynh_system_user_create --username=$app
|
||||
|
||||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Configuring php-fpm..."
|
||||
ynh_script_progression --message="Configuring php-fpm..." --weight=2
|
||||
|
||||
# Create a dedicated php-fpm config
|
||||
ynh_add_fpm_config
|
||||
|
@ -110,7 +104,7 @@ ynh_add_fpm_config
|
|||
#=================================================
|
||||
# INSTALL AND INITIALIZE COMPOSER
|
||||
#=================================================
|
||||
ynh_print_info "Installing roundcube with composer..."
|
||||
ynh_script_progression --message="Installing roundcube with composer..." --weight=30
|
||||
|
||||
# Install composer.json
|
||||
cp "$final_path/composer.json-dist" "$final_path/composer.json"
|
||||
|
@ -121,29 +115,29 @@ ynh_install_composer
|
|||
#=================================================
|
||||
# INITIALIZE DATABASE
|
||||
#=================================================
|
||||
ynh_print_info "Initializing database..."
|
||||
ynh_script_progression --message="Initializing database..." --weight=3
|
||||
|
||||
ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" \
|
||||
ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" \
|
||||
< "$final_path/SQL/mysql.initial.sql"
|
||||
|
||||
#=================================================
|
||||
# CONFIGURE ROUNDCUBE
|
||||
#=================================================
|
||||
ynh_print_info "Configuring roundcube..."
|
||||
ynh_script_progression --message="Configuring roundcube..."
|
||||
|
||||
rc_conf="$final_path/config/config.inc.php"
|
||||
|
||||
cp ../conf/config.inc.php "$rc_conf"
|
||||
|
||||
ynh_replace_string "__DESKEY__" "$(ynh_string_random 24)" "$rc_conf"
|
||||
ynh_replace_string "__DBUSER__" $db_name "$rc_conf"
|
||||
ynh_replace_string "__DBPASS__" "$db_pwd" "$rc_conf"
|
||||
ynh_replace_string "__DBNAME__" $db_name "$rc_conf"
|
||||
ynh_replace_string --match_string="__DESKEY__" --replace_string="$(ynh_string_random --length=24)" --target_file="$rc_conf"
|
||||
ynh_replace_string --match_string="__DBUSER__" --replace_string=$db_name --target_file="$rc_conf"
|
||||
ynh_replace_string --match_string="__DBPASS__" --replace_string="$db_pwd" --target_file="$rc_conf"
|
||||
ynh_replace_string --match_string="__DBNAME__" --replace_string=$db_name --target_file="$rc_conf"
|
||||
|
||||
#=================================================
|
||||
# INSTALL ADDITIONAL PLUGINS
|
||||
#=================================================
|
||||
ynh_print_info "Installing additional plugins..."
|
||||
ynh_script_progression --message="Installing additional plugins..." --weight=60
|
||||
|
||||
# Create logs and temp directories
|
||||
mkdir -p "$final_path/"{logs,temp}
|
||||
|
@ -172,12 +166,12 @@ then
|
|||
if [ -n "$carddav_app_id" ]
|
||||
then
|
||||
# Retrieve app settings and enable relevant preset
|
||||
carddav_domain=$(ynh_app_setting_get $carddav_app_id domain)
|
||||
carddav_path=$(ynh_app_setting_get $carddav_app_id path)
|
||||
carddav_domain=$(ynh_app_setting_get --app=$carddav_app_id --key=domain)
|
||||
carddav_path=$(ynh_app_setting_get --app=$carddav_app_id --key=path)
|
||||
carddav_url="https://${carddav_domain}${carddav_path%/}"
|
||||
ynh_replace_string "{${carddav_app}_url}" "$carddav_url" "$carddav_tmp_config"
|
||||
ynh_replace_string "/* PRESET FOR: $carddav_app" "" "$carddav_tmp_config"
|
||||
ynh_replace_string "END: $carddav_app */" "" "$carddav_tmp_config"
|
||||
ynh_replace_string --match_string="{${carddav_app}_url}" --replace_string="$carddav_url" --target_file="$carddav_tmp_config"
|
||||
ynh_replace_string --match_string="/* PRESET FOR: $carddav_app" --replace_string="" --target_file="$carddav_tmp_config"
|
||||
ynh_replace_string --match_string="END: $carddav_app */" --replace_string="" --target_file="$carddav_tmp_config"
|
||||
fi
|
||||
done
|
||||
|
||||
|
@ -192,22 +186,22 @@ if [ $with_enigma -eq 1 ]
|
|||
then
|
||||
cp -a "$final_path/plugins/enigma/config.inc.php.dist" "$final_path/plugins/enigma/config.inc.php" \
|
||||
&& installed_plugins+=" 'enigma'," \
|
||||
|| ynh_print_warn "Unable to install Enigma plugin"
|
||||
|| ynh_print_warn --message="Unable to install Enigma plugin"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# UPDATE ROUNDCUBE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Updating roundcube configuration..."
|
||||
ynh_script_progression --message="Updating roundcube configuration..." --weight=3
|
||||
|
||||
ynh_replace_string "^\s*// installed plugins" "&\n $installed_plugins" "$rc_conf"
|
||||
ynh_replace_string --match_string="^\s*// installed plugins" --replace_string="&\n $installed_plugins" --target_file="$rc_conf"
|
||||
|
||||
# Update javascript dependencies
|
||||
(cd "$final_path"
|
||||
/usr/bin/php -q ./bin/install-jsdeps.sh)
|
||||
|
||||
# Store the config file checksum into the app settings
|
||||
ynh_store_file_checksum "$rc_conf"
|
||||
ynh_store_file_checksum --file="$rc_conf"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
@ -222,12 +216,12 @@ chown -R $app: "$final_path/"{temp,logs,plugins/enigma/home}
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info "Reloading nginx web server..."
|
||||
ynh_script_progression --message="Reloading nginx web server..." --weight=2
|
||||
|
||||
systemctl reload nginx
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Installation of $app completed"
|
||||
ynh_script_progression --message="Installation of $app completed" --last
|
||||
|
|
|
@ -12,20 +12,20 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading installation settings..."
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_print_info "Removing dependencies"
|
||||
ynh_script_progression --message="Removing dependencies..." --weight=8
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies
|
||||
|
@ -33,23 +33,23 @@ ynh_remove_app_dependencies
|
|||
#=================================================
|
||||
# REMOVE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_print_info "Removing the MySQL database"
|
||||
ynh_script_progression --message="Removing the MySQL database..." --weight=2
|
||||
|
||||
# Remove a database if it exists, along with the associated user
|
||||
ynh_mysql_remove_db $db_name $db_name
|
||||
ynh_mysql_remove_db --db_user=$db_name --db_name=$db_name
|
||||
|
||||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_print_info "Removing app main directory"
|
||||
ynh_script_progression --message="Removing app main directory..." --weight=3
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove "$final_path"
|
||||
ynh_secure_remove --file="$final_path"
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Removing nginx web server configuration"
|
||||
ynh_script_progression --message="Removing nginx web server configuration..." --weight=2
|
||||
|
||||
# Remove the dedicated nginx config
|
||||
ynh_remove_nginx_config
|
||||
|
@ -57,7 +57,7 @@ ynh_remove_nginx_config
|
|||
#=================================================
|
||||
# REMOVE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Removing php-fpm configuration"
|
||||
ynh_script_progression --message="Removing php-fpm configuration..." --weight=3
|
||||
|
||||
# Remove the dedicated php-fpm config
|
||||
ynh_remove_fpm_config
|
||||
|
@ -67,13 +67,13 @@ ynh_remove_fpm_config
|
|||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_print_info "Removing the dedicated system user"
|
||||
ynh_script_progression --message="Removing the dedicated system user..." --weight=2
|
||||
|
||||
# Delete a system user
|
||||
ynh_system_user_delete $app
|
||||
ynh_system_user_delete --username=$app
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Removal of $app completed"
|
||||
ynh_script_progression --message="Removal of $app completed" --last
|
||||
|
|
|
@ -19,24 +19,24 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading settings..."
|
||||
ynh_script_progression --message="Loading settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path_url=$(ynh_app_setting_get $app path)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
ynh_print_info "Validating restoration parameters..."
|
||||
ynh_script_progression --message="Validating restoration parameters..." --weight=3
|
||||
|
||||
ynh_webpath_available $domain $path_url \
|
||||
|| ynh_die "Path not available: ${domain}${path_url}"
|
||||
ynh_webpath_available --domain=$domain --path_url=$path_url \
|
||||
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
||||
test ! -d $final_path \
|
||||
|| ynh_die "There is already a directory: $final_path "
|
||||
|| ynh_die --message="There is already a directory: $final_path "
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
|
@ -44,22 +44,22 @@ test ! -d $final_path \
|
|||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_print_info "Restoring the app main directory..."
|
||||
ynh_script_progression --message="Restoring the app main directory..."
|
||||
|
||||
ynh_restore_file "$final_path"
|
||||
ynh_restore_file --origin_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_print_info "Recreating the dedicated system user..."
|
||||
ynh_script_progression --message="Recreating the dedicated system user..." --weight=4
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create $app
|
||||
ynh_system_user_create --username=$app
|
||||
|
||||
#=================================================
|
||||
# RESTORE USER RIGHTS
|
||||
|
@ -73,14 +73,14 @@ chown -R $app: "$final_path/"{temp,logs,plugins/enigma/home}
|
|||
# RESTORE THE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf"
|
||||
ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_print_info "Reinstalling dependencies..."
|
||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=30
|
||||
|
||||
# Define and install dependencies
|
||||
ynh_install_app_dependencies "$pkg_dependencies"
|
||||
|
@ -88,24 +88,24 @@ ynh_install_app_dependencies "$pkg_dependencies"
|
|||
#=================================================
|
||||
# RESTORE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_print_info "Restoring the MySQL database..."
|
||||
ynh_script_progression --message="Restoring the MySQL database..." --weight=5
|
||||
|
||||
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||
ynh_mysql_setup_db $db_name $db_name $db_pwd
|
||||
ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||
ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd
|
||||
ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ./db.sql
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# RELOAD NGINX AND PHP-FPM
|
||||
#=================================================
|
||||
ynh_print_info "Reloading nginx web server and php-fpm..."
|
||||
ynh_script_progression --message="Reloading nginx web server and php-fpm..."
|
||||
|
||||
systemctl reload php7.0-fpm
|
||||
systemctl reload nginx
|
||||
ynh_systemd_action --service_name=php7.0-fpm --action=reload
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Restoration completed for $app"
|
||||
ynh_script_progression --message="Restoration completed for $app" --last
|
||||
|
|
275
scripts/upgrade
275
scripts/upgrade
|
@ -8,39 +8,42 @@
|
|||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
# Overload the helper ynh_handle_getopts_args to have fixes from unstable.
|
||||
# Needed for composer helpers
|
||||
source _getopts_fix.sh
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading installation settings..."
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=2
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path_url=$(ynh_app_setting_get $app path)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
with_carddav=$(ynh_app_setting_get $app with_carddav)
|
||||
with_enigma=$(ynh_app_setting_get $app with_enigma)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
with_carddav=$(ynh_app_setting_get --app=$app --key=with_carddav)
|
||||
with_enigma=$(ynh_app_setting_get --app=$app --key=with_enigma)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_print_info "Ensuring downward compatibility..."
|
||||
ynh_script_progression --message="Ensuring downward compatibility..."
|
||||
|
||||
# If db_name doesn't exist, create it
|
||||
if [ -z "$db_name" ]; then
|
||||
db_name=$(ynh_sanitize_dbid $app)
|
||||
ynh_app_setting_set $app db_name $db_name
|
||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
fi
|
||||
|
||||
# If final_path doesn't exist, create it
|
||||
if [ -z "$final_path" ]; then
|
||||
final_path=/var/www/$app
|
||||
ynh_app_setting_set $app final_path $final_path
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
fi
|
||||
|
||||
# If with_carddav doesn't exist, create it
|
||||
|
@ -51,7 +54,7 @@ if [ -z "$with_carddav" ]; then
|
|||
else
|
||||
with_carddav=0
|
||||
fi
|
||||
ynh_app_setting_set $app with_carddav $with_carddav
|
||||
ynh_app_setting_set --app=$app --key=with_carddav --value=$with_carddav
|
||||
fi
|
||||
|
||||
# If with_enigma doesn't exist, create it
|
||||
|
@ -62,13 +65,13 @@ if [ -z "$with_enigma" ]; then
|
|||
else
|
||||
with_enigma=0
|
||||
fi
|
||||
ynh_app_setting_set $app with_enigma $with_enigma
|
||||
ynh_app_setting_set --app=$app --key=with_enigma --value=$with_enigma
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_print_info "Backing up the app before upgrading (may take a while)..."
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=30
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
|
@ -84,25 +87,29 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
|
||||
# Normalize the URL path syntax
|
||||
path_url=$(ynh_normalize_url_path $path_url)
|
||||
path_url=$(ynh_normalize_url_path --path_url=$path_url)
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_print_info "Upgrading source files..."
|
||||
|
||||
# Get the current version of roundcube
|
||||
oldversion=$(grep RCMAIL_VERSION "$final_path/program/include/iniset.php" | cut -d\' -f4)
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source "$final_path"
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=3
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$final_path"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Upgrading nginx web server configuration..."
|
||||
ynh_script_progression --message="Upgrading nginx web server configuration..."
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
@ -110,22 +117,22 @@ ynh_add_nginx_config
|
|||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_print_info "Upgrading dependencies..."
|
||||
ynh_script_progression --message="Upgrading dependencies..." --weight=25
|
||||
|
||||
ynh_install_app_dependencies "$pkg_dependencies"
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_print_info "Making sure dedicated system user exists..."
|
||||
ynh_script_progression --message="Making sure dedicated system user exists..."
|
||||
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create $app
|
||||
ynh_system_user_create --username=$app
|
||||
|
||||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Upgrading php-fpm configuration..."
|
||||
ynh_script_progression --message="Upgrading php-fpm configuration..." --weight=5
|
||||
|
||||
# Create a dedicated php-fpm config
|
||||
ynh_add_fpm_config
|
||||
|
@ -135,113 +142,117 @@ ynh_add_fpm_config
|
|||
#=================================================
|
||||
# CONFIGURE ROUNDCUBE
|
||||
#=================================================
|
||||
ynh_print_info "Reconfiguring roundcube..."
|
||||
|
||||
rc_conf="$final_path/config/config.inc.php"
|
||||
|
||||
# Verify the checksum and backup the file if it's different
|
||||
ynh_backup_if_checksum_is_different "$rc_conf"
|
||||
|
||||
cp ../conf/config.inc.php "$rc_conf"
|
||||
|
||||
ynh_replace_string "__DESKEY__" "$(ynh_string_random 24)" "$rc_conf"
|
||||
ynh_replace_string "__DBUSER__" $db_name "$rc_conf"
|
||||
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||
ynh_replace_string "__DBPASS__" "$db_pwd" "$rc_conf"
|
||||
ynh_replace_string "__DBNAME__" $db_name "$rc_conf"
|
||||
|
||||
#=================================================
|
||||
# UPDATE DEPENDENCIES WITH COMPOSER
|
||||
#=================================================
|
||||
ynh_print_info "Updating dependencies with composer..."
|
||||
|
||||
# Check if dependencies need to be updated with composer
|
||||
if [ -f "$final_path/composer.json" ]
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_exec_warn_less ynh_composer_exec --commands=\"update --no-dev --prefer-dist\"
|
||||
else
|
||||
# Install composer.json
|
||||
cp "$final_path/composer.json-dist" "$final_path/composer.json"
|
||||
ynh_script_progression --message="Reconfiguring roundcube..."
|
||||
|
||||
# Install composer
|
||||
ynh_install_composer
|
||||
rc_conf="$final_path/config/config.inc.php"
|
||||
|
||||
# Verify the checksum and backup the file if it's different
|
||||
ynh_backup_if_checksum_is_different "$rc_conf"
|
||||
|
||||
cp ../conf/config.inc.php "$rc_conf"
|
||||
|
||||
ynh_replace_string --match_string="__DESKEY__" --replace_string="$(ynh_string_random --length=24)" --target_file="$rc_conf"
|
||||
ynh_replace_string --match_string="__DBUSER__" --replace_string=$db_name --target_file="$rc_conf"
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||
ynh_replace_string --match_string="__DBPASS__" --replace_string="$db_pwd" --target_file="$rc_conf"
|
||||
ynh_replace_string --match_string="__DBNAME__" --replace_string=$db_name --target_file="$rc_conf"
|
||||
|
||||
#=================================================
|
||||
# UPDATE DEPENDENCIES WITH COMPOSER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating dependencies with composer..." --weight=30
|
||||
|
||||
# Check if dependencies need to be updated with composer
|
||||
if [ -f "$final_path/composer.json" ]
|
||||
then
|
||||
ynh_exec_warn_less ynh_composer_exec --commands=\"update --no-dev --prefer-dist\"
|
||||
else
|
||||
# Install composer.json
|
||||
cp "$final_path/composer.json-dist" "$final_path/composer.json"
|
||||
|
||||
# Install composer
|
||||
ynh_install_composer
|
||||
fi
|
||||
#=================================================
|
||||
# UPGRADE ADDITIONAL PLUGINS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading additional plugins..." --weight=30
|
||||
|
||||
# Create logs and temp directories
|
||||
mkdir -p "$final_path/"{logs,temp}
|
||||
|
||||
# Update or install contextmenu and automatic_addressbook plugins
|
||||
# https://plugins.roundcube.net/packages/sblaisot/automatic_addressbook
|
||||
# https://plugins.roundcube.net/packages/johndoh/contextmenu
|
||||
ynh_composer_exec --commands="update --no-dev --prefer-dist \
|
||||
johndoh/contextmenu $contextmenu_version \
|
||||
sblaisot/automatic_addressbook $automatic_addressbook_version"
|
||||
|
||||
installed_plugins+=" 'contextmenu', 'automatic_addressbook',"
|
||||
|
||||
# Update or install CardDAV plugin
|
||||
if [ $with_carddav -eq 1 ]
|
||||
then
|
||||
ynh_composer_exec --commands="require roundcube/carddav $carddav_version"
|
||||
|
||||
carddav_tmp_config="../conf/carddav.config.inc.php"
|
||||
|
||||
# Look for installed and supported CardDAV servers
|
||||
for carddav_app in "owncloud" "nextcloud" "baikal"
|
||||
do
|
||||
carddav_app_id=$(yunohost app list --installed -f $carddav_app \
|
||||
--output-as json | grep -Po '"id":[ ]?"\K.*?(?=")' | head -1)
|
||||
if [ -n "$carddav_app_id" ]
|
||||
then
|
||||
# Retrieve app settings and enable relevant preset
|
||||
carddav_domain=$(ynh_app_setting_get --app=$carddav_app_id --key=domain)
|
||||
carddav_path=$(ynh_app_setting_get --app=$carddav_app_id --key=path)
|
||||
carddav_url="https://${carddav_domain}${carddav_path%/}"
|
||||
ynh_replace_string --match_string="{${carddav_app}_url}" --replace_string="$carddav_url" --target_file="$carddav_tmp_config"
|
||||
ynh_replace_string --match_string="\/\* PRESET FOR: $carddav_app" --replace_string="" --target_file="$carddav_tmp_config"
|
||||
ynh_replace_string --match_string="END: $carddav_app \*\/" --replace_string="" --target_file="$carddav_tmp_config"
|
||||
fi
|
||||
done
|
||||
|
||||
# Copy the plugin configuration file
|
||||
cp "$carddav_tmp_config" ""$final_path/plugins/carddav/config.inc.php""
|
||||
|
||||
installed_plugins+=" 'carddav',"
|
||||
fi
|
||||
|
||||
# Install Enigma plugin
|
||||
if [ $with_enigma -eq 1 ]
|
||||
then
|
||||
cp -a "$final_path/plugins/enigma/config.inc.php.dist" "$final_path/plugins/enigma/config.inc.php" \
|
||||
&& installed_plugins+=" 'enigma'," \
|
||||
|| ynh_print_warn --message="Unable to install Enigma plugin"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# UPDATE ROUNDCUBE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating roundcube configuration..." --weight=4
|
||||
|
||||
ynh_replace_string --match_string="^\s*// installed plugins" --replace_string="&\n $installed_plugins" --target_file="$rc_conf"
|
||||
|
||||
# Update javascript dependencies
|
||||
(cd "$final_path"
|
||||
/usr/bin/php -q ./bin/install-jsdeps.sh)
|
||||
|
||||
# Store the config file checksum into the app settings
|
||||
ynh_store_file_checksum --file="$rc_conf"
|
||||
|
||||
#=================================================
|
||||
# UPDATE ROUNDCUBE CORE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating roundcube core..." --weight=4
|
||||
|
||||
( cd "$final_path"
|
||||
ynh_exec_warn ./bin/update.sh --version=$oldversion -y)
|
||||
fi
|
||||
#=================================================
|
||||
# UPGRADE ADDITIONAL PLUGINS
|
||||
#=================================================
|
||||
ynh_print_info "Upgrading additional plugins..."
|
||||
|
||||
# Create logs and temp directories
|
||||
mkdir -p "$final_path/"{logs,temp}
|
||||
|
||||
# Update or install contextmenu and automatic_addressbook plugins
|
||||
# https://plugins.roundcube.net/packages/sblaisot/automatic_addressbook
|
||||
# https://plugins.roundcube.net/packages/johndoh/contextmenu
|
||||
ynh_composer_exec --commands="update --no-dev --prefer-dist \
|
||||
johndoh/contextmenu $contextmenu_version \
|
||||
sblaisot/automatic_addressbook $automatic_addressbook_version"
|
||||
|
||||
installed_plugins+=" 'contextmenu', 'automatic_addressbook',"
|
||||
|
||||
# Update or install CardDAV plugin
|
||||
if [ $with_carddav -eq 1 ]
|
||||
then
|
||||
ynh_composer_exec --commands="require roundcube/carddav $carddav_version"
|
||||
|
||||
carddav_tmp_config="../conf/carddav.config.inc.php"
|
||||
|
||||
# Look for installed and supported CardDAV servers
|
||||
for carddav_app in "owncloud" "nextcloud" "baikal"
|
||||
do
|
||||
carddav_app_id=$(yunohost app list --installed -f $carddav_app \
|
||||
--output-as json | grep -Po '"id":[ ]?"\K.*?(?=")' | head -1)
|
||||
if [ -n "$carddav_app_id" ]
|
||||
then
|
||||
# Retrieve app settings and enable relevant preset
|
||||
carddav_domain=$(ynh_app_setting_get $carddav_app_id domain)
|
||||
carddav_path=$(ynh_app_setting_get $carddav_app_id path)
|
||||
carddav_url="https://${carddav_domain}${carddav_path%/}"
|
||||
ynh_replace_string "{${carddav_app}_url}" "$carddav_url" "$carddav_tmp_config"
|
||||
ynh_replace_string "\/\* PRESET FOR: $carddav_app" "" "$carddav_tmp_config"
|
||||
ynh_replace_string "END: $carddav_app \*\/" "" "$carddav_tmp_config"
|
||||
fi
|
||||
done
|
||||
|
||||
# Copy the plugin configuration file
|
||||
cp "$carddav_tmp_config" ""$final_path/plugins/carddav/config.inc.php""
|
||||
|
||||
installed_plugins+=" 'carddav',"
|
||||
fi
|
||||
|
||||
# Install Enigma plugin
|
||||
if [ $with_enigma -eq 1 ]
|
||||
then
|
||||
cp -a "$final_path/plugins/enigma/config.inc.php.dist" "$final_path/plugins/enigma/config.inc.php" \
|
||||
&& installed_plugins+=" 'enigma'," \
|
||||
|| ynh_print_warn "Unable to install Enigma plugin"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# UPDATE ROUNDCUBE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Updating roundcube configuration..."
|
||||
|
||||
ynh_replace_string "^\s*// installed plugins" "&\n $installed_plugins" "$rc_conf"
|
||||
|
||||
# Update javascript dependencies
|
||||
(cd "$final_path"
|
||||
/usr/bin/php -q ./bin/install-jsdeps.sh)
|
||||
|
||||
# Store the config file checksum into the app settings
|
||||
ynh_store_file_checksum "$rc_conf"
|
||||
|
||||
#=================================================
|
||||
# UPDATE ROUNDCUBE CORE
|
||||
#=================================================
|
||||
ynh_print_info "Updating roundcube core..."
|
||||
|
||||
( cd "$final_path"
|
||||
ynh_exec_warn ./bin/update.sh --version=$oldversion -y)
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
@ -256,12 +267,12 @@ chown -R $app: "$final_path/"{temp,logs,plugins/enigma/home}
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info "Reloading nginx web server..."
|
||||
ynh_script_progression --message="Reloading nginx web server..."
|
||||
|
||||
systemctl reload nginx
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Upgrade of $app completed"
|
||||
ynh_script_progression --message="Installation of $app completed" --last
|
||||
|
|
Loading…
Reference in a new issue