forked from bluecherrydvr/bluecherry-apps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbluecherry.preinst.template
63 lines (55 loc) · 2.12 KB
/
bluecherry.preinst.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
#!/bin/bash -e
# Note: this template file is prepended with misc/sql/load_db_creds.sh at packaging stage.
# So "$dbname", "$user", "$password" variables are available.
if [[ $(cat /etc/os-release | grep "^ID=" | grep centos) ]]
then
systemctl stop httpd.service
else
if [ ! -z `which service` ]
then
service apache2 stop || true
else
invoke-rc.d apache2 stop || true
fi
fi
if [ "$1" = upgrade ] && dpkg --compare-versions "$2" lt "1:2.0.3"; then
echo "UPGRADES WILL NOT WORK!!"
echo "Please 'dpkg -P bluecherry' before installing this new package"
exit 1
fi
if [ "$1" = upgrade ] && [[ -s /etc/bluecherry.conf ]]
then
OLD_DB_VERSION=`echo "SELECT value from GlobalSettings WHERE parameter = 'G_DB_VERSION'" | mysql -h"${host:-localhost}" -D"$dbname" -u"$user" -p"$password" | tail -n 1`
NEW_DB_VERSION="%%CURRENT_DB_VERSION%%"
if [[ "$OLD_DB_VERSION" -gt "$NEW_DB_VERSION" ]]
then
echo "DOWNGRADE ACROSS DATABASE VERSIONS IS NOT SUPPORTED"
echo "Please 'dpkg -P bluecherry' before installing this package"
exit 1
fi
fi
# Fixing https://github.com/bluecherrydvr/bluecherry-apps/issues/191
if [[ "$1" == upgrade ]] && dpkg --compare-versions "$2" lt "1:2.2" && [[ -s /etc/bluecherry.conf ]]
then
G_MAX_RECORD_TIME=`echo "SELECT value FROM GlobalSettings WHERE parameter = 'G_MAX_RECORD_TIME';" | mysql -h"${host:-localhost}" -D"$dbname" -u"$user" -p"$password" | tail -n 1`
if [[ $G_MAX_RECORD_TIME == "15}" ]] || [[ $G_MAX_RECORD_TIME -le 900 ]]
then
echo "UPDATE GlobalSettings SET value = '900' WHERE parameter = 'G_MAX_RECORD_TIME';" | mysql -h"${host:-localhost}" -D"$dbname" -u"$user" -p"$password"
fi
fi
case "$1" in
upgrade|install)
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 bluecherry || true
usermod -c "Bluecherry DVR" -d /var/lib/bluecherry \
-g bluecherry -G audio,video bluecherry
fi
usermod -a -G video,audio,bluecherry,dialout,adm www-data || true
;;
esac
#DEBHELPER#