From 9d12d1a6b1b5578dcb1e5b70407bd88ec16d04ba Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Mon, 20 Mar 2023 12:27:20 +0100 Subject: [PATCH 01/34] cleanup on uninstall/reinstall Signed-off-by: Daniel Hansson --- apps/previewgenerator.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/previewgenerator.sh b/apps/previewgenerator.sh index f2c7770f..e92b534f 100644 --- a/apps/previewgenerator.sh +++ b/apps/previewgenerator.sh @@ -45,6 +45,11 @@ else nextcloud_occ app:remove previewgenerator # reset the preview formats nextcloud_occ_no_check config:system:delete "enabledPreviewProviders" + nextcloud_occ config:system:delete preview_max_x + nextcloud_occ config:system:delete preview_max_y + nextcloud_occ config:system:delete jpeg_quality + nextcloud_occ config:system:delete preview_max_memory + nextcloud_occ config:system:delete enable_previews # reset the cronjob crontab -u www-data -l | grep -v 'preview:pre-generate' | crontab -u www-data - # Remove apps From 4aa578fbb4ba9f6ce36c73260e8b1c1a6aea0e51 Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Mon, 20 Mar 2023 12:30:59 +0100 Subject: [PATCH 02/34] lower CPU check Signed-off-by: Daniel Hansson --- apps/recognize.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/recognize.sh b/apps/recognize.sh index 7453a572..94bc5914 100644 --- a/apps/recognize.sh +++ b/apps/recognize.sh @@ -19,7 +19,7 @@ root_check # Enough recouces? ram_check 8 -cpu_check 8 +cpu_check 4 # Check if recognize is already installed if ! is_app_installed recognize From 033aa2c00a6916fa43948747340329fdc5bf950d Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Mon, 20 Mar 2023 12:31:36 +0100 Subject: [PATCH 03/34] move CPU / RAM check Signed-off-by: Daniel Hansson --- apps/recognize.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/recognize.sh b/apps/recognize.sh index 94bc5914..48fd6e1a 100644 --- a/apps/recognize.sh +++ b/apps/recognize.sh @@ -17,10 +17,6 @@ debug_mode # Check if root root_check -# Enough recouces? -ram_check 8 -cpu_check 4 - # Check if recognize is already installed if ! is_app_installed recognize then @@ -44,6 +40,10 @@ else fi # Install recognize +# Enough recouces? +ram_check 8 +cpu_check 4 + install_and_enable_app recognize nextcloud_occ recognize:download-models From 6a72e2edee22cb5eab50efaf403f8b94c4889c34 Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Tue, 21 Mar 2023 17:29:12 +0100 Subject: [PATCH 04/34] make Talk default during first setup Signed-off-by: Daniel Hansson --- menu/additional_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu/additional_apps.sh b/menu/additional_apps.sh index 09372649..b032cdd6 100644 --- a/menu/additional_apps.sh +++ b/menu/additional_apps.sh @@ -44,10 +44,10 @@ $CHECKLIST_GUIDE\n\n$RUN_LATER_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \ "Recognize" "(Use [local] AI on your photos in Nextcloud)" OFF \ "PreviewGenerator" "(Pre-generate previews for Nextcloud)" OFF \ "Webmin" "(Server GUI like Cpanel)" OFF \ +"Talk" "(Video calls and chat for Nextcloud)" "$STARTUP_SWITCH" \ "Adminer" "(PostgreSQL GUI)" OFF \ "LDAP" "(Windows Active directory for Nextcloud)" OFF \ "Notify Push" "(High Performance Files Backend for Nextcloud)" OFF \ -"Talk" "(Video calls and chat for Nextcloud)" OFF \ "Netdata" "(Real-time server monitoring in Web GUI)" OFF \ "FullTextSearch" "(Search for text inside documents [4GB RAM])" OFF \ "BPYTOP" "(Real-time server monitoring in CLI)" OFF \ From 209ab3569854e3f7a27ffc7fa252146b0fdfcdc1 Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Tue, 21 Mar 2023 17:45:56 +0100 Subject: [PATCH 05/34] advice to reinstall Signed-off-by: Daniel Hansson --- nextcloud_update.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/nextcloud_update.sh b/nextcloud_update.sh index 253b27d1..20018087 100644 --- a/nextcloud_update.sh +++ b/nextcloud_update.sh @@ -602,6 +602,7 @@ $DOCKER_RUN_OUTPUT" if ! does_this_docker_exist onlyoffice-ee then print_text_in_color "$IRed" "Skipping OnlyOffice due to issues with Websockets: https://forum.onlyoffice.com/t/onlyoffice-7-3-websocket-path-changed/3767/5" + print_text_in_color "$IRed" "You are adviced to reinstall OnlyOffice with the menu script: sudo bash /var/scripts/menu.sh." #docker_update_specific 'onlyoffice' 'OnlyOffice' fi # Full Text Search From 2b93764531987493aac0ca574b8d166242902fa0 Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Tue, 21 Mar 2023 21:38:05 +0100 Subject: [PATCH 06/34] Fix OnlyOffice websockets (#2457) --- apps/onlyoffice_docker.sh | 7 ++++++- nextcloud_update.sh | 11 ++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/apps/onlyoffice_docker.sh b/apps/onlyoffice_docker.sh index db153f28..3a45dac4 100644 --- a/apps/onlyoffice_docker.sh +++ b/apps/onlyoffice_docker.sh @@ -30,6 +30,8 @@ else # Remove config.php value set when install was successful nextcloud_occ config:system:delete allow_local_remote_servers nextcloud_occ config:system:delete onlyoffice + nextcloud_occ config:system:delete onlyoffice jwt_secret + nextcloud_occ config:system:delete onlyoffice jwt_header # Show successful uninstall if applicable removal_popup "$SCRIPT_NAME" fi @@ -205,9 +207,12 @@ then # basic proxy settings ProxyRequests off - ProxyPassMatch (.*)(\/websocket)$ "ws://127.0.0.3:9090/\$1\$2" ProxyPass / "http://127.0.0.3:9090/" ProxyPassReverse / "http://127.0.0.3:9090/" + RewriteEngine on + RewriteCond %{HTTP:Upgrade} websocket [NC] + RewriteCond %{HTTP:Connection} upgrade [NC] + RewriteRule ^/?(.*) "ws://127.0.0.3:9090/" [P,L] ProxyPassReverse / diff --git a/nextcloud_update.sh b/nextcloud_update.sh index 20018087..ef931cc2 100644 --- a/nextcloud_update.sh +++ b/nextcloud_update.sh @@ -601,9 +601,14 @@ $DOCKER_RUN_OUTPUT" ## Don't upgrade to community if EE is installed if ! does_this_docker_exist onlyoffice-ee then - print_text_in_color "$IRed" "Skipping OnlyOffice due to issues with Websockets: https://forum.onlyoffice.com/t/onlyoffice-7-3-websocket-path-changed/3767/5" - print_text_in_color "$IRed" "You are adviced to reinstall OnlyOffice with the menu script: sudo bash /var/scripts/menu.sh." - #docker_update_specific 'onlyoffice' 'OnlyOffice' + if does_this_docker_exist 'onlyoffice/documentserver' + then + docker_update_specific 'onlyoffice' 'OnlyOffice' + msg_box "OnlyOffice updated the way websockets work, and you need to update your configuration.\n +Please update your Apache2 config to this: https://github.com/nextcloud/vm/blob/master/apps/onlyoffice_docker.sh#L210-L215. +Another option is to reinstall OnlyOffice with the menu script; sudo bash /var/scripts/menu.sh\n +If you need help, please get support here: https://shop.hanssonit.se/product/premium-support-per-30-minutes/" + fi fi # Full Text Search docker_update_specific 'fts_esror' 'Full Text Search' From c6701426fcf9e18ca5ceb2c3e10b00c113903d21 Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Wed, 22 Mar 2023 14:03:27 +0100 Subject: [PATCH 07/34] Update recognize.sh Signed-off-by: Daniel Hansson --- apps/recognize.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/recognize.sh b/apps/recognize.sh index 48fd6e1a..b40c53a2 100644 --- a/apps/recognize.sh +++ b/apps/recognize.sh @@ -28,6 +28,7 @@ else # Removal if yesno_box_no "Do you want to remove all facerecognitions and tags that were generated until now?" then + print_text_in_color "$ICyan" "This will take some time..." nextcloud_occ recognize:remove-legacy-tags nextcloud_occ recognize:cleanup-tags nextcloud_occ recognize:reset-face-clusters From 33ff2d62885677808ac6698e2d25974f2af01612 Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Fri, 24 Mar 2023 11:38:21 +0100 Subject: [PATCH 08/34] automatically restart services (#2459) Signed-off-by: Daniel Hansson --- nextcloud_update.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/nextcloud_update.sh b/nextcloud_update.sh index ef931cc2..f7325399 100644 --- a/nextcloud_update.sh +++ b/nextcloud_update.sh @@ -32,6 +32,16 @@ root_check is_process_running apt is_process_running dpkg +# Automatically restart services (Ubuntu 22.04) +if ! version 16.04.10 "$DISTRO" 20.04.10 +then + if ! grep -r "{restart} = 'a'" /etc/needrestart/needrestart.conf + then + # Restart mode: (l)ist only, (i)nteractive or (a)utomatically. + sed -i "s|#\$nrconf{restart} = .*|\$nrconf{restart} = 'a';|g" /etc/needrestart/needrestart.conf + fi +fi + # Check for pending-snapshot if does_snapshot_exist "NcVM-snapshot-pending" then From 0e6a86a4abf1fa73d49b65c3941681af59c5751b Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Fri, 31 Mar 2023 10:46:38 +0200 Subject: [PATCH 09/34] Check if Suspicious Login are installed and ask to remove. Signed-off-by: Daniel Hansson --- apps/recognize.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/recognize.sh b/apps/recognize.sh index b40c53a2..44b8ee9c 100644 --- a/apps/recognize.sh +++ b/apps/recognize.sh @@ -45,6 +45,17 @@ fi ram_check 8 cpu_check 4 +# Check if suspicios_login are installed +# https://github.com/nextcloud/recognize/issues/676 +if is_app_installed suspicios_login +then + msg_box "Since you have the app Suspicios Login installed, you can't install Recognize since it will cause issues with cron.php." + if yesno_box_no "Do you want to remove Suspicios Login to be able to install Recognize?" + then + nextcloud_occ app:remove suspicios_login + fi +fi + install_and_enable_app recognize nextcloud_occ recognize:download-models From 7c7b5f59473da6fd37ec7576abbbb7f22010a37d Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Fri, 31 Mar 2023 12:33:31 +0200 Subject: [PATCH 10/34] updates once per month is enough Signed-off-by: Daniel Hansson --- addons/automatic_updates.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/automatic_updates.sh b/addons/automatic_updates.sh index 5a87f859..7ca3c874 100644 --- a/addons/automatic_updates.sh +++ b/addons/automatic_updates.sh @@ -6,7 +6,7 @@ true SCRIPT_NAME="Automatic Updates" # shellcheck source=lib.sh source /var/scripts/fetch_lib.sh -SCRIPT_EXPLAINER="This option will update your server every week on Saturdays at $AUT_UPDATES_TIME:00. +SCRIPT_EXPLAINER="This option will update your server once every month on Saturdays at $AUT_UPDATES_TIME:00. The update will run the built in script '$SCRIPTS/update.sh' which will update both the server packages and Nextcloud itself.\n You can read more about it here: https://www.techandme.se/nextcloud-update-is-now-fully-automated/ Please keep in mind that automatic updates might fail, which is why it's \ @@ -39,7 +39,7 @@ fi # Install automatic updates mkdir -p "$VMLOGS"/updates -crontab -u root -l | { cat; echo "0 $AUT_UPDATES_TIME * * 6 $SCRIPTS/update.sh minor >> $VMLOGS/updates/update-\$(date +\%Y-\%m-\%d_\%H:\%M).log 2>&1"; } | crontab -u root - +crontab -u root -l | { cat; echo "0 $AUT_UPDATES_TIME * 1-12 6 $SCRIPTS/update.sh minor >> $VMLOGS/updates/update-\$(date +\%Y-\%m-\%d_\%H:\%M).log 2>&1"; } | crontab -u root - if yesno_box_yes "Do you want to reboot your server after every update? *recommended*" then sed -i "s|exit|/sbin/shutdown -r +1|g" "$SCRIPTS"/update.sh From 87249678db1ae4d1aae3ce868b47ff68996ff969 Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Fri, 31 Mar 2023 13:48:39 +0200 Subject: [PATCH 11/34] inform about new major release Signed-off-by: Daniel Hansson --- nextcloud-startup-script.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nextcloud-startup-script.sh b/nextcloud-startup-script.sh index 85fa4064..6e399892 100644 --- a/nextcloud-startup-script.sh +++ b/nextcloud-startup-script.sh @@ -549,6 +549,13 @@ run_script NETWORK trusted print_text_in_color "$ICyan" "System will now upgrade..." bash $SCRIPTS/update.sh minor +# Check if new major is out, and inform on how to update +if version_gt "$NCVERSION" "$CURRENTVERSION" +then + msg_box "We noticed that there's a new major release of Nextcloud ($NCVERSION).\nIf you want to update to the latest release instantly, please check this:\n +https://docs.hanssonit.se/s/W6fMouPiqQz3_Mog/virtual-machines-vm/d/W7Du9uPiqQz3_Mr1/nextcloud-vm-machine-configuration?currentPageId=W7D3quPiqQz3_MsE" +fi + # Cleanup 2 apt-get autoremove -y apt-get autoclean From 26bdbf51f5a607d84bc9d544b72a0de84aff9389 Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Fri, 31 Mar 2023 20:27:08 +0200 Subject: [PATCH 12/34] check php before restaring webserver Signed-off-by: Daniel Hansson --- lib.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib.sh b/lib.sh index bef735cb..d3c6f2c4 100644 --- a/lib.sh +++ b/lib.sh @@ -774,6 +774,7 @@ restart_webserver() { # https://github.com/nextcloud/vm/issues/2358 sleep 2 check_command systemctl restart apache2.service +check_php if is_this_installed php"$PHPVER"-fpm then check_command systemctl restart php"$PHPVER"-fpm.service @@ -2019,6 +2020,9 @@ then elif grep 8.2 <<< "$GETPHP" >/dev/null 2>&1 then export PHPVER=8.2 +elif grep 8.3 <<< "$GETPHP" >/dev/null 2>&1 +then + export PHPVER=8.3 fi # Export other PHP variables based on PHPVER From 2811c4fc11c0cd5a3e147fbee05074bb0e403d64 Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Fri, 31 Mar 2023 20:38:07 +0200 Subject: [PATCH 13/34] move app check Signed-off-by: Daniel Hansson --- apps/recognize.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/recognize.sh b/apps/recognize.sh index 44b8ee9c..ab6183d6 100644 --- a/apps/recognize.sh +++ b/apps/recognize.sh @@ -17,6 +17,17 @@ debug_mode # Check if root root_check +# Check if suspicios_login are installed +# https://github.com/nextcloud/recognize/issues/676 +if is_app_installed suspicios_login +then + msg_box "Since you have the app Suspicios Login installed, you can't install Recognize since it will cause issues with cron.php." + if yesno_box_no "Do you want to remove Suspicios Login to be able to install Recognize?" + then + nextcloud_occ app:remove suspicios_login + fi +fi + # Check if recognize is already installed if ! is_app_installed recognize then @@ -45,17 +56,6 @@ fi ram_check 8 cpu_check 4 -# Check if suspicios_login are installed -# https://github.com/nextcloud/recognize/issues/676 -if is_app_installed suspicios_login -then - msg_box "Since you have the app Suspicios Login installed, you can't install Recognize since it will cause issues with cron.php." - if yesno_box_no "Do you want to remove Suspicios Login to be able to install Recognize?" - then - nextcloud_occ app:remove suspicios_login - fi -fi - install_and_enable_app recognize nextcloud_occ recognize:download-models From 1ab04a2306d64afe082e5d73bdd6cf9b231d04fd Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Fri, 31 Mar 2023 20:47:35 +0200 Subject: [PATCH 14/34] don't stop on failure Signed-off-by: Daniel Hansson --- apps/recognize.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/recognize.sh b/apps/recognize.sh index ab6183d6..f73446de 100644 --- a/apps/recognize.sh +++ b/apps/recognize.sh @@ -40,11 +40,11 @@ else if yesno_box_no "Do you want to remove all facerecognitions and tags that were generated until now?" then print_text_in_color "$ICyan" "This will take some time..." - nextcloud_occ recognize:remove-legacy-tags - nextcloud_occ recognize:cleanup-tags - nextcloud_occ recognize:reset-face-clusters - nextcloud_occ recognize:reset-faces - nextcloud_occ recognize:reset-tags + nextcloud_occ_no_check recognize:remove-legacy-tags + nextcloud_occ_no_check recognize:cleanup-tags + nextcloud_occ_no_check recognize:reset-face-clusters + nextcloud_occ_no_check recognize:reset-faces + nextcloud_occ_no_check recognize:reset-tags fi nextcloud_occ app:remove recognize # Show successful uninstall if applicable From 1224348439de774ae68f66873e3ccf1fbc141c32 Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Fri, 31 Mar 2023 20:53:17 +0200 Subject: [PATCH 15/34] typo Signed-off-by: Daniel Hansson --- apps/recognize.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/recognize.sh b/apps/recognize.sh index f73446de..56a624fa 100644 --- a/apps/recognize.sh +++ b/apps/recognize.sh @@ -17,14 +17,14 @@ debug_mode # Check if root root_check -# Check if suspicios_login are installed +# Check if suspicious_login are installed # https://github.com/nextcloud/recognize/issues/676 -if is_app_installed suspicios_login +if is_app_installed suspicious_login then - msg_box "Since you have the app Suspicios Login installed, you can't install Recognize since it will cause issues with cron.php." - if yesno_box_no "Do you want to remove Suspicios Login to be able to install Recognize?" + msg_box "Since you have the app Suspicious Login installed, you can't install Recognize since it will cause issues with cron.php." + if yesno_box_no "Do you want to remove Suspicious Login to be able to install Recognize?" then - nextcloud_occ app:remove suspicios_login + nextcloud_occ app:remove suspicious_login fi fi From d15b85aac7cb6c348fabceea9ced9a21178c7271 Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Fri, 31 Mar 2023 20:59:42 +0200 Subject: [PATCH 16/34] exit if no Signed-off-by: Daniel Hansson --- apps/recognize.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/recognize.sh b/apps/recognize.sh index 56a624fa..007c9868 100644 --- a/apps/recognize.sh +++ b/apps/recognize.sh @@ -21,10 +21,12 @@ root_check # https://github.com/nextcloud/recognize/issues/676 if is_app_installed suspicious_login then - msg_box "Since you have the app Suspicious Login installed, you can't install Recognize since it will cause issues with cron.php." + msg_box "Since you have the app Suspicious Login Detection installed, you can't install Recognize. The reason is that it will cause issues with cron.php.\nIf you choose 'No' the installer will exit." if yesno_box_no "Do you want to remove Suspicious Login to be able to install Recognize?" then nextcloud_occ app:remove suspicious_login + else + exit fi fi From 47e91252ff30ae13c2b4eb205f250bb171c8e62e Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Fri, 31 Mar 2023 21:12:04 +0200 Subject: [PATCH 17/34] final fix for check Signed-off-by: Daniel Hansson --- apps/recognize.sh | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/apps/recognize.sh b/apps/recognize.sh index 007c9868..230ad796 100644 --- a/apps/recognize.sh +++ b/apps/recognize.sh @@ -19,15 +19,22 @@ root_check # Check if suspicious_login are installed # https://github.com/nextcloud/recognize/issues/676 -if is_app_installed suspicious_login +if is_app_enabled suspicious_login then - msg_box "Since you have the app Suspicious Login Detection installed, you can't install Recognize. The reason is that it will cause issues with cron.php.\nIf you choose 'No' the installer will exit." - if yesno_box_no "Do you want to remove Suspicious Login to be able to install Recognize?" - then - nextcloud_occ app:remove suspicious_login - else - exit - fi + msg_box "Since you have the app Suspicious Login Detection installed, you can't install Recognize. The reason is that it will cause issues with cron.php.\nIf you choose 'No' the installer will exit" + if yesno_box_no "Do you want to disable Suspicious Login to be able to install Recognize?" + then + nextcloud_occ app:disable suspicious_login + if ! [ -f /etc/fail2ban/filter.d/nextcloud.conf ] || ! is_this_installed fail2ban + then + if yesno_box_yes "Do you want to install Fail2ban (IP blocking in Linux) instead?" + then + run_script APP fail2ban + fi + fi + else + exit + fi fi # Check if recognize is already installed From d696ab2598298b5d3ac2b5fe35441e4aa5409338 Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Fri, 31 Mar 2023 21:42:23 +0200 Subject: [PATCH 18/34] Add some more checks (#2462) Signed-off-by: Daniel Hansson --- apps/recognize.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/apps/recognize.sh b/apps/recognize.sh index 230ad796..199c929a 100644 --- a/apps/recognize.sh +++ b/apps/recognize.sh @@ -17,6 +17,16 @@ debug_mode # Check if root root_check +# Encryption may not be enabled +if is_app_enabled encryption || is_app_enabled end_to_end_encryption +then + msg_box "It seems like you have encryption enabled which is unsupported by the $SCRIPT_NAME app!" + exit 1 +fi + +# Compatible with NC26 and above +lowest_compatible_nc 26 + # Check if suspicious_login are installed # https://github.com/nextcloud/recognize/issues/676 if is_app_enabled suspicious_login @@ -37,6 +47,21 @@ then fi fi +# Check if face-recognition is installed and ask to remove it +if ! is_app_installed facerecognition +then + msg_box "It seems like Face Recognition is installed. This app doesn't work with both installed at the same time. Please uninstall Face Recognition and try again: + +1. Hit OK here. +2. Choose 'Uninstall' +3. Run sudo bash $SCRIPTS/menu.sh --> Additional Apps --> Recognize +4. Install + +We will run the uninstaller for you now, then exit." + wget https://raw.githubusercontent.com/nextcloud/vm/master/old/face-recognition.sh && bash face-recognition.sh && rm -f face-recognition.sh + exit +fi + # Check if recognize is already installed if ! is_app_installed recognize then From c14adf47a7fc8197996e5037dfa7b656e8914fe1 Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Fri, 31 Mar 2023 21:44:24 +0200 Subject: [PATCH 19/34] fix check for face recognition Signed-off-by: Daniel Hansson --- apps/recognize.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/recognize.sh b/apps/recognize.sh index 199c929a..a3a6a808 100644 --- a/apps/recognize.sh +++ b/apps/recognize.sh @@ -48,7 +48,7 @@ then fi # Check if face-recognition is installed and ask to remove it -if ! is_app_installed facerecognition +if is_app_installed facerecognition then msg_box "It seems like Face Recognition is installed. This app doesn't work with both installed at the same time. Please uninstall Face Recognition and try again: From d5aa43c6f0ed16535e7b555c046c379937048469 Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Sat, 1 Apr 2023 20:51:38 +0200 Subject: [PATCH 20/34] improve docker-compose down function Signed-off-by: Daniel Hansson --- lib.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib.sh b/lib.sh index d3c6f2c4..d3eb7010 100644 --- a/lib.sh +++ b/lib.sh @@ -1736,13 +1736,19 @@ docker-compose_down() { if [ -f "$1" ] then cd "$(dirname "$1")" - docker-compose down --volume --rmi all + if is_this_installed docker-compose + then + docker-compose down --volumes --rmi all + else + docker compose down --volumes --rmi all + fi + # Remove leftovers + docker system prune -a -f else echo "Non-existing docker-compose file path, skipping..." fi } - # Update specific Docker image # docker_update_specific 'vaultwarden' 'Vaultwarden' (docker conainter name = $1, the name in text = $2) docker_update_specific() { From 64b69c9097c24ef81d9cf8a7e1d761ffbf5ad0b8 Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Sat, 1 Apr 2023 23:07:56 +0200 Subject: [PATCH 21/34] Add Imaginary Docker for previews (#2464) --- apps/imaginary.sh | 149 +++++++++++++++++++ apps/previewgenerator.sh | 298 +------------------------------------- lib.sh | 41 +++--- menu/additional_apps.sh | 10 +- nextcloud_update.sh | 2 + old/previewgenerator.sh | 302 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 482 insertions(+), 320 deletions(-) create mode 100644 apps/imaginary.sh create mode 100644 old/previewgenerator.sh diff --git a/apps/imaginary.sh b/apps/imaginary.sh new file mode 100644 index 00000000..ac73d162 --- /dev/null +++ b/apps/imaginary.sh @@ -0,0 +1,149 @@ +#!/bin/bash + +# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/ +# GNU General Public License v3.0 +# https://github.com/nextcloud/vm/blob/master/LICENSE + +true +SCRIPT_NAME="Imaginary Docker" +SCRIPT_EXPLAINER="This script will install Imaginary which is a replacement for the less secure Imagick. +It can speedup the loading of previews in Nextcloud a lot." +# shellcheck source=lib.sh +source /var/scripts/fetch_lib.sh + +# Check for errors + debug code and abort if something isn't right +# 1 = ON +# 0 = OFF +DEBUG=0 +debug_mode + +# Check if root +root_check + +# Check recources +ram_check 4 +cpu_check 4 + +# Compatible with NC24 and above +lowest_compatible_nc 26 + +# Check if Imaginary is already installed +if ! does_this_docker_exist nextcloud/aio-imaginary +then + # Ask for installing + install_popup "$SCRIPT_NAME" +else + # Ask for removal or reinstallation + reinstall_remove_menu "$SCRIPT_NAME" + # Removal + if yesno_box_yes "Do you want to remove the Imaginary docker container and settings?" + then + # Remove docker container + docker_prune_this 'nextcloud/aio-imaginary' + # reset the preview formats + nextcloud_occ config:system:delete "preview_imaginary_url" + nextcloud_occ config:system:delete "enabledPreviewProviders" + nextcloud_occ config:system:delete "preview_max_x" + nextcloud_occ config:system:delete "preview_max_y" + nextcloud_occ config:system:delete "jpeg_quality" + nextcloud_occ config:system:delete "preview_max_memory" + nextcloud_occ config:system:delete "enable_previews" + nextcloud_occ config:system:delete "preview_concurrency_new" + nextcloud_occ config:system:delete "preview_concurrency_all" + # Remove FFMPEG + if is_this_installed ffmpeg && ! is_app_installed integration_whiteboard + then + apt-get purge ffmpeg -y + apt-get autoremove -y + fi + # Show successful uninstall if applicable + removal_popup "$SCRIPT_NAME" + fi +fi + +# Remove everything that is related to previewgenerator +if is_app_enabled previewgenerator +then + if yesno_box_yes "We noticed that you have Preview Generator enabled. Imagniary replaces this, and the old app Preview Generator is now legacy. We recommend you to remove it. Do you want to do that?" + then + # Remove the app + nextcloud_occ app:remove previewgenerator + # Reset the cronjob + crontab -u www-data -l | grep -v 'preview:pre-generate' | crontab -u www-data - + # Remove apps + APPS=(php-imagick php"$PHPVER"-imagick libmagickcore-6.q16-3-extra imagemagick-6.q16-extra) + for app in "${APPS[@]}" + do + if is_this_installed "$app" + then + apt-get purge "$app" -y + fi + done + # Remove custom config + rm -rf /etc/ImageMagick-6 + # Remove previews + if yesno_box_yes "Do you want to remove all previews that were generated until now? +This will most likely clear a lot of space! Also, pre-generated previews are not needed anymore once Imaginary are installed." + then + countdown "Removing the preview folder. This can take a while..." "5" + rm -rfv "$NCDATA"/appdata_*/preview/* + print_text_in_color "$ICyan" "Scanning Nextclouds appdata directory after removing all previews. \ +This can take a while..." + nextcloud_occ files:scan-app-data preview -vvv + msg_box "All previews were successfully removed." + fi + # Remove log + rm -f "$VMLOGS"/previewgenerator.log + fi +fi +# Install Docker +install_docker + +# Pull and start +docker pull nextcloud/aio-imaginary:latest +docker run -t -d -p 127.0.0.1:9000:9000 --restart always --name imaginary nextcloud/aio-imaginary -concurrency 50 -enable-url-source -log-level debug + +# Test if imaginary is working +countdown "Testing if it works in 3 sedonds" "3" +if curl -O "http://127.0.0.1:9000/crop?width=500&height=400&url=https://raw.githubusercontent.com/h2non/imaginary/master/testdata/large.jpg" +then + print_text_in_color "$IGreen" "imaginary seems to be working OK!" + rm -f large.jpg +else + msg_box "Test failed, please report this to: $ISSUES" + exit +fi + +# Install dependencies +check_php +install_if_not php"$PHPVER"-sysvsem +install_if_not ffmpeg + +# Set default limits +# https://github.com/nextcloud/server/pull/18210/files#diff-3bbe91e1f85eec5dbd0031642dfb0ad6749b550fc3b94af7aa68a98210b78738R1121 +nextcloud_occ config:system:set preview_concurrency_all --value="8" +nextcloud_occ config:system:set preview_concurrency_new --value="4" + +# Set providers (https://github.com/nextcloud/server/blob/master/lib/private/Preview/Imaginary.php#L60) +# https://github.com/nextcloud/vm/pull/2464#discussion_r1155074227 +nextcloud_occ config:system:set enabledPreviewProviders 0 --value="OC\\Preview\\Imaginary" +nextcloud_occ config:system:set enabledPreviewProviders 1 --value="OC\\Preview\\Image" +nextcloud_occ config:system:set enabledPreviewProviders 2 --value="OC\\Preview\\MarkDown" +nextcloud_occ config:system:set enabledPreviewProviders 3 --value="OC\\Preview\\MP3" +nextcloud_occ config:system:set enabledPreviewProviders 4 --value="OC\\Preview\\TXT" +nextcloud_occ config:system:set enabledPreviewProviders 5 --value="OC\\Preview\\OpenDocument" +nextcloud_occ config:system:set enabledPreviewProviders 6 --value="OC\\Preview\\Movie" +nextcloud_occ config:system:set preview_imaginary_url --value="http://127.0.0.1:9000" + +# Set general values +nextcloud_occ config:system:set preview_max_x --value="2048" +nextcloud_occ config:system:set preview_max_y --value="2048" +nextcloud_occ config:system:set jpeg_quality --value="60" +nextcloud_occ config:system:set preview_max_memory --value="256" + +if docker logs imaginary +then + msg_box "Imaginary was successfully installed!" +else + msg_box "It seems that something is wrong. Please post the full installation output to $ISSUES" +fi diff --git a/apps/previewgenerator.sh b/apps/previewgenerator.sh index e92b534f..45cf437f 100644 --- a/apps/previewgenerator.sh +++ b/apps/previewgenerator.sh @@ -2,300 +2,6 @@ # T&M Hansson IT AB © - 2023, https://www.hanssonit.se/ -true -SCRIPT_NAME="Preview Generator" -SCRIPT_EXPLAINER="This script will install the Preview Generator. -It can speedup the loading of previews in Nextcloud a lot." -# shellcheck source=lib.sh -source /var/scripts/fetch_lib.sh +####### TEMPORARY 2023-04-01 ####### -# Check for errors + debug code and abort if something isn't right -# 1 = ON -# 0 = OFF -DEBUG=0 -debug_mode - -# Check if root -root_check - -# PHP 7.x is needed -if is_this_installed php5.6-common || is_this_installed php5.5-common -then - msg_box "At least PHP 7.X is required, please upgrade your PHP version: \ -https://shop.hanssonit.se/product/upgrade-php-version-including-dependencies/" - exit -fi - -# Encryption may not be enabled -if is_app_enabled encryption || is_app_enabled end_to_end_encryption -then - msg_box "It seems like you have encryption enabled which is unsupported when using the Preview Generator" - exit -fi - -# Check if previewgenerator is already installed -if ! is_app_installed previewgenerator -then - # Ask for installing - install_popup "$SCRIPT_NAME" -else - # Ask for removal or reinstallation - reinstall_remove_menu "$SCRIPT_NAME" - # Removal - nextcloud_occ app:remove previewgenerator - # reset the preview formats - nextcloud_occ_no_check config:system:delete "enabledPreviewProviders" - nextcloud_occ config:system:delete preview_max_x - nextcloud_occ config:system:delete preview_max_y - nextcloud_occ config:system:delete jpeg_quality - nextcloud_occ config:system:delete preview_max_memory - nextcloud_occ config:system:delete enable_previews - # reset the cronjob - crontab -u www-data -l | grep -v 'preview:pre-generate' | crontab -u www-data - - # Remove apps - APPS=(php-imagick libmagickcore-6.q16-3-extra imagemagick-6.q16-extra) - for app in "${APPS[@]}" - do - if is_this_installed "$app" - then - apt-get purge "$app" -y - fi - done - if is_this_installed ffmpeg && ! is_app_installed integration_whiteboard - then - apt-get purge ffmpeg -y - fi - apt-get autoremove -y - if yesno_box_no "Do you want to remove all previews that were generated until now? -This will most likely clear a lot of space but your server will need to re-generate the previews \ -if you should opt to re-enable previews again." - then - countdown "Removing the preview folder. This can take a while..." "5" - rm -rfv "$NCDATA"/appdata_*/preview - print_text_in_color "$ICyan" "Scanning Nextclouds appdata directory after removing all previews. \ -This can take a while..." - nextcloud_occ files:scan-app-data -vvv - msg_box "All previews were successfully removed." - fi - # Show successful uninstall if applicable - removal_popup "$SCRIPT_NAME" -fi - -# Install preview generator -install_and_enable_app previewgenerator - -# check if the previewgenerator is installed and enabled -if is_app_enabled previewgenerator -then - # enable previews - nextcloud_occ config:system:set enable_previews --value=true --type=boolean - - # install needed dependency for movies - install_if_not ffmpeg -else - exit -fi - -msg_box "In the next step you can choose to install a package called imagick \ -to speed up the generation of previews and add support for more filetypes. - -The currently supported filetypes are: -* PNG -* JPEG -* GIF -* BMP -* MarkDown -* MP3 -* TXT -* Movie -* Photoshop (needs imagick) -* SVG (needs imagick) -* TIFF (needs imagick)" - -msg_box "IMPORTANT NOTE!! - -Imagick will put your server at risk as it's is known to have several flaws. -You can check this issue to understand why: https://github.com/nextcloud/vm/issues/743 - -Please note: If you choose not to install imagick, it will get removed now." -if yesno_box_no "Do you want to install imagick?" -then - check_php - # Install imagick - install_if_not php"$PHPVER"-imagick - if version 22.04 "$DISTRO" 22.04.10 - then - install_if_not libmagickcore-6.q16-6-extra - elif version 20.04 "$DISTRO" 20.04.10 - then - install_if_not libmagickcore-6.q16-3-extra - fi - # Memory tuning - sed -i 's|policy domain="resource" name="memory" value=.*|policy domain="resource" name="memory" value="512MiB"|g' /etc/ImageMagick-6/policy.xml - sed -i 's|policy domain="resource" name="map" value=.*|policy domain="resource" name="map" value="1024MiB"|g' /etc/ImageMagick-6/policy.xml - sed -i 's|policy domain="resource" name="area" value=.*|policy domain="resource" name="area" value="256MiB"|g' /etc/ImageMagick-6/policy.xml - sed -i 's|policy domain="resource" name="disk" value=.*|policy domain="resource" name="disk" value="8GiB"|g' /etc/ImageMagick-6/policy.xml - - # Choose file formats fo the case when imagick is installed. - # for additional previews please look at the Nextcloud documentation. But these probably won't work. - choice=$(whiptail --title "$TITLE - Choose file formats" --checklist \ -"Now you can choose for which file formats you would like to generate previews for -$CHECKLIST_GUIDE\n\n$RUN_LATER_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \ -"PNG" "" ON \ -"JPEG" "" ON \ -"GIF" "" ON \ -"BMP" "" ON \ -"MarkDown" "" ON \ -"MP3" "" ON \ -"TXT" "" ON \ -"Movie" "" ON \ -"Photoshop" "" ON \ -"SVG" "" ON \ -"TIFF" "" ON 3>&1 1>&2 2>&3) - - case "$choice" in - *"PNG"*) - nextcloud_occ config:system:set enabledPreviewProviders 0 --value="OC\\Preview\\PNG" - ;;& - *"JPEG"*) - nextcloud_occ config:system:set enabledPreviewProviders 1 --value="OC\\Preview\\JPEG" - ;;& - *"GIF"*) - nextcloud_occ config:system:set enabledPreviewProviders 2 --value="OC\\Preview\\GIF" - ;;& - *"BMP"*) - nextcloud_occ config:system:set enabledPreviewProviders 3 --value="OC\\Preview\\BMP" - ;;& - *"MarkDown"*) - nextcloud_occ config:system:set enabledPreviewProviders 4 --value="OC\\Preview\\MarkDown" - ;;& - *"MP3"*) - nextcloud_occ config:system:set enabledPreviewProviders 5 --value="OC\\Preview\\MP3" - ;;& - *"TXT"*) - nextcloud_occ config:system:set enabledPreviewProviders 6 --value="OC\\Preview\\TXT" - ;;& - *"Movie"*) - nextcloud_occ config:system:set enabledPreviewProviders 7 --value="OC\\Preview\\Movie" - ;;& - *"Photoshop"*) - nextcloud_occ config:system:set enabledPreviewProviders 8 --value="OC\\Preview\\Photoshop" - ;;& - *"SVG"*) - nextcloud_occ config:system:set enabledPreviewProviders 9 --value="OC\\Preview\\SVG" - ;;& - *"TIFF"*) - nextcloud_occ config:system:set enabledPreviewProviders 10 --value="OC\\Preview\\TIFF" - ;;& - *) - ;; - esac -else - # check if imagick is installed and remove it - if is_this_installed php-imagick - then - apt-get purge php-imagick -y - elif is_this_installed php"$PHPVER"-imagick - then - apt-get purge php"$PHPVER"-imagick -y - fi - # check if libmagickcore is installed and remove it - if is_this_installed libmagickcore-6.q16-3-extra - then - apt-get purge libmagickcore-6.q16-3-extra -y - fi - # Choose file formats fo the case when imagick is not installed. - # for additional previews please look at the Nextcloud documentation. But these probably won't work. - choice=$(whiptail --title "$TITLE - Choose file formats" --checklist \ -"Now you can choose for which file formats you would like to generate previews for -$CHECKLIST_GUIDE\n\n$RUN_LATER_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \ -"PNG" "" ON \ -"JPEG" "" ON \ -"GIF" "" ON \ -"BMP" "" ON \ -"MarkDown" "" ON \ -"MP3" "" ON \ -"TXT" "" ON \ -"Movie" "" ON 3>&1 1>&2 2>&3) - - case "$choice" in - *"PNG"*) - nextcloud_occ config:system:set enabledPreviewProviders 11 --value="OC\\Preview\\PNG" - ;;& - *"JPEG"*) - nextcloud_occ config:system:set enabledPreviewProviders 12 --value="OC\\Preview\\JPEG" - ;;& - *"GIF"*) - nextcloud_occ config:system:set enabledPreviewProviders 13 --value="OC\\Preview\\GIF" - ;;& - *"BMP"*) - nextcloud_occ config:system:set enabledPreviewProviders 14 --value="OC\\Preview\\BMP" - ;;& - *"MarkDown"*) - nextcloud_occ config:system:set enabledPreviewProviders 15 --value="OC\\Preview\\MarkDown" - ;;& - *"MP3"*) - nextcloud_occ config:system:set enabledPreviewProviders 16 --value="OC\\Preview\\MP3" - ;;& - *"TXT"*) - nextcloud_occ config:system:set enabledPreviewProviders 17 --value="OC\\Preview\\TXT" - ;;& - *"Movie"*) - nextcloud_occ config:system:set enabledPreviewProviders 18 --value="OC\\Preview\\Movie" - ;;& - *) - ;; - esac -fi - -# Set aspect ratio -nextcloud_occ config:app:set previewgenerator squareSizes --value="32 256" -nextcloud_occ config:app:set previewgenerator widthSizes --value="256 384" -nextcloud_occ config:app:set previewgenerator heightSizes --value="256" -nextcloud_occ config:system:set preview_max_x --value="2048" -nextcloud_occ config:system:set preview_max_y --value="2048" -nextcloud_occ config:system:set jpeg_quality --value="60" -nextcloud_occ config:system:set preview_max_memory --value="128" -nextcloud_occ config:app:set preview jpeg_quality --value="60" - -# Add crontab for www-data -if ! crontab -u www-data -l | grep -q 'preview:pre-generate' -then - print_text_in_color "$ICyan" "Adding crontab for $SCRIPT_NAME" - crontab -u www-data -l | { cat; echo "*/10 * * * * php -f $NCPATH/occ preview:pre-generate >> $VMLOGS/previewgenerator.log"; } | crontab -u www-data - - touch "$VMLOGS"/previewgenerator.log - chown www-data:www-data "$VMLOGS"/previewgenerator.log -fi - -msg_box "In the last step you can define a specific Nextcloud user for \ -which will be the user that runs the Preview Generation. - -The default behavior (just hit [ENTER]) is to run with the \ -system user 'www-data' which will generate previews for all users. - -If you on the other hand choose to use a specific user, previews will ONLY be generated for that specific user." - -if ! yesno_box_no "Do you want to choose a specific Nextcloud user to generate previews?" -then - print_text_in_color "$ICyan" "Using www-data (all Nextcloud users) for generating previews..." - - # Pre generate everything - nextcloud_occ preview:generate-all -else - while : - do - PREVIEW_USER=$(input_box "Enter the Nextcloud user for \ -which you want to run the Preview Generation (as a scheduled task)") - if [ -z "$(nextcloud_occ user:list | grep "$PREVIEW_USER" | awk '{print $3}')" ] - then - msg_box "It seems like the user you entered ($PREVIEW_USER) doesn't exist, please try again." - else - break - fi - done - - # Pre generate everything - nextcloud_occ preview:generate-all "$PREVIEW_USER" -fi - -msg_box "Previewgenerator was successfully installed." +run_script APPS imaginary diff --git a/lib.sh b/lib.sh index d3eb7010..a55a75eb 100644 --- a/lib.sh +++ b/lib.sh @@ -70,7 +70,7 @@ INTERNET_DNS="9.9.9.9" # Default Quad9 DNS servers, overwritten by the systemd global DNS defined servers, if set DNS1="9.9.9.9" DNS2="149.112.112.112" -NONO_PORTS=(22 25 53 80 443 1024 3012 3306 5178 5179 5432 7867 7983 8983 10000 8081 8443 9443) +NONO_PORTS=(22 25 53 80 443 1024 3012 3306 5178 5179 5432 7867 7983 8983 10000 8081 8443 9443 9000 9980) use_global_systemd_dns() { if [ -f "/etc/systemd/resolved.conf" ] then @@ -1654,7 +1654,7 @@ is_image_present() { } # Check if old docker exists -# FULL NAME e.g. ark74/nc_fts or containrrr/watchtower or collabora/code +# FULL NAME e.g. ark74/nc_fts or containrrr/watchtower or collabora/code or 'nextcloud/aio-imaginary' does_this_docker_exist() { is_docker_running && is_image_present "$1"; } @@ -1691,30 +1691,33 @@ print_text_in_color "$ICyan" "Checking if there are any old images and removing DOCKERPS=$(docker ps -a | grep -v "$1" | awk 'NR>1 {print $1}') if [ "$DOCKERPS" != "" ] then - msg_box "Removing old Docker instance(s)... ($DOCKERPS) - -Please note that we will not remove $1 ($2). - -You will be given the option to abort when you hit OK." - any_key "Press any key to continue. Press CTRL+C to abort" - docker stop "$(docker ps -a | grep -v "$1" | awk 'NR>1 {print $1}')" - docker container prune -f - docker image prune -a -f - docker volume prune -f + if yesno_box_yes "Do you want to remove old Docker instance(s)... ($DOCKERPS)? Please note that we will not remove $1 ($2)." + then + docker stop "$(docker ps -a | grep -v "$1" | awk 'NR>1 {print $1}')" + docker container prune -f + docker image prune -a -f + docker volume prune -f + else + msg_box "OK, this script will now exit, but there's still leftovers to cleanup. You can run it again at any time." + exit + fi fi } # Remove selected Docker image -# docker_prune_this 'collabora/code' 'onlyoffice/documentserver' 'ark74/nc_fts' +# docker_prune_this 'collabora/code' 'onlyoffice/documentserver' 'ark74/nc_fts' 'nextcloud/aio-imaginary' docker_prune_this() { if does_this_docker_exist "$1" then - msg_box "Removing old Docker image: $1 -You will be given the option to abort when you hit OK." - any_key "Press any key to continue. Press CTRL+C to abort" - docker stop "$(docker container ls -a | grep "$1" | awk '{print $1}' | tail -1)" - docker rm "$(docker container ls -a | grep "$1" | awk '{print $1}' | tail -1)" --volumes - docker image prune -a -f + if yesno_box_yes "Do you want to remove $1?" + then + docker stop "$(docker container ls -a | grep "$1" | awk '{print $1}' | tail -1)" + docker rm "$(docker container ls -a | grep "$1" | awk '{print $1}' | tail -1)" --volumes + docker image prune -a -f + else + msg_box "OK, this script will now exit, but there's still leftovers to cleanup. You can run it again at any time." + exit + fi fi } diff --git a/menu/additional_apps.sh b/menu/additional_apps.sh index b032cdd6..ddb603f2 100644 --- a/menu/additional_apps.sh +++ b/menu/additional_apps.sh @@ -42,9 +42,10 @@ $CHECKLIST_GUIDE\n\n$RUN_LATER_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \ "Bitwarden" "(External password manager)" OFF \ "Fail2ban " "(Extra Bruteforce protection)" "$STARTUP_SWITCH" \ "Recognize" "(Use [local] AI on your photos in Nextcloud)" OFF \ -"PreviewGenerator" "(Pre-generate previews for Nextcloud)" OFF \ +"Imaginary" "(Generate image previews for Nextcloud) [4GB RAM + 4 CPU]" "$STARTUP_SWITCH" \ "Webmin" "(Server GUI like Cpanel)" OFF \ -"Talk" "(Video calls and chat for Nextcloud)" "$STARTUP_SWITCH" \ +"Talk" "(Video calls and chat for Nextcloud - requires port 3478)" "$STARTUP_SWITCH" \ +"SMB-mount" "(Mount SMB-shares from your local network)" OFF \ "Adminer" "(PostgreSQL GUI)" OFF \ "LDAP" "(Windows Active directory for Nextcloud)" OFF \ "Notify Push" "(High Performance Files Backend for Nextcloud)" OFF \ @@ -56,7 +57,6 @@ $CHECKLIST_GUIDE\n\n$RUN_LATER_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \ "Pico CMS" "(Lightweight CMS integration in Nextcloud)" OFF \ "Whiteboard" "(Whiteboard for Nextcloud)" OFF \ "Extract" "(Archive extraction for Nextcloud)" OFF \ -"SMB-mount" "(Mount SMB-shares from your local network)" OFF \ "PDF Annotations" "(Annotate PDF files in Nextcloud)" OFF 3>&1 1>&2 2>&3) case "$choice" in @@ -104,8 +104,8 @@ case "$choice" in print_text_in_color "$ICyan" "Downloading the Pico CMS script..." run_script APP pico_cms ;;& - *"PreviewGenerator"*) - print_text_in_color "$ICyan" "Downloading the PreviewGenerator script..." + *"Imaginary"*) + print_text_in_color "$ICyan" "Downloading the Imaginary script..." run_script APP previewgenerator ;;& *"Notify Push"*) diff --git a/nextcloud_update.sh b/nextcloud_update.sh index f7325399..91065dba 100644 --- a/nextcloud_update.sh +++ b/nextcloud_update.sh @@ -625,6 +625,8 @@ If you need help, please get support here: https://shop.hanssonit.se/product/pre docker-compose_update 'fts_os-node' 'Full Text Search' "$OPNSDIR" # Plex docker_update_specific 'plex' "Plex Media Server" + # Imaginary + docker_update_specific 'imaginary' "Imaginary" fi # Fix Collabora change too coolwsd diff --git a/old/previewgenerator.sh b/old/previewgenerator.sh new file mode 100644 index 00000000..6d06ec7e --- /dev/null +++ b/old/previewgenerator.sh @@ -0,0 +1,302 @@ +#!/bin/bash + +# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/ + +true +SCRIPT_NAME="Preview Generator" +SCRIPT_EXPLAINER="This script will install the Preview Generator. +It can speedup the loading of previews in Nextcloud a lot." +# shellcheck source=lib.sh +source /var/scripts/fetch_lib.sh + +# Check for errors + debug code and abort if something isn't right +# 1 = ON +# 0 = OFF +DEBUG=0 +debug_mode + +# Check if root +root_check + +# PHP 7.x is needed +if is_this_installed php5.6-common || is_this_installed php5.5-common +then + msg_box "At least PHP 7.X is required, please upgrade your PHP version: \ +https://shop.hanssonit.se/product/upgrade-php-version-including-dependencies/" + exit +fi + +# Encryption may not be enabled +if is_app_enabled encryption || is_app_enabled end_to_end_encryption +then + msg_box "It seems like you have encryption enabled which is unsupported when using the Preview Generator" + exit +fi + +# Check if previewgenerator is already installed +if ! is_app_installed previewgenerator +then + # Ask for installing + install_popup "$SCRIPT_NAME" +else + # Ask for removal or reinstallation + reinstall_remove_menu "$SCRIPT_NAME" + # Removal + nextcloud_occ app:remove previewgenerator + # reset the preview formats + nextcloud_occ_no_check config:system:delete "enabledPreviewProviders" + nextcloud_occ config:system:delete preview_max_x + nextcloud_occ config:system:delete preview_max_y + nextcloud_occ config:system:delete jpeg_quality + nextcloud_occ config:system:delete preview_max_memory + nextcloud_occ config:system:delete enable_previews + # reset the cronjob + crontab -u www-data -l | grep -v 'preview:pre-generate' | crontab -u www-data - + # Remove apps + APPS=(php-imagick libmagickcore-6.q16-3-extra imagemagick-6.q16-extra) + for app in "${APPS[@]}" + do + if is_this_installed "$app" + then + apt-get purge "$app" -y + fi + done + if is_this_installed ffmpeg && ! is_app_installed integration_whiteboard + then + apt-get purge ffmpeg -y + fi + apt-get autoremove -y + rm -rf /etc/ImageMagick-6 + if yesno_box_no "Do you want to remove all previews that were generated until now? +This will most likely clear a lot of space but your server will need to re-generate the previews \ +if you should opt to re-enable previews again." + then + countdown "Removing the preview folder. This can take a while..." "5" + rm -rfv "$NCDATA"/appdata_*/preview + print_text_in_color "$ICyan" "Scanning Nextclouds appdata directory after removing all previews. \ +This can take a while..." + nextcloud_occ files:scan-app-data -vvv + msg_box "All previews were successfully removed." + fi + # Show successful uninstall if applicable + removal_popup "$SCRIPT_NAME" +fi + +# Install preview generator +install_and_enable_app previewgenerator + +# check if the previewgenerator is installed and enabled +if is_app_enabled previewgenerator +then + # enable previews + nextcloud_occ config:system:set enable_previews --value=true --type=boolean + + # install needed dependency for movies + install_if_not ffmpeg +else + exit +fi + +msg_box "In the next step you can choose to install a package called imagick \ +to speed up the generation of previews and add support for more filetypes. + +The currently supported filetypes are: +* PNG +* JPEG +* GIF +* BMP +* MarkDown +* MP3 +* TXT +* Movie +* Photoshop (needs imagick) +* SVG (needs imagick) +* TIFF (needs imagick)" + +msg_box "IMPORTANT NOTE!! + +Imagick will put your server at risk as it's is known to have several flaws. +You can check this issue to understand why: https://github.com/nextcloud/vm/issues/743 + +Please note: If you choose not to install imagick, it will get removed now." +if yesno_box_no "Do you want to install imagick?" +then + check_php + # Install imagick + install_if_not php"$PHPVER"-imagick + if version 22.04 "$DISTRO" 22.04.10 + then + install_if_not libmagickcore-6.q16-6-extra + elif version 20.04 "$DISTRO" 20.04.10 + then + install_if_not libmagickcore-6.q16-3-extra + fi + # Memory tuning + sed -i 's|policy domain="resource" name="memory" value=.*|policy domain="resource" name="memory" value="512MiB"|g' /etc/ImageMagick-6/policy.xml + sed -i 's|policy domain="resource" name="map" value=.*|policy domain="resource" name="map" value="1024MiB"|g' /etc/ImageMagick-6/policy.xml + sed -i 's|policy domain="resource" name="area" value=.*|policy domain="resource" name="area" value="256MiB"|g' /etc/ImageMagick-6/policy.xml + sed -i 's|policy domain="resource" name="disk" value=.*|policy domain="resource" name="disk" value="8GiB"|g' /etc/ImageMagick-6/policy.xml + + # Choose file formats fo the case when imagick is installed. + # for additional previews please look at the Nextcloud documentation. But these probably won't work. + choice=$(whiptail --title "$TITLE - Choose file formats" --checklist \ +"Now you can choose for which file formats you would like to generate previews for +$CHECKLIST_GUIDE\n\n$RUN_LATER_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \ +"PNG" "" ON \ +"JPEG" "" ON \ +"GIF" "" ON \ +"BMP" "" ON \ +"MarkDown" "" ON \ +"MP3" "" ON \ +"TXT" "" ON \ +"Movie" "" ON \ +"Photoshop" "" ON \ +"SVG" "" ON \ +"TIFF" "" ON 3>&1 1>&2 2>&3) + + case "$choice" in + *"PNG"*) + nextcloud_occ config:system:set enabledPreviewProviders 0 --value="OC\\Preview\\PNG" + ;;& + *"JPEG"*) + nextcloud_occ config:system:set enabledPreviewProviders 1 --value="OC\\Preview\\JPEG" + ;;& + *"GIF"*) + nextcloud_occ config:system:set enabledPreviewProviders 2 --value="OC\\Preview\\GIF" + ;;& + *"BMP"*) + nextcloud_occ config:system:set enabledPreviewProviders 3 --value="OC\\Preview\\BMP" + ;;& + *"MarkDown"*) + nextcloud_occ config:system:set enabledPreviewProviders 4 --value="OC\\Preview\\MarkDown" + ;;& + *"MP3"*) + nextcloud_occ config:system:set enabledPreviewProviders 5 --value="OC\\Preview\\MP3" + ;;& + *"TXT"*) + nextcloud_occ config:system:set enabledPreviewProviders 6 --value="OC\\Preview\\TXT" + ;;& + *"Movie"*) + nextcloud_occ config:system:set enabledPreviewProviders 7 --value="OC\\Preview\\Movie" + ;;& + *"Photoshop"*) + nextcloud_occ config:system:set enabledPreviewProviders 8 --value="OC\\Preview\\Photoshop" + ;;& + *"SVG"*) + nextcloud_occ config:system:set enabledPreviewProviders 9 --value="OC\\Preview\\SVG" + ;;& + *"TIFF"*) + nextcloud_occ config:system:set enabledPreviewProviders 10 --value="OC\\Preview\\TIFF" + ;;& + *) + ;; + esac +else + # check if imagick is installed and remove it + if is_this_installed php-imagick + then + apt-get purge php-imagick -y + elif is_this_installed php"$PHPVER"-imagick + then + apt-get purge php"$PHPVER"-imagick -y + fi + # check if libmagickcore is installed and remove it + if is_this_installed libmagickcore-6.q16-3-extra + then + apt-get purge libmagickcore-6.q16-3-extra -y + fi + # Choose file formats fo the case when imagick is not installed. + # for additional previews please look at the Nextcloud documentation. But these probably won't work. + choice=$(whiptail --title "$TITLE - Choose file formats" --checklist \ +"Now you can choose for which file formats you would like to generate previews for +$CHECKLIST_GUIDE\n\n$RUN_LATER_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \ +"PNG" "" ON \ +"JPEG" "" ON \ +"GIF" "" ON \ +"BMP" "" ON \ +"MarkDown" "" ON \ +"MP3" "" ON \ +"TXT" "" ON \ +"Movie" "" ON 3>&1 1>&2 2>&3) + + case "$choice" in + *"PNG"*) + nextcloud_occ config:system:set enabledPreviewProviders 11 --value="OC\\Preview\\PNG" + ;;& + *"JPEG"*) + nextcloud_occ config:system:set enabledPreviewProviders 12 --value="OC\\Preview\\JPEG" + ;;& + *"GIF"*) + nextcloud_occ config:system:set enabledPreviewProviders 13 --value="OC\\Preview\\GIF" + ;;& + *"BMP"*) + nextcloud_occ config:system:set enabledPreviewProviders 14 --value="OC\\Preview\\BMP" + ;;& + *"MarkDown"*) + nextcloud_occ config:system:set enabledPreviewProviders 15 --value="OC\\Preview\\MarkDown" + ;;& + *"MP3"*) + nextcloud_occ config:system:set enabledPreviewProviders 16 --value="OC\\Preview\\MP3" + ;;& + *"TXT"*) + nextcloud_occ config:system:set enabledPreviewProviders 17 --value="OC\\Preview\\TXT" + ;;& + *"Movie"*) + nextcloud_occ config:system:set enabledPreviewProviders 18 --value="OC\\Preview\\Movie" + ;;& + *) + ;; + esac +fi + +# Set aspect ratio +nextcloud_occ config:app:set previewgenerator squareSizes --value="32 256" +nextcloud_occ config:app:set previewgenerator widthSizes --value="256 384" +nextcloud_occ config:app:set previewgenerator heightSizes --value="256" +nextcloud_occ config:system:set preview_max_x --value="2048" +nextcloud_occ config:system:set preview_max_y --value="2048" +nextcloud_occ config:system:set jpeg_quality --value="60" +nextcloud_occ config:system:set preview_max_memory --value="128" +nextcloud_occ config:app:set preview jpeg_quality --value="60" + +# Add crontab for www-data +if ! crontab -u www-data -l | grep -q 'preview:pre-generate' +then + print_text_in_color "$ICyan" "Adding crontab for $SCRIPT_NAME" + crontab -u www-data -l | { cat; echo "*/10 * * * * php -f $NCPATH/occ preview:pre-generate >> $VMLOGS/previewgenerator.log"; } | crontab -u www-data - + touch "$VMLOGS"/previewgenerator.log + chown www-data:www-data "$VMLOGS"/previewgenerator.log +fi + +msg_box "In the last step you can define a specific Nextcloud user for \ +which will be the user that runs the Preview Generation. + +The default behavior (just hit [ENTER]) is to run with the \ +system user 'www-data' which will generate previews for all users. + +If you on the other hand choose to use a specific user, previews will ONLY be generated for that specific user." + +if ! yesno_box_no "Do you want to choose a specific Nextcloud user to generate previews?" +then + print_text_in_color "$ICyan" "Using www-data (all Nextcloud users) for generating previews..." + + # Pre generate everything + nextcloud_occ preview:generate-all +else + while : + do + PREVIEW_USER=$(input_box "Enter the Nextcloud user for \ +which you want to run the Preview Generation (as a scheduled task)") + if [ -z "$(nextcloud_occ user:list | grep "$PREVIEW_USER" | awk '{print $3}')" ] + then + msg_box "It seems like the user you entered ($PREVIEW_USER) doesn't exist, please try again." + else + break + fi + done + + # Pre generate everything + nextcloud_occ preview:generate-all "$PREVIEW_USER" +fi + +msg_box "Previewgenerator was successfully installed." From 234f1e6985efa1dbfbb8fa72d52f8a0f6bb5cd88 Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Sat, 1 Apr 2023 23:14:54 +0200 Subject: [PATCH 22/34] fix menu for apps (#2466) --- apps/previewgenerator.sh | 2 ++ menu/additional_apps.sh | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/previewgenerator.sh b/apps/previewgenerator.sh index 45cf437f..e7f8daa5 100644 --- a/apps/previewgenerator.sh +++ b/apps/previewgenerator.sh @@ -2,6 +2,8 @@ # T&M Hansson IT AB © - 2023, https://www.hanssonit.se/ +source /var/scripts/lib.sh + ####### TEMPORARY 2023-04-01 ####### run_script APPS imaginary diff --git a/menu/additional_apps.sh b/menu/additional_apps.sh index ddb603f2..42afd98d 100644 --- a/menu/additional_apps.sh +++ b/menu/additional_apps.sh @@ -106,7 +106,7 @@ case "$choice" in ;;& *"Imaginary"*) print_text_in_color "$ICyan" "Downloading the Imaginary script..." - run_script APP previewgenerator + run_script APP imaginary ;;& *"Notify Push"*) print_text_in_color "$ICyan" "Downloading the Notify Push script..." From fe9b3ffdc27559821be6c093a9c0f9fa2273bd85 Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Sat, 1 Apr 2023 23:18:05 +0200 Subject: [PATCH 23/34] typo Signed-off-by: Daniel Hansson --- apps/previewgenerator.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/previewgenerator.sh b/apps/previewgenerator.sh index e7f8daa5..cd08c629 100644 --- a/apps/previewgenerator.sh +++ b/apps/previewgenerator.sh @@ -6,4 +6,4 @@ source /var/scripts/lib.sh ####### TEMPORARY 2023-04-01 ####### -run_script APPS imaginary +run_script APP imaginary From d748335f1abd691f733472b62b51b191bed2473c Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Sat, 1 Apr 2023 23:29:36 +0200 Subject: [PATCH 24/34] Fix SC Signed-off-by: Daniel Hansson --- apps/previewgenerator.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/previewgenerator.sh b/apps/previewgenerator.sh index cd08c629..901ba26b 100644 --- a/apps/previewgenerator.sh +++ b/apps/previewgenerator.sh @@ -1,8 +1,13 @@ #!/bin/bash # T&M Hansson IT AB © - 2023, https://www.hanssonit.se/ +# GNU General Public License v3.0 +# https://github.com/nextcloud/vm/blob/master/LICENSE -source /var/scripts/lib.sh +true +SCRIPT_NAME="Fix LEGACY Preview Generator" +# shellcheck source=lib.sh +source <(curl -sL https://raw.githubusercontent.com/nextcloud/vm/master/lib.sh) ####### TEMPORARY 2023-04-01 ####### From c57ab7eb9df7c8701bee45c1025bfe9da5df7be7 Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Sat, 1 Apr 2023 23:33:25 +0200 Subject: [PATCH 25/34] add more nono ports Signed-off-by: Daniel Hansson --- lib.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib.sh b/lib.sh index a55a75eb..421d0936 100644 --- a/lib.sh +++ b/lib.sh @@ -70,7 +70,8 @@ INTERNET_DNS="9.9.9.9" # Default Quad9 DNS servers, overwritten by the systemd global DNS defined servers, if set DNS1="9.9.9.9" DNS2="149.112.112.112" -NONO_PORTS=(22 25 53 80 443 1024 3012 3306 5178 5179 5432 7867 7983 8983 10000 8081 8443 9443 9000 9980) +NONO_PORTS=(22 25 53 80 443 1024 3012 3306 5178 5179 5432 7867 7983 8983 10000 8081 8443 9443 9000 9980 9090 9200 9600) +# 9000 9980 9090 9200 9600 are local docker ports, don't remember if they are needed here or not. use_global_systemd_dns() { if [ -f "/etc/systemd/resolved.conf" ] then From 197e233b1c62ca8bc5663620347e7a6a23cdb47b Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Sun, 2 Apr 2023 01:52:46 +0200 Subject: [PATCH 26/34] Change Updatenotification (#2461) --- menu/main_menu.sh | 13 ++++++++----- nextcloud_update.sh | 2 ++ static/updatenotification.sh | 12 ++++++------ 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/menu/main_menu.sh b/menu/main_menu.sh index 960b2107..e80c9ebe 100644 --- a/menu/main_menu.sh +++ b/menu/main_menu.sh @@ -57,12 +57,15 @@ do_the_update() { msg_box "Since you have automated updates enabled with the reboot option set, we won't run update script a second time to the latest version automatically. To upgrade to the latest version, please run: 'sudo bash $SCRIPTS/update.sh' from your CLI." else - if yesno_box_yes "We will now run the update script a second time to update to the latest major version ($NCVERSION). Do you want to continue?" + if version_gt "$NCVERSION" "$CURRENTVERSION" then - # Check if it's an unsupported major version (will exit if it is) - major_versions_unsupported - # Do the upgrade if it's not - bash "$SCRIPTS"/update.sh + if yesno_box_yes "We will now run the update script a second time to update to the latest major version ($NCVERSION). Do you want to continue?" + then + # Check if it's an unsupported major version (will exit if it is) + major_versions_unsupported + # Do the upgrade if it's not + bash "$SCRIPTS"/update.sh + fi fi fi fi diff --git a/nextcloud_update.sh b/nextcloud_update.sh index 91065dba..c1203cdb 100644 --- a/nextcloud_update.sh +++ b/nextcloud_update.sh @@ -794,6 +794,8 @@ if [ -f "$SCRIPTS"/updatenotification.sh ] then download_script STATIC updatenotification chmod +x "$SCRIPTS"/updatenotification.sh + crontab -u root -l | grep -v "$SCRIPTS/updatenotification.sh" | crontab -u root - + crontab -u root -l | { cat; echo "59 $AUT_UPDATES_TIME * * * $SCRIPTS/updatenotification.sh > /dev/null 2>&1"; } | crontab -u root - fi ############# Don't upgrade to specific version diff --git a/static/updatenotification.sh b/static/updatenotification.sh index c762b565..22daad92 100644 --- a/static/updatenotification.sh +++ b/static/updatenotification.sh @@ -51,18 +51,18 @@ if [ "$NCVERSION" == "$NCMIN" ] && version_gt "$NCMIN" "$REPORTEDMIN" && version then sed -i "s|^REPORTEDMAJ.*|REPORTEDMAJ=$NCVERSION|" $SCRIPTS/updatenotification.sh sed -i "s|^REPORTEDMIN.*|REPORTEDMIN=$NCMIN|" $SCRIPTS/updatenotification.sh - if crontab -l -u root | grep -q $SCRIPTS/update.sh + if crontab -l -u root | grep -q $SCRIPTS/menu.sh then notify_admin_gui \ "New minor Nextcloud Update!" \ "Nextcloud $NCMIN just became available. Since you are running Automatic \ -Updates on Saturdays at $AUT_UPDATES_TIME:00, you don't need to bother about updating \ +Updates every month on Saturdays at $AUT_UPDATES_TIME:00, you don't need to bother about updating \ the server to minor Nextcloud versions manually, as that's already taken care of." else notify_admin_gui \ "New minor Nextcloud Update!" \ "Nextcloud $NCMIN just became available. Please run 'sudo bash \ -/var/scripts/update.sh minor' from your CLI to update your server to Nextcloud $NCMIN." +/var/scripts/menu.sh' --> Update Nextcloud from your CLI to update your server to Nextcloud $NCMIN." fi exit fi @@ -70,7 +70,7 @@ fi if version_gt "$NCMIN" "$REPORTEDMIN" && version_gt "$NCMIN" "$CURRENTVERSION" then sed -i "s|^REPORTEDMIN.*|REPORTEDMIN=$NCMIN|" $SCRIPTS/updatenotification.sh - if crontab -l -u root | grep -q $SCRIPTS/update.sh + if crontab -l -u root | grep -q $SCRIPTS/menu.sh then notify_admin_gui \ "New minor Nextcloud Update!" \ @@ -81,7 +81,7 @@ the server to minor Nextcloud versions manually, as that's already taken care of notify_admin_gui \ "New minor Nextcloud Update!" \ "Nextcloud $NCMIN just became available. Please run 'sudo bash \ -/var/scripts/update.sh minor' from your CLI to update your server to Nextcloud $NCMIN." +/var/scripts/menu.sh' --> Update Nextcloud from your CLI to update your server to Nextcloud $NCMIN." fi fi @@ -91,7 +91,7 @@ then notify_admin_gui \ "New major Nextcloud Update!" \ "Nextcloud $NCVERSION just became available. Please run 'sudo bash \ -/var/scripts/update.sh' from your CLI to update your server to Nextcloud $NCVERSION. \ +/var/scripts/menu.sh' --> Update Nextcloud from your CLI to update your server to Nextcloud $NCVERSION. \ Before updating though, you should visit https://your-nc-domain/settings/admin/overview \ and make sure that all apps are compatible with the new version. And please never forget to \ create a backup and/or snapshot before updating!" From 8f797d5f745bbcc9f30f21fc482320cac6d5c42e Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Sun, 2 Apr 2023 02:46:46 +0200 Subject: [PATCH 27/34] remove imagick even if it's held Signed-off-by: Daniel Hansson --- apps/imaginary.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/imaginary.sh b/apps/imaginary.sh index ac73d162..717bc33d 100644 --- a/apps/imaginary.sh +++ b/apps/imaginary.sh @@ -64,19 +64,20 @@ fi # Remove everything that is related to previewgenerator if is_app_enabled previewgenerator then - if yesno_box_yes "We noticed that you have Preview Generator enabled. Imagniary replaces this, and the old app Preview Generator is now legacy. We recommend you to remove it. Do you want to do that?" + if yesno_box_yes "We noticed that you have Preview Generator enabled. Imagniary replaces this, and the old app Preview Generator is now legacy.\nWe recommend you to remove it. Do you want to do that?" then # Remove the app nextcloud_occ app:remove previewgenerator # Reset the cronjob crontab -u www-data -l | grep -v 'preview:pre-generate' | crontab -u www-data - - # Remove apps - APPS=(php-imagick php"$PHPVER"-imagick libmagickcore-6.q16-3-extra imagemagick-6.q16-extra) - for app in "${APPS[@]}" + # Remove dependecies + DEPENDENCY=(php-imagick php"$PHPVER"-imagick libmagickcore-6.q16-3-extra imagemagick-6.q16-extra) + for installeddependency in "${DEPENDENCY[@]}" do - if is_this_installed "$app" + if is_this_installed "$installeddependency" then - apt-get purge "$app" -y + # --allow-change-held-packages in case running on Ondrejs PPA and it's held + apt-get purge "$installeddependency" -y --allow-change-held-packages fi done # Remove custom config From 949872cfca262f1c0b3820cfc933f4496fe47e4e Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Sun, 2 Apr 2023 17:19:51 +0200 Subject: [PATCH 28/34] Install Imaginary by default (#2467) --- menu/additional_apps.sh | 2 +- nextcloud_install_production.sh | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/menu/additional_apps.sh b/menu/additional_apps.sh index 42afd98d..29c1b2e3 100644 --- a/menu/additional_apps.sh +++ b/menu/additional_apps.sh @@ -42,7 +42,7 @@ $CHECKLIST_GUIDE\n\n$RUN_LATER_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \ "Bitwarden" "(External password manager)" OFF \ "Fail2ban " "(Extra Bruteforce protection)" "$STARTUP_SWITCH" \ "Recognize" "(Use [local] AI on your photos in Nextcloud)" OFF \ -"Imaginary" "(Generate image previews for Nextcloud) [4GB RAM + 4 CPU]" "$STARTUP_SWITCH" \ +"Imaginary" "(Generate image previews for Nextcloud) [4GB RAM + 4 CPU]" "OFF" \ "Webmin" "(Server GUI like Cpanel)" OFF \ "Talk" "(Video calls and chat for Nextcloud - requires port 3478)" "$STARTUP_SWITCH" \ "SMB-mount" "(Mount SMB-shares from your local network)" OFF \ diff --git a/nextcloud_install_production.sh b/nextcloud_install_production.sh index 36e0000d..15e32a4f 100644 --- a/nextcloud_install_production.sh +++ b/nextcloud_install_production.sh @@ -920,6 +920,7 @@ $CHECKLIST_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \ "Deck" "" ON \ "Collectives" "" ON \ "Suspicios Login detetion" "" ON \ +"Imaginary" "" ON \ "IssueTemplate" "" OFF \ "Group-Folders" "" OFF 3>&1 1>&2 2>&3) fi @@ -964,6 +965,9 @@ case "$choice" in *"Suspicios Login detetion"*) install_and_enable_app suspicios_login ;;& + *"Imaginary"*) + run_script APP imaginary + ;;& *"Group-Folders"*) install_and_enable_app groupfolders ;;& From 123e1516ecc33db6e492aa9fbf9d8f94017f12b4 Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Sun, 2 Apr 2023 17:28:55 +0200 Subject: [PATCH 29/34] default to 2 cpu cores since that's what the VM is released with Signed-off-by: Daniel Hansson --- apps/imaginary.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/imaginary.sh b/apps/imaginary.sh index 717bc33d..06995f33 100644 --- a/apps/imaginary.sh +++ b/apps/imaginary.sh @@ -22,7 +22,7 @@ root_check # Check recources ram_check 4 -cpu_check 4 +cpu_check 2 # Compatible with NC24 and above lowest_compatible_nc 26 @@ -121,12 +121,12 @@ install_if_not php"$PHPVER"-sysvsem install_if_not ffmpeg # Set default limits -# https://github.com/nextcloud/server/pull/18210/files#diff-3bbe91e1f85eec5dbd0031642dfb0ad6749b550fc3b94af7aa68a98210b78738R1121 -nextcloud_occ config:system:set preview_concurrency_all --value="8" -nextcloud_occ config:system:set preview_concurrency_new --value="4" +# https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#previews +nextcloud_occ config:system:set preview_concurrency_all --value="4" +nextcloud_occ config:system:set preview_concurrency_new --value="2" # Set providers (https://github.com/nextcloud/server/blob/master/lib/private/Preview/Imaginary.php#L60) -# https://github.com/nextcloud/vm/pull/2464#discussion_r1155074227 +# https://github.com/nextcloud/vm/issues/2465 nextcloud_occ config:system:set enabledPreviewProviders 0 --value="OC\\Preview\\Imaginary" nextcloud_occ config:system:set enabledPreviewProviders 1 --value="OC\\Preview\\Image" nextcloud_occ config:system:set enabledPreviewProviders 2 --value="OC\\Preview\\MarkDown" From 618509895caa893aa79e7bf70cab77569efaad85 Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Sun, 2 Apr 2023 18:27:00 +0200 Subject: [PATCH 30/34] Calculate CPU cores It's already done in Nextcloud core code, but we want another default cc @szaimen Signed-off-by: Daniel Hansson --- apps/imaginary.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/imaginary.sh b/apps/imaginary.sh index 06995f33..cafd351d 100644 --- a/apps/imaginary.sh +++ b/apps/imaginary.sh @@ -120,10 +120,16 @@ check_php install_if_not php"$PHPVER"-sysvsem install_if_not ffmpeg -# Set default limits +# Calculate CPU cores # https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#previews -nextcloud_occ config:system:set preview_concurrency_all --value="4" -nextcloud_occ config:system:set preview_concurrency_new --value="2" +if which nproc >/dev/null 2>&1 +then + nextcloud_occ config:system:set preview_concurrency_new --value="$(nproc)" + nextcloud_occ config:system:set preview_concurrency_all --value="$(expr $(nproc) '*' 2)" +else + nextcloud_occ config:system:set preview_concurrency_new --value="2" + nextcloud_occ config:system:set preview_concurrency_all --value="4" +fi # Set providers (https://github.com/nextcloud/server/blob/master/lib/private/Preview/Imaginary.php#L60) # https://github.com/nextcloud/vm/issues/2465 From fc88cc8f95d32b42c92d03a9ed6b62adc325c65e Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Sun, 2 Apr 2023 18:35:47 +0200 Subject: [PATCH 31/34] update CPU cores during first setup + fix SC (#2468) --- apps/imaginary.sh | 2 +- nextcloud-startup-script.sh | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/imaginary.sh b/apps/imaginary.sh index cafd351d..4f8d8db3 100644 --- a/apps/imaginary.sh +++ b/apps/imaginary.sh @@ -125,7 +125,7 @@ install_if_not ffmpeg if which nproc >/dev/null 2>&1 then nextcloud_occ config:system:set preview_concurrency_new --value="$(nproc)" - nextcloud_occ config:system:set preview_concurrency_all --value="$(expr $(nproc) '*' 2)" + nextcloud_occ config:system:set preview_concurrency_all --value="$(($(nproc)*2))"" else nextcloud_occ config:system:set preview_concurrency_new --value="2" nextcloud_occ config:system:set preview_concurrency_all --value="4" diff --git a/nextcloud-startup-script.sh b/nextcloud-startup-script.sh index 6e399892..6bfbeff6 100644 --- a/nextcloud-startup-script.sh +++ b/nextcloud-startup-script.sh @@ -286,6 +286,7 @@ It will also do the following: - Set correct Rewriterules for Nextcloud - Copy content from .htaccess to .user.ini (because we use php-fpm) - Add additional options if you choose them +- Set correct CPU cores for Imaginary - And more..." msg_box "PLEASE NOTE: @@ -480,6 +481,16 @@ else calculate_php_fpm fi +# Set correct amount of CPUs for Imaginary +if which nproc >/dev/null 2>&1 +then + nextcloud_occ config:system:set preview_concurrency_new --value="$(nproc)" + nextcloud_occ config:system:set preview_concurrency_all --value="$(($(nproc)*2))" +else + nextcloud_occ config:system:set preview_concurrency_new --value="2" + nextcloud_occ config:system:set preview_concurrency_all --value="4" +fi + # Add temporary fix if needed if network_ok then From 905765a44c9e0ba99bf7fd29e57b47a9e0ac6102 Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Sun, 2 Apr 2023 20:12:35 +0200 Subject: [PATCH 32/34] fix SC Signed-off-by: Daniel Hansson --- apps/imaginary.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/imaginary.sh b/apps/imaginary.sh index 4f8d8db3..1c94f3db 100644 --- a/apps/imaginary.sh +++ b/apps/imaginary.sh @@ -125,7 +125,7 @@ install_if_not ffmpeg if which nproc >/dev/null 2>&1 then nextcloud_occ config:system:set preview_concurrency_new --value="$(nproc)" - nextcloud_occ config:system:set preview_concurrency_all --value="$(($(nproc)*2))"" + nextcloud_occ config:system:set preview_concurrency_all --value="$(("$(nproc)"*2))" else nextcloud_occ config:system:set preview_concurrency_new --value="2" nextcloud_occ config:system:set preview_concurrency_all --value="4" From c08b28e7a44dbac6dd94d12534219de0a88c20d1 Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Sun, 2 Apr 2023 20:17:37 +0200 Subject: [PATCH 33/34] Hide output from apt-hold Signed-off-by: Daniel Hansson --- nextcloud_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nextcloud_update.sh b/nextcloud_update.sh index c1203cdb..5b049186 100644 --- a/nextcloud_update.sh +++ b/nextcloud_update.sh @@ -260,7 +260,7 @@ if apt-cache policy | grep "ondrej" >/dev/null 2>&1 then print_text_in_color "$ICyan" "Ondrejs PPA is installed. \ Holding PHP to avoid upgrading to a newer version without migration..." - apt-mark hold php* + apt-mark hold php* >/dev/null 2>&1 fi # Don't allow MySQL/MariaDB From 468665c7f2d7e1f3e47cf60a6e1ed186b7732dda Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Sun, 2 Apr 2023 20:36:57 +0200 Subject: [PATCH 34/34] wording Signed-off-by: Daniel Hansson --- apps/imaginary.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/imaginary.sh b/apps/imaginary.sh index 1c94f3db..cd8be0e8 100644 --- a/apps/imaginary.sh +++ b/apps/imaginary.sh @@ -36,7 +36,7 @@ else # Ask for removal or reinstallation reinstall_remove_menu "$SCRIPT_NAME" # Removal - if yesno_box_yes "Do you want to remove the Imaginary docker container and settings?" + if yesno_box_yes "Do you want to remove the Imaginary and all it's settings?" then # Remove docker container docker_prune_this 'nextcloud/aio-imaginary'