This file is indexed.

postinst is in backuppc 3.3.1-2ubuntu3.

This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.

The actual contents of the file can be viewed below.

  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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#!/bin/bash
# postinst script for backuppc
#
# see: dh_installdeb(1)

#set -e
#set -x

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
#
# quoting from the policy:
#     Any necessary prompting should almost always be confined to the
#     post-installation script, and should be protected with a conditional
#     so that unnecessary prompting doesn't happen if a package's
#     installation fails and the `postinst' is called with `abort-upgrade',
#     `abort-remove' or `abort-deconfigure'.

. /usr/share/debconf/confmodule
db_version 2.0

case "$1" in
    configure)
    
    # TODO: I should detect if par2, bzip2 ... are really installed
    # and modify config.pl accordingly.
    
    db_get backuppc/reconfigure-webserver
    webservers="$RET"
    db_get backuppc/restart-webserver
    webservers_rst="$RET"
    inc="/etc/backuppc/apache.conf"
    
    for webserver in $webservers ; do
	webserver=${webserver%,}
	test -x /usr/sbin/$webserver || continue
	
	case "$webserver" in                                    
        apache|apache-perl|apache-ssl|apache2)
	    # remove wwwconfig-common stuff
	    if grep -qs "^Include $inc" /etc/$webserver/httpd.conf; then
		mv -f /etc/$webserver/httpd.conf /etc/$webserver/httpd.conf.old.backuppc
		grep -v "^Include $inc" /etc/$webserver/httpd.conf.old.backuppc \
			> /etc/$webserver/httpd.conf
	    fi
	    # add new links
	    
	    # Apache 2.4 
	    if [ -d /etc/$webserver/conf-available -a ! -f /etc/$webserver/conf-available/backuppc.conf -a ! -h /etc/$webserver/conf-available/backuppc.conf ]; then
                ln -s /etc/backuppc/apache.conf /etc/$webserver/conf-available/backuppc.conf
                [ -f /etc/$webserver/conf.d/backuppc.conf ] && rm /etc/$webserver/conf.d/backuppc.conf

                if [ -e /usr/share/apache2/apache2-maintscript-helper ] ; then
                    . /usr/share/apache2/apache2-maintscript-helper
            	    apache2_invoke enconf backuppc.conf
                fi
            fi

	    # Apache < 2.4
	    newfile=false
            if [ -d /etc/$webserver/conf.d -a ! -f /etc/$webserver/conf.d/backuppc.conf -a ! -h /etc/$webserver/conf.d/backuppc.conf ]; then
                ln -s /etc/backuppc/apache.conf /etc/$webserver/conf.d/backuppc.conf
                [ -f /etc/$webserver/conf.d/backuppc ] && rm /etc/$webserver/conf.d/backuppc
		if [ "$webservers_rst" = "true" ]; then
		    # restart
    		    if [ -x /usr/sbin/invoke-rc.d ]; then
        		    invoke-rc.d $webserver reload
    		    else
        		    /etc/init.d/$webserver reload
    		    fi
		fi
            fi
	    ;;
	esac
    done

    # creating backuppc group if he isn't already there
    if ! getent group backuppc >/dev/null; then
	addgroup --system backuppc >/dev/null
    fi

    # creating backuppc user if he isn't already there
    if ! getent passwd backuppc >/dev/null; then
	adduser --system --gecos "BackupPC" --ingroup backuppc \
	    --shell /bin/sh --home /var/lib/backuppc backuppc >/dev/null
	    
        # add backuppc to /etc/aliases
        if [ -f /etc/aliases ] || [ -L /etc/aliases ]; then
	    if ! grep -qi "^backuppc[[:space:]]*:" /etc/aliases; then
        	echo "backuppc: root" >> /etc/aliases
	        test -x "$(command -v newaliases)" && newaliases || :
	    fi
	fi
    fi
    
    #usermod -c "BackupPC Daemon" backuppc
    
    # chown some files only on the 1st install
    if [ -z "$2" ]; then 
    	mkdir /var/lib/backuppc/pc/localhost/
	chown backuppc:backuppc /var/lib/backuppc /var/lib/backuppc/* /var/lib/backuppc/pc/* /var/lib/backuppc/log/*
	chmod 750 /var/lib/backuppc /var/lib/backuppc/* /var/lib/backuppc/pc/*
    fi

    OVERRIDDEN=`dpkg-statoverride --list /usr/lib/backuppc/cgi-bin/index.cgi || true`
    # Force the perms to 4750 if 4755 was found
    echo "$OVERRIDDEN" | grep -q 4755 && OVERRIDDEN=""
    [ "${OVERRIDDEN}" = "" ] && dpkg-statoverride --force --update --add backuppc www-data 4750 /usr/lib/backuppc/cgi-bin/index.cgi

    if [ ! -f /etc/backuppc/htpasswd ]; then
	touch /etc/backuppc/htpasswd
	db_get backuppc/tmppass
	if [ -f /usr/bin/htpasswd ]; then
	    htpasswd -bm /etc/backuppc/htpasswd backuppc $RET
	else 
	    htpasswd2 -bm /etc/backuppc/htpasswd backuppc $RET
	fi
    fi
    db_reset backuppc/tmppass
    db_subst "backuppc/configuration-note" "pass" ""
    
    if [ -x /usr/sbin/a2enmod ]; then
	a2enmod auth_basic
	a2enmod authz_groupfile
	a2enmod authn_file
	a2enmod authz_user
	a2enmod cgi
    fi
    
    # create a symlink to have the same directories as in the doc
    cd /etc/backuppc
    [ ! -e pc ] && ln -s /etc/backuppc pc
    
    # ucf stuff
    ucf --debconf-ok --three-way /usr/share/backuppc/conf/config.pl /etc/backuppc/config.pl

    # remove conffile
    #dpkg-maintscript-helper rm_conffile /etc/backuppc/config.pl 3.3.0-1 backuppc -- "$@";
    
    
    # change the rights of /etc/backuppc so that the CGI can modify the conf.
    chown -R backuppc:www-data /etc/backuppc

    # fix the perms of the backuppc password files
    chmod 640 /etc/backuppc/htpasswd
    
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)

    ;;

    *)
    echo "postinst called with unknown argument \`$1'" >&2
    exit 1
    ;;
esac

db_stop

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

# Automatically added by dh_installmenu
if [ "$1" = "configure" ] && [ -x "`which update-menus 2>/dev/null`" ]; then
	update-menus
fi
# End automatically added section
# Automatically added by dh_installinit
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then
	if [ -x "/etc/init.d/backuppc" ]; then
		update-rc.d backuppc start 20 2 3 4 5 . stop 20 1 . >/dev/null
	fi
	if [ -x "/etc/init.d/backuppc" ] || [ -e "/etc/init/backuppc.conf" ]; then
		invoke-rc.d backuppc start || exit $?
	fi
fi
# End automatically added section


exit 0