Category: Bash

Bash coding

Security Update Check Using GLSA

Security Update Check Using GLSA

Date: 08/20/2009
Program Name: Security Update Check Using GLSA
Description: The object of this script is to get an update respiratory from a Gentoo server and check to see if their is any security issues that effect a system.

#!/bin/bash
 
# The script will check for new Security updates available in portage

#Information needed inorder to mail the admin
echo "From: root@test.com" >> $stat
echo "To: admin@test.com" >> $stat
echo "Subject: System Security Check" >> $stat
 
echo -e "Security Check Report for $HOSTNAME $(date)\n-------------------------------------------\n" >> $stat
#Were going to update The package Libarary
emerge --sync >> $stat
 
# Then check if it went ok
result=$(grep 'metadata/glsa/timestamp.chk' /tmp/test.txt)
 
if [ !$result ]; then
    echo -e "The Portage Library Update Failed. Here is the last message that was picked up by Portage.\n" >> $stat
    tail -n10 /tmp/test.txt >> $stat
    echo -e "\n-------------------------------------------\n" >> $stat
    echo -e "\nThings to Check with the system:\nPlease check if the system is able to resovle name server.\nCheck if their is any conitivity on the network.\nCall an Admin!!" >> $stat
else
    echo -e "The Portage Library Update Works! Doing a security Check on the system\n" >> $stat
    glsa-check --list affected >> $stat
    echo -e "\n System security Check Completed.\n-------------------------------------------" >> $stat
fi
 
#Mail the Results
cat $stat | /usr/sbin/sendmail -t -bm -v
#Clean up the mess
echo "" > $stat
%d bloggers like this: