Skip to content

Commit 743272b

Browse files
authored
NC 26 prep (#2454)
1 parent d39421f commit 743272b

File tree

5 files changed

+258
-172
lines changed

5 files changed

+258
-172
lines changed

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/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

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..."

nextcloud_install_production.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,12 +913,14 @@ else
913913
$CHECKLIST_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \
914914
"Calendar" "" ON \
915915
"Contacts" "" ON \
916-
"IssueTemplate" "" OFF \
917916
"PDFViewer" "" ON \
918917
"Extract" "" ON \
919918
"Text" "" ON \
920919
"Mail" "" ON \
921920
"Deck" "" ON \
921+
"Collectives" "" ON \
922+
"Suspicios Login detetion" "" ON \
923+
"IssueTemplate" "" OFF \
922924
"Group-Folders" "" OFF 3>&1 1>&2 2>&3)
923925
fi
924926

@@ -956,6 +958,12 @@ case "$choice" in
956958
*"Deck"*)
957959
install_and_enable_app deck
958960
;;&
961+
*"Collectives"*)
962+
install_and_enable_app collectives
963+
;;&
964+
*"Suspicios Login detetion"*)
965+
install_and_enable_app suspicios_login
966+
;;&
959967
*"Group-Folders"*)
960968
install_and_enable_app groupfolders
961969
;;&

0 commit comments

Comments
 (0)