home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2006 May / PCpro_2006_05.ISO / files / free_security / languard / languardnss7.exe / applicationversion.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2004-12-17  |  7.0 KB  |  188 lines

  1. #!/bin/bash
  2.  
  3. appfile=applications
  4.  
  5. #below is a list of applications and their version, please note that the application name and version are
  6. #seperated by the "~" symbol 
  7. #if you wish to check for other applications simply add the entry you wish belowno further changes will be necessary
  8. #records below use the following structure:
  9. #<RPM Package name>~<Major release>~<Latest security update version>~<Latest application update version>
  10. #<Major release> is used by the script below to differenciate between major release of packages. 
  11. #the system works by matching the value of <Major release> with the first corresponding number of characters of the actually version.
  12.  
  13. #data file starting below
  14. cat << EOF > applications 
  15. apache2~2.0~2.0.52~2.0.52
  16. apache~1.3~1.3.33~1.3.33
  17. bash~2~2.05c~2.05c
  18. bash~1~1.14.7~1.14.7
  19. kernel-smp~2.6~2.6.9~2.6.9
  20. kernel~2.6~2.6.9~2.6.9
  21. kernel-smp~2.4~2.4.28~2.4.28
  22. kernel~2.4~2.4.28~2.4.28
  23. kernel-smp~2.2~2.2.26~2.2.26
  24. kernel~2.2~2.2.26~2.2.26
  25. kernel-smp~2.0~2.0.40~2.0.40
  26. kernel~2.0~2.0.40~2.0.40
  27. openssh~3~3.9p1~3.9p1
  28. samba~3~3.0.9~3.0.9
  29. openssl~0.9~0.9.7e~0.9.7e
  30. bind~9~9.3.0~9.3.0
  31. bind~8~8.4.5~8.4.5
  32. bind~4~4.9.11~4.9.11
  33. dhcp~3~3.0.2rc3~3.0.2rc3
  34. gcc-c++~3~3.4.3~3.4.3
  35. sudo~1~1.6.8p2~1.6.8.p5
  36. gcc~3~3.4.3~3.4.3
  37. iptables~1.2~1.2.11~1.2.11
  38. sendmail~8~8.12.10~8.13.1
  39. mysql-shared~4.0~4.0.22~4.0.22
  40. mysql-shared~4.1~4.1.7~4.1.7
  41. mysql-shared~5.0~5.0.2~5.0.2
  42. mysql~4.0~4.0.22~4.0.22
  43. mysql~4.1~4.1.7~4.1.7
  44. mysql~5.0~5.0.2~5.0.2
  45. postgresql~7~7.4.6~7.4.6
  46. cvs~1.11~1.11.18~1.11.18
  47. cvs~1.12~1.12.11~1.12.11
  48. net-snmp~5~5.2~5.2
  49. postfix~2.1~2.1.5-4~2.1.5-4
  50. EOF
  51. #data file finished
  52. #anything below here should not require any editing. Unless there's a need to change the script's functionality ofcourse.
  53.  
  54. declare -a apps
  55. filestore=`date --iso-8601`_apps 
  56.  
  57. if [ ! -e "$filestore" ]
  58. then
  59.     rpm -qa --qf '%{NAME}~%{VERSION}\n' > "$filestore"
  60.     filetodelete=`cat filestorever`
  61.     rm -f `echo $filetodelete`
  62.     echo "$filestore" > filestorever
  63.  
  64. fi
  65. oldversions=FALSE
  66. treecreate=FALSE
  67. apps=(` cat "$filestore" | tr '\n' ' '`)
  68. count=${#apps[*]}
  69. echo "" > installedapps
  70. for ap in ${apps[@]}
  71. do
  72.     echo $ap >> installedapps
  73. done
  74. #echo ${apps[@]} > installedapps
  75. declare -a applist
  76. applist=( `cat "$appfile" | tr '\n' ' '`)
  77. appcount=${#applist[*]}
  78.  
  79. for AppToTest in ${applist[@]}
  80. do
  81.     appname=`echo $AppToTest | awk -F~ ' { print $1 } '`
  82.     appmajorrelease=`echo $AppToTest | awk -F~ ' { print $2 } '`
  83.     appfullversec=`echo $AppToTest | awk -F~ ' { print $3 } '`
  84.     appfullverapp=`echo $AppToTest | awk -F~ ' { print $4 } '`
  85.     appmajor1app=`echo $appfullverapp | awk -F. ' { print $1 } '`
  86.         appmajor2app=`echo $appfullverapp | awk -F. ' { print $2 } '`
  87.         appminorapp=`echo $appfullverapp | awk -F. ' { print $3 } '`
  88.     matchapps=`grep $appname installedapps`
  89.     for AppRecord in ${matchapps[@]}
  90.     do
  91.         StAppName=`echo $AppRecord | awk -F~ ' { print $1 } '`
  92.         if [ "$StAppName" == "$appname" ]
  93.         then
  94.             len=`echo $appmajorrelease | awk ' { print length } '`
  95.             tempapp=`echo $AppRecord~$len`
  96.             stmajorrelease=`echo $tempapp | awk -F~ ' { print substr($2,1,$3) } '`
  97.             stappfullver=`echo $tempapp | awk -F~ ' { print $2 } '`
  98.             stappfullversec=`echo $AppRecord | awk -F~ ' { print $3 } '`
  99.             stappfullverapp=`echo $AppRecord | awk -F~ ' { print $4 } '`
  100.                 stappmajor1=`echo $stappfullver | awk -F. ' { print $1 } '`
  101.                 stappmajor2=`echo $stappfullver | awk -F. ' { print $2 } '`
  102.                 stappminor=`echo $stappfullver | awk -F. ' { print $3 } '`
  103.             if [ "$stmajorrelease" == "$appmajorrelease" ]
  104.             then
  105.  
  106.                 #substitution for version which include RC
  107.                 stappmajor1=`echo $stappmajor1 |  sed s/rc/./`
  108.                 stappmajor2=`echo $stappmajor2 | sed s/rc/./`
  109.                 stappminor=`echo $stappminor | sed s/rc/./`
  110.                 appmajor1app=`echo $appmajor1app | sed s/rc/./`
  111.                                 appmajor2app=`echo $appmajor2app | sed s/rc/./`
  112.                                 appminorapp=`echo $appminorapp | sed s/rc/./`
  113.                                 #substitution for version which include p
  114.                 stappmajor1=`echo $stappmajor1 |  sed s/p/./`
  115.                 stappmajor2=`echo $stappmajor2 | sed s/p/./`
  116.                 stappminor=`echo $stappminor | sed s/p/./`
  117.                 appmajor1app=`echo $appmajor1app | sed s/p/./`
  118.                             appmajor2app=`echo $appmajor2app | sed s/p/./`
  119.                             appminorapp=`echo $appminorapp | sed s/p/./`
  120.                                 
  121.                                 stappmajor1=`echo $stappmajor1 | sed 's/[a-f]/.&/'`
  122.                                 stappmajor2=`echo $stappmajor2 | sed 's/[a-f]/.&/'`
  123.                                 stappminor=`echo $stappminor | sed 's/[a-f]/.&/'`
  124.                                 appmajor1app=`echo $appmajor1app |  sed 's/[a-f]/.&/'`
  125.                                 appmajor2app=`echo $appmajor2app |  sed 's/[a-f]/.&/'`
  126.                                 appminorapp=`echo $appminorapp |  sed 's/[a-f]/.&/'`
  127.  
  128.                 stappmajor1=`echo $stappmajor1 |  tr [a-f] [1-6]`
  129.                             stappmajor2=`echo $stappmajor2 | tr [a-f] [1-6]`
  130.                             stappminor=`echo $stappminor |  tr [a-f] [1-6]`
  131.                 appmajor1app=`echo $appmajor1app | tr [a-f] [1-6]`
  132.                                 appmajor2app=`echo $appmajor2app | tr [a-f] [1-6]`
  133.                                 appminorapp=`echo $appminorapp | tr [a-f] [1-6]`
  134.  
  135.                             if [ "$stappmajor2" == "" ]
  136.                             then
  137.                                     stappmajor2=0
  138.                             fi
  139.     
  140.                  if [ "$appmajor2app" == "" ]
  141.                                 then
  142.                                         appmajor2app=0
  143.                                 fi
  144.  
  145.                                 if [ "$appminorapp" == "" ]
  146.                                 then
  147.                                         appminorapp=0
  148.                                 fi
  149.  
  150.                 if [ "$stappminor" == "" ]
  151.                             then
  152.                                     stappminor=0
  153.                                 fi
  154.  
  155.     
  156.                                 temp=`echo "$appmajor1app $appmajor2app $appminorapp"`
  157.                                 procappverapp=`echo $temp | awk '{ print $1 * 10000 + $2 * 100 + $3 }'`
  158.                                 temp=`echo "$stappmajor1 $stappmajor2 $stappminor"`
  159.                                 procstappver=`echo $temp | awk ' { print $1 * 10000 + $2 * 100 + $3 }'`
  160.  
  161.  
  162.  
  163.                 if [ $procstappver \< $procappverapp ]
  164.                                 then
  165.                     if [ "$oldversions" == FALSE ]
  166.                     then
  167.                         echo "TRUE:"
  168.                         oldversions=TRUE
  169.                     fi
  170.                                        
  171.                     app=`echo $AppToTest | awk -F~ ' { print $1 } '`
  172.                                         echo "AddListItem([[[]]],[[[Application: $app current version is: $stappfullver. The latest release version for this application is: $appfullverapp]]])"
  173.                                         
  174.                                 fi
  175.  
  176.  
  177.             fi
  178.         fi
  179.     done
  180. done
  181. if [ "$oldversions" == FALSE ]
  182. then
  183.     echo "FALSE:"
  184. fi
  185. rm -f applications
  186. rm -f installedapps
  187. echo "!!SCRIPT_FINISHED!!"
  188.