-
Notifications
You must be signed in to change notification settings - Fork 341
/
Copy pathpostinst.in
executable file
·64 lines (54 loc) · 2.05 KB
/
postinst.in
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
#!/bin/sh
# Create MaxScale user if it doesnt' exist
if ! getent passwd maxscale > /dev/null
then
groupadd -r maxscale
useradd -r -s /bin/false -g maxscale maxscale
fi
# Change the owner of the directories to maxscale:maxscale
for path in "@DEFAULT_LOGDIR@" "@DEFAULT_DATADIR@" "@DEFAULT_CACHEDIR@" "@DEFAULT_PIDDIR@" "@DEFAULT_MODULE_CONFIGDIR@" "@DEFAULT_CONFIGSUBDIR@"
do
chown -R maxscale:maxscale "$path"
chmod 0755 "$path"
done
# Install ldconfig files
if [ -f "@DEFAULT_SHAREDIR@/maxscale.conf" ]
then
cp @DEFAULT_SHAREDIR@/maxscale.conf /etc/ld.so.conf.d/
else
echo "Could not find ldconfig file: @DEFAULT_SHAREDIR@/maxscale.conf" >& 2
fi
# Only copy the service files if the systemd folder and systemctl executable are found
if [ -f @DEFAULT_SHAREDIR@/maxscale.service ] && command -v systemctl > /dev/null
then
if [ -d "/lib/systemd/system" ]
then
cp @DEFAULT_SHAREDIR@/maxscale.service /lib/systemd/system
systemctl daemon-reload > /dev/null 2>&1
elif [ -d "/usr/lib/systemd/system" ]
then
cp @DEFAULT_SHAREDIR@/maxscale.service /usr/lib/systemd/system
systemctl daemon-reload > /dev/null 2>&1
fi
# Remove old directories, mistakenly installed by a few versions
if [ -d /lib/systemd/system/maxscale.service.d ]
then
rmdir /lib/systemd/system/maxscale.service.d
elif [ -d /usr/lib/systemd/system/maxscale.service.d ]
then
rmdir /lib/systemd/system/maxscale.service.d
fi
systemctl enable maxscale.service > /dev/null 2>&1
systemctl is-active maxscale.service --quiet > /dev/null 2>&1 && systemctl restart maxscale.service > /dev/null 2>&1
fi
# If no maxscale.cnf file is found in /etc, copy the template file there
if [ ! -f "@MAXSCALE_CONFDIR@/maxscale.cnf" ]
then
cp @MAXSCALE_CONFDIR@/maxscale.cnf.template @MAXSCALE_CONFDIR@/maxscale.cnf
fi
# If no logrotate config file is found, create one
if [ ! -f "/etc/logrotate.d/maxscale_logrotate" ]
then
cp @DEFAULT_SHAREDIR@/maxscale_logrotate /etc/logrotate.d/maxscale_logrotate
fi
/sbin/ldconfig