summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 485425a0b547ccb4f8179a1903d455b9d8d16743 (plain)
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
# Maintainer: Luis Aranguren <pizzaman@hotmail.com>

pkgname=zmeventnotification-git
_pkgname=zmeventnotification
pkgver=v4.6.1.r20.gf70308a
pkgrel=2
pkgdesc='Event Notification Server sits along with ZoneMinder and offers real time notifications, support for push notifications as well as Machine Learning powered recognition + hooks'
arch=('x86_64')
url='https://github.com/pliablepixels/zmeventnotification'
license=('GPL' 'MIT')
depends=('perl-crypt-mysql' 'perl-config-inifiles' 'perl-crypt-eksblowfish' 'perl-net-websocket-server' 'perl-json' 'perl-lwp-protocol-https'
         'perl-io-socket-ssl' 'perl-net-mqtt-simple' 'perl-config-inifiles' 'opencv'
         #hooks
         'geos' 'hdf5' 'python-numpy' 'python-imutils' 'python-pyzm-git' 'python-sqlalchemy' 'python-psutil' 'python-future' 'python-shapely' 'python-mysql-connector'
         'python-sklearn-bayes' 'python-face_recognition'
)
makedepends=('cmake' 'wget' 'git')
optdepends=()
conflicts=()
backup=('etc/zoneminder/objectconfig.ini' 'etc/zoneminder/secrets.ini' 'etc/zoneminder/zmeventnotification.ini')
NoUpgrade=('etc/zoneminder/objectconfig.ini' 'etc/zoneminder/secrets.ini' 'etc/zoneminder/zmeventnotification.ini')
install=
source=("git://github.com/pliablepixels/$_pkgname.git"
        'https://raw.githubusercontent.com/pjreddie/darknet/master/cfg/yolov3.cfg'
        'yolov3_classes.txt::https://raw.githubusercontent.com/pjreddie/darknet/master/data/coco.names'
        'https://pjreddie.com/media/files/yolov3.weights'
)
sha256sums=('SKIP'
            'SKIP'
            'SKIP'
            '523e4e69e1d015393a1b0a441cef1d9c7659e3eb2d7e15f793f060a21b32f297'
)

pkgver() {
    cd "$_pkgname"
    git describe --long | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

prepare () {
    cd $_pkgname
    #objectconfig.ini
    sed -i "s|/etc/zm|/etc/zoneminder|" hook/objectconfig.ini
    sed -i "s|/var/lib/zmeventnotification/models|/opt/zmeventnotification/models|" hook/objectconfig.ini
    sed -i "s|models=yolo,face|models=yolo|" hook/objectconfig.ini

    #zmeventnotification.ini
    sed -i "s|/etc/zm|/etc/zoneminder|" zmeventnotification.ini
    sed -i "s|/var/lib/zmeventnotification/bin/zm_detect_wrapper.sh|/opt/zmeventnotification/bin/zm_detect_wrapper.sh|" zmeventnotification.ini
    sed -i "s|/etc/apache2/ssl/yourportal|/etc/ssl/private|"  zmeventnotification.ini

    #secrets.ini
    sed -i "s|URL=https://portal/zm|ZM_PORTAL=http://your_website|" secrets.ini
    sed -i "s|ZM_PORTAL=https://portal/zm|ZM_PORTAL=http://127.0.0.1:8095|" secrets.ini

    #zm_detect_wrapper.sh
    sed -i "s|/etc/zm|/etc/zoneminder|" hook/zm_detect_wrapper.sh
    sed -i "s|/var/lib|/opt|" hook/zm_detect_wrapper.sh

    #zmeventnotification.pl
    sed -i "s|/etc/zm/zmeventnotification.ini|/etc/zoneminder/zmeventnotification.ini|" zmeventnotification.pl
}

build() {
    cd $_pkgname/hook
    python setup.py build
}
     
package() {
    cd $_pkgname
    #bin
    install -Dm 755 zmeventnotification.pl "${pkgdir}/usr/bin/zmeventnotification.pl"

    #Folder structure
    mkdir -p "${pkgdir}/var/lib/zmeventnotification/push" 2>/dev/null
    mkdir -p "${pkgdir}/opt/zmeventnotification/bin" 2>/dev/null
    mkdir -p "${pkgdir}/var/lib/zmeventnotification/images" 2>/dev/null
    mkdir -p "${pkgdir}/var/lib/zmeventnotification/known_faces" 2>/dev/null
    mkdir -p "${pkgdir}/opt/zmeventnotification/misc" 2>/dev/null

    #Yolo
    install -Dm644 ${srcdir}/yolo* --target-directory "${pkgdir}/opt/zmeventnotification/models/yolov3/"

    #ML Hooks
    install -Dm 755 hook/zm_detect_wrapper.sh "${pkgdir}/opt/zmeventnotification/bin/zm_detect_wrapper.sh"
    install -Dm 755 hook/zm_detect.py "${pkgdir}/opt/zmeventnotification/bin/zm_detect.py"
    install -Dm 755 hook/zm_train_faces.py "${pkgdir}/opt/zmeventnotification/bin/zm_train_faces.py"
    cd hook
    python setup.py install --root="$pkgdir/" --optimize=1 --skip-build
    cd ..

    #ES config files
    mkdir -p "${pkgdir}/etc/zoneminder" 2>/dev/null
    install --backup=numbered -m 644 zmeventnotification.ini "${pkgdir}/etc/zoneminder/"
    install --backup=numbered -m 644 secrets.ini "${pkgdir}/etc/zoneminder/"

    #Hook config files
    install --backup=numbered -m 644 hook/objectconfig.ini "${pkgdir}/etc/zoneminder/"

    #webserver should access
    chown -R http:http "${pkgdir}/var/lib/zmeventnotification"

    #Notes
    #Disabled SSL and Authnetication in zmeventnotificaiton.ini
    #Make a guide so people fill secrets.ini ZM_USER ZM_PASSWORD ZMES_PICTURE_URL or link to he website
}