Skip to content

Commit 22551e6

Browse files
authored
Merge branch 'master' into desec-apps
2 parents 839d9e0 + 743272b commit 22551e6

15 files changed

+365
-228
lines changed

addons/notify-crontab.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,13 @@ root_check
1616

1717
MOUNT_ID="$1"
1818

19-
# Add crontab for this external storage
20-
nextcloud_occ files_external:notify -v "$MOUNT_ID" >> "$VMLOGS"/files_inotify.log
19+
if nextcloud_occ files_external:list | grep "$MOUNT_ID"
20+
then
21+
# Start the iNotify for this external storage
22+
countdown "iNotify starts in 120 seconds" "120" >> "$VMLOGS"/files_inotify.log
23+
nextcloud_occ files_external:notify -v "$MOUNT_ID" >> "$VMLOGS"/files_inotify.log
24+
else
25+
notify_admin_gui \
26+
"Files iNotify Failed!" \
27+
"There seems to be an issue with iNofity. Please check the Mount ID (nextcloud_occ files_external:list) and change the crontab accordingly."
28+
fi

apps/face-recognition.sh

Lines changed: 5 additions & 167 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
#!/bin/bash
22

33
# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/
4-
# Copyright © 2021 Simon Lindner (https://github.com/szaimen)
54

65
true
7-
SCRIPT_NAME="Face Recognition"
8-
SCRIPT_EXPLAINER="The $SCRIPT_NAME app allows to automatically scan for faces inside your Nextcloud."
6+
SCRIPT_NAME="Redirect to Recognize"
97
# shellcheck source=lib.sh
108
source /var/scripts/fetch_lib.sh
119

@@ -15,170 +13,10 @@ source /var/scripts/fetch_lib.sh
1513
DEBUG=0
1614
debug_mode
1715

18-
# Check if root
16+
# Must be root
1917
root_check
2018

21-
# Check compatibility
22-
check_distro_version
23-
check_php
24-
if [[ "$PHPVER" != "8.1" ]] && [[ "$PHPVER" != "7.4" ]]
25-
then
26-
msg_box "Currently only PHP 7.4 and PHP 8.1 is supported by this script."
27-
exit 1
28-
fi
19+
# This is because we move the old script to old, and replaced it with this instead.
20+
run_script APP recognize
2921

30-
# Encryption may not be enabled
31-
if is_app_enabled encryption || is_app_enabled end_to_end_encryption
32-
then
33-
msg_box "It seems like you have encryption enabled which is unsupported by the $SCRIPT_NAME app!"
34-
exit 1
35-
fi
36-
37-
# Compatible with NC21 and above
38-
lowest_compatible_nc 21
39-
40-
# Hardware requirements
41-
# https://github.com/matiasdelellis/facerecognition/wiki/Requirements-and-Limitations#hardware-requirements
42-
# https://github.com/matiasdelellis/facerecognition/wiki/Models#model-3
43-
ram_check 2
44-
cpu_check 2
45-
46-
# Check if facerecognition is already installed
47-
if ! is_app_installed facerecognition && ! is_this_installed php7.4-pdlib && ! is_this_installed php8.1-pdli
48-
then
49-
# Ask for installing
50-
install_popup "$SCRIPT_NAME"
51-
else
52-
# Ask for removal or reinstallation
53-
reinstall_remove_menu "$SCRIPT_NAME"
54-
# Removal
55-
if is_this_installed php7.4-pdlib
56-
then
57-
apt-get purge php7.4-pdlib -y
58-
rm -f /etc/apt/sources.list.d/20-pdlib.list
59-
apt-get update -q4 & spinner_loading
60-
apt-get autoremove -y
61-
rm -f /etc/apt/trusted.gpg.d/facerecognition.gpg
62-
elif is_this_installed php8.1-pdlib
63-
then
64-
apt-get purge php8.1-pdlib -y
65-
rm -f /etc/apt/sources.list.d/facerecognition-pdlib.list
66-
apt-get update -q4 & spinner_loading
67-
apt-get autoremove -y
68-
rm -f /etc/apt/keyrings/repo.gpg.key
69-
fi
70-
crontab -u www-data -l | grep -v "face_background_job.log" | crontab -u www-data -
71-
crontab -u www-data -l | grep -v "face:background_job" | crontab -u www-data -
72-
if is_app_enabled facerecognition
73-
then
74-
if yesno_box_no "Do you want to reset all face data?
75-
The background scanner will then have to rescan all files for faces when you install the app again."
76-
then
77-
echo y | nextcloud_occ face:reset --all
78-
fi
79-
nextcloud_occ config:app:set facerecognition handle_external_files --value false
80-
nextcloud_occ config:app:set facerecognition handle_group_files --value false
81-
nextcloud_occ config:app:set facerecognition handle_shared_files --value false
82-
fi
83-
if is_app_installed facerecognition
84-
then
85-
nextcloud_occ app:remove facerecognition
86-
fi
87-
rm -f "$VMLOGS"/face_background_job.log
88-
# Show successful uninstall if applicable
89-
removal_popup "$SCRIPT_NAME"
90-
fi
91-
92-
# Inform about dependencies
93-
msg_box "Please note that the $SCRIPT_NAME app needs an additional PHP dependency \
94-
to work which will need to be installed from an external repository.
95-
This can set your server under risk."
96-
if ! yesno_box_yes "Do you want to install the required dependency?
97-
If you choose 'No', the installation will be aborted."
98-
then
99-
exit 1
100-
fi
101-
102-
# Install requirements
103-
if version 20.04 "$DISTRO" 20.04.10
104-
then
105-
# https://github.com/matiasdelellis/facerecognition/wiki/PDlib-Installation#ubuntu-focal
106-
add_trusted_key_and_repo "repo.gpg.key" \
107-
"https://repo.delellis.com.ar" \
108-
"https://repo.delellis.com.ar" \
109-
"focal focal" \
110-
"facerecognition-pdlib.list"
111-
install_if_not php"$PHPVER"-pdlib
112-
elif version 22.04 "$DISTRO" 22.04.10
113-
then
114-
# https://github.com/matiasdelellis/facerecognition/wiki/PDlib-Installation#ubuntu-jammy
115-
add_trusted_key_and_repo "repo.gpg.key" \
116-
"https://repo.delellis.com.ar" \
117-
"https://repo.delellis.com.ar" \
118-
"$CODENAME $CODENAME" \
119-
"facerecognition-pdlib.list"
120-
install_if_not php"$PHPVER"-pdlib
121-
fi
122-
123-
# Install the app
124-
install_and_enable_app facerecognition
125-
if ! is_app_enabled facerecognition
126-
then
127-
msg_box "Could not install the $SCRIPT_NAME app. Cannot proceed."
128-
exit 1
129-
fi
130-
131-
# Set up face model and max memory usage
132-
# https://github.com/matiasdelellis/facerecognition/wiki/Models#comparison
133-
# https://github.com/matiasdelellis/facerecognition/tree/master#initial-setup
134-
nextcloud_occ face:setup --memory 2GB
135-
nextcloud_occ face:setup --model 3
136-
137-
# Set temporary files size
138-
nextcloud_occ config:app:set facerecognition analysis_image_area --value="4320000"
139-
140-
# Additional settings
141-
# https://github.com/matiasdelellis/facerecognition/wiki/Settings#hidden-settings
142-
if yesno_box_no "Do you want the $SCRIPT_NAME app to scan external storages?
143-
This is currently highly inefficient since it will scan all external storges multiple times (once for each user) \
144-
and can produce a lot of network traffic.
145-
(The scan will need to access all files, also if they are stored externally.)
146-
Hence, you should only enable this option if you are only using local external storage \
147-
or if you don't use the external storage app at all."
148-
then
149-
nextcloud_occ config:app:set facerecognition handle_external_files --value true
150-
fi
151-
if yesno_box_no "Do you want the $SCRIPT_NAME app to scan groupfolders?
152-
This is currently highly inefficient since it will scan all groupfolders multiple times (once for each user)."
153-
then
154-
nextcloud_occ config:app:set facerecognition handle_group_files --value true
155-
fi
156-
if yesno_box_no "Do you want the $SCRIPT_NAME app to scan shared folders/files?
157-
This is currently highly inefficient since it will scan all shared folders/files multiple times (once for each user)."
158-
then
159-
nextcloud_occ config:app:set facerecognition handle_shared_files --value true
160-
fi
161-
162-
# Allow the background scanner to scan the files for each user again and enable face scanning for all users
163-
# https://github.com/matiasdelellis/facerecognition/wiki/Settings#notes
164-
NC_USERS_NEW=$(nextcloud_occ_no_check user:list | sed 's|^ - ||g' | sed 's|:.*||')
165-
mapfile -t NC_USERS_NEW <<< "$NC_USERS_NEW"
166-
for user in "${NC_USERS_NEW[@]}"
167-
do
168-
nextcloud_occ user:setting "$user" facerecognition full_image_scan_done false
169-
nextcloud_occ user:setting "$user" facerecognition enabled true
170-
done
171-
172-
# Make sure that the logfile doesn't get crazy big.
173-
crontab -u www-data -l | grep -v "face_background_job.log" | crontab -u www-data -
174-
crontab -u www-data -l | { cat; echo "@daily rm -f $VMLOGS/face_background_job.log"; } | crontab -u www-data -
175-
176-
# Schedule background scan
177-
# https://github.com/matiasdelellis/facerecognition/wiki/Schedule-Background-Task#cron
178-
crontab -u www-data -l | grep -v "face:background_job" | crontab -u www-data -
179-
crontab -u www-data -l | { cat; echo "*/30 * * * * php -f $NCPATH/occ \
180-
face:background_job -t 900 --defer-clustering >> $VMLOGS/face_background_job.log"; } | crontab -u www-data -
181-
182-
msg_box "Congratulations, $SCRIPT_NAME was successfully installed!
183-
You just need to wait now and let the background job do its work.
184-
After a while, you should see more and more faces that were found in your Nextcloud."
22+
exit

apps/previewgenerator.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ else
4848
# reset the cronjob
4949
crontab -u www-data -l | grep -v 'preview:pre-generate' | crontab -u www-data -
5050
# Remove apps
51-
APPS=(php-imagick libmagickcore-6.q16-3-extra)
51+
APPS=(php-imagick libmagickcore-6.q16-3-extra imagemagick-6.q16-extra)
5252
for app in "${APPS[@]}"
5353
do
5454
if is_this_installed "$app"
@@ -118,8 +118,19 @@ then
118118
check_php
119119
# Install imagick
120120
install_if_not php"$PHPVER"-imagick
121-
install_if_not libmagickcore-6.q16-3-extra
122-
121+
if version 22.04 "$DISTRO" 22.04.10
122+
then
123+
install_if_not libmagickcore-6.q16-6-extra
124+
elif version 20.04 "$DISTRO" 20.04.10
125+
then
126+
install_if_not libmagickcore-6.q16-3-extra
127+
fi
128+
# Memory tuning
129+
sed -i 's|policy domain="resource" name="memory" value=.*|policy domain="resource" name="memory" value="512MiB"|g' /etc/ImageMagick-6/policy.xml
130+
sed -i 's|policy domain="resource" name="map" value=.*|policy domain="resource" name="map" value="1024MiB"|g' /etc/ImageMagick-6/policy.xml
131+
sed -i 's|policy domain="resource" name="area" value=.*|policy domain="resource" name="area" value="256MiB"|g' /etc/ImageMagick-6/policy.xml
132+
sed -i 's|policy domain="resource" name="disk" value=.*|policy domain="resource" name="disk" value="8GiB"|g' /etc/ImageMagick-6/policy.xml
133+
123134
# Choose file formats fo the case when imagick is installed.
124135
# for additional previews please look at the Nextcloud documentation. But these probably won't work.
125136
choice=$(whiptail --title "$TITLE - Choose file formats" --checklist \

apps/recognize.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
3+
# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/
4+
5+
true
6+
SCRIPT_NAME="Recognize for Nextcloud"
7+
SCRIPT_EXPLAINER="$SCRIPT_NAME enables [local] AI detection of photos in your Nextcloud. Recognize improves the Photos app."
8+
# shellcheck source=lib.sh
9+
source /var/scripts/fetch_lib.sh
10+
11+
# Check for errors + debug code and abort if something isn't right
12+
# 1 = ON
13+
# 0 = OFF
14+
DEBUG=0
15+
debug_mode
16+
17+
# Check if root
18+
root_check
19+
20+
# Enough recouces?
21+
ram_check 8
22+
cpu_check 8
23+
24+
# Check if recognize is already installed
25+
if ! is_app_installed recognize
26+
then
27+
# Ask for installing
28+
install_popup "$SCRIPT_NAME"
29+
else
30+
# Ask for removal or reinstallation
31+
reinstall_remove_menu "$SCRIPT_NAME"
32+
# Removal
33+
if yesno_box_no "Do you want to remove all facerecognitions and tags that were generated until now?"
34+
then
35+
nextcloud_occ recognize:remove-legacy-tags
36+
nextcloud_occ recognize:cleanup-tags
37+
nextcloud_occ recognize:reset-face-clusters
38+
nextcloud_occ recognize:reset-faces
39+
nextcloud_occ recognize:reset-tags
40+
fi
41+
nextcloud_occ app:remove recognize
42+
# Show successful uninstall if applicable
43+
removal_popup "$SCRIPT_NAME"
44+
fi
45+
46+
# Install recognize
47+
install_and_enable_app recognize
48+
nextcloud_occ recognize:download-models
49+
50+
# Check if it was installed
51+
if is_app_enabled recognize
52+
then
53+
msg_box "$SCRIPT_NAME was successfully installed!"
54+
else
55+
msg_box "The installation wasn't successful. Please try again by running this script again!"
56+
fi

apps/smbmount.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ $MENU_GUIDE\n$RUN_LATER_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \
147147
print_text_in_color "$ICyan" "Using for backups..."
148148
umount "$SMBSHARES/$count"
149149
sed -i "/$SMBSHARES_SED\/$count /d" /etc/fstab
150-
echo "$SERVER_SHARE_NAME $SMBSHARES/$count cifs credentials=$SMB_CREDENTIALS/SMB$count,uid=root,gid=root,file_mode=0600,dir_mode=0600,nounix,noserverino,cache=none,nofail,noauto 0 0" >> /etc/fstab
150+
echo "$SERVER_SHARE_NAME $SMBSHARES/$count cifs credentials=$SMB_CREDENTIALS/SMB$count,uid=root,gid=root,file_mode=0600,dir_mode=0600,nounix,noserverino,cache=none,nofail 0 0" >> /etc/fstab
151151
unset SMB_USER && unset SMB_PASSWORD
152152
sleep 1
153153
msg_box "The backup mount was successfully created!"
@@ -415,7 +415,7 @@ files_inotify app and set up the cronjob for this external storage."
415415

416416
# Add crontab
417417
print_text_in_color "$ICyan" "Generating crontab..."
418-
crontab -u root -l | { cat; echo "@reboot $SCRIPTS/notify-crontab.sh $MOUNT_ID"; } | crontab -u root
418+
crontab -u root -l | { cat; echo "@reboot $SCRIPTS/notify-crontab.sh $MOUNT_ID"; } | crontab -u root -
419419

420420
# Run the command in a subshell and don't exit if the smbmount script exits
421421
nohup sudo -u www-data php "$NCPATH"/occ files_external:notify -v "$MOUNT_ID" >> $VMLOGS/files_inotify.log &

lib.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ then
905905
# Generate DHparams cipher
906906
if [ ! -f "$DHPARAMS_TLS" ]
907907
then
908-
openssl dhparam -dsaparam -out "$DHPARAMS_TLS" 4096
908+
openssl dhparam -out "$DHPARAMS_TLS" 2048
909909
fi
910910
# Choose which port for public access
911911
msg_box "You will now be able to choose which port you want to put your Nextcloud on for public access.\n
@@ -1146,10 +1146,7 @@ then
11461146
print_text_in_color "$IRed" "Error: ${1} GB RAM required to install ${2}!" >&2
11471147
print_text_in_color "$IRed" "Current RAM is: ($mem_available_gb GB)" >&2
11481148
sleep 3
1149-
msg_box "** Error: insufficient memory. ${mem_available_gb}GB RAM installed, ${1}GB required.
1150-
1151-
To bypass this check, comment out (add # before the line) 'ram_check X' in the script that you are trying to run.
1152-
Please note this may affect performance. USE AT YOUR OWN RISK!"
1149+
msg_box "** Error: insufficient memory. ${mem_available_gb}GB RAM installed, ${1}GB required."
11531150
exit 1
11541151
else
11551152
print_text_in_color "$IGreen" "RAM for ${2} OK! ($mem_available_gb GB)"
@@ -1690,7 +1687,7 @@ then
16901687
print_text_in_color "$ICyan" "Installing Docker CE..."
16911688
apt-get update -q4 & spinner_loading
16921689
install_if_not curl
1693-
curl -fsSL get.docker.com | sh
1690+
curl -fsSL https://get.docker.com | sh
16941691
fi
16951692

16961693
# Set overlay2
@@ -1837,11 +1834,14 @@ fi
18371834
home_sme_server() {
18381835
# OLD DISKS: "Samsung SSD 860" || ST5000LM000-2AN1 || ST5000LM015-2E81
18391836
# OLD MEMORY: BLS16G4 (Balistix Sport) || 18ASF2G72HZ (ECC)
1840-
if lshw -c system | grep -q "NUC8i3BEH\|NUC10i3FNH\|PN50\|PN51"
1837+
if lshw -c system | grep -q "NUC8i3BEH\|NUC10i3FNH\|PN50\|PN51\|PN52"
18411838
then
1842-
if lshw -c memory | grep -q "BLS16G4\|18ASF2G72HZ\|16ATF2G64HZ\|CT16G4SFD8266\|M471A4G43MB1\|9905744\|HMA82GS6JJR8N\|HMA82GS6CJR8N\|9905703-023"
1839+
if lshw -c memory | grep -q "BLS16G4\|18ASF2G72HZ\|16ATF2G64HZ\|CT16G4SFD8266\|M471A4G43MB1\|9905744\|HMA82GS6JJR8N\|HMA82GS6CJR8N\|9905703-023\|9905744-110"
18431840
then
18441841
if lshw -c disk | grep -q "ST2000LM015-2E81\|WDS400\|ST5000LM000-2AN1\|ST5000LM015-2E81\|Samsung SSD 860\|WDS500G1R0B"
1842+
then
1843+
NEXTCLOUDHOMESME=yes-this-is-the-home-sme-server
1844+
elif lshw -c storage | grep -q "SN700"
18451845
then
18461846
NEXTCLOUDHOMESME=yes-this-is-the-home-sme-server
18471847
fi

menu/additional_apps.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ $CHECKLIST_GUIDE\n\n$RUN_LATER_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \
4141
"Documentserver" "(OnlyOffice or Collabora - Docker or Integrated)" OFF \
4242
"Bitwarden" "(External password manager)" OFF \
4343
"Fail2ban " "(Extra Bruteforce protection)" "$STARTUP_SWITCH" \
44+
"Recognize" "(Use [local] AI on your photos in Nextcloud)" OFF \
4445
"PreviewGenerator" "(Pre-generate previews for Nextcloud)" OFF \
4546
"Webmin" "(Server GUI like Cpanel)" OFF \
4647
"Adminer" "(PostgreSQL GUI)" OFF \
@@ -55,7 +56,6 @@ $CHECKLIST_GUIDE\n\n$RUN_LATER_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \
5556
"Pico CMS" "(Lightweight CMS integration in Nextcloud)" OFF \
5657
"Whiteboard" "(Whiteboard for Nextcloud)" OFF \
5758
"Extract" "(Archive extraction for Nextcloud)" OFF \
58-
"Face Recognition" "(Scan your photos for faces in Nextcloud)" OFF \
5959
"SMB-mount" "(Mount SMB-shares from your local network)" OFF \
6060
"PDF Annotations" "(Annotate PDF files in Nextcloud)" OFF 3>&1 1>&2 2>&3)
6161

@@ -135,9 +135,9 @@ to finish the setup once this script is done." "$SUBTITLE"
135135
print_text_in_color "$ICyan" "Downloading the Whiteboard script..."
136136
run_script APP whiteboard
137137
;;&
138-
*"Face Recognition"*)
139-
print_text_in_color "$ICyan" "Downloading the Face Recognition script..."
140-
run_script APP face-recognition
138+
*"Recognize"*)
139+
print_text_in_color "$ICyan" "Downloading the Recognize script..."
140+
run_script APP recognize
141141
;;&
142142
*"SMB-mount"*)
143143
print_text_in_color "$ICyan" "Downloading the SMB-mount script..."

network/asusnuc/pn51.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ install_if_not build-essential
3333
install_if_not dkms
3434

3535
INSTALLDIR="$SCRIPTS/PN51"
36-
OLDRVERSION=( 9.005.06 9.006.04 9.007.01 9.008.00 9.009.00 9.009.01)
36+
OLDRVERSION=( 9.005.06 9.006.04 9.007.01 9.008.00 9.009.00 9.009.01 9.010.01)
3737
# Add old versions with a single space inside the variable above.
38-
RVERSION="9.010.01"
38+
RVERSION="9.011.00"
3939
# Before changing the RVERSION here, please download it to the repo first.
4040

4141
# Make sure the installation directory exist
95.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)