File: debtorrent.postinst

package info (click to toggle)
debtorrent 0.1.9
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 1,452 kB
  • ctags: 1,183
  • sloc: python: 13,526; sh: 274; makefile: 51
file content (94 lines) | stat: -rw-r--r-- 3,551 bytes parent folder | download
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
#! /bin/sh
# postinst script for bittorrent
#
# see: dh_installdeb(1)

set -e

# 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'.

case "$1" in
    configure)
		if ! getent passwd debtorrent >/dev/null; then
			adduser --quiet --system --no-create-home \
					--home /var/cache/debtorrent --disabled-password \
					--disabled-login --shell /bin/false --group debtorrent
		fi
		
		mkdir -p /var/cache/debtorrent
		
		if [ -n "$2" ] && dpkg --compare-versions "$2" lt 0.1.6 ; then
			# Upgrade for the new separate_all options
			UPGRADE_FILE=/tmp/debtorrent-pre0.1.6-upgrade
			echo "Beginning upgrade of debtorrent directories from pre 0.1.6 version"
			echo "Beginning upgrade of debtorrent directories from pre 0.1.6 version" > $UPGRADE_FILE
			if [ -r /etc/default/debtorrent-client ] ; then
				. /etc/default/debtorrent-client
				echo "Upgrading debtorrent cache..."
				echo "Upgrading debtorrent cache..." > $UPGRADE_FILE
				/usr/share/debtorrent/split_cache_for_all $DEBTORRENT_DOWNLOAD_DIR >> $UPGRADE_FILE
				if [ -z "$DEBTORRENT_CACHE_DIR" ] ; then
					if [ -z "$DEBTORRENT_DOWNLOAD_DIR" ] ; then
						DEBTORRENT_CACHE_DIR=/var/cache/debtorrent/.DebTorrent
					else
						DEBTORRENT_CACHE_DIR=$DEBTORRENT_DOWNLOAD_DIR/.DebTorrent
					fi
				fi
				if [ -d $DEBTORRENT_CACHE_DIR ] ; then
					echo "Removing (and saving) the old debtorrent saved state..."
					echo "Removing (and saving) the old debtorrent saved state..." >> $UPGRADE_FILE
					mv $DEBTORRENT_CACHE_DIR ${DEBTORRENT_CACHE_DIR}.dpkg-old
					echo "Moved $DEBTORRENT_CACHE_DIR to ${DEBTORRENT_CACHE_DIR}.dpkg-old" >> $UPGRADE_FILE
				else
					echo "WARNING: Could not find the old debtorrent state to remove"
					echo "WARNING: Could not find the old debtorrent state to remove" >> $UPGRADE_FILE
				fi
			else
				echo "WARNING: Could not upgrade the debtorrent directories"
				echo "WARNING: Could not upgrade the debtorrent directories" >> $UPGRADE_FILE
			fi
			echo "Upgrade of debtorrent directories from pre 0.1.6 version is complete"
			echo "Upgrade of debtorrent directories from pre 0.1.6 version is complete" >> $UPGRADE_FILE
			echo "Details of debtorrent directory upgrade are in $UPGRADE_FILE"
			echo "Don't forget to run 'apt-get update'"
		fi

		chown -R debtorrent:debtorrent /var/log/debtorrent
		chown -R debtorrent:debtorrent /var/cache/debtorrent
		chmod -R 775 /var/log/debtorrent
		chmod -R 775 /var/cache/debtorrent
    ;;

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

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

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

#DEBHELPER#

exit 0