aboutsummaryrefslogtreecommitdiffstats
path: root/net/gatekeeper/pkg-install
blob: 9879f14726d8d485c55778205901d1afae58aeb1 (plain) (blame)
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
#!/bin/sh
#
# $FreeBSD$
#

PATH=/bin:/usr/bin:/usr/sbin

pkgname=$1
gnugk_user=gnugk
gnugk_group=gnugk
gnugk_config=${PKG_PREFIX:-"/usr/local"}/etc/gnugk.ini
gnugk_logdir="/var/log/gnugk"
gnugk_piddir="/var/run/gnugk"

if [ -x /usr/sbin/nologin ]; then
    nologin=/usr/sbin/nologin
else
    nologin=/sbin/nologin
fi

case $2 in
PRE-INSTALL)
    echo "===> Pre-installation configuration for ${pkgname}"
    if ! pw groupshow ${gnugk_group} -q >/dev/null ; then
        echo "There is no group '${gnugk_group}' on this system, so I will try to create it:"
        if ! pw groupadd ${gnugk_group} -q -h - ; then
            echo "Failed to create group \"${gnugk_group}\"!" >&2
            echo "Please create it manually." >&2
            exit 1
        else
            echo "Group '${gnugk_group}' created successfully:"
        fi
    else
        echo "I will use the existing group '${gnugk_group}':"
    fi
    pw groupshow ${gnugk_group}

    if ! pw usershow ${gnugk_user} -q >/dev/null ; then
        echo "There is no account '${gnugk_user}' on this system, so I will try to create it:"
        if ! pw useradd -q -n ${gnugk_user} \
            -g ${gnugk_group} -d/nonexistent \
            -c "GNU Gatekeeper pseudo user" \
            -s "${nologin}" -h - ; then
            echo "Failed to create user '${gnugk_user}'!" >&2
            echo "Please create it manually." >&2
            exit 1
        else
            echo "User '${gnugk_user}' created successfully:"
        fi
    else
        echo "I will use the existing user '${gnugk_user}':"
    fi
    pw usershow ${gnugk_user}

    for dir in ${gnugk_logdir} ${gnugk_piddir}; do
        if [ ! -d ${dir} ]; then
            echo "Creating ${dir}..."
            install -d -o ${gnugk_user} -g ${gnugk_group} \
                -m 0750 ${dir}
        fi
    done
    ;;
POST-INSTALL)
    if [ ! -f ${gnugk_config} \
        -a -f ${gnugk_config}.default ]; then
        echo "Creating ${gnugk_config} from default..."
        install -c -o root -g ${gnugk_group} -m 0640 \
                ${gnugk_config}.default \
            ${gnugk_config}
    fi

    echo "===> Post-installation informations for ${pkgname}"
    echo ""
    echo "     o A sample configuration file for this package is installed"
    echo "       as ${gnugk_config}."
    echo "       More example configurations can be found in"
    echo "       ${PKG_PREFIX}/share/examples/openh323/gatekeeper."
    echo ""
    echo "     o Documentation can be found in"
    echo "       ${PKG_PREFIX}/share/doc/openh323/gatekeeper."
    echo ""
    echo "     o A log directory has been created in ${gnugk_logdir}."
    echo ""
    echo "     To enable gatekeeper, set gnugk_enable=yes in either"
    echo "     /etc/rc.conf, /etc/rc.conf.local or /etc/rc.conf.d/gnugk"
    echo "     See ${PKG_PREFIX}/etc/rc.d/gnugk.sh for more"
    echo "     configuration options."
    echo ""
    ;;
*)
    exit 64
    ;;
esac
exit 0