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
LF_SCRIPT_ACTION
-
- Moderator
- Posts: 1524
- Joined: 01 Oct 2008, 09:24
Re: LF_SCRIPT_ACTION
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
Your awesome thank you!
Re: LF_SCRIPT_ACTION
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