diff --git a/manifest.toml b/manifest.toml index 9edf547..b0cd343 100644 --- a/manifest.toml +++ b/manifest.toml @@ -57,6 +57,7 @@ ram.runtime = "512M" [resources.install_dir] [resources.data_dir] + subdirs = ["data"] [resources.permissions] main.url = "/" diff --git a/scripts/install b/scripts/install index 878907e..2423baf 100755 --- a/scripts/install +++ b/scripts/install @@ -63,8 +63,8 @@ ynh_setup_source --dest_dir="$install_dir" #================================================= ynh_script_progression --message="Configuring PHP-FPM..." --weight=50 -# Create a dedicated php-fpm config -ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$YNH_PHP_VERSION +# Create a dedicated PHP-FPM config +ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint #================================================= # NGINX CONFIGURATION @@ -107,7 +107,7 @@ exec_occ maintenance:install \ --database "mysql" --database-name $db_name \ --database-user $db_user --database-pass "$db_pwd" \ --admin-user "admin" --admin-pass "$admin_password" \ - --data-dir "$data_dir" \ + --data-dir "$data_dir/data" \ || ynh_die --message="Unable to install Nextcloud" #================================================= @@ -158,10 +158,10 @@ exec_occ ldap:test-config '' \ # Define a function to add an external storage # Create the external storage for the given folders and enable sharing create_external_storage() { - local data_dir="$1" + local data_dir/data="$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 @@ -259,8 +259,8 @@ chown -R $app:www-data "$install_dir" chown -R $app: "$data_dir" find $install_dir/ -type f -print0 | xargs -0 chmod 0644 find $install_dir/ -type d -print0 | xargs -0 chmod 0755 -find $data_dir/ -type f -print0 | xargs -0 chmod 0640 -find $data_dir/ -type d -print0 | xargs -0 chmod 0750 +find $data_dir/data/ -type f -print0 | xargs -0 chmod 0640 +find $data_dir/data/ -type d -print0 | xargs -0 chmod 0750 chmod 640 "$install_dir/config/config.php" chmod 755 /home/yunohost.app chmod 750 $install_dir @@ -271,7 +271,7 @@ chmod 750 $install_dir ynh_script_progression --message="Configuring log rotation..." --weight=1 # Use logrotate to manage application logfile(s) -ynh_use_logrotate --logfile="$data_dir/nextcloud.log" +ynh_use_logrotate --logfile="$data_dir/data/nextcloud.log" #================================================= # SETUP FAIL2BAN @@ -279,7 +279,7 @@ ynh_use_logrotate --logfile="$data_dir/nextcloud.log" ynh_script_progression --message="Configuring Fail2Ban..." --weight=8 # Create a dedicated Fail2Ban config -ynh_add_fail2ban_config --logpath="$data_dir/nextcloud.log" --failregex="^.*Login failed: '.*' \(Remote IP: ''.*$" --max_retry=5 +ynh_add_fail2ban_config --logpath="$data_dir/data/nextcloud.log" --failregex="^.*Login failed: '.*' \(Remote IP: ''.*$" --max_retry=5 #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index 36df451..d37161d 100755 --- a/scripts/restore +++ b/scripts/restore @@ -10,14 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers source ../settings/scripts/_ynh_mysql_connect_as.sh -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading settings..." - -fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) -fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) - #================================================= # STANDARD RESTORATION STEPS #================================================= @@ -32,11 +24,6 @@ ynh_restore_file --origin_path="$install_dir" #================================================= ynh_script_progression --message="Restoring the MySQL database..." --weight=9 -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 \ - <<< "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;" - ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name --default_character_set="utf8mb4" < ./db.sql #================================================= @@ -47,9 +34,6 @@ ynh_script_progression --message="Reconfiguring PHP-FPM..." --weight=50 # 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" -# Recreate a dedicated php-fpm config -ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion - #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= @@ -87,7 +71,7 @@ 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. ynh_restore_file --origin_path="$data_dir" --not_mandatory -mkdir -p "$data_dir" +chown -R $app:www-data "$data_dir" #================================================= # RESTORE USER RIGHTS @@ -98,8 +82,8 @@ chown -R $app:www-data "$install_dir" chown -R $app: "$data_dir" find $install_dir/ -type f -print0 | xargs -0 chmod 0644 find $install_dir/ -type d -print0 | xargs -0 chmod 0755 -find $data_dir/ -type f -print0 | xargs -0 chmod 0640 -find $data_dir/ -type d -print0 | xargs -0 chmod 0750 +find $data_dir/data/ -type f -print0 | xargs -0 chmod 0640 +find $data_dir/data/ -type d -print0 | xargs -0 chmod 0750 chmod 640 "$install_dir/config/config.php" chmod 755 /home/yunohost.app chmod 750 $install_dir @@ -107,7 +91,7 @@ chmod 750 $install_dir # Iterate over users to extend their home folder permissions - for the external # storage plugin usage - and create relevant Nextcloud directories for u in $(ynh_user_list); do - mkdir -p "$data_dir/$u" + mkdir -p "$data_dir/data/$u" setfacl --modify g:$app:rwx "/home/$u" || true done diff --git a/scripts/upgrade b/scripts/upgrade index faef657..f508d3f 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -121,7 +121,7 @@ local mount_id=$(exec_occ files_external:create --output=json \ || exec_occ files_external:option "$mount_id" enable_sharing true } # Define app's data directory -data_dir="/home/yunohost.app/$app/data" +#data_dir="/home/yunohost.app/$app/data" if [ "$upgrade_type" == "UPGRADE_APP" ] then @@ -342,8 +342,8 @@ chown -R $app:www-data "$install_dir" chown -R $app: "$data_dir" find $install_dir/ -type f -print0 | xargs -0 chmod 0644 find $install_dir/ -type d -print0 | xargs -0 chmod 0755 -find $data_dir/ -type f -print0 | xargs -0 chmod 0640 -find $data_dir/ -type d -print0 | xargs -0 chmod 0750 +find $data_dir/data/ -type f -print0 | xargs -0 chmod 0640 +find $data_dir/data/ -type d -print0 | xargs -0 chmod 0750 chmod 640 "$install_dir/config/config.php" chmod 755 /home/yunohost.app chmod 750 $install_dir