This file is indexed.

postrm is in zentyal-core 2.3.21+quantal1.

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

set -e

PORT=443

stop_ebox_processes() {
    stop ebox.redis 2>/dev/null || true
    OLD_APACHE_PID=`ps aux | grep 'apache2.* -f /var/lib/ebox' | grep -v grep | awk '/^root/{print $2;exit}'`;
    kill $OLD_APACHE_PID 2>/dev/null || true
    pkill -9 -u ebox || true
}

# This function uses the eBox API to fetch the configured apache port used
# by eBox
#
# Usage: port=$(fetch_ebox_port)
fetch_ebox_port()
{
    set +e

    ret=$(perl -e '
            use EBox;
            use EBox::Global;
            EBox::init();

            my $apache = EBox::Global->modInstance('apache');
            print $apache->port();
            exit 0;
            ' 2> /dev/null );

    if [ $? -eq 0 ]; then
        PORT=$ret;
    fi

    set -e
}

# This function is used to try guess if a given port is available. It tries
# to connect to the port. Note that it does not distinguish if the port
# is being already used by eBox.
#
# Usage: check_port_available port_number
check_port_available()
{
    check_port=$1

    set +e

    perl -e '
        use IO::Socket;
        my $port = $ARGV[0];
        IO::Socket::INET->new(
            PeerAddr => "127.0.0.1",
            PeerPort => $port,
            Proto    => "tcp",
            Timeout  => 5) or exit 0;
        exit 1;
        ' $check_port 2> /dev/null;
    ret=$?

    set -e
    return $ret;
}

# This function uses the eBox API to set the apache port to be used by eBox.
#
# In case the current port and the new port are the same it returns without
# modifying the current value.
#
# We have to do two things to set the port:
#
#   Tell apache module its new port
#   Save changes in apache and services
#
# Usage: set_ebox_port new_port
set_ebox_port()
{
    db_get zentyal-core/port
    new_port=$RET

    fetch_ebox_port;
    if [ $new_port -eq $PORT ]; then
        return 0;
    fi

    set +e

    ret=$(perl -e '
            use EBox;
            use EBox::Global;

            EBox::init();
            my $port = $ARGV[0];
            my $global = EBox::Global->getInstance();
            my $apache = $global->modInstance('apache');
            $apache->setPort($port);
            $apache->saveConfig();
            if ($global->modExists('services')) {
                $global->modInstance('services')->saveConfig();
            }
            ' $new_port);

    set -e
}


# Automatically added by dh_installinit
if [ "$1" = "purge" ] ; then
	update-rc.d zentyal remove >/dev/null
fi
# End automatically added section
# Automatically added by dh_installdebconf
if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then
	. /usr/share/debconf/confmodule
	db_purge
fi
# End automatically added section


case "$1" in
    purge)
        # logs database
        db_name="zentyal"
        db_user="zentyal"
        echo "DROP DATABASE $db_name;
              DROP USER '$db_user'@'localhost';" | mysql --defaults-file=/etc/mysql/debian.cnf
        rm -f /var/lib/zentyal/.db-created

        # delete apache certificates
        rm -f /var/lib/zentyal/conf/ssl.crt/ebox.cert /var/lib/zentyal/conf/ssl.key/ebox.key \
            /var/lib/zentyal/conf/ssl.pem/ebox.pem

        # delete logs
        rm -rf /var/log/zentyal

        # delete ebox user
        stop_ebox_processes
        deluser --remove-home ebox

        # delete shared memory data
        rm -rf /run/shm/zentyal
    ;;
esac

exit 0