forked from pliablepixels/zmeventnotification
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·1136 lines (965 loc) · 45.2 KB
/
install.sh
File metadata and controls
executable file
·1136 lines (965 loc) · 45.2 KB
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
#-----------------------------------------------------
# Install script for the EventServer and the
# machine learning hooks
#
# /install.sh --help
#
# Note that this does not install all the event server
# dependencies. You still need to follow the README
#
# It does however try to install all the hook dependencies
#
#-----------------------------------------------------
# --- Change these if you want --
PYTHON=${PYTHON:-python3}
PIP=${PIP:-pip3}
ZM_VENV="${ZM_VENV:-/opt/zoneminder/venv}"
USE_VENV="${USE_VENV:-yes}"
INSTALLER=${INSTALLER:-$(which apt-get || which yum)}
# Models to install
# If you do not want them, pass them as variables to install.sh
# example: sudo INSTALL_YOLO4=no ./install.sh
INSTALL_YOLOV3=${INSTALL_YOLOV3:-no}
INSTALL_TINYYOLOV3=${INSTALL_TINYYOLOV3:-no}
INSTALL_YOLOV4=${INSTALL_YOLOV4:-yes}
INSTALL_TINYYOLOV4=${INSTALL_TINYYOLOV4:-yes}
INSTALL_CORAL_EDGETPU=${INSTALL_CORAL_EDGETPU:-no}
INSTALL_YOLOV11=${INSTALL_YOLOV11:-yes}
INSTALL_YOLOV26=${INSTALL_YOLOV26:-yes}
INSTALL_BIRDNET=${INSTALL_BIRDNET:-no}
TARGET_CONFIG=${TARGET_CONFIG:-'/etc/zm'}
TARGET_DATA=${TARGET_DATA:-'/var/lib/zmeventnotification'}
TARGET_BIN_ES=${TARGET_BIN_ES:-'/usr/bin'}
TARGET_BIN_HOOK=${TARGET_BIN_HOOK:-'/var/lib/zmeventnotification/bin'}
TARGET_PERL_LIB=${TARGET_PERL_LIB:-'/usr/share/perl5'}
INSTALL_OPENCV=${INSTALL_OPENCV:-no}
WGET=${WGET:-$(which wget)}
_WEB_OWNER_FROM_PS=$(ps xao user,group,comm | grep -E '(httpd|hiawatha|apache|apache2|nginx)' | grep -v whoami | grep -v root | head -n1 | awk '{print $1}')
#_WEB_OWNER='www-data' # uncomment this if the above mechanism fails
_WEB_GROUP_FROM_PS=$(ps xao user,group,comm | grep -E '(httpd|hiawatha|apache|apache2|nginx)' | grep -v whoami | grep -v root | head -n1 | awk '{print $2}')
#_WEB_GROUP='www-data' # uncomment if above line fails
# make this empty if you do not want backups
MAKE_CONFIG_BACKUP='--backup=numbered'
# --- end of change these ---
# set default values
# if we have a value from ps use it, otherwise look in env
WEB_OWNER=${WEB_OWNER:-${_WEB_OWNER_FROM_PS}}
WEB_GROUP=${WEB_GROUP:-${_WEB_GROUP_FROM_PS}}
# if we do not have a value from ps or env, use default
WEB_OWNER=${WEB_OWNER:-'www-data'}
WEB_GROUP=${WEB_GROUP:-'www-data'}
# utility functions for color coded pretty printing
print_error() {
COLOR="\033[1;31m"
NOCOLOR="\033[0m"
echo -e "${COLOR}ERROR:${NOCOLOR}$1"
}
print_important() {
COLOR="\033[0;34m"
NOCOLOR="\033[0m"
echo -e "${COLOR}IMPORTANT:${NOCOLOR}$1"
}
print_warning() {
COLOR="\033[0;33m"
NOCOLOR="\033[0m"
echo -e "${COLOR}WARNING:${NOCOLOR}$1"
}
print_success() {
COLOR="\033[1;32m"
NOCOLOR="\033[0m"
echo -e "${COLOR}Success:${NOCOLOR}$1"
}
print_section() {
COLOR="\033[1;36m"
NOCOLOR="\033[0m"
echo ""
echo -e "${COLOR}──── $1 ────${NOCOLOR}"
}
print_skip() {
COLOR="\033[0;33m"
NOCOLOR="\033[0m"
echo -e "${COLOR}Skipping: $1${NOCOLOR}"
}
# Run a command with its output dimmed (gray)
# Usage: run_dimmed <command> [args...]
run_dimmed() {
local DIM="\033[0;90m"
local NOCOLOR="\033[0m"
echo -ne "${DIM}"
"$@" 2>&1
local rc=$?
echo -ne "${NOCOLOR}"
return $rc
}
# Ensure python3-venv is available and create the shared venv
ensure_venv() {
if [[ "${USE_VENV}" != "yes" ]]; then
print_warning "Venv disabled — using global pip with --break-system-packages"
PIP_COMPAT="--break-system-packages"
return 0
fi
PIP_COMPAT=""
print_section "Setting up Python virtual environment"
# Check if venv already exists and is usable
if [[ -d "${ZM_VENV}" && -x "${ZM_VENV}/bin/python" ]]; then
print_success "Venv already exists at ${ZM_VENV}"
else
# Make sure python3 -m venv works
if ! ${PYTHON} -m venv --help &>/dev/null; then
echo "python3-venv not available — installing..."
if command -v apt-get &>/dev/null; then
run_dimmed apt-get update -qq && run_dimmed apt-get install -y -qq python3-venv
elif command -v dnf &>/dev/null; then
run_dimmed dnf install -y python3-libs
elif command -v yum &>/dev/null; then
run_dimmed yum install -y python3-libs
else
print_error "Cannot auto-install python3-venv. Install it manually, then re-run."
exit 1
fi
fi
echo "Creating venv at ${ZM_VENV} ..."
mkdir -p "$(dirname "${ZM_VENV}")"
${PYTHON} -m venv --system-site-packages "${ZM_VENV}"
print_success "Venv created (Python: $(${ZM_VENV}/bin/python --version))"
fi
# Point PYTHON and PIP at the venv — no sudo needed for venv installs
PYTHON="${ZM_VENV}/bin/python"
PIP="${ZM_VENV}/bin/pip"
PY_SUDO=""
# Upgrade pip inside the venv
run_dimmed "${PIP}" install --upgrade pip setuptools wheel -q
# If cv2 is already importable (e.g. source-built or system-packaged),
# create a fake dist-info so pip won't pull opencv-python from PyPI
shim_opencv
print_success "Using venv Python: ${PYTHON}"
}
# Shim opencv-python if cv2 is already available via system-site-packages
shim_opencv() {
local venv_python="${ZM_VENV}/bin/python"
# Can the venv Python already import cv2?
local cv2_version
cv2_version=$("${venv_python}" -c "import cv2; print(cv2.__version__)" 2>/dev/null) || return 0
# Is there already a pip-registered opencv-python? If so, no shim needed.
if "${venv_python}" -m pip show opencv-python &>/dev/null; then
return 0
fi
local site_packages
site_packages=$("${venv_python}" -c "import sysconfig; print(sysconfig.get_path('purelib'))")
local dist_dir="${site_packages}/opencv_python-${cv2_version}.dist-info"
mkdir -p "${dist_dir}"
cat > "${dist_dir}/METADATA" <<EOF
Metadata-Version: 2.1
Name: opencv-python
Version: ${cv2_version}
Summary: Shim — real cv2 is provided by a source/system build
EOF
echo > "${dist_dir}/RECORD"
echo "opencv-python" > "${dist_dir}/top_level.txt"
echo "Wheel-Version: 1.0" > "${dist_dir}/WHEEL"
print_success "opencv-python shim created (cv2 ${cv2_version} from source/system)"
}
get_distro() {
local DISTRO=`(lsb_release -ds || cat /etc/*release || uname -om ) 2>/dev/null | head -n1`
local DISTRO_NORM='ubuntu'
if echo "${DISTRO}" | grep -iqF 'ubuntu'; then
DISTRO_NORM='ubuntu'
elif echo "${DISTRO}" | grep -iqF 'centos'; then
DISTRO_NORM='centos'
fi
echo ${DISTRO_NORM}
}
get_installer() {
local DISTRO=$(get_distro)
local installer='apt-get'
case $DISTRO in
ubuntu)
installer='apt-get'
;;
centos)
installer='yum'
;;
esac
echo ${installer}
}
# generic confirm function that returns 0 for yes and 1 for no
confirm() {
display_str=$1
default_ans=$2
if [[ $default_ans == 'y/N' ]]
then
must_match='[yY]'
else
must_match='[nN]'
fi
read -p "${display_str} [${default_ans}]:" ans
[[ $ans == $must_match ]]
}
# Are we running as root? If not, install may fail
check_root() {
if [[ $EUID -ne 0 ]]
then
echo
echo "********************************************************************************"
print_warning "Unless you have changed paths, this script requires to be run as sudo"
echo "********************************************************************************"
echo
[[ ${INTERACTIVE} == 'yes' ]] && read -p "Press any key to continue or Ctrl+C to quit and run again with sudo..."
fi
}
# Some of these may be default values, so give user a change to change
verify_config() {
if [[ ${INTERACTIVE} == 'no' &&
( ${INSTALL_ES} == 'prompt' || ${INSTALL_HOOK} == 'prompt' ||
${INSTALL_HOOK_CONFIG} == 'prompt' || ${INSTALL_ES_CONFIG} == 'prompt' )
]]
then
print_error 'In non-interactive mode, you need to specify flags for all components'
echo
exit
fi
print_section 'Configured Values'
echo "Your distro seems to be ${DISTRO}"
echo "Your webserver user seems to be ${WEB_OWNER}"
echo "Your webserver group seems to be ${WEB_GROUP}"
echo "wget is ${WGET}"
echo "installer software is ${INSTALLER}"
echo "Install Event Server: ${INSTALL_ES}"
echo "Install Event Server config: ${INSTALL_ES_CONFIG}"
echo "Install Hooks: ${INSTALL_HOOK}"
echo "Install Hooks config: ${INSTALL_HOOK_CONFIG}"
echo "Upgrade Hooks config (if applicable): ${HOOK_CONFIG_UPGRADE}"
echo "Download and install models (if needed): ${DOWNLOAD_MODELS}"
echo "Install OpenCV: ${INSTALL_OPENCV}"
echo "Perl module install path: ${TARGET_PERL_LIB}"
if [[ "${USE_VENV}" == "yes" ]]; then
echo "Python venv: ${ZM_VENV}"
else
echo "Python venv: DISABLED (global install)"
fi
echo
[[ ${INSTALL_ES} != 'no' ]] && echo "The Event Server will be installed to ${TARGET_BIN_ES}"
[[ ${INSTALL_ES_CONFIG} != 'no' ]] && echo "The Event Server config will be installed to ${TARGET_CONFIG}"
[[ ${INSTALL_HOOK} != 'no' ]] && echo "Hooks will be installed to ${TARGET_DATA} sub-folders"
[[ ${INSTALL_HOOK_CONFIG} != 'no' ]] && echo "Hook config files will be installed to ${TARGET_CONFIG}"
echo
if [[ ${DOWNLOAD_MODELS} == 'yes' ]]
then
echo "Models that will be checked/installed:"
echo "(Note, if you have already downloaded a model, it will not be deleted)"
echo "Yolo V3 (INSTALL_YOLOV3): ${INSTALL_YOLOV3}"
echo "TinyYolo V3 (INSTALL_TINYYOLOV3): ${INSTALL_TINYYOLOV3}"
echo "Yolo V4 (INSTALL_YOLOV4): ${INSTALL_YOLOV4}"
echo "Tiny Yolo V4 (INSTALL_TINYYOLOV4)": ${INSTALL_TINYYOLOV4}
echo "Google Coral Edge TPU (INSTALL_CORAL_EDGETPU)": ${INSTALL_CORAL_EDGETPU}
echo "ONNX YOLOv11 (INSTALL_YOLOV11)": ${INSTALL_YOLOV11}
echo "ONNX YOLOv26 (INSTALL_YOLOV26)": ${INSTALL_YOLOV26}
echo "BirdNET audio (INSTALL_BIRDNET)": ${INSTALL_BIRDNET}
fi
echo
[[ ${INTERACTIVE} == 'yes' ]] && read -p "If any of this looks wrong, please hit Ctrl+C and edit the variables in this script..."
}
# move proc for zmeventnotification.pl
install_es() {
print_section 'Installing ES Dependencies'
if [[ "$DISTRO" == "ubuntu" || "$DISTRO" == "debian" ]]; then
run_dimmed $INSTALLER install -y libyaml-libyaml-perl libcrypt-eksblowfish-perl \
libcrypt-openssl-rsa-perl libmodule-build-perl libyaml-perl libjson-perl \
liblwp-protocol-https-perl libio-socket-ssl-perl liburi-perl libdbi-perl \
libtest-warn-perl
echo "Note: Net::WebSocket::Server is also required but not available via apt."
echo "Install it via CPAN if not already present: sudo cpanm Net::WebSocket::Server"
else
echo "Not ubuntu or debian - please install Perl dependencies manually"
fi
print_section 'Installing Event Server'
mkdir -p "${TARGET_DATA}/push" 2>/dev/null
local es_target="${TARGET_BIN_ES}/zmeventnotification.pl"
if install -m 755 -o "${WEB_OWNER}" -g "${WEB_GROUP}" zmeventnotification.pl "${TARGET_BIN_ES}"; then
print_success "Completed, but you will still have to install ES dependencies as per https://zmeventnotificationv7.readthedocs.io/en/latest/guides/install.html#install-dependencies"
elif [ -f "$es_target" ]; then
# install(1) unlinks the target first, which fails on bind mounts.
# Fall back to in-place copy which overwrites contents without unlinking.
print_warning "'install' failed (target may be a bind mount). Trying in-place copy..."
if cp zmeventnotification.pl "$es_target" && chmod 755 "$es_target"; then
chown "${WEB_OWNER}:${WEB_GROUP}" "$es_target" 2>/dev/null
print_success "Copied in-place"
else
print_error "In-place copy also failed. Check permissions on ${es_target}"
fi
else
print_error "failed to install to ${es_target}"
fi
print_section 'Installing Perl modules'
mkdir -p "${TARGET_PERL_LIB}/ZmEventNotification/"
for pm_file in ZmEventNotification/*.pm; do
local pm_target="${TARGET_PERL_LIB}/ZmEventNotification/$(basename "$pm_file")"
if install -m 644 "$pm_file" "${TARGET_PERL_LIB}/ZmEventNotification/"; then
echo "Installed $(basename $pm_file)"
elif cp "$pm_file" "$pm_target" && chmod 644 "$pm_target"; then
echo "Installed $(basename $pm_file) (in-place copy)"
else
print_error "Failed to install $(basename $pm_file)"
fi
done
# Update Version.pm with the version from VERSION file
if [ -f "VERSION" ]; then
ES_VERSION=$(cat VERSION | tr -d '[:space:]')
sed -i "s/^\(.*\)\$FALLBACK_VERSION = '.*';$/\1\$FALLBACK_VERSION = '${ES_VERSION}';/" \
"${TARGET_PERL_LIB}/ZmEventNotification/Version.pm" &&
echo "Set version to ${ES_VERSION} in Version.pm" || print_error "Failed to set version"
fi
# No need to patch use lib - FindBin resolves the script's directory at runtime,
# and installed modules in ${TARGET_PERL_LIB} are already in @INC.
}
# Download model files if they don't already exist
# Usage: download_if_needed <model_dir> <target1> <source1> [<target2> <source2> ...]
download_if_needed() {
local model_dir="$1"; shift
mkdir -p "${TARGET_DATA}/models/${model_dir}"
while [ $# -ge 2 ]; do
local target="$1" source="$2"; shift 2
if [ ! -f "${TARGET_DATA}/models/${model_dir}/${target}" ]; then
run_dimmed ${WGET} "${source}" -O"${TARGET_DATA}/models/${model_dir}/${target}"
else
print_success " ${target} already exists"
fi
done
}
# install proc for ML hooks
download_models() {
# Create model directories
mkdir -p "${TARGET_DATA}/models/yolov3" 2>/dev/null
mkdir -p "${TARGET_DATA}/models/tinyyolov3" 2>/dev/null
mkdir -p "${TARGET_DATA}/models/tinyyolov4" 2>/dev/null
mkdir -p "${TARGET_DATA}/models/yolov4" 2>/dev/null
mkdir -p "${TARGET_DATA}/models/coral_edgetpu" 2>/dev/null
mkdir -p "${TARGET_DATA}/models/ultralytics" 2>/dev/null
if [ "${DOWNLOAD_MODELS}" == "yes" ]
then
if [ "${INSTALL_CORAL_EDGETPU}" == "yes" ]
then
print_important ' Checking for Google Coral Edge TPU data files...'
download_if_needed coral_edgetpu \
'coco_indexed.names' 'https://dl.google.com/coral/canned_models/coco_labels.txt' \
'ssd_mobilenet_v2_coco_quant_postprocess_edgetpu.tflite' 'https://github.com/google-coral/edgetpu/raw/master/test_data/ssd_mobilenet_v2_coco_quant_postprocess_edgetpu.tflite' \
'ssdlite_mobiledet_coco_qat_postprocess_edgetpu.tflite' 'https://github.com/google-coral/test_data/raw/master/ssdlite_mobiledet_coco_qat_postprocess_edgetpu.tflite' \
'ssd_mobilenet_v2_face_quant_postprocess_edgetpu.tflite' 'https://github.com/google-coral/test_data/raw/master/ssd_mobilenet_v2_face_quant_postprocess_edgetpu.tflite'
fi
if [ "${INSTALL_YOLOV3}" == "yes" ]
then
print_important ' Checking for YOLOv3 data files...'
[ -f "${TARGET_DATA}/models/yolov3/yolov3_classes.txt" ] && rm "${TARGET_DATA}/models/yolov3/yolov3_classes.txt"
download_if_needed yolov3 \
'yolov3.cfg' 'https://github.com/pliablepixels/zmes_ai_assets/raw/master/models/yolov3/yolov3.cfg' \
'coco.names' 'https://github.com/pliablepixels/zmes_ai_assets/raw/master/models/yolov3/coco.names' \
'yolov3.weights' 'https://github.com/pliablepixels/zmes_ai_assets/raw/master/models/yolov3/yolov3.weights'
fi
if [ "${INSTALL_TINYYOLOV3}" == "yes" ]
then
[ -d "${TARGET_DATA}/models/tinyyolo" ] && mv "${TARGET_DATA}/models/tinyyolo" "${TARGET_DATA}/models/tinyyolov3"
print_important ' Checking for TinyYOLOv3 data files...'
[ -f "${TARGET_DATA}/models/tinyyolov3/yolov3-tiny.txt" ] && rm "${TARGET_DATA}/models/yolov3/yolov3-tiny.txt"
download_if_needed tinyyolov3 \
'yolov3-tiny.cfg' 'https://github.com/pliablepixels/zmes_ai_assets/raw/master/models/tinyyolov3/yolov3-tiny.cfg' \
'coco.names' 'https://github.com/pliablepixels/zmes_ai_assets/raw/master/models/tinyyolov3/coco.names' \
'yolov3-tiny.weights' 'https://github.com/pliablepixels/zmes_ai_assets/raw/master/models/tinyyolov3/yolov3-tiny.weights'
fi
if [ "${INSTALL_TINYYOLOV4}" == "yes" ]
then
print_important ' Checking for TinyYOLOv4 data files...'
download_if_needed tinyyolov4 \
'yolov4-tiny.cfg' 'https://github.com/pliablepixels/zmes_ai_assets/raw/master/models/tinyyolov4/yolov4-tiny.cfg' \
'coco.names' 'https://github.com/pliablepixels/zmes_ai_assets/raw/master/models/tinyyolov4/coco.names' \
'yolov4-tiny.weights' 'https://github.com/pliablepixels/zmes_ai_assets/raw/master/models/tinyyolov4/yolov4-tiny.weights'
fi
if [ "${INSTALL_YOLOV4}" == "yes" ]
then
if [ -d "${TARGET_DATA}/models/cspn" ]
then
echo "Removing old CSPN files, it is YoloV4 now"
rm -rf "${TARGET_DATA}/models/cspn" 2>/dev/null
fi
print_important ' Checking for YOLOv4 data files...'
print_warning ' Note, you need OpenCV 4.4+ for Yolov4 to work'
download_if_needed yolov4 \
'yolov4.cfg' 'https://github.com/pliablepixels/zmes_ai_assets/raw/master/models/yolov4/yolov4.cfg' \
'coco.names' 'https://github.com/pliablepixels/zmes_ai_assets/raw/master/models/yolov4/coco.names' \
'yolov4.weights' 'https://github.com/pliablepixels/zmes_ai_assets/raw/master/models/yolov4/yolov4.weights'
fi
if [ "${INSTALL_YOLOV11}" == "yes" ]
then
print_important ' Checking for ONNX YOLOv11 model files...'
print_warning 'Note, you need OpenCV 4.13+ for ONNX YOLOv11 to work'
download_if_needed ultralytics \
'yolo11n.onnx' 'https://github.com/pliablepixels/zmes_ai_assets/raw/master/models/ultralytics/yolo11n.onnx' \
'yolo11s.onnx' 'https://github.com/pliablepixels/zmes_ai_assets/raw/master/models/ultralytics/yolo11s.onnx' \
'yolo11m.onnx' 'https://github.com/pliablepixels/zmes_ai_assets/raw/master/models/ultralytics/yolo11m.onnx' \
'yolo11l.onnx' 'https://github.com/pliablepixels/zmes_ai_assets/raw/master/models/ultralytics/yolo11l.onnx'
fi
if [ "${INSTALL_YOLOV26}" == "yes" ]
then
print_important ' Checking for ONNX YOLOv26 model files...'
print_warning 'Note, you need OpenCV 4.13+ for ONNX YOLOv26 to work (TopK layer support required)'
download_if_needed ultralytics \
'yolo26n.onnx' 'https://github.com/pliablepixels/zmes_ai_assets/raw/master/models/ultralytics/yolo26n.onnx' \
'yolo26s.onnx' 'https://github.com/pliablepixels/zmes_ai_assets/raw/master/models/ultralytics/yolo26s.onnx' \
'yolo26m.onnx' 'https://github.com/pliablepixels/zmes_ai_assets/raw/master/models/ultralytics/yolo26m.onnx' \
'yolo26l.onnx' 'https://github.com/pliablepixels/zmes_ai_assets/raw/master/models/ultralytics/yolo26l.onnx' \
'yolo26x.onnx' 'https://github.com/pliablepixels/zmes_ai_assets/raw/master/models/ultralytics/yolo26x.onnx'
fi
else
print_skip 'Model downloads'
fi
}
install_hook() {
if [ "${INSTALL_OPENCV}" == "yes" ]; then
echo "Installing python3-opencv..."
run_dimmed ${INSTALLER} install -y python3-opencv
else
print_skip "python3-opencv installation"
fi
print_section 'Installing Hooks'
mkdir -p "${TARGET_DATA}/bin" 2>/dev/null
rm -fr "${TARGET_DATA}/bin/*" 2>/dev/null
#don't delete contrib so custom user files remain
mkdir -p "${TARGET_DATA}/contrib" 2>/dev/null
mkdir -p "${TARGET_DATA}/images" 2>/dev/null
mkdir -p "${TARGET_DATA}/mlapi" 2>/dev/null
mkdir -p "${TARGET_DATA}/known_faces" 2>/dev/null
mkdir -p "${TARGET_DATA}/unknown_faces" 2>/dev/null
mkdir -p "${TARGET_DATA}/misc" 2>/dev/null
echo "everything that does not fit anywhere else :-)" > "${TARGET_DATA}/misc/README.txt" 2>/dev/null
download_models
# Now install the ML hooks
print_section 'Installing push API plugins'
install -m 755 -o "${WEB_OWNER}" pushapi_plugins/pushapi_pushover.py "${TARGET_BIN_HOOK}"
print_section 'Installing detection scripts'
install -m 755 -o "${WEB_OWNER}" hook/zm_event_start.sh "${TARGET_BIN_HOOK}"
install -m 755 -o "${WEB_OWNER}" hook/zm_event_end.sh "${TARGET_BIN_HOOK}"
install -m 755 -o "${WEB_OWNER}" hook/zm_detect.py "${TARGET_BIN_HOOK}"
install -m 755 -o "${WEB_OWNER}" hook/zm_train_faces.py "${TARGET_BIN_HOOK}"
# Fix hardcoded paths in installed scripts to match TARGET_CONFIG / TARGET_BIN_HOOK
sed -i "s|CONFIG_FILE=\"/etc/zm/objectconfig.yml\"|CONFIG_FILE=\"${TARGET_CONFIG}/objectconfig.yml\"|" \
"${TARGET_BIN_HOOK}/zm_event_start.sh"
sed -i "s|/var/lib/zmeventnotification/bin/zm_detect.py|${TARGET_BIN_HOOK}/zm_detect.py|g" \
"${TARGET_BIN_HOOK}/zm_event_start.sh"
sed -i "s|default='/etc/zm/objectconfig.yml'|default='${TARGET_CONFIG}/objectconfig.yml'|" \
"${TARGET_BIN_HOOK}/zm_detect.py" \
"${TARGET_BIN_HOOK}/zm_train_faces.py"
# Patch shebangs to use the venv Python
if [[ "${USE_VENV}" == "yes" ]]; then
sed -i "s|#!/usr/bin/python3|#!${ZM_VENV}/bin/python|" \
"${TARGET_BIN_HOOK}/zm_detect.py" \
"${TARGET_BIN_HOOK}/zm_train_faces.py"
print_success "Patched shebangs to use ${ZM_VENV}/bin/python"
fi
print_section 'Installing user contributions'
cp docs/guides/contrib_guidelines.rst "${TARGET_DATA}/contrib"
for file in contrib/*; do
echo "Copying over ${file}..."
install -m 755 -o "${WEB_OWNER}" "$file" "${TARGET_DATA}/contrib"
done
echo
print_section 'Installing Python hook package'
${PY_SUDO} ${PIP} uninstall -y zmes-hooks ${PIP_COMPAT} >/dev/null 2>&1
${PY_SUDO} ${PIP} uninstall -y zmes_hook_helpers ${PIP_COMPAT} >/dev/null 2>&1
ZM_DETECT_VERSION=`./hook/zm_detect.py --bareversion`
if [ "$ZM_DETECT_VERSION" == "" ]; then
echo "Failed to detect hooks version."
else
echo "__version__ = \"${ZM_DETECT_VERSION}\"" > hook/zmes_hook_helpers/__init__.py
echo "VERSION=__version__" >> hook/zmes_hook_helpers/__init__.py
fi
PYZM_PREINSTALLED=false
${PIP} show pyzm &>/dev/null && PYZM_PREINSTALLED=true
echo "Running: ${PY_SUDO} ${PIP} -v install hook/ ${PIP_COMPAT}"
run_dimmed ${PY_SUDO} ${PIP} -v install hook/ ${PIP_COMPAT} && print_opencv_message || print_error "python hooks setup failed"
print_section 'Installing package dependencies'
run_dimmed ${INSTALLER} install -y gifsicle -qq
}
# move ES config files
install_es_config() {
# Ensure pyyaml is installed for config migration/upgrade scripts
run_dimmed ${PY_SUDO} ${PIP} install pyyaml ${PIP_COMPAT}
# Auto-migrate from INI to YAML if needed
if [ -f "${TARGET_CONFIG}/zmeventnotification.ini" ] && [ ! -f "${TARGET_CONFIG}/zmeventnotification.yml" ]; then
echo "Found existing zmeventnotification.ini but no zmeventnotification.yml - running migration..."
if ${PYTHON} tools/es_config_migrate_yaml.py -c "${TARGET_CONFIG}/zmeventnotification.ini" -o "${TARGET_CONFIG}/zmeventnotification.yml"; then
print_success "ES config migration complete"
mv "${TARGET_CONFIG}/zmeventnotification.ini" "${TARGET_CONFIG}/zmeventnotification.ini.migrated"
print_important "Renamed old zmeventnotification.ini to zmeventnotification.ini.migrated"
else
print_warning "ES config migration failed"
fi
fi
if [ -f "${TARGET_CONFIG}/secrets.ini" ] && [ ! -f "${TARGET_CONFIG}/secrets.yml" ]; then
echo "Found existing secrets.ini but no secrets.yml - running migration..."
if ${PYTHON} tools/es_config_migrate_yaml.py --secrets -c "${TARGET_CONFIG}/secrets.ini" -o "${TARGET_CONFIG}/secrets.yml"; then
print_success "secrets migration complete"
mv "${TARGET_CONFIG}/secrets.ini" "${TARGET_CONFIG}/secrets.ini.migrated"
print_important "Renamed old secrets.ini to secrets.ini.migrated"
else
print_warning "secrets migration failed"
fi
fi
if [ ! -f "${TARGET_CONFIG}/zmeventnotification.yml" ]; then
echo 'No existing ES config found, installing example as active config'
install -o "${WEB_OWNER}" -g "${WEB_GROUP}" -m 644 zmeventnotification.example.yml "${TARGET_CONFIG}/zmeventnotification.yml" &&
print_success "config copied" || print_error "could not copy config"
else
echo "Upgrading existing ES config with any new keys..."
${PYTHON} tools/config_upgrade_yaml.py -c "${TARGET_CONFIG}/zmeventnotification.yml" -e zmeventnotification.example.yml &&
print_success "ES config upgraded" || print_warning "ES config upgrade failed"
fi
if [ ! -f "${TARGET_CONFIG}/secrets.yml" ]; then
echo 'No existing secrets found, installing example as active config'
install -o "${WEB_OWNER}" -g "${WEB_GROUP}" -m 644 secrets.example.yml "${TARGET_CONFIG}/secrets.yml" &&
print_success "secrets copied" || print_error "could not copy secrets"
else
echo "Upgrading existing secrets with any new keys..."
${PYTHON} tools/config_upgrade_yaml.py -c "${TARGET_CONFIG}/secrets.yml" -e secrets.example.yml &&
print_success "secrets upgraded" || print_warning "secrets upgrade failed"
fi
# Fix stale secrets.ini reference in config if secrets.yml exists
if [ -f "${TARGET_CONFIG}/zmeventnotification.yml" ] && [ -f "${TARGET_CONFIG}/secrets.yml" ]; then
if grep -q 'secrets\.ini' "${TARGET_CONFIG}/zmeventnotification.yml"; then
sed -i 's|secrets\.ini|secrets.yml|g' "${TARGET_CONFIG}/zmeventnotification.yml"
print_success "Updated secrets path from .ini to .yml in zmeventnotification.yml"
fi
fi
# Fix hardcoded /etc/zm paths in ES config when TARGET_CONFIG differs
if [ "${TARGET_CONFIG}" != "/etc/zm" ] && [ -f "${TARGET_CONFIG}/zmeventnotification.yml" ]; then
sed -i "s|/etc/zm/|${TARGET_CONFIG}/|g" "${TARGET_CONFIG}/zmeventnotification.yml"
print_success "Updated /etc/zm paths to ${TARGET_CONFIG} in zmeventnotification.yml"
fi
# Migrate es_rules.json to YAML if needed
if [ -f "${TARGET_CONFIG}/es_rules.json" ] && [ ! -f "${TARGET_CONFIG}/es_rules.yml" ]; then
echo "Found existing es_rules.json but no es_rules.yml - converting..."
if ${PYTHON} -c "
import json, yaml, sys
with open('${TARGET_CONFIG}/es_rules.json') as f:
data = json.load(f)
with open('${TARGET_CONFIG}/es_rules.yml', 'w') as f:
f.write('# Migrated from es_rules.json\n')
yaml.dump(data, f, default_flow_style=False, sort_keys=False)
"; then
print_success "es_rules migration complete"
mv "${TARGET_CONFIG}/es_rules.json" "${TARGET_CONFIG}/es_rules.json.migrated"
print_important "Renamed old es_rules.json to es_rules.json.migrated"
else
print_warning "es_rules migration failed"
fi
fi
if [ ! -f "${TARGET_CONFIG}/es_rules.yml" ]; then
echo 'No existing rules file found, installing example'
install -o "${WEB_OWNER}" -g "${WEB_GROUP}" -m 644 es_rules.example.yml "${TARGET_CONFIG}/es_rules.yml" &&
print_success "rules copied" || print_error "could not copy rules"
else
echo "Upgrading existing rules with any new keys..."
${PYTHON} tools/config_upgrade_yaml.py -c "${TARGET_CONFIG}/es_rules.yml" -e es_rules.example.yml &&
print_success "rules upgraded" || print_warning "rules upgrade failed"
fi
print_warning " Remember to fill in the right values in the config files, or your system won't work!"
echo
}
# move Hook config files
install_hook_config() {
# Download models if needed (uses download_if_needed, so existing files are skipped)
download_models
# Auto-migrate from INI to YAML if needed
if [ -f "${TARGET_CONFIG}/objectconfig.ini" ] && [ ! -f "${TARGET_CONFIG}/objectconfig.yml" ]; then
echo "Found existing objectconfig.ini but no objectconfig.yml - running migration..."
if ${PYTHON} tools/config_migrate_yaml.py -c "${TARGET_CONFIG}/objectconfig.ini" -o "${TARGET_CONFIG}/objectconfig.yml"; then
print_success "migration complete"
mv "${TARGET_CONFIG}/objectconfig.ini" "${TARGET_CONFIG}/objectconfig.ini.migrated"
print_important "Renamed old objectconfig.ini to objectconfig.ini.migrated"
else
print_warning "migration failed"
fi
fi
if [ ! -f "${TARGET_CONFIG}/objectconfig.yml" ]; then
echo 'No existing hook config found, installing example as active config'
install -o "${WEB_OWNER}" -g "${WEB_GROUP}" -m 644 hook/objectconfig.yml "${TARGET_CONFIG}" &&
print_success "config copied" || print_error "could not copy config"
else
echo "Upgrading existing hook config with any new keys..."
${PYTHON} tools/config_upgrade_yaml.py -c "${TARGET_CONFIG}/objectconfig.yml" -e hook/objectconfig.yml &&
print_success "hook config upgraded" || print_warning "hook config upgrade failed"
fi
# Fix stale secrets.ini reference in objectconfig if secrets.yml exists
if [ -f "${TARGET_CONFIG}/objectconfig.yml" ] && [ -f "${TARGET_CONFIG}/secrets.yml" ]; then
if grep -q 'secrets\.ini' "${TARGET_CONFIG}/objectconfig.yml"; then
sed -i 's|secrets\.ini|secrets.yml|g' "${TARGET_CONFIG}/objectconfig.yml"
print_success "Updated secrets path from .ini to .yml in objectconfig.yml"
fi
fi
# Fix hardcoded /etc/zm paths in hook config when TARGET_CONFIG differs
if [ "${TARGET_CONFIG}" != "/etc/zm" ] && [ -f "${TARGET_CONFIG}/objectconfig.yml" ]; then
sed -i "s|/etc/zm/|${TARGET_CONFIG}/|g" "${TARGET_CONFIG}/objectconfig.yml"
print_success "Updated /etc/zm paths to ${TARGET_CONFIG} in objectconfig.yml"
fi
print_warning " Remember to fill in the right values in the config files, or your system won't work!"
echo
}
# returns 'ok' if openCV version >= version passed
check_opencv_version() {
MAJOR=$1
MINOR=$2
CVVERS=`${PYTHON} -c "import cv2; print (cv2.__version__)" 2>/dev/null`
if [ -z "${CVVERS}" ]; then
echo "fail"
return 1
fi
IFS='.'
list=($CVVERS)
if [ ${list[0]} -ge ${MAJOR} ] && [ ${list[1]} -ge ${MINOR} ]; then
echo "ok"
return 0
else
echo "fail"
return 1
fi
}
print_opencv_message() {
print_success "Done"
cat << EOF
|-------------------------- NOTE -------------------------------------|
Hooks are installed, but please make sure you have the right version
of OpenCV installed. ONNX models (YOLOv11, YOLOv26) require OpenCV 4.13+.
See https://zmeventnotificationv7.readthedocs.io/en/latest/guides/hooks.html#opencv-install
|----------------------------------------------------------------------|
EOF
}
# Post-install diagnostic checks
run_doctor_checks() {
local hook_config="${TARGET_CONFIG}/objectconfig.yml"
local es_config="${TARGET_CONFIG}/zmeventnotification.yml"
[ ! -f "$hook_config" ] && [ ! -f "$es_config" ] && return
print_section 'Post-install diagnostic checks'
${PYTHON} tools/install_doctor.py \
--hook-config "$hook_config" \
--es-config "$es_config" \
--web-owner "${WEB_OWNER}" \
--web-group "${WEB_GROUP}" \
--base-data "${TARGET_DATA}" \
|| true
}
# wuh
display_help() {
cat << EOF
sudo -H [VAR1=value|VAR2=value...] $0 [-h|--help] [--install-es|--no-install-es] [--install-hook|--no-install-hook] [--install-config|--no-install-config] [--install-es-config|--no-install-es-config] [--install-hook-config|--no-install-hook-config] [--hook-config-upgrade|--no-hook-config-upgrade] [--no-pysudo] [--no-download-models] [--install-opencv|--no-install-opencv] [--install-birdnet|--no-install-birdnet] [--venv-path PATH] [--no-venv]
When used without any parameters executes in interactive mode
-h: This help
--install-es: installs Event Server without prompting
--no-install-es: skips Event Server install without prompting
--install-hook: installs hooks without prompting
--no-install-hook: skips hooks install without prompting
--install-config: installs/overwrites both ES and hook config files without prompting
--no-install-config: skips both ES and hook config install without prompting
--install-es-config: installs/overwrites ES config without prompting
--no-install-es-config: skips ES config install without prompting
--install-hook-config: installs/overwrites hook config without prompting
--no-install-hook-config: skips hook config install without prompting
--no-interactive: run automatically, but you need to specify flags for all components
--no-pysudo: If specified will install python packages
without sudo (some users don't install packages globally)
--no-download-models: If specified will not download any models.
You may want to do this if using mlapi
--install-opencv: Install python3-opencv (default)
--no-install-opencv: Skip python3-opencv installation
--hook-config-upgrade: Upgrades legacy objectconfig.ini and migrates to objectconfig.yml
You will need to manually review the migrated config
--no-hook-config-upgrade: skips above process
--install-birdnet: Install birdnet-analyzer for audio bird species detection
--no-install-birdnet: Skip BirdNET installation (default)
--venv-path PATH: Path for the shared Python venv (default: /opt/zoneminder/venv)
--no-venv: Skip venv creation and install globally with --break-system-packages
(not recommended — only for backward compatibility)
In addition to the above, you can also override all variables used for your own needs
Overridable variables are:
PYTHON: python interpreter (default: python3)
PIP: pip package installer (default: pip3)
WGET: path to wget (default \`which wget\`)
INSTALLER: Your OS equivalent of apt-get or yum (default: apt-get or yum)
INSTALL_YOLOV3: Download and install yolov3 model (default:no)
INSTALL_TINYYOLOV3: Download and install tiny yolov3 model (default:no)
INSTALL_YOLOV4: Download and install yolov4 model (default:yes)
INSTALL_TINY_YOLOV4: Download and install tiny yolov4 model (default:yes)
INSTALL_CORAL_EDGETPU: Download and install coral models (default:no)
INSTALL_YOLOV11: Download and install ONNX YOLOv11 models (default:yes). Needs OpenCV 4.13+
INSTALL_YOLOV26: Download and install ONNX YOLOv26 models (default:yes). Needs OpenCV 4.13+
INSTALL_BIRDNET: Install birdnet-analyzer for audio bird detection (default:no)
TARGET_CONFIG: Path to ES config dir (default: /etc/zm)
TARGET_DATA: Path to ES data dir (default: /var/lib/zmeventnotification)
TARGET_BIN_ES: Path to ES binary (default:/usr/bin)
TARGET_BIN_HOOK: Path to hook script files (default: /var/lib/zmeventnotification/bin)
TARGET_PERL_LIB: Path to install Perl modules (default: /usr/share/perl5)
INSTALL_OPENCV: Install python3-opencv (default: no)
ZM_VENV: Path to shared Python venv (default: /opt/zoneminder/venv)
USE_VENV: Set to 'no' to disable venv and use global install (default: yes)
WEB_OWNER: Your webserver user (default: www-data)
WEB_GROUP: Your webserver group (default: www-data)
EOF
}
# parses arguments and does a bit of conflict sanitization
check_args() {
# credit: https://stackoverflow.com/a/14203146/1361529
INSTALL_ES='prompt'
INSTALL_HOOK='prompt'
INSTALL_ES_CONFIG='prompt'
INSTALL_HOOK_CONFIG='prompt'
INSTALL_ES_CONFIG_EXPLICIT='no'
INSTALL_HOOK_CONFIG_EXPLICIT='no'
INTERACTIVE='yes'
PY_SUDO='sudo -H'
DOWNLOAD_MODELS='yes'
HOOK_CONFIG_UPGRADE='yes'
local i=0
while [[ $i -lt ${#cmd_args[@]} ]]; do
local key="${cmd_args[$i]}"
case $key in
-h|--help)
display_help && exit
;;
--no-download-models)
DOWNLOAD_MODELS='no'
;;
--no-pysudo)
PY_SUDO=''
;;
--no-interactive)
INTERACTIVE='no'
;;
--install-es)
INSTALL_ES='yes'
;;
--no-install-es)
INSTALL_ES='no'
;;
--install-hook)
INSTALL_HOOK='yes'
;;
--no-install-hook)
INSTALL_HOOK='no'
;;
--no-hook-config-upgrade)
HOOK_CONFIG_UPGRADE='no'
;;
--hook-config-upgrade)
HOOK_CONFIG_UPGRADE='yes'
;;
--install-config)
INSTALL_HOOK_CONFIG='yes'
INSTALL_ES_CONFIG='yes'
;;
--no-install-config)
INSTALL_ES_CONFIG='no'
INSTALL_HOOK_CONFIG='no'
;;
--install-es-config)
INSTALL_ES_CONFIG='yes'
INSTALL_ES_CONFIG_EXPLICIT='yes'
;;
--no-install-es-config)
INSTALL_ES_CONFIG='no'
INSTALL_ES_CONFIG_EXPLICIT='yes'
;;
--install-hook-config)
INSTALL_HOOK_CONFIG='yes'
INSTALL_HOOK_CONFIG_EXPLICIT='yes'
;;
--no-install-hook-config)
INSTALL_HOOK_CONFIG='no'
INSTALL_HOOK_CONFIG_EXPLICIT='yes'
;;
--install-opencv)
INSTALL_OPENCV='yes'
;;
--no-install-opencv)
INSTALL_OPENCV='no'
;;
--venv-path)
ZM_VENV="${cmd_args[$((i+1))]}"
i=$((i + 1))
;;
--no-venv)
USE_VENV='no'
;;
--install-birdnet)
INSTALL_BIRDNET='yes'
;;
--no-install-birdnet)
INSTALL_BIRDNET='no'
;;
esac
i=$((i + 1))
done
# If ES/hook won't be installed and config wasn't explicitly requested, skip config too
if [[ ${INSTALL_ES_CONFIG_EXPLICIT} == 'no' ]]; then
[[ ${INSTALL_ES} == 'no' ]] && INSTALL_ES_CONFIG='no'
[[ ${INSTALL_ES} == 'prompt' && ${INSTALL_ES_CONFIG} == 'yes' ]] && INSTALL_ES_CONFIG='prompt'
fi
if [[ ${INSTALL_HOOK_CONFIG_EXPLICIT} == 'no' ]]; then
[[ ${INSTALL_HOOK} == 'no' ]] && INSTALL_HOOK_CONFIG='no'
[[ ${INSTALL_HOOK} == 'prompt' && ${INSTALL_HOOK_CONFIG} == 'yes' ]] && INSTALL_HOOK_CONFIG='prompt'
fi
}
check_deps() {
local missing=0
if [[ ${INSTALL_ES} != 'no' ]]; then
if ! perl -MNet::WebSocket::Server -e1 2>/dev/null; then
print_error "Net::WebSocket::Server Perl module is not installed."
echo " Install it with: sudo cpanm Net::WebSocket::Server"
missing=1
fi
if ! perl -MIO::Socket::SSL -e1 2>/dev/null; then
print_error "IO::Socket::SSL Perl module is not installed."
echo " Install it with: sudo ${INSTALLER} install libio-socket-ssl-perl"
missing=1
fi
if ! perl -MURI::Escape -e1 2>/dev/null; then
print_error "URI::Escape Perl module is not installed."
echo " Install it with: sudo ${INSTALLER} install liburi-perl"
missing=1
fi
if ! perl -MDBI -e1 2>/dev/null; then
print_error "DBI Perl module is not installed."
echo " Install it with: sudo ${INSTALLER} install libdbi-perl"
missing=1
fi
fi
if [[ ${INSTALL_HOOK} != 'no' ]]; then
if ! command -v ${PIP} >/dev/null 2>&1; then
print_error "${PIP} is not installed."
echo " Install it with: sudo ${INSTALLER} install python3-pip"
missing=1
fi
fi
if [[ ${missing} -eq 1 ]]; then
print_error "Please install missing dependencies and re-run."
exit 1
fi
}
###################################################
# script main
###################################################
cmd_args=("$@") # because we need a function to access them