diff --git a/src/InstallServer.sh b/src/InstallServer.sh index e619d99..307ada7 100755 --- a/src/InstallServer.sh +++ b/src/InstallServer.sh @@ -1,37 +1,14 @@ #!/bin/sh - -# Checking if it is executed from the right place -LOCATION=./LOCATION -ls ${LOCATION} > /dev/null 2>&1 -if [ $? != 0 ]; then - echo "Cannot execute. Wrong directory" - exit 1; -fi - -# Getting any argument -if [ "X$1" = "Xlocal" ]; then - # Setting local install - LOCAL="local" -fi - UNAME=`uname`; - -# Getting default variables -DIR=`grep DIR ${LOCATION} | cut -f2 -d\"` -GROUP="ossec" -USER="ossec" -USER_MAIL="ossecm" -USER_REM="ossecr" +DIR=$5/var/ossec +# Need this to have $pkgusers and $pkggroups being passed from APKBUILD +GROUP="$4" +USER="$1" +USER_MAIL="$2" +USER_REM="$3" subdirs="logs logs/archives logs/alerts logs/firewall bin stats rules queue queue/alerts queue/ossec queue/fts queue/syscheck queue/rootcheck queue/diff queue/agent-info queue/agentless queue/rids tmp var var/run etc etc/shared active-response active-response/bin agentless .ssh" -# ${DIR} must be set -if [ "X${DIR}" = "X" ]; then - echo "Error building OSSEC HIDS." - exit 1; -fi - - # Creating root directory ls ${DIR} > /dev/null 2>&1 if [ $? != 0 ]; then mkdir -m 700 -p ${DIR}; fi @@ -42,78 +19,6 @@ if [ $? != 0 ]; then fi -# Creating groups/users -if [ "$UNAME" = "FreeBSD" -o "$UNAME" = "DragonFly" ]; then - grep "^${USER_REM}" /etc/passwd > /dev/null 2>&1 - if [ ! $? = 0 ]; then - /usr/sbin/pw groupadd ${GROUP} - /usr/sbin/pw useradd ${USER} -d ${DIR} -s /sbin/nologin -g ${GROUP} - /usr/sbin/pw useradd ${USER_MAIL} -d ${DIR} -s /sbin/nologin -g ${GROUP} - /usr/sbin/pw useradd ${USER_REM} -d ${DIR} -s /sbin/nologin -g ${GROUP} - fi - -elif [ "$UNAME" = "SunOS" ]; then - grep "^${USER_REM}" /etc/passwd > /dev/null 2>&1 - if [ ! $? = 0 ]; then - /usr/sbin/groupadd ${GROUP} - /usr/sbin/useradd -d ${DIR} -s /bin/false -g ${GROUP} ${USER} - /usr/sbin/useradd -d ${DIR} -s /bin/false -g ${GROUP} ${USER_MAIL} - /usr/sbin/useradd -d ${DIR} -s /bin/false -g ${GROUP} ${USER_REM} - fi - -elif [ "$UNAME" = "AIX" ]; then - AIXSH="" - ls -la /bin/false > /dev/null 2>&1 - if [ $? = 0 ]; then - AIXSH="-s /bin/false" - fi - - grep "^${USER_REM}" /etc/passwd > /dev/null 2>&1 - if [ ! $? = 0 ]; then - /usr/bin/mkgroup ${GROUP} - /usr/sbin/useradd -d ${DIR} ${AIXSH} -g ${GROUP} ${USER} - /usr/sbin/useradd -d ${DIR} ${AIXSH} -g ${GROUP} ${USER_MAIL} - /usr/sbin/useradd -d ${DIR} ${AIXSH} -g ${GROUP} ${USER_REM} - fi - -# Thanks Chuck L. for the mac addusers -elif [ "$UNAME" = "Darwin" ]; then - id -u ${USER} > /dev/null 2>&1 - if [ ! $? = 0 ]; then - - # Creating for <= 10.4 - /usr/bin/sw_vers 2>/dev/null| grep "ProductVersion" | grep -E "10.2.|10.3|10.4" > /dev/null 2>&1 - if [ $? = 0 ]; then - chmod +x ./init/darwin-addusers.pl - ./init/darwin-addusers.pl - else - chmod +x ./init/osx105-addusers.sh - ./init/osx105-addusers.sh - fi - fi -else - grep "^${USER_REM}" /etc/passwd > /dev/null 2>&1 - if [ ! $? = 0 ]; then - /usr/sbin/groupadd ${GROUP} - - # We first check if /sbin/nologin is present. If it is not, - # we look for bin/false. If none of them is present, we - # just stick with nologin (no need to fail the install for that). - OSMYSHELL="/sbin/nologin" - ls -la ${OSMYSHELL} > /dev/null 2>&1 - if [ ! $? = 0 ]; then - ls -la /bin/false > /dev/null 2>&1 - if [ $? = 0 ]; then - OSMYSHELL="/bin/false" - fi - fi - /usr/sbin/useradd -d ${DIR} -s ${OSMYSHELL} -g ${GROUP} ${USER} - /usr/sbin/useradd -d ${DIR} -s ${OSMYSHELL} -g ${GROUP} ${USER_MAIL} - /usr/sbin/useradd -d ${DIR} -s ${OSMYSHELL} -g ${GROUP} ${USER_REM} - fi -fi - - # Creating sub directories for i in ${subdirs}; do ls ${DIR}/${i} > /dev/null 2>&1 @@ -221,13 +126,6 @@ if [ $? = 0 ]; then chown root:${GROUP} ${DIR}/etc/localtime fi -# Solaris Needs some extra files -if [ "$UNAME" = "SunOS" ]; then - mkdir -p ${DIR}/usr/share/lib/zoneinfo/ - chmod -R 550 ${DIR}/usr/ - cp -pr /usr/share/lib/zoneinfo/* ${DIR}/usr/share/lib/zoneinfo/ -fi - ls /etc/TIMEZONE > /dev/null 2>&1 if [ $? = 0 ]; then cp -p /etc/TIMEZONE ${DIR}/etc/; @@ -263,13 +161,6 @@ cp -pr ../contrib/util.sh ${DIR}/bin/ chown root:${GROUP} ${DIR}/bin/util.sh chmod +x ${DIR}/bin/util.sh -# Local install chosen -if [ "X$LOCAL" = "Xlocal" ]; then - cp -pr ./init/ossec-local.sh ${DIR}/bin/ossec-control -else - cp -pr ./init/ossec-server.sh ${DIR}/bin/ossec-control -fi - # Moving the decoders/internal_conf file. cp -pr ../etc/decoder.xml ${DIR}/etc/ @@ -281,7 +172,6 @@ cp -pr ../etc/client.keys ${DIR}/etc/ > /dev/null 2>&1 # Copying agentless files. cp -pr agentlessd/scripts/* ${DIR}/agentless/ - # Backup currently internal_options file. ls ${DIR}/etc/internal_options.conf > /dev/null 2>&1 if [ $? = 0 ]; then