This file is indexed.

postinst is in bit-babbler 0.8.

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
#!/bin/sh

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>
#        * <postinst> `abort-remove'
#        * <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


migrate_seedd_conf()
{
    local oldconf='/etc/default/seedd'
    local newconf='/etc/bit-babbler/seedd.conf'
    local saveconf="${oldconf}.dpkg-old"

    # Remove the old config if it was unmodified
    rm -f "${oldconf}.dpkg-remove"

    # Otherwise, if it's still there and we still own it, let's convert it.
    [ -e "$oldconf" ] || return 0
    dpkg-query -L bit-babbler | grep -F -q -x "$oldconf" || return 0

    # Preserve the new config file that was shipped with the package, in the
    # same way as if the user had chosen "keep my local changes" at the dpkg
    # conffile update prompt.  Except for this we keep them without prompting.
    [ ! -e "$newconf" ] || mv -f "$newconf" "${newconf}.dpkg-new"

    # Simulate how the old config was converted to command line options in the
    # init script, then generate a new format config file using those options.
    # Pretend we were invoked by systemd for that, since the new init script
    # will itself add the needed options which that would omit.
    (
      SEEDD_ARGS="-k"
      . "$oldconf"
      [ -z "$CONTROL_GROUP" ] || SEEDD_ARGS="$SEEDD_ARGS --socket-group $CONTROL_GROUP"

      export NOTIFY_SOCKET=@dummy

      cat > "$newconf" <<-EOF
	# These options were automatically migrated from $oldconf
	# during upgrade to the bit-babbler 0.8 (or later) release.
	#
	# A copy of the old file has been preserved in $saveconf
	# which can safely be deleted now after confirming that there is nothing
	# remaining in it which you do wish to retain a copy of.
	#
	# This file can safely be edited to customise the seedd configuration, it will
	# not be automatically (re)generated again after the initial conversion of the
	# old configuration file has created it.

	EOF

      if /usr/bin/seedd --gen-conf $SEEDD_ARGS >> "$newconf" 2>/dev/null; then
	# Preserve a copy of their old config.  We migrated anything which was
	# actively being used by the old init script, but there may be comments
	# or commented out configurations, or other things which it would be a
	# bit rude of us to just completely delete without asking.
	cat - "$oldconf" > "$saveconf" <<-EOF
		# NOTE: This file contains the last content from $oldconf
		#       prior to it being converted into the new $newconf
		#
		#       It may safely be deleted if there is nothing else in it which you wish
		#       to retain.  The seedd configuration uses options from the new file now
		#       and there is nothing which still uses anything from the old one at all.

	EOF

	rm -f "$oldconf"
	echo "Automatically migrated $oldconf configuration to $newconf"
	echo "The previous configuration file was saved to $saveconf"
      fi
    )
}

case "$1" in
    configure)
	addgroup --quiet --system bit-babbler
	sysctl -q -p /etc/sysctl.d/bit-babbler-sysctl.conf || true

	# Version 0.8 adds /etc/bit-babbler/seedd.conf, replacing the previous
	# daemon configuration options which were set in /etc/default/seedd.
	dpkg --compare-versions -- "$2" ge-nl '0.8~' || migrate_seedd_conf
    ;;

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

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

# Automatically added by dh_systemd_enable/11.1.4ubuntu1
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
	# This will only remove masks created by d-s-h on package removal.
	deb-systemd-helper unmask 'seedd.service' >/dev/null || true

	# was-enabled defaults to true, so new installations run enable.
	if deb-systemd-helper --quiet was-enabled 'seedd.service'; then
		# Enables the unit on first installation, creates new
		# symlinks on upgrades if the unit file has changed.
		deb-systemd-helper enable 'seedd.service' >/dev/null || true
	else
		# Update the statefile to add new symlinks (if any), which need to be
		# cleaned up on purge. Also remove old symlinks.
		deb-systemd-helper update-state 'seedd.service' >/dev/null || true
	fi
fi
# End automatically added section
# Automatically added by dh_systemd_enable/11.1.4ubuntu1
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
	if deb-systemd-helper debian-installed 'seedd-wait.service'; then
		# This will only remove masks created by d-s-h on package removal.
		deb-systemd-helper unmask 'seedd-wait.service' >/dev/null || true

		if deb-systemd-helper --quiet was-enabled 'seedd-wait.service'; then
			# Create new symlinks, if any.
			deb-systemd-helper enable 'seedd-wait.service' >/dev/null || true
		fi
	fi

	# Update the statefile to add new symlinks (if any), which need to be cleaned
	# up on purge. Also remove old symlinks.
	deb-systemd-helper update-state 'seedd-wait.service' >/dev/null || true
fi
# End automatically added section
# Automatically added by dh_installinit/11.1.4ubuntu1
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
	if [ -x "/etc/init.d/seedd" ]; then
		update-rc.d seedd defaults >/dev/null
		if [ -n "$2" ]; then
			_dh_action=restart
		else
			_dh_action=start
		fi
		invoke-rc.d seedd $_dh_action || exit 1
	fi
fi
# End automatically added section


exit 0

# vi:sts=4:sw=4:noet