aboutsummaryrefslogtreecommitdiffstats
path: root/resources/install/debian/postinst
blob: 0d019179898d95aa46ebe384f212715eb9bf8844 (plain)
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
#!/bin/sh
#
# Jitsi, the OpenSource Java VoIP and Instant Messaging client.
#
# Copyright @ 2015 Atlassian Pty Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# sources.list setting for Jitsi updates.
REPOCONFIG="deb http://download.jitsi.org/deb unstable/"

SOURCES_PREAMBLE="### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out this entry, but any other modifications may be lost.\n"

APT_CONFIG="`which apt-config 2> /dev/null`"

# Install the repository signing key
install_key() {
  APT_KEY="`which apt-key 2> /dev/null`"
  if [ -x "$APT_KEY" ]; then
    "$APT_KEY" add - >/dev/null 2>&1 <<KEYDATA
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.10 (GNU/Linux)

mQGhBEhbdJIRBACN5cMoea12WK3PX+DbMVgW/q31iyirUAZD/s0AB4yF49Nsiw2C
FLeu4/FRec43xiiprE9GSpWqRNTz2L2J+EeQPR7xIW9LFEL6D9ekua7keO2pkxh6
DoaOx59ThvEPqIr4v93NXwm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ybdu0EE25qPGA9TUtnSnTBdB0ON5ymb61l40ycVsyhUH9VgL3SuIUFG0yxzg
I45arm/kSrfbnyZcdtRftkKgUl9dDXQ1b6Q7TFWHbkJV2A5tpQbuh2DWCMCLx3vM
Ot3ts1bdk6hgf1nrYkazWueTPvmmkxxMkWoS7Ga6e9ZQi45054Ssy0hO+WtQ0JjN
PEKf/O4O3JP/DNiyPs13ZGcBkTs8Aodyhpl856TRXPfESSPBk2hjQKrIilFUvmXp
h48WldEraT2ISQQYEQIACQUCSFt0swIbDAAKCRDGl9gj6wq2VP+eAJ4kO1yrhNtL
HQ4MBGSQiCYjsZZqEgCeN703sb9cqYr/K04d8NCLx5M4BOE=
=lUEu
-----END PGP PUBLIC KEY BLOCK-----
KEYDATA
  fi
}

# Parse apt configuration and return requested variable value.
apt_config_val() {
  APTVAR="$1"
  if [ -x "$APT_CONFIG" ]; then
    "$APT_CONFIG" dump | sed -e "/^$APTVAR /"'!d' -e "s/^$APTVAR \"\(.*\)\".*/\1/"
  fi
}

# Set variables for the locations of the apt sources lists.
find_apt_sources() {
  APTDIR=$(apt_config_val Dir)
  APTETC=$(apt_config_val 'Dir::Etc')
  APT_SOURCES="$APTDIR$APTETC$(apt_config_val 'Dir::Etc::sourcelist')"
  APT_SOURCESDIR="$APTDIR$APTETC$(apt_config_val 'Dir::Etc::sourceparts')"
}

# Add the Jitsi repository to the apt sources.
# Returns:
# 0 - sources list was created
# 2 - error
create_sources_lists() {
  if [ ! "$REPOCONFIG" ]; then
    return 0
  fi

  find_apt_sources

  SOURCELIST="$APT_SOURCESDIR/jitsi.list"

  # Check if the correct repository configuration is in there.
  REPOMATCH=$(grep "^[[:space:]#]*\b$REPOCONFIG\b" "$SOURCELIST" \
    2>/dev/null)

  # Don't do anything if the file is there, since that probably means
  # we have already installed it
  if [ -r "$SOURCELIST" ]; then
    if [ ! "$REPOMATCH" ]; then
        # At this point wrong configuration is active. In that case,
        # just abandon the mess and recreate the file
        # with the correct configuration.
        printf "$SOURCES_PREAMBLE" > "$SOURCELIST"
        printf "$REPOCONFIG\n" >> "$SOURCELIST"

        if [ $? -eq 0 ]; then
            return 0
        fi
        return 2
    fi
  fi

  if [ -d "$APT_SOURCESDIR" ]; then
    printf "$SOURCES_PREAMBLE" > "$SOURCELIST"
    printf "$REPOCONFIG\n" >> "$SOURCELIST"
    if [ $? -eq 0 ]; then
      return 0
    fi
  fi
  return 2
}

## MAIN ##
install_key
create_sources_lists