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
|
install_db() {
. /etc/systemconfig
if [ $SystemType = Master_backend -o $SystemType = Standalone ]
then
mysql -e "use zm" > /dev/null
rc=$?
if [ $rc = 1 ]
then
echo "Installing zoneminder database zm"
cat /usr/share/zoneminder/db/zm_create.sql | mysql
echo 'grant lock tables, alter,select,insert,update,delete on zm.* to 'zmuser'@localhost identified by "zmpass";' | mysql
fi
else
echo "Will only init the database for StandAlone or Master_backend LinHES systems"
fi
}
pre_install() {
set -e
abort=false
if [ -L /srv/http/zoneminder/events ]; then
l=$(readlink /srv/http/zoneminder/events)
if [ $l != /var/cache/zoneminder/events ]; then
abort=true
fi
fi
if [ -L /srv/http/zoneminder/images ]; then
l=$(readlink /srv/http/zoneminder/images)
if [ $l != /var/cache/zoneminder/images ]; then
abort=true
fi
fi
if [ $abort = true ]; then
cat >&2 << EOF
Aborting installation of zoneminder due to non-default symlinks in
/srv/http/zoneminder for the images and/or events directory, which could
result in loss of data. Please move your data in each of these directories to
/var/cache/zoneminder before installing zoneminder from the package.
EOF
exit 1
fi
exit 0
}
post_install() {
if [[ -d /var/log/zoneminder ]]; then
chmod 0755 /var/log/zoneminder
chown http.http /var/log/zoneminder
else
mkdir -m 0755 /var/log/zoneminder
chown http.http /var/log/zoneminder
fi
if [[ -d /tmp/zm ]]; then
chmod 0700 /tmp/zm
chown http.http /tmp/zm
else
mkdir -m 0700 /tmp/zm
chown http.http /tmp/zm
fi
# edit /etc/php.ini for Zoneminder
sed -e '
# Enable these libraries by removing the leading comment character
\|^;extension=mysql.so$| s|^;||;
\|^;extension=mysqli.so$| s|^;||;
\|^;extension=pdo_mysql.so$| s|^;||;
\|^;extension=gd.so$| s|^;||;
\|^;extension=gettext.so$| s|^;||;
\|^;extension=mcrypt.so$| s|^;||;
\|^;extension=session.so$| s|^;||;
\|^;extension=sockets.so$| s|^;||;
\|^;extension=openssl.so$| s|^;||;
\|^;extension=ftp.so$| s|^;||;
\|^;extension=zip.so$| s|^;||;
# Add zoneminder paths to open_basedir
s|^open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/$|&:/etc:/srv/http/zoneminder/:/var/cache/zoneminder/|;
' /etc/php/php.ini > /etc/php/php.ini.zoneminder
# edit /etc/httpd/conf/httpd.conf for Zoneminder
sed -e '
# Use mod_mpm_prefork instead of mod_mpm_event.so (FS#39218).
s|^LoadModule mpm_event_module modules/mod_mpm_event.so$|#&\nLoadModule mpm_prefork_module modules/mod_mpm_prefork.so|;
# Zoneminder requires cgi
\|^#LoadModule cgi_module modules/mod_cgi.so$| s|#||;
# libphp5
\|^LoadModule php5_module modules/libphp5.so$|d;
s|^#*LoadModule rewrite_module modules/mod_rewrite.so$|&\nLoadModule php5_module modules/libphp5.so|;
\|^Include /etc/httpd/conf/extra/php5_module.conf|d;
s|^Include conf/extra/httpd-default.conf$|&\nInclude /etc/httpd/conf/extra/php5_module.conf|;
# Include httpd-zoneminder.conf
\|^Include /etc/httpd/conf/extra/httpd-zoneminder.conf$|d;
s|^# Server-pool management (MPM specific)$|\nInclude /etc/httpd/conf/extra/httpd-zoneminder.conf\n&|;
' /etc/httpd/conf/httpd.conf > /etc/httpd/conf/httpd.conf.zoneminder
#---LinHES Stuff
usermod -G video http
install_db
gen_light_include.py
/sbin/sv hup /service/lighttpd
#---
cat << EOF
Note for mysql:
==> To run Zoneminder, you must install the database running mysql service (as root):
==> "rc.d start mysqld" (in initscripts) or "systemctl start mysqld.service" (in systemd)
==> and add Zoneminder database typing (with passsword):
==> "mysqladmin --defaults-file=/etc/mysql/my.cnf -p -f reload"
==> "cat /usr/share/zoneminder/db/zm_create.sql | mysql --defaults-file=/etc/mysql/my.cnf -p"
==> "echo 'grant lock tables, alter,select,insert,update,delete on zm.* to 'zmuser'@localhost identified by "zmpass";' | mysql --defaults-file=/etc/mysql/my.cnf -p mysql"
==> (or without passsword):
==> "mysqladmin --defaults-file=/etc/mysql/my.cnf -f reload"
==> "cat /usr/share/zoneminder/db/zm_create.sql | mysql --defaults-file=/etc/mysql/my.cnf"
==> "echo 'grant lock tables, alter,select,insert,update,delete on zm.* to 'zmuser'@localhost identified by "zmpass";' | mysql --defaults-file=/etc/mysql/my.cnf mysql"
Note for php:
==> You must uncomment that line in /etc/php/php.ini:
==> "extension=mysql.so"
==> check and make sure these are uncommented:
==> "extension=gd.so"
==> "extension=gettext.so"
==> "extension=mcrypt.so"
==> "extension=mysqli.so"
==> "extension=session.so"
==> "extension=sockets.so"
==> "extension=openssl.so"
==> "extension=ftp.so"
==> "extension=zip.so"
==> check and add to open_basedir "/etc" and
==> "/srv/http/zoneminder" like so
==> "open_basedir = /home:/tmp:/usr/share/pear:/etc:/srv/http/zoneminder"
==> and set your timezone in php.ini:
==> "date.timezone = <your_country>/<your_city>"
Note for apache:
==> You must edit /etc/httpd/conf/httpd.conf and add the line:
==> "LoadModule php5_module modules/libphp5.so"
==> and:
==> "Include /etc/httpd/conf/extra/php5_module.conf"
==> "Include /etc/httpd/conf/extra/httpd-zoneminder.conf"
EOF
}
post_upgrade() {
post_install
/usr/bin/zmupdate.pl -f >/dev/null
#---LinHES Stuff
gen_light_include.py
/sbin/sv hup /service/lighttpd
#--
}
post_remove() {
if [[ -d /tmp/zoneminder ]]; then
rm -vr /tmp/zoneminder
fi
# sed -i -e '
# /^open_basedir/ s/:\/srv\/http\/zoneminder//;
# /^open_basedir/ s/:\/srv\/http\/zoneminder\///;
# ' /etc/php/php.ini || read
# sed -i -e '
# /^# ZoneMinder/d;
# /Include \/etc\/httpd\/conf\/extra\/httpd-zoneminder.conf/d;
# ' /etc/httpd/conf/httpd.conf || read
#---LinHES Stuff
gen_light_include.py
/sbin/sv hup /service/lighttpd
#--
cat << EOF
Note:
==> To clean Zoneminder mysql database, run as root (with password):
==> "echo 'delete from user where User="zmuser";' | mysql --defaults-file=/etc/mysql/my.cnf -p mysql"
==> "echo 'delete from db where User="zmuser";' | mysql --defaults-file=/etc/mysql/my.cnf -p mysql"
==> "mysqladmin --defaults-file=/etc/mysql/my.cnf -p -f drop zm"
==> (or without password):
==> "echo 'delete from user where User="zmuser";' | mysql --defaults-file=/etc/mysql/my.cnf mysql"
==> "echo 'delete from db where User="zmuser";' | mysql --defaults-file=/etc/mysql/my.cnf mysql"
==> "mysqladmin --defaults-file=/etc/mysql/my.cnf -f drop zm"
==> Disable http with php if it isn't needed with others servers,
==> comment or remove that lines in /etc/httpd/conf/httpd.conf:
==> "LoadModule php5_module modules/libphp5.so"
==> "Include /etc/httpd/conf/extra/php5_module.conf"
==> Remove line in /etc/httpd/conf/httpd.conf:
==> "Include /etc/httpd/conf/extra/httpd-zoneminder.conf"
==> Disable php with mysql if it isn't needed with others servers,
==> comment that lines in /etc/php/php.ini:
==> "extension=mysql.so"
==> "extension=gd.so"
==> "extension=gettext.so"
==> "extension=mcrypt.so"
==> "extension=mysqli.so"
==> "extension=session.so"
==> "extension=sockets.so"
==> "date.timezone = <my_country>/<my_city>"
==> Edit /etc/php/php.ini and remove "/etc" and "/srv/http/zoneminder"
==> in the "open_basedir".
==> Remove log files and "zonemider" directory in "/var/log/zoneminder".
==> Backup and remove "events", "images" and "temp" dirs in "/var/cache/zoneminder".
EOF
}
|