Skip to content

Commit 1d61047

Browse files
authored
Merge branch 'master' into desec-apps
2 parents 22551e6 + 468665c commit 1d61047

13 files changed

+626
-340
lines changed

addons/automatic_updates.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ true
66
SCRIPT_NAME="Automatic Updates"
77
# shellcheck source=lib.sh
88
source /var/scripts/fetch_lib.sh
9-
SCRIPT_EXPLAINER="This option will update your server every week on Saturdays at $AUT_UPDATES_TIME:00.
9+
SCRIPT_EXPLAINER="This option will update your server once every month on Saturdays at $AUT_UPDATES_TIME:00.
1010
The update will run the built in script '$SCRIPTS/update.sh' which will update both the server packages and Nextcloud itself.\n
1111
You can read more about it here: https://www.techandme.se/nextcloud-update-is-now-fully-automated/
1212
Please keep in mind that automatic updates might fail, which is why it's \
@@ -39,7 +39,7 @@ fi
3939

4040
# Install automatic updates
4141
mkdir -p "$VMLOGS"/updates
42-
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 -
42+
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 -
4343
if yesno_box_yes "Do you want to reboot your server after every update? *recommended*"
4444
then
4545
sed -i "s|exit|/sbin/shutdown -r +1|g" "$SCRIPTS"/update.sh

apps/imaginary.sh

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
#!/bin/bash
2+
3+
# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/
4+
# GNU General Public License v3.0
5+
# https://github.com/nextcloud/vm/blob/master/LICENSE
6+
7+
true
8+
SCRIPT_NAME="Imaginary Docker"
9+
SCRIPT_EXPLAINER="This script will install Imaginary which is a replacement for the less secure Imagick.
10+
It can speedup the loading of previews in Nextcloud a lot."
11+
# shellcheck source=lib.sh
12+
source /var/scripts/fetch_lib.sh
13+
14+
# Check for errors + debug code and abort if something isn't right
15+
# 1 = ON
16+
# 0 = OFF
17+
DEBUG=0
18+
debug_mode
19+
20+
# Check if root
21+
root_check
22+
23+
# Check recources
24+
ram_check 4
25+
cpu_check 2
26+
27+
# Compatible with NC24 and above
28+
lowest_compatible_nc 26
29+
30+
# Check if Imaginary is already installed
31+
if ! does_this_docker_exist nextcloud/aio-imaginary
32+
then
33+
# Ask for installing
34+
install_popup "$SCRIPT_NAME"
35+
else
36+
# Ask for removal or reinstallation
37+
reinstall_remove_menu "$SCRIPT_NAME"
38+
# Removal
39+
if yesno_box_yes "Do you want to remove the Imaginary and all it's settings?"
40+
then
41+
# Remove docker container
42+
docker_prune_this 'nextcloud/aio-imaginary'
43+
# reset the preview formats
44+
nextcloud_occ config:system:delete "preview_imaginary_url"
45+
nextcloud_occ config:system:delete "enabledPreviewProviders"
46+
nextcloud_occ config:system:delete "preview_max_x"
47+
nextcloud_occ config:system:delete "preview_max_y"
48+
nextcloud_occ config:system:delete "jpeg_quality"
49+
nextcloud_occ config:system:delete "preview_max_memory"
50+
nextcloud_occ config:system:delete "enable_previews"
51+
nextcloud_occ config:system:delete "preview_concurrency_new"
52+
nextcloud_occ config:system:delete "preview_concurrency_all"
53+
# Remove FFMPEG
54+
if is_this_installed ffmpeg && ! is_app_installed integration_whiteboard
55+
then
56+
apt-get purge ffmpeg -y
57+
apt-get autoremove -y
58+
fi
59+
# Show successful uninstall if applicable
60+
removal_popup "$SCRIPT_NAME"
61+
fi
62+
fi
63+
64+
# Remove everything that is related to previewgenerator
65+
if is_app_enabled previewgenerator
66+
then
67+
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?"
68+
then
69+
# Remove the app
70+
nextcloud_occ app:remove previewgenerator
71+
# Reset the cronjob
72+
crontab -u www-data -l | grep -v 'preview:pre-generate' | crontab -u www-data -
73+
# Remove dependecies
74+
DEPENDENCY=(php-imagick php"$PHPVER"-imagick libmagickcore-6.q16-3-extra imagemagick-6.q16-extra)
75+
for installeddependency in "${DEPENDENCY[@]}"
76+
do
77+
if is_this_installed "$installeddependency"
78+
then
79+
# --allow-change-held-packages in case running on Ondrejs PPA and it's held
80+
apt-get purge "$installeddependency" -y --allow-change-held-packages
81+
fi
82+
done
83+
# Remove custom config
84+
rm -rf /etc/ImageMagick-6
85+
# Remove previews
86+
if yesno_box_yes "Do you want to remove all previews that were generated until now?
87+
This will most likely clear a lot of space! Also, pre-generated previews are not needed anymore once Imaginary are installed."
88+
then
89+
countdown "Removing the preview folder. This can take a while..." "5"
90+
rm -rfv "$NCDATA"/appdata_*/preview/*
91+
print_text_in_color "$ICyan" "Scanning Nextclouds appdata directory after removing all previews. \
92+
This can take a while..."
93+
nextcloud_occ files:scan-app-data preview -vvv
94+
msg_box "All previews were successfully removed."
95+
fi
96+
# Remove log
97+
rm -f "$VMLOGS"/previewgenerator.log
98+
fi
99+
fi
100+
# Install Docker
101+
install_docker
102+
103+
# Pull and start
104+
docker pull nextcloud/aio-imaginary:latest
105+
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
106+
107+
# Test if imaginary is working
108+
countdown "Testing if it works in 3 sedonds" "3"
109+
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"
110+
then
111+
print_text_in_color "$IGreen" "imaginary seems to be working OK!"
112+
rm -f large.jpg
113+
else
114+
msg_box "Test failed, please report this to: $ISSUES"
115+
exit
116+
fi
117+
118+
# Install dependencies
119+
check_php
120+
install_if_not php"$PHPVER"-sysvsem
121+
install_if_not ffmpeg
122+
123+
# Calculate CPU cores
124+
# https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#previews
125+
if which nproc >/dev/null 2>&1
126+
then
127+
nextcloud_occ config:system:set preview_concurrency_new --value="$(nproc)"
128+
nextcloud_occ config:system:set preview_concurrency_all --value="$(("$(nproc)"*2))"
129+
else
130+
nextcloud_occ config:system:set preview_concurrency_new --value="2"
131+
nextcloud_occ config:system:set preview_concurrency_all --value="4"
132+
fi
133+
134+
# Set providers (https://github.com/nextcloud/server/blob/master/lib/private/Preview/Imaginary.php#L60)
135+
# https://github.com/nextcloud/vm/issues/2465
136+
nextcloud_occ config:system:set enabledPreviewProviders 0 --value="OC\\Preview\\Imaginary"
137+
nextcloud_occ config:system:set enabledPreviewProviders 1 --value="OC\\Preview\\Image"
138+
nextcloud_occ config:system:set enabledPreviewProviders 2 --value="OC\\Preview\\MarkDown"
139+
nextcloud_occ config:system:set enabledPreviewProviders 3 --value="OC\\Preview\\MP3"
140+
nextcloud_occ config:system:set enabledPreviewProviders 4 --value="OC\\Preview\\TXT"
141+
nextcloud_occ config:system:set enabledPreviewProviders 5 --value="OC\\Preview\\OpenDocument"
142+
nextcloud_occ config:system:set enabledPreviewProviders 6 --value="OC\\Preview\\Movie"
143+
nextcloud_occ config:system:set preview_imaginary_url --value="http://127.0.0.1:9000"
144+
145+
# Set general values
146+
nextcloud_occ config:system:set preview_max_x --value="2048"
147+
nextcloud_occ config:system:set preview_max_y --value="2048"
148+
nextcloud_occ config:system:set jpeg_quality --value="60"
149+
nextcloud_occ config:system:set preview_max_memory --value="256"
150+
151+
if docker logs imaginary
152+
then
153+
msg_box "Imaginary was successfully installed!"
154+
else
155+
msg_box "It seems that something is wrong. Please post the full installation output to $ISSUES"
156+
fi

apps/onlyoffice_docker.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ else
3030
# Remove config.php value set when install was successful
3131
nextcloud_occ config:system:delete allow_local_remote_servers
3232
nextcloud_occ config:system:delete onlyoffice
33+
nextcloud_occ config:system:delete onlyoffice jwt_secret
34+
nextcloud_occ config:system:delete onlyoffice jwt_header
3335
# Show successful uninstall if applicable
3436
removal_popup "$SCRIPT_NAME"
3537
fi
@@ -205,9 +207,12 @@ then
205207
# basic proxy settings
206208
ProxyRequests off
207209
208-
ProxyPassMatch (.*)(\/websocket)$ "ws://127.0.0.3:9090/\$1\$2"
209210
ProxyPass / "http://127.0.0.3:9090/"
210211
ProxyPassReverse / "http://127.0.0.3:9090/"
212+
RewriteEngine on
213+
RewriteCond %{HTTP:Upgrade} websocket [NC]
214+
RewriteCond %{HTTP:Connection} upgrade [NC]
215+
RewriteRule ^/?(.*) "ws://127.0.0.3:9090/" [P,L]
211216
212217
<Location />
213218
ProxyPassReverse /

0 commit comments

Comments
 (0)