-
-
Notifications
You must be signed in to change notification settings - Fork 670
Add Imaginary Docker for previews #2464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
4bb587e
Create imaginary.sh
enoch85 ac1e56b
Add to NONO ports
enoch85 fde44ea
replace Imagick!
enoch85 146a25f
NC 24
enoch85 346a6d3
use a more updated image
enoch85 b07171e
add previewproviders
enoch85 7e9c0a4
fix spelling
enoch85 61c2a87
details!
enoch85 0accc0e
too tired now :sleeping:
enoch85 bc28731
only rebuild if previewgenerator was installed before
enoch85 fb6c37d
some more changes to Imaginary
enoch85 533584f
move to old
enoch85 9edf6c8
Create previewgenerator.sh
enoch85 62439d0
move to apps
enoch85 b2fa698
learn how to spell :)
enoch85 0b51e5a
change menu
enoch85 34ea2a7
typos
enoch85 10a37a6
update menu
enoch85 4633b15
more typos
enoch85 53f9cb9
cleanup testimage
enoch85 a87d2e3
improve docker prune
enoch85 475b9d8
update it!
enoch85 621deb5
change to docker run
enoch85 846517a
Merge branch 'master' into imaginary
enoch85 a796c74
only look for previews
enoch85 54b76d8
commit suggestion
enoch85 72fad48
SC
enoch85 332c6ab
remove custom config old
enoch85 2a3afba
add back providers and split preview generator uninstall
enoch85 b295dbb
tested and works!
enoch85 c6ddcac
commit suggestions
enoch85 4ecdd44
typo
enoch85 c804f9e
without this tha pp-data scan fails
enoch85 a66e6b7
fix preview removal
enoch85 8a7d2e8
remove more leftovers
enoch85 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
enoch85 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Check for errors + debug code and abort if something isn't right | ||
# 1 = ON | ||
# 0 = OFF | ||
DEBUG=0 | ||
enoch85 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 | ||
enoch85 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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. \ | ||
enoch85 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 | ||
enoch85 marked this conversation as resolved.
Show resolved
Hide resolved
enoch85 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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!" | ||
enoch85 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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" | ||
enoch85 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# 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" | ||
enoch85 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.