mirror of
https://github.com/YunoHost-Apps/nextcloud_ynh.git
synced 2024-09-03 19:55:57 +02:00
Merge 4e0a6356b8
into 46bffb0797
This commit is contained in:
commit
b9d494e4a2
10 changed files with 62 additions and 112 deletions
|
@ -14,6 +14,7 @@
|
|||
"hashing_default_password": true,
|
||||
"localstorage.allowsymlinks": true,
|
||||
"simpleSignUpLink.shown": false,
|
||||
"default_phone_region": "",
|
||||
"maintenance_window_start": 1,
|
||||
"mail_smtpmode": "smtp",
|
||||
"mail_smtpport": "25",
|
||||
|
|
|
@ -74,7 +74,7 @@ location ^~ __PATH__/ {
|
|||
# that file is correctly served; if it doesn't, then the request is passed to
|
||||
# the front-end controller. This consistent behaviour means that we don't need
|
||||
# to specify custom rules for certain paths (e.g. images and other assets,
|
||||
# `/updater`, `/ocm-provider`, `/ocs-provider`), and thus
|
||||
# `/updater`, `/ocs-provider`), and thus
|
||||
# `try_files $uri $uri/ /nextcloud/index.php$request_uri`
|
||||
# always provides the desired behaviour.
|
||||
index index.php index.html __PATH__/index.php$request_uri;
|
||||
|
|
|
@ -122,8 +122,8 @@ ram.runtime = "512M"
|
|||
api.allowed = ["visitors", "all_users"]
|
||||
|
||||
[resources.apt]
|
||||
packages = "mariadb-server, imagemagick, libmagickcore-6.q16-6-extra, acl, tar, smbclient, at, redis-server, php8.3-fpm, php8.3-bz2, php8.3-imap, php8.3-gmp, php8.3-gd, php8.3-intl, php8.3-curl, php8.3-apcu, php8.3-redis, php8.3-ldap, php8.3-imagick, php8.3-zip, php8.3-mbstring, php8.3-xml, php8.3-mysql, php8.3-igbinary, php8.3-bcmath"
|
||||
packages = "postgresql, imagemagick, libmagickcore-6.q16-6-extra, acl, tar, smbclient, at, redis-server, php8.3-pgsql, php8.3-mysql, php8.3-fpm, php8.3-bz2, php8.3-imap, php8.3-gmp, php8.3-gd, php8.3-intl, php8.3-curl, php8.3-apcu, php8.3-redis, php8.3-ldap, php8.3-imagick, php8.3-zip, php8.3-mbstring, php8.3-xml, php8.3-igbinary, php8.3-bcmath"
|
||||
|
||||
[resources.database]
|
||||
type = "mysql"
|
||||
|
||||
type = "postgresql"
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Open a connection as a user
|
||||
#
|
||||
# example: ynh_mysql_connect_as --user="user" --password="pass" <<< "UPDATE ...;"
|
||||
# example: ynh_mysql_connect_as --user="user" --password="pass" --default_character_set="utf8mb4" < /path/to/file.sql
|
||||
#
|
||||
# usage: ynh_mysql_connect_as --user=user --password=password [--database=database] [--default_character_set=character-set]
|
||||
# | arg: -u, --user= - the user name to connect as
|
||||
# | arg: -p, --password= - the user password
|
||||
# | arg: -d, --database= - the database to connect to
|
||||
# | arg: -c, --default_character_set= - the charset to use
|
||||
#
|
||||
# Requires YunoHost version 2.2.4 or higher.
|
||||
ynh_mysql_connect_as() {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=updc
|
||||
local -A args_array=( [u]=user= [p]=password= [d]=database= [c]=default_character_set= )
|
||||
local user
|
||||
local password
|
||||
local database
|
||||
local default_character_set
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
database="${database:-}"
|
||||
default_character_set="${default_character_set:-}"
|
||||
|
||||
if [ -n "$default_character_set" ]
|
||||
then
|
||||
default_character_set="--default-character-set=$default_character_set"
|
||||
else
|
||||
default_character_set="--default-character-set=latin1"
|
||||
fi
|
||||
|
||||
mysql --user="$user" --password="$password" "$default_character_set" --batch "$database"
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Dump a database
|
||||
#
|
||||
# example: ynh_mysql_dump_db --database=roundcube --default_character_set="utf8mb4" > ./dump.sql
|
||||
#
|
||||
# usage: ynh_mysql_dump_db --database=database
|
||||
# | arg: -d, --database= - the database name to dump
|
||||
# | arg: -c, --default_character_set= - the charset to use
|
||||
# | ret: the mysqldump output
|
||||
#
|
||||
# Requires YunoHost version 2.2.4 or higher.
|
||||
ynh_mysql_dump_db() {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=dc
|
||||
local -A args_array=( [d]=database= [c]=default_character_set= )
|
||||
local database
|
||||
local default_character_set
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
default_character_set="${default_character_set:-}"
|
||||
MYSQL_ROOT_PWD_FILE=/etc/yunohost/mysql
|
||||
|
||||
if [ -n "$default_character_set" ]
|
||||
then
|
||||
default_character_set="--default-character-set=$default_character_set"
|
||||
else
|
||||
# By default, default character set is "latin1"
|
||||
default_character_set="--default-character-set=latin1"
|
||||
fi
|
||||
|
||||
if [ -f "$MYSQL_ROOT_PWD_FILE" ]; then
|
||||
mysqldump --user="root" --password="$(cat $MYSQL_ROOT_PWD_FILE)" --single-transaction --skip-dump-date "$default_character_set" "$database"
|
||||
else
|
||||
mysqldump --single-transaction --skip-dump-date "$default_character_set" "$database"
|
||||
fi
|
||||
}
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
source ../settings/scripts/_ynh_mysql_dump_db.sh
|
||||
|
||||
#=================================================
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
|
@ -60,11 +59,11 @@ ynh_backup --src_path="/etc/cron.d/$app"
|
|||
ynh_backup --src_path="/var/log/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE MYSQL DATABASE
|
||||
# BACKUP THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_print_info --message="Backing up the MySQL database..."
|
||||
ynh_print_info --message="Backing up the PostgreSQL database..."
|
||||
|
||||
ynh_mysql_dump_db --database="$db_name" --default_character_set="utf8mb4" > db.sql
|
||||
ynh_psql_dump_db --database="$db_name" > db.sql
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NOTIFY_PUSH APP
|
||||
|
|
|
@ -2,20 +2,11 @@
|
|||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
source _ynh_mysql_connect_as.sh
|
||||
|
||||
phpflags="--define apc.enable_cli=1"
|
||||
|
||||
ynh_app_setting_set --app=$app --key=phpflags --value="$phpflags"
|
||||
|
||||
#=================================================
|
||||
# CREATE A MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Migrate MySQL database to utf8..." --weight=2
|
||||
|
||||
ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name \
|
||||
<<< "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
@ -82,7 +73,7 @@ admin_password="$(ynh_string_random --length=6)"
|
|||
|
||||
# Install Nextcloud using a temporary admin user
|
||||
exec_occ maintenance:install \
|
||||
--database "mysql" --database-name $db_name \
|
||||
--database "pgsql" --database-name $db_name \
|
||||
--database-user $db_user --database-pass "$db_pwd" \
|
||||
--admin-user "admin" --admin-pass "$admin_password" \
|
||||
--data-dir "$data_dir/data" \
|
||||
|
@ -185,8 +176,9 @@ exec_occ config:system:set overwrite.cli.url --value="https://${domain}${path}"
|
|||
#=================================================
|
||||
|
||||
# Set the user as admin
|
||||
ynh_mysql_connect_as --user=$db_name --password="$db_pwd" --database=$db_name --default_character_set="utf8mb4" \
|
||||
ynh_psql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name \
|
||||
<<< "INSERT INTO oc_group_user VALUES ('admin','$admin');"
|
||||
|
||||
# And delete admin user
|
||||
exec_occ user:delete admin
|
||||
|
||||
|
@ -250,10 +242,12 @@ ynh_script_progression --message="Adding multimedia directories..." --weight=6
|
|||
|
||||
# Build YunoHost multimedia directories
|
||||
ynh_multimedia_build_main_dir
|
||||
|
||||
# Mount the user directory in Nextcloud
|
||||
exec_occ app:enable files_external
|
||||
create_external_storage "/home/yunohost.multimedia/\$user" "Multimedia"
|
||||
create_external_storage "/home/yunohost.multimedia/share" "Shared multimedia"
|
||||
|
||||
# Allow nextcloud to write into these directories
|
||||
ynh_multimedia_addaccess $app
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# REMOVE SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing system configurations related to $app..." --weight=5
|
||||
ynh_script_progression --message="Removing system configurations related to $app..." --weight=10
|
||||
|
||||
# Remove the dedicated NGINX config
|
||||
ynh_remove_nginx_config
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
source ../settings/scripts/_ynh_mysql_connect_as.sh
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
|
@ -14,16 +13,16 @@ ynh_script_progression --message="Restoring the app main directory..."
|
|||
ynh_restore_file --origin_path="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE MYSQL DATABASE
|
||||
# RESTORE THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the MySQL database..." --weight=9
|
||||
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=9
|
||||
|
||||
ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name --default_character_set="utf8mb4" < ./db.sql
|
||||
ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reconfiguring PHP-FPM..." --weight=50
|
||||
ynh_script_progression --message="Reconfiguring PHP-FPM..." --weight=5
|
||||
|
||||
# Restore the file first, so it can have a backup if different
|
||||
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||
|
|
|
@ -55,6 +55,12 @@ filter_boring_occ_warnings() {
|
|||
sed -E 's@\s*([0-9]+\/[0-9]+\s+\[(-|>|=)+\]\s+[0-9]+%|\s*Starting ...|Nextcloud or one of the apps require upgrade - only a limited number of commands are available|You may use your browser or the occ upgrade command to do the upgrade)@@g'
|
||||
}
|
||||
|
||||
current_version=$(grep OC_VersionString "$install_dir/version.php" | cut -d\' -f2)
|
||||
current_major_version=${current_version%%.*}
|
||||
|
||||
last_version=$(ynh_read_manifest --manifest_key="resources.sources.main.url" | grep -o '[0-9][0-9]\.[0-9]\.[0-9]')
|
||||
last_major_version=${last_version%%.*}
|
||||
|
||||
# Define a function to execute commands with `occ`
|
||||
exec_occ() {
|
||||
# Backward compatibility to upgrade from older versions
|
||||
|
@ -87,6 +93,35 @@ exec_occ() {
|
|||
php$NEXTCLOUD_PHP_VERSION --define apc.enable_cli=1 occ --no-interaction --no-ansi "$@") 2> >(filter_boring_occ_warnings >&2)
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# HANDLE DATABASE MIGRATION FROM MYSL TO PSQL
|
||||
#=================================================
|
||||
|
||||
# If we're moving through version 29.0.3~ynh1 (in which the switch to psql is made)
|
||||
if ynh_compare_current_package_version --comparison lt --version 29.0.3~ynh1
|
||||
then
|
||||
# Double-check the MySQL DB is here
|
||||
if ! mysql -e "USE $db_name" 2>/dev/null
|
||||
then
|
||||
ynh_print_warn "Uhoh? The Nextcloud MySQL DB doesn't exist? We are supposed to move it to PostgreSQL... Maybe it was already migrated?"
|
||||
# Double check the psql is not empty, otherwise big whoops?
|
||||
if [[ "$(ynh_psql_execute_as_root --database=$db_name --sql="\dt" 2>/dev/null | wc -l)" == 0 ]]
|
||||
then
|
||||
ynh_die "Apparently the PostgreSQL DB is also empty, this is kind of worrying, what happened?!"
|
||||
else
|
||||
ynh_print_warn "Apparently the PostgreSQL DB is not empty, so this is probably OK?"
|
||||
fi
|
||||
else
|
||||
ynh_print_info --message="Migrating to PostgreSQL database..."
|
||||
ynh_exec_warn_less exec_occ db:convert-type --all-apps --clear-schema pgsql $db_name 127.0.0.1 $db_name --password=$db_pwd -n
|
||||
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
|
||||
fi
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
||||
# Define a function to add an external storage
|
||||
# Create the external storage for the given folders and enable sharing
|
||||
create_external_storage() {
|
||||
|
@ -122,12 +157,11 @@ function list_installed_apps_not_compatible_with_future_version()
|
|||
comm -23 <(comm -23 $installed_apps $core_apps_in_current_version) $nextcloud_destination_appcatalog
|
||||
}
|
||||
|
||||
#current_version=$(grep OC_VersionString "$install_dir/version.php" | cut -d\' -f2)
|
||||
#current_major_version=${current_version%%.*}
|
||||
|
||||
current_version=$(grep OC_VersionString "$install_dir/version.php" | cut -d\' -f2)
|
||||
current_major_version=${current_version%%.*}
|
||||
|
||||
last_version=$(ynh_read_manifest --manifest_key="resources.sources.main.url" | grep -o '[0-9][0-9]\.[0-9]\.[0-9]')
|
||||
last_major_version=${last_version%%.*}
|
||||
#last_version=$(ynh_read_manifest --manifest_key="resources.sources.main.url" | grep -o '[0-9][0-9]\.[0-9]\.[0-9]')
|
||||
#last_major_version=${last_version%%.*}
|
||||
|
||||
if [[ "$last_major_version" != "$current_major_version" ]]
|
||||
then
|
||||
|
@ -148,15 +182,6 @@ then
|
|||
# Print the current version number of Nextcloud
|
||||
exec_occ -V
|
||||
|
||||
if [ "$(exec_occ config:system:get mysql.utf8mb4)" != "true" ]; then
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||
# Change your databases character set and collation
|
||||
ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name \
|
||||
<<< "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"
|
||||
# Set the mysql.utf8mb4 config to true in config.php
|
||||
exec_occ config:system:set mysql.utf8mb4 --type boolean --value="true"
|
||||
exec_occ maintenance:repair
|
||||
fi
|
||||
|
||||
# Upgrade may fail if this app is enabled
|
||||
# Take all apps enabled, and check if mail is one of them
|
||||
|
@ -274,6 +299,11 @@ then
|
|||
# Then remove the config file
|
||||
ynh_secure_remove --file="$nc_conf"
|
||||
|
||||
# Occasionally new mimetypes are added to better handle certain file types.
|
||||
# Migrating the mimetypes take a long time on larger instances
|
||||
# so this is not done automatically during upgrades.
|
||||
exec_occ maintenance:repair --include-expensive
|
||||
|
||||
#=================================================
|
||||
# ALLOW USERS TO DISCONNECT FROM NEXTCLOUD
|
||||
#=================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue