mirror of
https://github.com/YunoHost-Apps/nextcloud_ynh.git
synced 2024-09-03 19:55:57 +02:00
Add multimedia support
This commit is contained in:
parent
17e6ea7d42
commit
ada812a79c
4 changed files with 70 additions and 5 deletions
|
@ -19,10 +19,12 @@ exec_occ() {
|
||||||
php occ --no-interaction --no-ansi "$@")
|
php occ --no-interaction --no-ansi "$@")
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create the external storage for the home folders and enable sharing
|
# Create the external storage for the given folders and enable sharing
|
||||||
create_home_external_storage() {
|
create_external_storage() {
|
||||||
|
local datadir="$1"
|
||||||
|
local mount_name="$2"
|
||||||
local mount_id=`exec_occ files_external:create --output=json \
|
local mount_id=`exec_occ files_external:create --output=json \
|
||||||
'Home' 'local' 'null::null' -c 'datadir=/home/$user' || true`
|
"$2" 'local' 'null::null' -c "datadir=$datadir" || true`
|
||||||
! [[ $mount_id =~ ^[0-9]+$ ]] \
|
! [[ $mount_id =~ ^[0-9]+$ ]] \
|
||||||
&& echo "Unable to create external storage" >&2 \
|
&& echo "Unable to create external storage" >&2 \
|
||||||
|| exec_occ files_external:option "$mount_id" enable_sharing true
|
|| exec_occ files_external:option "$mount_id" enable_sharing true
|
||||||
|
@ -315,3 +317,31 @@ ynh_handle_app_migration () {
|
||||||
migration_process=1
|
migration_process=1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# EXPERIMENTAL HELPERS
|
||||||
|
#=================================================
|
||||||
|
#=================================================
|
||||||
|
# YUNOHOST MULTIMEDIA INTEGRATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Install or update the main directory yunohost.multimedia
|
||||||
|
#
|
||||||
|
# usage: ynh_multimedia_build_main_dir
|
||||||
|
ynh_multimedia_build_main_dir () {
|
||||||
|
wget -nv https://github.com/YunoHost-Apps/yunohost.multimedia/archive/master.zip 2>&1
|
||||||
|
unzip -q master.zip
|
||||||
|
./yunohost.multimedia-master/script/ynh_media_build.sh
|
||||||
|
}
|
||||||
|
|
||||||
|
# Allow an user to have an write authorisation in multimedia directories
|
||||||
|
#
|
||||||
|
# usage: ynh_multimedia_addaccess user_name
|
||||||
|
#
|
||||||
|
# | arg: user_name - The name of the user which gain this access.
|
||||||
|
ynh_multimedia_addaccess () {
|
||||||
|
local user_name=$1
|
||||||
|
groupadd -f multimedia
|
||||||
|
usermod -a -G multimedia $user_name
|
||||||
|
}
|
||||||
|
|
|
@ -182,7 +182,7 @@ exec_occ ldap:test-config \'\' \
|
||||||
# Enable External Storage and create local mount to home folder
|
# Enable External Storage and create local mount to home folder
|
||||||
if [ $user_home -eq 1 ]; then
|
if [ $user_home -eq 1 ]; then
|
||||||
exec_occ app:enable files_external
|
exec_occ app:enable files_external
|
||||||
create_home_external_storage
|
create_external_storage "/home/\$user" "Home"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -237,6 +237,19 @@ exec_occ background:cron
|
||||||
# Set system group in hooks
|
# Set system group in hooks
|
||||||
ynh_replace_string "#GROUP#" "$app" ../hooks/post_user_create
|
ynh_replace_string "#GROUP#" "$app" ../hooks/post_user_create
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# YUNOHOST MULTIMEDIA INTEGRATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# 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
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -134,6 +134,15 @@ for u in $(ynh_user_list); do
|
||||||
setfacl -m g:$app:rwx "/home/$u" || true
|
setfacl -m g:$app:rwx "/home/$u" || true
|
||||||
done
|
done
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# YUNOHOST MULTIMEDIA INTEGRATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Build YunoHost multimedia directories
|
||||||
|
ynh_multimedia_build_main_dir
|
||||||
|
# Allow nextcloud to write into these directories
|
||||||
|
ynh_multimedia_addaccess $app
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -272,7 +272,7 @@ if [ $user_home -eq 1 ]; then
|
||||||
exec_occ app:enable files_external
|
exec_occ app:enable files_external
|
||||||
exec_occ files_external:list --output=json \
|
exec_occ files_external:list --output=json \
|
||||||
| grep -q '"storage":"\\\\OC\\\\Files\\\\Storage\\\\Local"' \
|
| grep -q '"storage":"\\\\OC\\\\Files\\\\Storage\\\\Local"' \
|
||||||
|| create_home_external_storage
|
|| create_external_storage "/home/\$user" "Home"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -303,6 +303,19 @@ exec_occ background:cron
|
||||||
# Set system group in hooks
|
# Set system group in hooks
|
||||||
ynh_replace_string "#GROUP#" "$app" ../hooks/post_user_create
|
ynh_replace_string "#GROUP#" "$app" ../hooks/post_user_create
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# YUNOHOST MULTIMEDIA INTEGRATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# 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