This file is indexed.

postinst is in diaspora-installer 0.5.7.1+debian2.

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
#! /bin/sh
# postinst script for diaspora-installer
# copied from postinst script for hplip
# $Id: hplip.postinst,v 1.1 2005/10/15 21:39:04 hmh Exp $
#
# 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'.

# Run migrations are start diaspora

migrate() {
	echo "Running migrations..."
        su diaspora -s /bin/sh -c 'bundle exec rake db:migrate'
        su diaspora -s /bin/sh -c 'bundle exec rake tmp:cache:clear assets:precompile'
        echo "Remove backup..."
        rm -rf ${diaspora_home}-backup.*

        echo "Starting diaspora..."
        invoke-rc.d diaspora start
}

install_gems() {
# Needs latest bundler
# Needs eye for init script
        gem install bundler
	ln -sf /usr/local/bin/bundle ${diaspora_home}/bin/bundle
}

case "$1" in
    configure)
        # Source varibales
	. /etc/diaspora/diaspora-common.conf
	cd ${diaspora_home}
        if ! test -z $2
        then
            # Find our major and minor versions of diaspora
            . /usr/lib/diaspora-common/scripts/diaspora-versions.sh

            if test $(echo "${installed_diaspora_major_version} < 0.5" |bc) -eq 1
            then
                # source diaspora variables	
                . ${diaspora_conf}
                echo "This update involves long running migrations..."
                echo "Some migrations may take upto 2 hours in large pods..."
               # Download diaspora from github
                . /usr/lib/diaspora-common/scripts/diaspora-download.sh

	        cd ${diaspora_home}

                install_gems

		# https://github.com/hyperic/sigar/issues/60
                su diaspora -s /bin/sh -c "bundle config --local build.sigar '--with-cppflags=\"-fgnu89-inline\"'"
                su diaspora -s /bin/sh -c 'bundle install'
                su diaspora -s /bin/sh -c "sed -i s/Rails.application.config.secret_token/Diaspora::Application.config.secret_key_base/ ${diaspora_home}/config/initializers/secret_token.rb"
		migrate
            else
                if test $(echo "${installed_diaspora_minor_version} < ${diaspora_minor_version}" |bc) -eq 1
                then
                    # Download diaspora from github
                    . /usr/lib/diaspora-common/scripts/diaspora-download.sh

	            cd ${diaspora_home}
                    # source diaspora variables	
                    . ${diaspora_conf}
		    install_gems

                    su diaspora -s /bin/sh -c 'bundle install --without development test'
		    migrate
                else
                    echo "This version is already installed..."
                fi
            fi
        else
            # Download diaspora from github
            . /usr/lib/diaspora-common/scripts/diaspora-download.sh
	    cd ${diaspora_home}
            echo "Setting up environment varibales..."
	    . /usr/lib/diaspora-common/scripts/set-env-diaspora.sh
	    echo RAILS_ENV=$RAILS_ENV DB=$DB ENVIRONMENT_URL=$ENVIRONMENT_URL

            install_gems

	    echo "Installing gems with rubygems ..."
	    sudo -u diaspora -E -H bundle install --path vendor/bundle --without development test

#	echo "Setting up secret_token..."
#	if ! grep config.secret_token ${diaspora_home}/config/initializers/secret_token.rb
#		then 
#		echo Diaspora::Application.config.secret_token = \'$(sudo -u diaspora -E bundle exec rake secret)\' >> ${diaspora_home}/config/initializers/secret_token.rb
#	fi
	    echo "Running final rake tasks..."
	    . /usr/lib/diaspora-common/scripts/rake-tasks.sh
        fi
        ;;

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

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




exit 0