Skip to content
Permalink
Browse files

Added --install-man this will automatically generate and install the …

…man (help) file

Script options are added to the man file
Prepare for 5.1.2 release
  • Loading branch information...
extremeshok committed Apr 15, 2016
1 parent 4d5be3a commit a4cbc78383f8109a32fab70cce333c5b61fff7d6
Showing with 193 additions and 75 deletions.
  1. +15 −0 .travis/ci-test.sh
  2. +6 −3 INSTALL
  3. +12 −2 README.md
  4. +0 −28 clamav-unofficial-sigs.8
  5. +154 −42 clamav-unofficial-sigs.sh
  6. +6 −0 config/master.conf
@@ -11,6 +11,7 @@ else
exit 1
fi

#check cron file generation
if bash clamav-unofficial-sigs.sh --install-cron ; then
if [ -e "/etc/cron.d/clamav-unofficial-sigs" ] ; then
echo .. OK
@@ -23,6 +24,7 @@ else
exit 1
fi

#check logrotate file generation
if bash clamav-unofficial-sigs.sh --install-logrotate ; then
if [ -e "/etc/logrotate.d/clamav-unofficial-sigs" ] ; then
echo .. OK
@@ -33,4 +35,17 @@ if bash clamav-unofficial-sigs.sh --install-logrotate ; then
else
echo .. ERROR
exit 1
fi

#check man file generation
if bash clamav-unofficial-sigs.sh --install-man ; then
if [ -e "/usr/share/man/man8/clamav-unofficial-sigs.8" ] ; then
echo .. OK
else
echo .. ERROR
exit 1
fi
else
echo .. ERROR
exit 1
fi
@@ -51,11 +51,11 @@ Uncompress/Unpackage the archive:
* Set 755 permissions on /usr/local/bin/clamav-unofficial-sigs.sh
* Make the directory /etc/clamav-unofficial-sigs/
* Copy the contents of config/ into /etc/clamav-unofficial-sigs/
* Copy clamav-unofficial-sigs.8 into /usr/share/man/man8/
* Rename the your os.your-distro.conf to os.conf, where your-distro is your distribution
* Set your user config options in the configs /etc/clamav-unofficial-sigs/user.conf
* Run the script with --install-cron to install the cron file
* Run the script with --install-logrotate to install the logrotate file
* Run the script with --install-man to install the man file

Install:
* mkdir -p /usr/local/bin/
@@ -64,7 +64,6 @@ Install:
* cp -f /tmp/clamav-unofficial-sigs/clamav-unofficial-sigs.sh /usr/local/bin/clamav-unofficial-sigs.sh
* chmod +x /usr/local/bin/clamav-unofficial-sigs.sh
* cp -f /tmp/clamav-unofficial-sigs/config/*.* /etc/clamav-unofficial-sigs/
* cp -f /tmp/clamav-unofficial-sigs/clamav-unofficial-sigs.8 /usr/share/man/man8/clamav-unofficial-sigs.8

Install Systemd configs:
* cp -f /tmp/clamav-unofficial-sigs/systemd/*.* /etc/systemd/
@@ -77,12 +76,16 @@ Configure:

Install Cron configs:
* After the configs have been configured
* Run: bash clamav-unofficial-sigs.sh --install-croCron:
* Run: bash clamav-unofficial-sigs.sh --install-cron:

Install logrotate configs::
* After the configs have been configured
* Run: bash clamav-unofficial-sigs.sh --install-logrotate

Install man (help) file:
* After the configs have been configured
* Run: bash clamav-unofficial-sigs.sh --install-man:

### First Usage
* Run the script once as your superuser to set all the permissions and create the relevant directories

@@ -21,12 +21,12 @@ Please post them on the issue tracker : https://github.com/extremeshok/clamav-un
* Set 755 permissions on /usr/local/bin/clamav-unofficial-sigs.sh
* Make the directory /etc/clamav-unofficial-sigs/
* Copy the contents of config/ into /etc/clamav-unofficial-sigs/
* Copy clamav-unofficial-sigs.8 into /usr/share/man/man8/
* Make the directory /var/log/clamav-unofficial-sigs/
* Rename the your os.your-distro.conf to os.conf, where your-distro is your distribution
* Set your user config options in the configs /etc/clamav-unofficial-sigs/user.conf
* Run the script with --install-cron to install the cron file
* Run the script with --install-logrotate to install the logrotate file
* Run the script with --install-man to install the man file

### First Usage
* Run the script once as your superuser to set all the permissions and create the relevant directories
@@ -81,7 +81,17 @@ Usage of free Linux Malware Detect clamav signatures: https://www.rfxn.com/proje
- Enabled by default, no configuration required
## Change Log
### Version 5.1.1 (updated 2016-04-13)
### Version 5.1.2 (updated 2016-04-15)
- eXtremeSHOK.com Maintenance
- Added --install-man this will automatically generate and install the man (help) file
- Script options are added to the man file
- Fixed hardcoded logrotate and cron in remove_script
- Fixed incorrectly assigned logrotate varibles in install-logrotate
- Config added info for port/package maintainers regarding: pkg_mgr and pkg_rm
- Removed pkg_mgr and pkg_rm from freebsd and openbsd os configs
- Bump config to 62
### Version 5.1.1
- eXtremeSHOK.com Maintenance
- Added OS X and openbsd configs
- Fixed host fallback sed issues by @MichaelKuch

This file was deleted.

Oops, something went wrong.
@@ -154,6 +154,81 @@ function clamav_files () {
# ADDITIONAL PROGRAM FUNCTIONS
################################################################################


#generates a man config and installs it
function install_man (){
echo ""
echo "Generating man file for install...."

#Use defined varibles or attempt to use default varibles
if [ ! -n "$man_dir" ] ; then
man_dir="/usr/share/man/man8"
fi
if [ ! -n "$man_filename" ] ; then
man_filename="clamav-unofficial-sigs.8"
fi
if [ ! -n "$man_log_file_full_path" ] ; then
man_log_file_full_path="$log_file_path/$log_file_name"
fi

man_dir=$(echo "$man_dir" | sed 's:/*$::')

if [ ! -e "$man_dir/$man_filename" ] ; then
mkdir -p "$man_dir"
touch "$man_dir/$man_filename" 2>/dev/null
fi
if [ ! -w "$man_dir/$man_filename" ] ; then
echo "ERROR: man install aborted, as file not writable: $man_dir/$man_filename"
else

BOLD="\fB"
REV=""
NORM="\fR"
manresult=`help_and_usage "man"`

#Our template..
cat << EOF > "$man_dir/$man_filename"
.\" Manual page for eXtremeSHOK.com ClamAV Unofficial Signature Updater
.TH clamav-unofficial-sigs 8 "$script_version_date" "Version: $script_version" "SCRIPT COMMANDS"
.SH NAME
clamav-unofficial-sigs \- Download, test, and install third-party ClamAV signature databases.
.SH SYNOPSIS
.B clamav-unofficial-sigs
.RI [ options ]
.SH DESCRIPTION
\fBclamav-unofficial-sigs\fP script provides a simple way to download, test, and update third-party
signature databases provided by Sanesecurity, FOXHOLE, OITC, Scamnailer, BOFHLAND, CRDF, Porcupine,
Securiteinfo, MalwarePatrol. The package also contains cron, logrotate, and man files.
.SH UPDATES
Script updates can be found at: \fBhttps://github.com/extremeshok/clamav-unofficial-sigs\fP
.SH OPTIONS
This script follows the standard GNU command line syntax.
.LP
$manresult
.SH SEE ALSO
.BR clamd (8),
.BR clamscan (1)
.SH COPYRIGHT
Copyright (c) Adrian Jon Kriel :: admin@extremeshok.com
.TP
You are free to use, modify and distribute, however you may not remove this notice.
.SH LICENSE
BSD (Berkeley Software Distribution)
.SH BUGS
Report bugs to \fBhttps://github.com/extremeshok/clamav-unofficial-sigs\fP
.SH AUTHOR
Adrian Jon Kriel :: admin@extremeshok.com
Originially based on Script provide by Bill Landry
EOF

fi
echo "Completed: man installed, as file: $man_dir/$man_filename"
}


#generates a logrotate config and installs it
function install_logrotate (){
echo ""
@@ -561,10 +636,10 @@ function remove_script () {
rm -f "$logrotate_file_full_path"
echo " Removed file: $logrotate_file_full_path"
fi
man_file="/usr/share/man/man8/clamav-unofficial-sigs.8"
if [ -r "$man_file" ] ; then
rm -f "$man_file"
echo " Removed file: $man_file"
man_file_full_path="$man_dir/$man_filename"
if [ -r "$man_file_full_path" ] ; then
rm -f "$man_file_full_path"
echo " Removed file: $man_file_full_path"
fi

#rather keep the configs
@@ -808,48 +883,84 @@ function check_new_version () {
}

#function for help and usage
##usage:
# help_and_usage "1" - enables the man output formatting
# help_and_usage - enables help output formatting
function help_and_usage () {
echo "Usage: `basename $0` [OPTION] [PATH|FILE]"

echo -e "\n${BOLD}-c${NORM}, ${BOLD}--config${NORM}\tUse a specific configuration file or directory\n\teg: '-c /your/dir' or ' -c /your/file.name' \n\tNote: If a directory is specified the directory must contain atleast: \n\tmaster.conf, os.conf or user.conf\n\tDefault Directory: $config_dir"

echo -e "\n${BOLD}-F${BOLD}, --force${NORM}\tForce all databases to be downloaded, could cause ip to be blocked"

echo -e "\n${BOLD}-h${NORM}, ${BOLD}--help${NORM}\tDisplay this script's help and usage information"

echo -e "\n${BOLD}-V${NORM}, ${BOLD}--version${NORM}\tOutput script version and date information"

echo -e "\n${BOLD}-v${NORM}, ${BOLD}--verbose${NORM}\tBe verbose, enabled when not run under cron"

echo -e "\n${BOLD}-s${NORM}, ${BOLD}--silence${NORM}\tOnly output error messages, enabled when run under cron"

echo -e "\n${BOLD}-d${NORM}, ${BOLD}--decode-sig${NORM}\tDecode a third-party signature either by signature name\n\t(eg: Sanesecurity.Junk.15248) or hexadecimal string.\n\tThis flag will 'NOT' decode image signatures"

echo -e "\n${BOLD}-e${NORM}, ${BOLD}--encode-string${NORM}\tHexadecimal encode an entire input string that can\n\tbe used in any '*.ndb' signature database file"

echo -e "\n${BOLD}-f${NORM}, ${BOLD}--encode-formatted${NORM}\tHexadecimal encode a formatted input string containing\n\tsignature spacing fields '{}, (), *', without encoding\n\tthe spacing fields, so that the encoded signature\n\tcan be used in any '*.ndb' signature database file"

echo -e "\n${BOLD}-g${NORM}, ${BOLD}--gpg-verify${NORM}\tGPG verify a specific Sanesecurity database file\n\teg: '-g filename.ext' (do not include file path)"

echo -e "\n${BOLD}-i${NORM}, ${BOLD}--information${NORM}\tOutput system and configuration information for\n\tviewing or possible debugging purposes"

echo -e "\n${BOLD}-m${NORM}, ${BOLD}--make-database${NORM}\tMake a signature database from an ascii file containing\n\tdata strings, with one data string per line. Additional\n\tinformation is provided when using this flag"

echo -e "\n${BOLD}-r${NORM}, ${BOLD}--remove-script${NORM}\tRemove the clamav-unofficial-sigs script and all of\n\tits associated files and databases from the system"

echo -e "\n${BOLD}-t${NORM}, ${BOLD}--test-database${NORM}\tClamscan integrity test a specific database file\n\teg: '-s filename.ext' (do not include file path)"
if [ "$1" ]; then
#option_format_start
ofs="\fB"
#option_format_end
ofe="\fR"
#option_format_blankline
ofb=".TP"
#option_format_tab_line
oft=" "
else
#option_format_start
ofs="${BOLD}"
#option_format_end
ofe="${NORM}\t"
#option_format_blankline
ofb="\n"
#option_format_tab_line
oft="\n\t"
fi

echo -e "\n${BOLD}-o${NORM}, ${BOLD}--output-triggered${NORM}\tIf HAM directory scanning is enabled in the script's\n\tconfiguration file, then output names of any third-party\n\tsignatures that triggered during the HAM directory scan"
helpcontents=`cat << EOF
$ofs Usage: $(basename $0) $ofe [OPTION] [PATH|FILE]
$ofb
$ofs -c, --config $ofe Use a specific configuration file or directory $oft eg: '-c /your/dir' or ' -c /your/file.name' $oft Note: If a directory is specified the directory must contain atleast: $oft master.conf, os.conf or user.conf $oft Default Directory: $config_dir
$ofb
$ofs -F, --force $ofe Force all databases to be downloaded, could cause ip to be blocked
$ofb
$ofs -h, --help $ofe Display this script's help and usage information
$ofb
$ofs -V, --version $ofe Output script version and date information
$ofb
$ofs -v, --verbose $ofe Be verbose, enabled when not run under cron
$ofb
$ofs -s, --silence $ofe Only output error messages, enabled when run under cron
$ofb
$ofs -d, --decode-sig $ofe Decode a third-party signature either by signature name $oft (eg: Sanesecurity.Junk.15248) or hexadecimal string. $oft This flag will 'NOT' decode image signatures
$ofb
$ofs -e, --encode-string $ofe Hexadecimal encode an entire input string that can $oft be used in any '*.ndb' signature database file
$ofb
$ofs -f, --encode-formatted $ofe Hexadecimal encode a formatted input string containing $oft signature spacing fields '{}, (), *', without encoding $oft the spacing fields, so that the encoded signature $oft can be used in any '*.ndb' signature database file
$ofb
$ofs -g, --gpg-verify $ofe GPG verify a specific Sanesecurity database file $oft eg: '-g filename.ext' (do not include file path)
$ofb
$ofs -i, --information $ofe Output system and configuration information for $oft viewing or possible debugging purposes
$ofb
$ofs -m, --make-database $ofe Make a signature database from an ascii file containing $oft data strings, with one data string per line. Additional $oft information is provided when using this flag
$ofb
$ofs -r, --remove-script $ofe Remove the clamav-unofficial-sigs script and all of $oft its associated files and databases from the system
$ofb
$ofs -t, --test-database $ofe Clamscan integrity test a specific database file $oft eg: '-s filename.ext' (do not include file path)
$ofb
$ofs -o, --output-triggered $ofe If HAM directory scanning is enabled in the script's $oft configuration file, then output names of any third-party $oft signatures that triggered during the HAM directory scan
$ofb
$ofs -w, --whitelist $ofe Adds a signature whitelist entry in the newer ClamAV IGN2 $oft format to 'my-whitelist.ign2' in order to temporarily resolve $oft a false-positive issue with a specific third-party signature. $oft Script added whitelist entries will automatically be removed $oft if the original signature is either modified or removed from $oft the third-party signature database
$ofb
$ofs --check-clamav $ofe If ClamD status check is enabled and the socket path is correctly $oft specifiedthen test to see if clamd is running or not
$ofb
$ofs --install-cron $ofe Install and generate the cron file, autodetects the values $oft based on your config files
$ofb
$ofs --install-logrotate $ofe Install and generate the logrotate file, autodetects the $oft values based on your config files
$ofb
$ofs --install-man $ofe Install and generate the man file, autodetects the $oft values based on your config files
$ofb
EOF
` #this is very important...

echo -e "\n${BOLD}-w${NORM}, ${BOLD}--whitelist${NORM}\tAdds a signature whitelist entry in the newer ClamAV IGN2\n\tformat to 'my-whitelist.ign2' in order to temporarily resolve\n\ta false-positive issue with a specific third-party signature.\n\tScript added whitelist entries will automatically be removed\n\tif the original signature is either modified or removed from\n\tthe third-party signature database"
if [ "$1" ]; then
echo "${helpcontents//-/\\-}"
else
echo -e "$helpcontents"
fi

echo -e "\n${BOLD}--check-clamav${NORM}\tIf ClamD status check is enabled and the socket path is correctly\n\tspecifiedthen test to see if clamd is running or not"

echo -e "\n${BOLD}--install-cron${NORM}\tInstall and generate the cron file, autodetects the values\n\tbased on your config files"

echo -e "\n${BOLD}--install-logrotate${NORM}\tInstall and generate the logrotate file, autodetects the\n\tvalues based on your config files"

echo -e "\nMail suggestions and bug reports to ${BOLD}<admin@extremeshok.com>${NORM}"

}

@@ -858,8 +969,8 @@ function help_and_usage () {
################################################################################

#Script Info
script_version="5.1.1"
script_version_date="13 April 2016"
script_version="5.1.2"
script_version_date="15 April 2016"
minimum_required_config_version="60"

#default config files
@@ -1091,6 +1202,7 @@ while true; do
--check-clamav ) check_clamav; exit; break ;;
--install-cron ) install_cron; exit; break ;;
--install-logrotate ) install_logrotate; exit; break ;;
--install-man ) install_man; exit; break ;;
* ) break ;;
esac
done
@@ -403,6 +403,12 @@ curl_proxy=""
#logrotate_group="" #default: uses the clam_group
#logrotate_log_file_full_path="" #default: detected to the $log_file_path/$log_file_name

# Custom man install settings, these are detected and only used if you want to override
# the automatic detection and generation of the values when not set
#man_dir="" #default: /etc/man.d
#man_filename="" #default: clamav-unofficial-sigs
#man_log_file_full_path="" #default: detected to the $log_file_path/$log_file_name

# Provided two variables that package and port maintainers can use in order to
# prevent the script from removing itself with the '-r' flag
# If the script was installed via a package manager like yum, apt, pkg, etc.

0 comments on commit a4cbc78

Please sign in to comment.
You can’t perform that action at this time.