#!/bin/bash
#
# Initialization functions for raperca
#

# Initializes the location variables, if the argument is non-empty
# it overrides the default raperca service directory
init_dirs() {
    SRVDIR=/srv/raperca
    if [ -n "$1" ]; then
	SRVDIR="$1"
    fi
    STARTDIR="$SRVDIR"
    TMPSRVDIR="$SRVDIR"/tmp
    CACHEDIR="$SRVDIR"/cache
    LOGDIR="$SRVDIR"/log
    USRCOMPORTDIR=/etc/raperca/comportfsm
    SPOOLDIR=/var/spool/raperca
    CAPTUREDIR="$SRVDIR"/capture
    WEBSTORAGEDIR="$SRVDIR"/webstorage
    COOKIEJARDIR="$SRVDIR"/cookiejar
    WEBSERVICEDIR="$SRVDIR"/webservice
    TMPWEBSERVICEDIR="$WEBSERVICEDIR"/tmp
    CACHEWSDIR="$WEBSERVICEDIR"/cache
    COOKIEJARWSDIR="$WEBSERVICEDIR"/cookiejar
    WEBSTORAGEWSDIR="$WEBSERVICEDIR"/webstorage
    OFFSTORAGEWSDIR="$WEBSERVICEDIR"/offstorage
    CEFDATAWSDIR="$WEBSERVICEDIR"/cefdata
}

# Removes the contents of all the directories passed as arguments
clean() {
    # remove all contents of the passed-in dirs, but not the dirs themselves
    find  "$@" -mindepth 1 -delete 2>/dev/null
}
