/
packetfence.postinst
88 lines (73 loc) · 2.87 KB
/
packetfence.postinst
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
#!/bin/sh
# postinst script for packetfence
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <postinst> `abort-remove'
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
case "$1" in
configure)
export PACKETFENCE=/usr/local/pf
export PERL5LIB=/usr/local/pf/lib
# link to latest SQL schema
if [ ! -e "$PACKETFENCE/db/pf-schema.sql" ]; then
cd $PACKETFENCE/db
VERSIONSQL=$(ls pf-schema-* |sort -r | head -1)
ln -s $VERSIONSQL ./pf-schema.sql
fi
# we are not compatible with suhosin session encryption
sed -i "1i\suhosin.session.encrypt=Off\n" /etc/php5/apache2/php.ini
#Check if log files exist and create them with the correct owner
for fic_log in packetfence.log access_log error_log admin_access_log admin_error_log
do
if [ ! -e /usr/local/pf/logs/$fic_log ]; then
touch /usr/local/pf/logs/$fic_log
chown pf.pf /usr/local/pf/logs/$fic_log
fi
done
#Make ssl certificate
if [ ! -f /usr/local/pf/conf/ssl/server.crt ]; then
openssl req -x509 -new -nodes -days 365 -batch\
-out /usr/local/pf/conf/ssl/server.crt\
-keyout /usr/local/pf/conf/ssl/server.key\
-nodes -config /usr/local/pf/conf/openssl.cnf
fi
if [ ! -f /usr/local/pf/raddb/certs/dh ]; then
echo "Bulding default RADIUS certificates..."
cd /usr/local/pf/raddb/certs
make dh
else
echo "DH already exists, won't touch it!"
fi
# managing services
for service in snort apache2 snmptrapfmt bind9 freeradius isc-dhcp-server; do
service $service stop > /dev/null 2>&1
update-rc.d $service remove > /dev/null 2>&1
done
update-rc.d packetfence defaults . || exit 0
update-rc.d pfappserver defaults . || exit 0
invoke-rc.d pfappserver start
echo "* Reboot your server and after please fire up your Web browser and go to http://@ip_packetfence:3000/configurator to complete your PacketFence configuration."
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0
# vim: set shiftwidth=4:
# vim: set expandtab: