Mint Serena 64 bit using the Mate desktop environment. Most of the following scripts will run on this machine, although some have only been tested with the Gnome desktop. Extra software requirements can be met by the Ubuntu and safe PPA repositories. Scripts may be re-written or added to from time to time, the date serves as the version number. Syntax highlighting on these pages is provided by GVim's "Convert to HTML" option.
Showing posts with label test. Show all posts
Showing posts with label test. Show all posts

RKHunter script

#!/bin/bash
# Filename: RKHunter.sh
# Author: robz
# Version: 051210
# Root Kit Hunter
# Strictly speaking best results from RKHunter are obtained by setting it up
# with a fresh Linux install, so there is no doubt as to the integrity of the
# system files present.
# However, this script runs RKHunter manually, saves a logfile to your home
# directory then parses that log to display any problems it "may" have found.
# Run the script directly, from nautilus-scripts or make yourself a launcher.
# For configuration info. and interpretation of the logfile look at
# /usr/share/doc/rkhunter/FAQ.gz or the readme or goto:
# http://rkhunter.cvs.sourceforge.net/viewvc/rkhunter/rkhunter/files/FAQ
# Don't worry too much if you get a terminal full of red warnings at first,
# read the FAQs or Google for answers first, worry after:)

LOG=/home/$USER/.rkhunter.log

gnome-terminal --geometry=90x65+0+0 -x bash -c "\
    rm -f /home/$USER/.rkhunter*.log
    sudo rkhunter --update -c --sk -l $LOG;\
    read -p 'Hit a key to see logged warnings' -n 1;\
    tput cuu1; tput cuu1; tput cuu1; tput cuu1; echo;\
    sudo chmod a+r $LOG;\
    export GREP_COLOR='1;37;41';\
    grep -A4 -B4 --color=always Warning $LOG |\
    more;\
    export GREP_COLOR='1;31';\
    read -p 'Hit a key to exit' -n 1"
    
sudo -K


Powered by ScribeFire.

Automate ClamAV antivirus

#!/bin/bash
# Filename: ClamAV-scan
# Version: 291110
# Author: robz
# This runs clamscan via a "user crontab", scans reports & logs to your home
# directory every 3 days, or alter to your prefs. "30 19 */3 * * export
# DISPLAY=:0 && /home//.scripts/ClamAV-scan > /dev/null 2>&1" all on one
# line without the enclosing quotes.
# The patched notify-osd package is reqd. see this page for an explanation.
# http://www.webupd8.org/2010/05/finally-easy-way-to-customize-notify.html
# You might also need to "sudo chmod 444" some files to allow read access for
# "others", something to check if script fails see below.

LOGFILE="$HOME/ClamAV-scan-for-$(date +%A-%H:%M).log"
SUBJECT="ClamAV scan report:"
VERSION="271010"
TARGET=/home/robz1                                  # Where to scan.
SOUND=$HOME/Audio/HyprBlip.wav                      # Warning sound (file.wav)
ICON=$HOME/Pictures/user_graphics/Icons/clam.png    # Find yourself an icon.
OSDRC=$HOME/.notify-osd
BBCOL="bubble-background-color = "

mod_osd ()                                          # Mod colours etc.
{
echo $SUBJECT >> $LOGFILE
sed -i "s/bubble-background-color.*/${BBCOL}/" $OSDRC
pkill notify-osd; notify-send -i "$ICON" "$SUBJECT"
# Next bit returns notify-osd to original check yours in "~/.notify-osd"
sed -i 's/bubble-background-color.*/bubble-background-color = 131313/' $OSDRC
/usr/bin/canberra-gtk-play --loop 2 --volume 6 -f $SOUND &
sleep 10; pkill notify-osd
}

rm -f "$HOME/ClamAV-scan-for-"*.log                 # Junk old logfile.
echo -e "$SUBJECT - $(date)\n" > $LOGFILE           # Create new logfile.
echo -e "Script: $(basename $0) v$VERSION - for user: $LOGNAME" >> $LOGFILE
echo -e "Scanmode: Recursive\nFiles Scanned: $TARGET" >> $LOGFILE

# If nessesary, may fail otherwise!
sudo chmod 444 /var/lib/clamav/bytecode.cld /var/lib/clamav/main.cld\
/var/lib/clamav/daily.cld

# Read man clamscan to configure, this may require a tweak or not.
nice -n 19 /usr/bin/clamscan\
    $TARGET\
    --exclude-dir="$TARGET/Music"\
    --exclude-dir="$TARGET/Audio"\
    --exclude-dir="$TARGET/Pictures"\
    --exclude-dir="$TARGET/.Private"\
    --log=$LOGFILE\
    --infected\
    --recursive\
    --max-files=500\
    --max-recursion=8\
    --max-dir-recursion=8
CLAMSCAN=$?                                         # Exit status.

if [ "$CLAMSCAN" -eq "1" ]; then
    SUBJECT=$SUBJECT" [VIRUS FOUND!]"
    BBCOL=$BBCOL"ff0000"; mod_osd                   # Red osd warning.
elif [ "$CLAMSCAN" -gt "1" ]; then
    SUBJECT=$SUBJECT" [ERROR $CLAMSCAN]"
    BBCOL=$BBCOL"0000ff"; mod_osd                   # Blue advisory.
else SUBJECT=$SUBJECT" No virus Found"
    SOUND=$HOME/Audio/2tone.wav                     # All OK sound (file.wav)
    BBCOL=$BBCOL"00cc00"; mod_osd                   # Green OK, nothing found.
fi



Powered by ScribeFire.

Suspend resume tester

#!/bin/bash
# Filename: testsuspend.sh
# Author: robz
# Version: 161010
# Soak test for Suspend/Resume.
# If pm-suspend fails, which in my case means a hard boot instead of a resume,
# I find that booting into WinXP just to the password prompt then rebooting
# into Ubuntu fixes things for a while. This script will then run it's 10 test
# cycles without fault. Of course you need to be running a dual boot machine
# or the above ain't gonna help ya.:)
# Suspends/resumes 10 times, checks for valid internet connection and logs the
# results.

LOG=~/pm-suspend_soak.log
> $LOG                                          # Make a logfile
sudo /bin/true                                  # Get root privileges.
echo -e "Soak testing of \"pm-suspend function\"" | tee $LOG
echo "Test started at: `date +%T`" | tee -a $LOG
sleep 3
for x in {1..10}; do
    sudo killall rtcwake; clear                 # Kill any residual process
    poff; sleep 2                               # Disconnect ADSL
    sudo rtcwake -s 10 -m on & sleep 2          # Wake in 10 seconds
    sudo /usr/sbin/pm-suspend                   # Bodge for bug in rtcwake
    echo -ne "Test $x -- `date +%T` restore good -- " | tee -a $LOG
    sleep 10
    pon adsl; sleep 20                          # Reconnect ADSL
    CHECK=0
    while ! ping -c 1 www.google.com > /dev/null && [ "$CHECK" -le "5" ]; do
        let "CHECK += 1"
        sleep 3
    done
    if ping -c 1 www.google.com; then
        echo "ADSL connection success" | tee -a $LOG
        else echo "but no connection!" | tee -a $LOG
    fi
    echo -e "Soak testing of \"pm-suspend function\""
    echo -e "Test has cycled $x times\nCTRL c to stop"
    for i in {5..1}; do                         # Count down to next suspend
        printf "\r%s""Next test in: "$i
        tput el
        sleep 1                                 # 1 second plus the loop!
    done
clear
done
echo -e "Soak Test Complete\n\n" | tee -a $LOG
cat < $LOG


Powered by ScribeFire.