File: activemq.postinst

package info (click to toggle)
activemq 5.6.0%2Bdfsg1-4%2Bdeb8u3
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 35,728 kB
  • ctags: 48,009
  • sloc: java: 278,891; xml: 12,475; jsp: 1,352; sh: 814; ruby: 114; makefile: 11
file content (36 lines) | stat: -rw-r--r-- 851 bytes parent folder | download | duplicates (3)
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
#!/bin/sh

set -e

AMQ_HOME=/var/lib/activemq
AMQ_GROUP=activemq
AMQ_USER=activemq

create_group() {
    if ! getent group $AMQ_GROUP > /dev/null 2>&1; then
        addgroup --system $AMQ_GROUP
    fi
}

create_user() {
    if ! getent passwd $AMQ_USER > /dev/null 2>&1; then
        adduser --system --no-create-home --ingroup $AMQ_GROUP \
                --home $AMQ_HOME --shell /bin/bash $AMQ_USER
    else
        AMQ_HOME=`getent passwd $AMQ_USER | cut -f6 -d:`
        # Renable user (give him a shell)
        usermod --shell /bin/bash $AMQ_USER
    fi
}

if [ "$1" = "configure" ]; then
    create_group
    create_user
    
    # Use dpkg-statoverride instead of direct chmod/chown
    if ! dpkg-statoverride --list $AMQ_HOME >/dev/null 2>&1; then
        dpkg-statoverride --update --add $AMQ_USER root 755 $AMQ_HOME
    fi
fi

#DEBHELPER#