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>
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
16
. /usr/share/debconf/confmodule
17
trap "db_stop || true" EXIT HUP INT QUIT TERM
19
PACKAGE=landscape-client
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
29
db_input medium $PACKAGE/sysinfo_in_motd || true
30
db_get $PACKAGE/sysinfo
32
# * Do not display sysinfo on login
33
# * Cache sysinfo in /etc/motd
34
# * Run sysinfo on every login
35
SYSINFO="${RET:-Cache sysinfo in /etc/motd}"
36
if [ "$RET" = "Cache sysinfo in /etc/motd" ]; then
37
rm -f /etc/profile.d/landscape-sysinfo.sh 2>/dev/null || true
38
ln -s /usr/bin/landscape-sysinfo /etc/update-motd.d/50-landscape-sysinfo
39
/etc/init.d/update-motd refresh || true
40
elif [ "$RET" = "Run sysinfo on every login" ]; then
41
if rm -f /etc/update-motd.d/50-landscape-sysinfo 2>/dev/null; then
42
/etc/init.d/update-motd refresh || true
44
echo /usr/bin/landscape-sysinfo > /etc/profile.d/landscape-sysinfo.sh
46
if rm -f /etc/update-motd.d/50-landscape-sysinfo 2>/dev/null; then
47
/etc/init.d/update-motd refresh || true
49
rm -f /etc/profile.d/landscape-sysinfo.sh || true
52
# 0.9.1 introduces non-backwards compatible changes. This detects
53
# whether or not the data is in the current format. If not, all
54
# existing data is removed.
55
DATA_DIR=/var/lib/landscape
57
if [ -d $DATA_DIR/data ]; then
59
elif [ -f $DATA_DIR/client/data.bpickle ]; then
60
LAST_BYTE=`sed -n '$,$s/.*\(.\)/\1/p' $DATA_DIR/client/data.bpickle`
61
if [ "$LAST_BYTE" = e ]; then
66
# Create landscape system user
67
if ! getent passwd landscape >/dev/null; then
68
adduser --quiet --system --disabled-password \
69
--gecos "Landscape Client Daemon" \
70
--home /var/lib/landscape --no-create-home landscape
73
# Fix prior ownerships
74
chown -R landscape /var/log/landscape /var/lib/landscape
76
# Tell dbus to reload its configuration since we've installed a conf
77
# to its system.d. We must do this before invoking landscape-config.
78
invoke-rc.d dbus reload || true
80
CONFIG_FILE=/etc/landscape/client.conf
81
if [ ! -f $CONFIG_FILE ]; then
82
# Create new configuration, with private mode
83
TEMPFILE=$(mktemp -p /etc/landscape)
87
url = https://landscape.canonical.com/message-system
88
ping_url = http://landscape.canonical.com/ping
89
data_path = /var/lib/landscape/client
91
chown landscape $TEMPFILE
92
mv $TEMPFILE $CONFIG_FILE
94
# Do debconf configuration
95
db_get $PACKAGE/register_system
96
if [ "$RET" = true ]; then
101
db_input "$priority" $PACKAGE/computer_title || true
102
db_input "$priority" $PACKAGE/account_name || true
103
db_input "$priority" $PACKAGE/registration_password || true
106
db_get $PACKAGE/computer_title
107
COMPUTER_TITLE="${RET}"
108
db_get $PACKAGE/account_name
109
ACCOUNT_NAME="${RET}"
110
db_get $PACKAGE/registration_password
111
REGISTRATION_PASSWORD="${RET}"
113
# If we got the needed information, actually do the registration.
114
if [ -n "$ACCOUNT_NAME" -a -n "$COMPUTER_TITLE" ]; then
115
landscape-config --silent -a "$ACCOUNT_NAME" \
116
-p "$REGISTRATION_PASSWORD" \
120
# Fix non-private permissions
121
chmod 0600 $CONFIG_FILE
124
# old monolithic clients have a single persist data file and a single
125
# package hash db. This data should be migrated to the new format
126
# where each service has a persist and the package data is kept in a
129
DATA_BPICKLE=$DATA_DIR/client/data.bpickle
130
BROKER_BPICKLE=$DATA_DIR/client/broker.bpickle
132
if [ -f $DATA_BPICKLE -a ! -f $BROKER_BPICKLE ]; then
133
$PYTHON -c "from landscape.upgraders import legacy; legacy.migrate_data_file('$DATA_DIR/client')"
134
mv $DATA_BPICKLE $DATA_BPICKLE.migrated
135
echo "Old monolithic client data file migrated to new format."
140
abort-upgrade|abort-remove|abort-deconfigure)
144
echo "postinst called with unknown argument \`$1'" >&2
149
# dh_installdeb will replace this with shell code automatically
150
# generated by other debhelper scripts.