Page 1 of 1

LF_SCRIPT_ACTION

Posted: 03 Jan 2015, 14:39
by jcats
Hello,

I was just wondering how I can pass the actual contents of the LF_SCRIPT_ALERT to the bash script for LF_SCRIPT_ACTION, example my LF_SCRIPT_ACTION is set to

"/etc/csf/csf.lf_script_perm_action"

which contains

#!/bin/bash

# email subject
SUBJECT="$HOSTNAME - Possible Spam Script"

# Email To
EMAIL="email"

# Email text/message
# EMAILMESSAGE="/tmp/emailmessage.txt"
EMAILMESSAGE="TEST"
echo "info from CSF should go here"> $EMAILMESSAGE

# send an email using /bin/mail
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE

Re: LF_SCRIPT_ACTION

Posted: 15 Jan 2015, 16:38
by ForumAdmin
You have to use BASH programming to store the values passed to the script. BASH stores command line arguments passed to it in $1, $2, $3 etc, so:

Code: Select all

#!/bin/bash
HOSTNAME=`hostname`
SPATH=$1
COUNT=$2
SAMPLE=$3
SCRIPTS=$4

# email subject
SUBJECT="$HOSTNAME - Possible Spam Script"

# Email To
EMAIL="email"

# Email text/message
# EMAILMESSAGE="/tmp/emailmessage.txt"
EMAILMESSAGE="TEST"
echo -e "A script in $SPATH has sent at least $COUNT emails.\n\nHere is a sample from the exim log:\n$SAMPLE\n\nHere are some of the likely scripts:\n$SCRIPTS\n"> $EMAILMESSAGE

# send an email using /bin/mail
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE

Re: LF_SCRIPT_ACTION

Posted: 15 Jan 2015, 17:02
by jcats
Your awesome thank you!

Re: LF_SCRIPT_ACTION

Posted: 14 Sep 2015, 19:17
by jcats
Would you be able to provide a template for RT_ACTION as well like below?

ForumAdmin wrote:You have to use BASH programming to store the values passed to the script. BASH stores command line arguments passed to it in $1, $2, $3 etc, so:

Code: Select all

#!/bin/bash
HOSTNAME=`hostname`
SPATH=$1
COUNT=$2
SAMPLE=$3
SCRIPTS=$4

# email subject
SUBJECT="$HOSTNAME - Possible Spam Script"

# Email To
EMAIL="email"

# Email text/message
# EMAILMESSAGE="/tmp/emailmessage.txt"
EMAILMESSAGE="TEST"
echo -e "A script in $SPATH has sent at least $COUNT emails.\n\nHere is a sample from the exim log:\n$SAMPLE\n\nHere are some of the likely scripts:\n$SCRIPTS\n"> $EMAILMESSAGE

# send an email using /bin/mail
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE