From ada812a79cfe0d9fb4bed918d5659e53a60dbf2f Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Fri, 4 May 2018 20:50:12 +0200 Subject: [PATCH 1/9] Add multimedia support --- scripts/_common.sh | 36 +++++++++++++++++++++++++++++++++--- scripts/install | 15 ++++++++++++++- scripts/restore | 9 +++++++++ scripts/upgrade | 15 ++++++++++++++- 4 files changed, 70 insertions(+), 5 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 7a7b3b9..f1618eb 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -19,10 +19,12 @@ exec_occ() { php occ --no-interaction --no-ansi "$@") } -# Create the external storage for the home folders and enable sharing -create_home_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 \ - 'Home' 'local' 'null::null' -c 'datadir=/home/$user' || true` + "$2" 'local' 'null::null' -c "datadir=$datadir" || true` ! [[ $mount_id =~ ^[0-9]+$ ]] \ && echo "Unable to create external storage" >&2 \ || exec_occ files_external:option "$mount_id" enable_sharing true @@ -315,3 +317,31 @@ ynh_handle_app_migration () { migration_process=1 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 +} diff --git a/scripts/install b/scripts/install index cf22534..6900ed2 100755 --- a/scripts/install +++ b/scripts/install @@ -182,7 +182,7 @@ exec_occ ldap:test-config \'\' \ # Enable External Storage and create local mount to home folder if [ $user_home -eq 1 ]; then exec_occ app:enable files_external - create_home_external_storage + create_external_storage "/home/\$user" "Home" fi #================================================= @@ -237,6 +237,19 @@ exec_occ background:cron # Set system group in hooks 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 #================================================= diff --git a/scripts/restore b/scripts/restore index b476d80..44a7f58 100755 --- a/scripts/restore +++ b/scripts/restore @@ -134,6 +134,15 @@ for u in $(ynh_user_list); do setfacl -m g:$app:rwx "/home/$u" || true 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 #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 099d842..5997003 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -272,7 +272,7 @@ if [ $user_home -eq 1 ]; then exec_occ app:enable files_external exec_occ files_external:list --output=json \ | grep -q '"storage":"\\\\OC\\\\Files\\\\Storage\\\\Local"' \ - || create_home_external_storage + || create_external_storage "/home/\$user" "Home" fi #================================================= @@ -303,6 +303,19 @@ exec_occ background:cron # Set system group in hooks 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 #================================================= From 628cead60fa17dccb8eaf0f0e518e5fa70557e82 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sat, 5 May 2018 19:42:58 +0200 Subject: [PATCH 2/9] Use a checksum for yunohost.multimedia --- scripts/_common.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index f1618eb..ae524d8 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -330,8 +330,19 @@ ynh_handle_app_migration () { # # 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 + local ynh_media_release="v1.0" + local checksum="4852c8607db820ad51f348da0dcf0c88" + + # Download yunohost.multimedia scripts + wget -nv https://github.com/YunoHost-Apps/yunohost.multimedia/archive/${ynh_media_release}.tar.gz + + # Check the control sum + echo "${checksum} ${ynh_media_release}.tar.gz" | md5sum -c --status \ + || ynh_die "Corrupt source" + + # Extract + mkdir yunohost.multimedia-master + tar -xf ${ynh_media_release}.tar.gz -C yunohost.multimedia-master --strip-components 1 ./yunohost.multimedia-master/script/ynh_media_build.sh } From 055d750d98b95ab175fd18576024a38e6f84ccc8 Mon Sep 17 00:00:00 2001 From: Jimmy Monin Date: Sat, 12 May 2018 19:30:55 +0200 Subject: [PATCH 3/9] Upgrade to upstream version 13.0.2 --- README.md | 2 +- manifest.json | 2 +- scripts/upgrade.d/upgrade.last.sh | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 05205e1..cb5426d 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Nextcloud for YunoHost own data. A personal cloud which run on your own server. With Nextcloud you can synchronize your files over your devices. -**Shipped version:** 13.0.1 +**Shipped version:** 13.0.2 [![Install Nextcloud with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=nextcloud) ![](https://github.com/nextcloud/screenshots/blob/master/files/filelist.png) diff --git a/manifest.json b/manifest.json index 7021b04..2f8cd21 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Access & share your files, calendars, contacts, mail & more from any device, on your terms", "fr": "Consultez et partagez vos fichiers, agendas, carnets d'adresses, emails et bien plus depuis les appareils de votre choix, sous vos conditions" }, - "version": "13.0.1~ynh1", + "version": "13.0.2~ynh1", "url": "https://nextcloud.com", "license": "AGPL-3.0", "maintainer": { diff --git a/scripts/upgrade.d/upgrade.last.sh b/scripts/upgrade.d/upgrade.last.sh index f19c2e2..2e25020 100755 --- a/scripts/upgrade.d/upgrade.last.sh +++ b/scripts/upgrade.d/upgrade.last.sh @@ -1,7 +1,7 @@ #!/bin/bash # Last available nextcloud version -next_version="13.0.1" +next_version="13.0.2" # Nextcloud tarball checksum sha256 -nextcloud_source_sha256="5743314a71e972ae46a14b36b37394d4545915aa5f32d9e12ba786d04c1f1d11" +nextcloud_source_sha256="7396f98a1a53a9f4b144f55360d87c89cb6ee899feef1cfbf29a736219f9c47d" From 56e4620128d46302c5c6996b24a651e898e63bbe Mon Sep 17 00:00:00 2001 From: JimboJoe Date: Sat, 12 May 2018 19:56:46 +0200 Subject: [PATCH 4/9] Fix typos --- scripts/_common.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index ae524d8..b5f113d 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -336,7 +336,7 @@ ynh_multimedia_build_main_dir () { # Download yunohost.multimedia scripts wget -nv https://github.com/YunoHost-Apps/yunohost.multimedia/archive/${ynh_media_release}.tar.gz - # Check the control sum + # Verify checksum echo "${checksum} ${ynh_media_release}.tar.gz" | md5sum -c --status \ || ynh_die "Corrupt source" @@ -346,11 +346,11 @@ ynh_multimedia_build_main_dir () { ./yunohost.multimedia-master/script/ynh_media_build.sh } -# Allow an user to have an write authorisation in multimedia directories +# Grant write access to multimedia directories to a specified user # # usage: ynh_multimedia_addaccess user_name # -# | arg: user_name - The name of the user which gain this access. +# | arg: user_name - User to be granted write access ynh_multimedia_addaccess () { local user_name=$1 groupadd -f multimedia From 3fdcdf6576a62b26c232ff415c68ba0a64abca42 Mon Sep 17 00:00:00 2001 From: Jimmy Monin Date: Mon, 14 May 2018 18:53:02 +0200 Subject: [PATCH 5/9] Fix automatic logout from YunoHost when logging out from Nextcloud (#106): - fix Nextcloud source patch - fix patches not applied on installation - add an empty patches directory to work around a nasty cache issue when running package_check --- scripts/upgrade | 4 +--- scripts/upgrade.d/upgrade.last.sh | 3 +++ sources/patches/.gitignore | 0 .../app-00-add-logout_url-conf.patch | 12 ++++++------ 4 files changed, 10 insertions(+), 9 deletions(-) create mode 100644 sources/patches/.gitignore diff --git a/scripts/upgrade b/scripts/upgrade index 099d842..ed1cf99 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -175,9 +175,7 @@ do # If the current version has the same major version than the next one, # then it's the last upgrade to do if [ "$major_version" -eq "$current_major_version" ]; then - current_major_version=last - # Patch nexcloud files only for the last upgrade. - cp -a ../sources/patches_last_version ../sources/patches + current_major_version=last fi # Load the value for this version diff --git a/scripts/upgrade.d/upgrade.last.sh b/scripts/upgrade.d/upgrade.last.sh index f19c2e2..04a819b 100755 --- a/scripts/upgrade.d/upgrade.last.sh +++ b/scripts/upgrade.d/upgrade.last.sh @@ -5,3 +5,6 @@ next_version="13.0.1" # Nextcloud tarball checksum sha256 nextcloud_source_sha256="5743314a71e972ae46a14b36b37394d4545915aa5f32d9e12ba786d04c1f1d11" + +# Patch nextcloud files only for the last version +cp -a ../sources/patches_last_version/* ../sources/patches diff --git a/sources/patches/.gitignore b/sources/patches/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/sources/patches_last_version/app-00-add-logout_url-conf.patch b/sources/patches_last_version/app-00-add-logout_url-conf.patch index 5565e21..3659fb1 100644 --- a/sources/patches_last_version/app-00-add-logout_url-conf.patch +++ b/sources/patches_last_version/app-00-add-logout_url-conf.patch @@ -1,14 +1,14 @@ --- a/core/Controller/LoginController.php +++ b/core/Controller/LoginController.php -@@ -100,7 +100,10 @@ class LoginController extends Controller { +@@ -119,7 +119,10 @@ } $this->userSession->logout(); - -- return new RedirectResponse($this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm')); + +- $response = new RedirectResponse($this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm')); + $redirectUrl = $this->config->getSystemValue('logout_url', + $this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm') + ); -+ return new RedirectResponse($redirectUrl); ++ $response = new RedirectResponse($redirectUrl); + $response->addHeader('Clear-Site-Data', '"cache", "cookies", "storage", "executionContexts"'); + return $response; } - - /** From 1cdb9ea1619c6acaaa90bae88b5c4bed5084a2a7 Mon Sep 17 00:00:00 2001 From: Jimmy Monin Date: Mon, 14 May 2018 19:37:40 +0200 Subject: [PATCH 6/9] Fix Debian Stretch dependencies by installing php-apcu, php-mbstring and php-xml --- scripts/_common.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 7a7b3b9..d66bfad 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,7 +6,7 @@ pkg_dependencies="php5-gd php5-json php5-intl php5-mcrypt php5-curl php5-apcu php5-redis php5-ldap php5-imagick imagemagick acl tar smbclient" if [ "$(lsb_release --codename --short)" != "jessie" ]; then - pkg_dependencies="$pkg_dependencies php-zip" + pkg_dependencies="$pkg_dependencies php-zip php-apcu php-mbstring php-xml" fi #================================================= @@ -139,7 +139,7 @@ ynh_handle_app_migration () { fi #================================================= - # CHECK IF IT HAS TO MIGRATE + # CHECK IF IT HAS TO MIGRATE #================================================= migration_process=0 @@ -209,7 +209,7 @@ ynh_handle_app_migration () { new_label=$(echo $new_app_id | cut -c1 | tr [:lower:] [:upper:])$(echo $new_app_id | cut -c2-) ynh_app_setting_set $new_app label $new_label fi - + #================================================= # MOVE FILES TO THE NEW DESTINATION #================================================= From 3a17a63abc01d22f748ee8dd4c4317e2d9a66838 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Mon, 28 May 2018 10:54:39 +0200 Subject: [PATCH 7/9] Create pull_request_template.md Duplicated from https://github.com/YunoHost-Apps/searx_ynh/pull/35, merged as a micro decision --- pull_request_template.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 pull_request_template.md diff --git a/pull_request_template.md b/pull_request_template.md new file mode 100644 index 0000000..2342905 --- /dev/null +++ b/pull_request_template.md @@ -0,0 +1,25 @@ +## Problem +- *Description of why you made this PR* + +## Solution +- *And how you fix that* + +## PR Status +- [ ] Code finished. +- [ ] Tested with Package_check. +- [ ] Fix or enhancement tested. +- [ ] Upgrade from last version tested. +- [ ] Can be reviewed and tested. + +## Validation +--- +*Minor decision* +- **Upgrade previous version** : +- [ ] **Code review** : +- [ ] **Approval (LGTM)** : +- [ ] **Approval (LGTM)** : +- **CI succeeded** : +[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/nextcloud_ynh%20-BRANCH-%20(Official)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/nextcloud_ynh%20-BRANCH-%20(Official)/) *Please replace '-BRANCH-' in this link for a PR from a local branch.* +or +[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/nextcloud_ynh%20PR-NUM-%20(Official_fork)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/nextcloud_ynh%20PR-NUM-%20(Official_fork)/) *Replace '-NUM-' by the PR number in this link for a PR from a forked repository.* +When the PR is marked as ready to merge, you have to wait for 3 days before really merging it. From 8cd01bdc8da0de38906e5a3380d12ee8bfa3ca27 Mon Sep 17 00:00:00 2001 From: Jimmy Monin Date: Mon, 28 May 2018 19:30:51 +0200 Subject: [PATCH 8/9] Fix failed access after first installation Don't create the user data folder (automatically created by Nextcloud), thus avoiding giving wrong ownership... --- hooks/post_user_create | 1 - scripts/install | 11 ++++------- scripts/upgrade | 11 ++++------- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/hooks/post_user_create b/hooks/post_user_create index 24ebf8c..f215f00 100644 --- a/hooks/post_user_create +++ b/hooks/post_user_create @@ -2,5 +2,4 @@ user=$1 -sudo mkdir -p /home/$user sudo setfacl -m g:#GROUP#:rwx /home/$user diff --git a/scripts/install b/scripts/install index 6900ed2..0b2aac1 100755 --- a/scripts/install +++ b/scripts/install @@ -183,6 +183,10 @@ exec_occ ldap:test-config \'\' \ if [ $user_home -eq 1 ]; then exec_occ app:enable files_external create_external_storage "/home/\$user" "Home" + # Iterate over users to extend their home folder permissions + for u in $(ynh_user_list); do + setfacl -m g:$app:rwx "/home/$u" || true + done fi #================================================= @@ -265,13 +269,6 @@ find ${datadir}/ -type d -print0 | xargs -0 chmod 0750 chmod 640 "${final_path}/config/config.php" chmod 755 /home/yunohost.app -# 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 "${datadir}/${u}" - setfacl -m g:$app:rwx "/home/$u" || true -done - #================================================= # SETUP LOGROTATE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index faeaf86..e1901b8 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -271,6 +271,10 @@ if [ $user_home -eq 1 ]; then exec_occ files_external:list --output=json \ | grep -q '"storage":"\\\\OC\\\\Files\\\\Storage\\\\Local"' \ || create_external_storage "/home/\$user" "Home" + # Iterate over users to extend their home folder permissions + for u in $(ynh_user_list); do + setfacl -m g:$app:rwx "/home/$u" || true + done fi #================================================= @@ -329,13 +333,6 @@ find ${datadir}/ -type d -print0 | xargs -0 chmod 0750 chmod 640 "${final_path}/config/config.php" chmod 755 /home/yunohost.app -# 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 "${datadir}/${u}" - setfacl -m g:$app:rwx "/home/$u" || true -done - #================================================= # WARNING ABOUT THIRD-PARTY APPS #================================================= From 4963b6f6cbe2e0fd05a968b4f7ecfe4d894caf79 Mon Sep 17 00:00:00 2001 From: Jimmy Monin Date: Sun, 3 Jun 2018 16:03:09 +0200 Subject: [PATCH 9/9] Add known warning message to the README --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index cb5426d..014b49c 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,11 @@ Also, note we made the choice to disable third-parties applications at the upgrade. It allows to prevent an unstable - and sometimes broken - Nextcloud installation. You will just have to manually activate them after the upgrade. +Finally, the following error message in Nextcloud logs can be safely ignored: +``` +Following symlinks is not allowed ('/home/yunohost.multimedia/user/Share' -> '/home/yunohost.multimedia/share/' not inside '/home/yunohost.multimedia/user/') +``` + ## Migrate from ownCloud **This is not considered as stable yet, please do it with care and only for