1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/nextcloud_ynh.git synced 2024-09-03 19:55:57 +02:00
This commit is contained in:
Éric Gaspar 2023-06-11 10:25:12 +02:00
parent 66cdfff98f
commit 5d384066ec
6 changed files with 12 additions and 58 deletions

View file

@ -69,8 +69,8 @@ ram.runtime = "512M"
api.allowed = ["visitors", "all_users"]
[resources.apt]
packages = "mariadb-server, imagemagick, libmagickcore-6.q16-6-extra, acl, tar, smbclient, at, php8.2-fpm, php8.2-bz2, php8.2-imap, php8.2-gmp, php8.2-gd, php8.2-intl, php8.2-curl, php8.2-apcu, php8.2-redis, php8.2-ldap, php8.2-imagick, php8.2-zip, php8.2-mbstring, php8.2-xml, php8.2-mysql, php8.2-igbinary, php8.2-bcmath"
packages = "postgresql, imagemagick, libmagickcore-6.q16-6-extra, acl, tar, smbclient, at, php8.2-pgsql, php8.2-fpm, php8.2-bz2, php8.2-imap, php8.2-gmp, php8.2-gd, php8.2-intl, php8.2-curl, php8.2-apcu, php8.2-redis, php8.2-ldap, php8.2-imagick, php8.2-zip, php8.2-mbstring, php8.2-xml, php8.2-mysql, php8.2-igbinary, php8.2-bcmath"
[resources.database]
type = "mysql"
type = "postgresql"

View file

@ -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
}

View file

@ -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

View file

@ -28,14 +28,6 @@ ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
#=================================================
# 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
#=================================================
@ -99,12 +91,12 @@ chown -R $app: "$install_dir" "$data_dir"
# Define password in an intermediate var
# The fact that it's called _password allows it to be
# picked up by Yunohost's auto-redact mecanism
# picked up by YunoHost's auto-redact mecanism
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" \
@ -115,9 +107,6 @@ exec_occ maintenance:install \
#=================================================
ynh_script_progression --message="Configuring $app..." --weight=8
# Set the mysql.utf8mb4 config to true in config.php
exec_occ config:system:set mysql.utf8mb4 --type boolean --value="true"
# Ensure that UpdateNotification app is disabled
exec_occ app:disable updatenotification
@ -203,8 +192,9 @@ exec_occ config:system:set overwrite.cli.url --value="https://${domain}"
#=================================================
# 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
@ -241,10 +231,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

View file

@ -20,11 +20,11 @@ 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_pgsql_connect_as --user=$db_user --password=$db_pwd --database=$db_name --default_character_set="utf8mb4" < ./db.sql
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION

View file

@ -118,7 +118,7 @@ create_external_storage() {
local data_dir="$1"
local mount_name="$2"
local mount_id=$(exec_occ files_external:create --output=json \
"$mount_name" 'local' 'null::null' -c "data_dir=$data_dir" || true)
"$mount_name" 'local' 'null::null' -c "data_dir=$data_dir/data" || true)
! [[ $mount_id =~ ^[0-9]+$ ]] \
&& ynh_print_warn --message="Unable to create external storage" \
|| exec_occ files_external:option "$mount_id" enable_sharing true