~tribaal/+junk/landscape-client-14.12-0ubuntu1.15.04

« back to all changes in this revision

Viewing changes to debian/landscape-client.postinst

  • Committer: Chris Glass
  • Date: 2014-12-12 15:02:18 UTC
  • Revision ID: chris.glass@canonical.com-20141212150218-pryod8v4nr262b00
Initial import of released debian/ subdir.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
set -e
 
3
 
 
4
# summary of how this script can be called:
 
5
#        * <postinst> `configure' <most-recently-configured-version>
 
6
#        * <old-postinst> `abort-upgrade' <new version>
 
7
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
 
8
#          <new-version>
 
9
#        * <postinst> `abort-remove'
 
10
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
 
11
#          <failed-install-package> <version> `removing'
 
12
#          <conflicting-package> <version>
 
13
# for details, see http://www.debian.org/doc/debian-policy/ or
 
14
# the debian-policy package
 
15
 
 
16
. /usr/share/debconf/confmodule
 
17
trap "db_stop || true" EXIT HUP INT QUIT TERM
 
18
 
 
19
PACKAGE=landscape-client
 
20
 
 
21
# Use the default installed Python.  Running just "python" might run
 
22
# something from /usr/local/bin, which doesn't necessarily support
 
23
# running the landscape client.
 
24
PYTHON=/usr/bin/python
 
25
 
 
26
case "$1" in
 
27
    configure)
 
28
 
 
29
        CONFIG_FILE=/etc/landscape/client.conf
 
30
        if [ ! -f $CONFIG_FILE ]; then
 
31
            # Create new configuration, with private mode
 
32
            TEMPFILE=$(mktemp -p /etc/landscape)
 
33
            cat > $TEMPFILE <<END
 
34
[client]
 
35
log_level = info
 
36
url = https://landscape.canonical.com/message-system
 
37
ping_url = http://landscape.canonical.com/ping
 
38
data_path = /var/lib/landscape/client
 
39
END
 
40
            chown landscape $TEMPFILE
 
41
            mv $TEMPFILE $CONFIG_FILE
 
42
 
 
43
            # Get configuration values from debconf
 
44
            db_get $PACKAGE/computer_title
 
45
            COMPUTER_TITLE="${RET}"
 
46
            db_get $PACKAGE/account_name
 
47
            ACCOUNT_NAME="${RET}"
 
48
            db_get $PACKAGE/registration_key
 
49
            REGISTRATION_KEY="${RET}"
 
50
            db_get $PACKAGE/url
 
51
            URL="${RET}"
 
52
            db_get $PACKAGE/exchange_interval
 
53
            EXCHANGE_INTERVAL="${RET}"
 
54
            db_get $PACKAGE/urgent_exchange_interval
 
55
            URGENT_EXCHANGE_INTERVAL="${RET}"
 
56
            db_get $PACKAGE/ping_url
 
57
            PING_URL="${RET}"
 
58
            db_get $PACKAGE/ping_interval
 
59
            PING_INTERVAL="${RET}"
 
60
            db_get $PACKAGE/http_proxy
 
61
            HTTP_PROXY="${RET}"
 
62
            db_get $PACKAGE/https_proxy
 
63
            HTTPS_PROXY="${RET}"
 
64
            db_get $PACKAGE/tags
 
65
            TAGS="${RET}"
 
66
 
 
67
            # If we got the needed information, actually do the registration.
 
68
            if [ -n "$ACCOUNT_NAME" -a -n "$COMPUTER_TITLE" ]; then
 
69
                landscape-config --silent --ok-no-register \
 
70
                    --computer-title "$COMPUTER_TITLE" \
 
71
                    --account-name "$ACCOUNT_NAME" \
 
72
                    --registration-key "$REGISTRATION_KEY" \
 
73
                    --url "$URL" \
 
74
                    --exchange-interval "$EXCHANGE_INTERVAL" \
 
75
                    --urgent-exchange-interval "$URGENT_EXCHANGE_INTERVAL" \
 
76
                    --ping-url "$PING_URL" \
 
77
                    --ping-interval "$PING_INTERVAL" \
 
78
                    --http-proxy "$HTTP_PROXY" \
 
79
                    --https-proxy "$HTTPS_PROXY" \
 
80
                    --tags "$TAGS"
 
81
            fi
 
82
        else
 
83
            # Fix non-private permissions
 
84
            chmod 0600 $CONFIG_FILE
 
85
            chown landscape $CONFIG_FILE
 
86
        fi
 
87
 
 
88
        # Remove statoverride for smart-update, if there's one
 
89
        smart_update=/usr/lib/landscape/smart-update
 
90
        if dpkg-statoverride --list $smart_update >/dev/null 2>&1; then
 
91
            dpkg-statoverride --remove $smart_update
 
92
        fi
 
93
 
 
94
        # Add the setuid flag to apt-update, and make it be executable by
 
95
        # users in the landscape group (that normally means landscape itself)
 
96
        apt_update=/usr/lib/landscape/apt-update
 
97
        if ! dpkg-statoverride --list $apt_update >/dev/null 2>&1; then
 
98
            dpkg-statoverride --update --add root landscape 4754 $apt_update
 
99
        fi
 
100
 
 
101
        # Remove old cron jobs
 
102
        old_cron_job=/etc/cron.hourly/landscape-client
 
103
        if [ -e $old_cron_job ]; then
 
104
            rm $old_cron_job
 
105
        fi
 
106
        very_old_cron_job=/etc/cron.hourly/smartpm-core
 
107
        if [ -e $very_old_cron_job ]; then
 
108
            rm $very_old_cron_job
 
109
        fi
 
110
 
 
111
        # Check if we're upgrading from a D-Bus version like the client in the
 
112
        # lucid archives.
 
113
        if ! [ -z $2 ]; then
 
114
            if dpkg --compare-versions $2 lt 1.5.1; then
 
115
                # Launch a proxy service that will forward requests over DBus
 
116
                # from the old package-changer to the new AMP-based broker. This
 
117
                # is a one-off only needed for the DBus->AMP upgrade
 
118
                start-stop-daemon -x /usr/bin/landscape-dbus-proxy -b -c landscape -u landscape -S
 
119
            fi
 
120
         fi
 
121
 
 
122
    ;;
 
123
 
 
124
    abort-upgrade|abort-remove|abort-deconfigure)
 
125
    ;;
 
126
 
 
127
    *)
 
128
        echo "postinst called with unknown argument \`$1'" >&2
 
129
        exit 1
 
130
    ;;
 
131
esac
 
132
 
 
133
# dh_installdeb will replace this with shell code automatically
 
134
# generated by other debhelper scripts.
 
135
 
 
136
#DEBHELPER#
 
137
 
 
138
exit 0