mirror of
https://github.com/YunoHost-Apps/nextcloud_ynh.git
synced 2024-09-03 19:55:57 +02:00
Merge pull request #325 from YunoHost-Apps/add-add_multimedia_dir-action
Add action add_multimedia_directories
This commit is contained in:
commit
2667722dc9
3 changed files with 75 additions and 14 deletions
|
@ -6,3 +6,12 @@ command = "/bin/bash scripts/actions/disable_maintenance"
|
||||||
# accepted_return_codes = [0, 1, 2, 3] # optional
|
# accepted_return_codes = [0, 1, 2, 3] # optional
|
||||||
accepted_return_codes = [0]
|
accepted_return_codes = [0]
|
||||||
description = "Disable the maintenance mode of Nextcloud if you're stuck after an upgrade"
|
description = "Disable the maintenance mode of Nextcloud if you're stuck after an upgrade"
|
||||||
|
|
||||||
|
[add_multimedia_directories]
|
||||||
|
name = "Add multimedia directories"
|
||||||
|
command = "/bin/bash scripts/actions/add_multimedia_directories"
|
||||||
|
# user = "root" # optional
|
||||||
|
# cwd = "/" # optional
|
||||||
|
# accepted_return_codes = [0, 1, 2, 3] # optional
|
||||||
|
accepted_return_codes = [0]
|
||||||
|
description = "Add the multimedia and shared multimedia directories again"
|
||||||
|
|
66
scripts/actions/add_multimedia_directories
Executable file
66
scripts/actions/add_multimedia_directories
Executable file
|
@ -0,0 +1,66 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC STARTING
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
source scripts/_common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RETRIEVE ARGUMENTS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CHECK IF ARGUMENTS ARE CORRECT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# DEFINE FUNCTION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Define a function to execute commands with `occ`
|
||||||
|
exec_occ() {
|
||||||
|
(cd "$final_path" && exec_as "$app" \
|
||||||
|
php$YNH_PHP_VERSION occ --no-interaction --no-ansi "$@")
|
||||||
|
}
|
||||||
|
|
||||||
|
# Define a function to add an external storage
|
||||||
|
# Create the external storage for the given folders and enable sharing
|
||||||
|
create_external_storage() {
|
||||||
|
local datadir="$1"
|
||||||
|
local mount_name="$2"
|
||||||
|
local mount_id=`exec_occ files_external:create --output=json \
|
||||||
|
"$mount_name" 'local' 'null::null' -c "datadir=$datadir" || true`
|
||||||
|
! [[ $mount_id =~ ^[0-9]+$ ]] \
|
||||||
|
&& ynh_print_warn --message="Unable to create external storage" \
|
||||||
|
|| exec_occ files_external:option "$mount_id" enable_sharing true
|
||||||
|
}
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC ACTION
|
||||||
|
#=================================================
|
||||||
|
# YUNOHOST MULTIMEDIA INTEGRATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Updating 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
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Execution completed" --last
|
|
@ -403,20 +403,6 @@ exec_occ background:cron
|
||||||
# Set system group in hooks
|
# Set system group in hooks
|
||||||
ynh_replace_string --match_string="__GROUP__" --replace_string="$app" --target_file=../hooks/post_user_create
|
ynh_replace_string --match_string="__GROUP__" --replace_string="$app" --target_file=../hooks/post_user_create
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# YUNOHOST MULTIMEDIA INTEGRATION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Updating 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
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Add table
Reference in a new issue