Browse Source
Merge pull request #325 from YunoHost-Apps/add-add_multimedia_dir-action
Merge pull request #325 from YunoHost-Apps/add-add_multimedia_dir-action
Add action add_multimedia_directoriespull/327/head
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 75 additions and 14 deletions
@ -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 |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue