aboutsummaryrefslogblamecommitdiff
path: root/security/ossec-hids-local/files/pkg-install.in
blob: 01816078af72ff29070c2c6b33c87033e547dd31 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16















                                                                              



                             


                                                
                                                 
 
                                                             
  
#!/bin/sh

ossec_home="%%OSSEC_HOME%%"
client_keys="${ossec_home}/etc/client.keys"

create_file() {
    local path=$1
    local owner=$2
    local mode=$3

    if [ ! -e "${path}" ]; then
        touch "${path}" && chown ${owner} "${path}" && chmod ${mode} "${path}"
    fi
}

if [ "$2" == "POST-INSTALL"  ]; then
    if [ -z "${USER}" ]; then
        USER=$(id -un)
    fi

    pw usermod %%OSSEC_USER%% -d "${ossec_home}"
    pw usermod ossecm -d "${ossec_home}"
    pw usermod ossecr -d "${ossec_home}"
    chown ${USER}:%%OSSEC_GROUP%% "${ossec_home}"

    create_file "${client_keys}" ${USER}:%%OSSEC_GROUP%% 0640
fi