forked from bluecherrydvr/bluecherry-apps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbluecherry.spec.template
144 lines (131 loc) · 5.17 KB
/
bluecherry.spec.template
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
Name: bluecherry
Version: %%UPSTREAM_VERSION%%
Release: 1
Epoch: 2
Summary: Bluecherry DVR Server
Group: Applications/Multimedia
License: Proprietary
URL: http://www.bluecherrydvr.com/
Source: %{name}-%{version}.tar.gz
Prefix: %{_prefix}
BuildRequires: git,make,rpm-build,gcc-c++,ccache,autoconf,automake,libtool,bison,flex
BuildRequires: texinfo,php-devel,yasm,cmake,libbsd-devel,chrpath
BuildRequires: mariadb-devel,opencv-devel,systemd-devel
BuildRequires: systemd
Requires: epel-release,dpkg,httpd,mod_ssl,php,php-mysqlnd,php-pdo,php-pear-Mail,php-pear-Mail-Mime,mkvtoolnix,dpkg
Requires: mariadb,mariadb-server,sysstat,opencv-core,epel-release,libbsd,policycoreutils-python
Requires: nmap,mkvtoolnix-gui
Requires: v4l-utils
%description
This package contains the server components for the Bluecherry DVR system.
%prep
%autosetup -n %{name} -c %{name}
echo "#define GIT_REVISION \"`git describe --dirty --always --long` `git describe --all`\"" > server/version.h
%build
git submodule foreach --recursive "git clean -dxf && git reset --hard"
git clean -dxf && git reset --hard
git submodule update
echo "#define GIT_REVISION \"`git describe --dirty --always --long` `git describe --all`\"" > server/version.h
make clean
make
%install
%make_install
%{_builddir}/%{name}/scripts/build_helper/post_make_install.sh rpm "%{_builddir}/%{name}" "%{buildroot}" %{epoch}:%{version}-%{release}
mkdir -p %{buildroot}/etc/logrotate.d
cp %{_builddir}/%{name}/rpm/bluecherry.logrotate %{buildroot}/etc/logrotate.d/bluecherry
chmod 755 %{buildroot}/usr/lib/libbluecherry.so.0
install -m644 -D %{_builddir}/%{name}/rpm/bluecherry.service %{buildroot}/%{_unitdir}/bluecherry.service
%files
%config(noreplace) %{_sysconfdir}/httpd/sites-available/bluecherry.conf
%config(noreplace) %{_sysconfdir}/cron.d/bluecherry
%config(noreplace) %{_sysconfdir}/logrotate.d/bluecherry
%config(noreplace) %{_sysconfdir}/monit/conf.d/bluecherry
%config(noreplace) %{_sysconfdir}/rsyslog.d/10-bluecherry.conf
%{_sbindir}/*
/usr/lib/libbluecherry.so.0
/usr/lib/bluecherry/*
%{_datadir}/%{name}/*
%{_unitdir}/*
%pre
set -x
if [[ $(getenforce) == "Enforcing" ]]
then
echo Configuring selinux. Please wait.
semanage port -m -t http_port_t -p tcp 7001 # for selinux
setsebool -P httpd_can_network_connect 1
fi
systemctl enable mariadb.service
systemctl start mariadb.service
INSTALL="1"
UPGRADE="2"
if [[ "$1" == "$UPGRADE" ]] && [[ -s /etc/bluecherry.conf ]]
then
eval $(sed '/\(host\|dbname\|user\|password\)/!d;s/ *= */=/'";s/\"/'/g" /etc/bluecherry.conf)
DB_VERSION=$(cat /usr/share/bluecherry/installed_db_version)
OLD_DB_VERSION=`echo "SELECT value from GlobalSettings WHERE parameter = 'G_DB_VERSION'" | mysql -h"$host" -D"$dbname" -u"$user" -p"$password" | tail -n 1`
NEW_DB_VERSION=$DB_VERSION
if [[ "$OLD_DB_VERSION" -gt "$NEW_DB_VERSION" ]]
then
echo "DOWNGRADE ACROSS DATABASE VERSIONS IS NOT SUPPORTED"
echo "Only clean install of older version"
echo "To cleanup your installation remove package 'rpm -e bluecherry'"
echo "And then run as root ~bluecherry/bin/remove_all_data.sh"
echo "Or manually remove all mediafiles, drop database,"
echo "remove config '/etc/bluecherry.conf' then 'userdel -r -f bluecherry'"
echo "ALL your data will be lost!!!"
exit 1
fi
fi
case "$1" in
1|2)
if ! id bluecherry > /dev/null 2>&1; then
groupadd -r -f bluecherry
useradd -c "Bluecherry DVR" -d /var/lib/bluecherry \
-g bluecherry -G audio,video -r -m bluecherry
else
# just to be sure we have such group, if user was created manually
groupadd -r -f bluecherry || true
usermod -c "Bluecherry DVR" -d /var/lib/bluecherry \
-g bluecherry -G audio,video bluecherry
fi
usermod -a -G video,audio,bluecherry,dialout apache || true
;;
esac
if [[ "$1" == "$UPGRADE" ]]
then
systemctl stop bluecherry.service || true
fi
%post
/sbin/ldconfig
bash -x %{_datadir}/%{name}/postinstall.sh "$@"
install -m 750 -o bluecherry -g bluecherry -D /usr/share/bluecherry/remove_all_data.sh ~bluecherry/bin/remove_all_data.sh
%posttrans
systemctl enable httpd.service || true
systemctl enable bluecherry.service || true
systemctl daemon-reload || true
systemctl restart bluecherry.service || true
%preun
set -x
if [[ $1 == 0 ]] # uninstall, not upgrade
then
systemctl stop bluecherry.service
if [[ -e /etc/httpd/sites-enabled/bluecherry.conf ]]
then
rm /etc/httpd/sites-enabled/bluecherry.conf
fi
systemctl reload httpd.service || true
fi
%postun
/sbin/ldconfig
if [[ $1 == 0 ]] # uninstall, not upgrade
then
echo -e "\n\t\t!!!ATTENTION!!!\n"
echo "Bluecherry server package removed but configs, records, database and"
echo "bluecherry user still exist. To cleanup your installation run as root "
echo "sudo ~bluecherry/bin/remove_all_data.sh"
echo "Or manually remove all mediafiles, drop database,"
echo "remove config '/etc/bluecherry.conf' then 'userdel -r -f bluecherry'"
echo "ALL bluecherry server data will be removed!!!"
echo ""
echo "====================================================================="
fi