source: ocsinventory-agent/trunk/fuentes/debian/ocsinventory-agent.postinst @ 468

Last change on this file since 468 was 468, checked in by mabarracus, 4 years ago

Copyt trusty code

File size: 2.2 KB
Line 
1#!/bin/sh
2# postinst script for ocsinventory-agent
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#        * <postinst> `abort-remove'
14#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
15#          <failed-install-package> <version> `removing'
16#          <conflicting-package> <version>
17# for details, see http://www.debian.org/doc/debian-policy/ or
18# the debian-policy package
19
20case "$1" in
21    configure|reconfigure)
22
23      if [ -f /etc/ocsinventory-client/last_state ]; then
24        echo "Moving autogenerated file to right directory"
25        mv -v /etc/ocsinventory-client/last_state \
26          /var/cache/ocsinventory-agent/
27      fi
28      if [ -f /etc/ocsinventory-client/ocsinv.adm ]; then
29        echo "Moving autogenerated file to right directory"
30        mv -v /etc/ocsinventory-client/ocsinv.adm \
31          /var/lib/ocsinventory-agent/
32        ucf --purge /etc/ocsinventory-client/ocsinv.adm
33      fi
34      if [ -f /etc/init.d/ocsinventory-client ]; then
35        echo "Deleting old init.d file"
36        rm -fv /etc/init.d/ocsinventory-client
37        update-rc.d ocsinventory-client remove >/dev/null || exit 0
38      fi
39
40      # source debconf library
41      . /usr/share/debconf/confmodule
42
43      SERVER=""
44      db_get ocsinventory-agent/method || true
45      if [ "$RET" = "http" ]; then
46        db_get ocsinventory-agent/server || true
47        SERVER="$RET"
48      fi
49      db_get ocsinventory-agent/tag || true
50      TAG="$RET"
51
52      # Creating local sample config
53      TMPFILE=`mktemp /tmp/ocsinv.XXXXXXXX`
54      if [ -n "$SERVER" ]; then
55        echo "server=$SERVER" >> $TMPFILE
56      fi
57      if [ -n "$TAG" ]; then
58        echo "tag=$TAG" >> $TMPFILE
59      fi
60
61      # Install the config
62      ucf --debconf-ok $TMPFILE /etc/ocsinventory/ocsinventory-agent.cfg
63
64      db_stop
65      rm -f $TMPFILE
66
67    ;;
68
69    abort-upgrade|abort-remove|abort-deconfigure)
70    ;;
71
72    *)
73        echo "postinst called with unknown argument \`$1'" >&2
74        exit 1
75    ;;
76esac
77
78# dh_installdeb will replace this with shell code automatically
79# generated by other debhelper scripts.
80
81#DEBHELPER#
82
83exit 0
84
85
Note: See TracBrowser for help on using the repository browser.