-
-
Notifications
You must be signed in to change notification settings - Fork 653
/
recognize.sh
102 lines (88 loc) · 3.23 KB
/
recognize.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/
true
SCRIPT_NAME="Recognize for Nextcloud"
SCRIPT_EXPLAINER="$SCRIPT_NAME enables [local] AI detection of photos in your Nextcloud. Recognize improves the Photos app."
# 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
# 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
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 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 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/24.04-LTS/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
# Ask for installing
install_popup "$SCRIPT_NAME"
else
# Ask for removal or reinstallation
reinstall_remove_menu "$SCRIPT_NAME"
# 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_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
removal_popup "$SCRIPT_NAME"
fi
# Install recognize
# Enough recouces?
ram_check 8
cpu_check 4
install_and_enable_app recognize
nextcloud_occ recognize:download-models
# Check if it was installed
if is_app_enabled recognize
then
msg_box "$SCRIPT_NAME was successfully installed!"
else
msg_box "The installation wasn't successful. Please try again by running this script again!"
fi