This file is indexed.

postinst is in chef-solr 10.12.0+dfsg-2.

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
#!/bin/bash
set -e

. /usr/share/debconf/confmodule
. /etc/default/chef-solr

export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin

TEMPLATE=/usr/share/chef-solr/solr.rb
TMPDIR=`mktemp -d` # used for holding temp files
TMPFILE=`mktemp -p ${TMPDIR}` # used for holding rendered template
CONFIGFILE=/etc/chef/solr.rb

rabbitmq_has_vhost() {
  rabbitmqctl list_vhosts | grep -qx "^/chef$"
}

rabbitmq_has_user() {
  # using -q for grep causes rabbit to terminate on do_boot, redirect
  # STDOUT to /dev/null instead.
  rabbitmqctl list_users | grep -x "^chef\(\W*\w*\)$" 1>/dev/null
}

rabbitmq_has_perms() {
  rabbitmqctl list_permissions -p /chef | egrep -qx "chef[[:space:]]+.*{3}"
}

case "$1" in
  configure)
    db_get chef-solr/amqp_password && amqp_pass="$RET"
    tsed=`mktemp -p ${TMPDIR}`
    cat << EOF > $tsed
s/^amqp_pass \".*\"/amqp_pass \"${amqp_pass}\"/g
EOF
    if ! rabbitmq_has_vhost; then
      rabbitmqctl add_vhost /chef
    fi
    if ! rabbitmq_has_user; then
      # NOTE: Bug filed with upstream to allow password from a file.
      rabbitmqctl add_user chef "$amqp_pass"
    fi
    if ! rabbitmq_has_perms; then
      rabbitmqctl set_permissions -p /chef chef ".*" ".*" ".*"
    fi
    if [ -n "$amqp_pass" ]; then
      sed -f $tsed $TEMPLATE > $TMPFILE
    fi
    ucf --debconf-ok $TMPFILE $CONFIGFILE
    test -f $CONFIGFILE && chmod 0640 $CONFIGFILE
    rm -rf $TMPDIR
    if ! getent passwd chef > /dev/null; then
      adduser --system --quiet \
        --home /var/lib/chef --no-create-home \
        --shell /bin/false --group --gecos "Chef Daemon" chef
    fi
    chown -R $USER:$GROUP /etc/chef
    chown -R $USER:$GROUP /var/lib/chef
    chown -R $USER:$GROUP /var/log/chef
    chown -R $USER:$GROUP /var/cache/chef
    chown -R $USER:$GROUP /var/run/chef
  ;;

  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_installinit
if [ -x "/etc/init.d/chef-solr" ]; then
	if [ ! -e "/etc/init/chef-solr.conf" ]; then
		update-rc.d chef-solr defaults >/dev/null
	fi
	invoke-rc.d chef-solr start || exit $?
fi
# End automatically added section


exit 0