Suppression du serveur de test de Dakar. Normalisation à Danang.
[asterisk-config-auf-connexions.git] / debian / postinst
CommitLineData
0afa8158
TN
1#! /bin/bash
2# postinst script for asterisk-config-auf-connexions
3#
4# see: dh_installdeb(1)
5
6set -e
7
8# summary of how this script can be called:
9# * <postinst> `configure' <most-recently-configured-version>
10# * <old-postinst> `abort-upgrade' <new version>
11# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
12# <new-version>
13# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
14# <failed-install-package> <version> `removing'
15# <conflicting-package> <version>
16# for details, see http://www.debian.org/doc/debian-policy/ or
17# the debian-policy package
18#
19
20
21case "$1" in
22 configure)
23
24 # extrait du postinst general a tous les paquets asterisk...
25
26 # add asterisk user and add it to dialout and audio groups
27 if ! getent passwd asterisk > /dev/null ; then
28 echo 'Adding system user and group for Asterisk' 1>&2
29 adduser --system --group --quiet \
30 --home /var/lib/asterisk \
31 --no-create-home --disabled-login \
32 --gecos "Asterisk PBX daemon" \
33 asterisk
34
35 for group in dialout audio; do
36 if groups asterisk | grep -w -q -v $group; then
37 adduser asterisk $group
38 fi
39 done
40 fi
41
42 # préparation du répertoire pour les config spécifiques à l'AUF
43 test -d /etc/asterisk/auf || mkdir -p /etc/asterisk/auf
44
45 # on (re)force les droits minimum sur /etc/asterisk
46 chown -R root:asterisk /etc/asterisk
47 chmod 0755 /etc/asterisk
48 chmod 0755 /etc/asterisk/auf
49 chmod 0640 /etc/asterisk/*.conf 2> /dev/null || true
50 #chmod 0640 /etc/asterisk/auf/* 2> /dev/null || true
51
52 # migration vers /usr/share pour asterisk 1.4 : on copie les *.key
53 # et les *.pub correspondantes de /var/lib vers /usr/share
49bb45c5
P
54 if test -d /var/lib/asterisk/keys ; then
55 cd /var/lib/asterisk/keys
56 if ls *.key > /dev/null 2>&1; then
0afa8158
TN
57 for KEY in *.key
58 do
59 # si la clé privée n'existe pas dans /usr/share, on la copie
60 if [ ! -e /usr/share/asterisk/keys/$KEY ]
61 then
62 echo "asterisk1.4 : cp /var/lib/asterisk/keys/$KEY /usr/share/asterisk/keys/$KEY"
63 cp -a $KEY /usr/share/asterisk/keys/ || true
64 # clé publique correspondante, sera copiée si elle existe dans /var/lib
65 # et si elle n'existe pas dans /usr/share/
66 PUB=`basename $KEY .key`.pub
67 if [ -e $PUB -a ! -e /usr/share/asterisk/keys/$PUB ]
68 then
69 echo "asterisk1.4 : cp /var/lib/asterisk/keys/$PUB /usr/share/asterisk/keys/$PUB"
70 cp -a $PUB /usr/share/asterisk/keys/ || true
71 fi
72 fi
73 done
49bb45c5
P
74 fi
75 # droits minimums sur les clés dans /var/lib
76 chown -R root:asterisk /var/lib/asterisk/keys
77 chmod 0755 /var/lib/asterisk/keys
78 chmod 0444 /var/lib/asterisk/keys/*.pub 2> /dev/null || true
79 chmod 0440 /var/lib/asterisk/keys/*.key 2> /dev/null || true
0afa8158
TN
80 fi
81
49bb45c5 82 # droits minimums sur les clés dans /usr/share
0afa8158
TN
83 chown -R root:asterisk /usr/share/asterisk/keys
84 chmod 0755 /usr/share/asterisk/keys
85 chmod 0444 /usr/share/asterisk/keys/*.pub 2> /dev/null || true
86 chmod 0440 /usr/share/asterisk/keys/*.key 2> /dev/null || true
87
88 # on ne reload que ce qui a été changé par ce paquet : iax et extensions
89 if [ -x /usr/sbin/rasterisk ]; then
c09fec8f 90 rasterisk -x "iax2 reload" || true
1d706ec2 91 rasterisk -x "diaplan reload" || true
0afa8158
TN
92 fi
93
94 ;;
95
96 abort-upgrade|abort-remove|abort-deconfigure)
97
98 ;;
99
100 *)
101 echo "postinst called with unknown argument \`$1'" >&2
102 exit 1
103 ;;
104esac
105
106# dh_installdeb will replace this with shell code automatically
107# generated by other debhelper scripts.
108
109#DEBHELPER#
110
111exit 0