[prev in list] [next in list] [prev in thread] [next in thread] 

List:       opensuse-autoinstall
Subject:    PXE boot check script
From:       "Frank Pascher" <fpascher () mpifr-bonn ! mpg ! de>
Date:       2003-02-10 10:51:11
Message-ID: 000101c2d0f2$3e976f10$32106886 () DOLPHIN
[Download RAW message or body]

Hi,

this is the script I use to check whether a pxe-file has been accesed or
not.

As soon a pxe-configuration has been served to a client the atime-value of
the file is changed.

After this happened the file can be deleted.

Copy this script to a location you want and change it to be executable. Next
set up a cron jop to run this script periodically. For example every 15 min.


Have fun.

frank



#!/usr/bin/perl

$logfile = "/var/log/pxecheck";
$dirname = "/tftpboot/pxelinux.cfg";

($day,$mon,$year,$h,$min,$sec) = (localtime)[3,4,5,2,1,0];

open (logdatei,">> $logfile") ||die "cannot open logfile $logfile";
print logdatei
"---------------------------------------------------------------------------
-----\n";
print logdatei "PXE-Directory : $dirname\n";
print logdatei "$day.",$mon+1,".", $year+1900," $h:$min:$sec\n";

opendir(d,$dirname);
@content = sort(grep(!/(^\.\.?$)|(default)/,readdir(d)));
closedir(d);
while ($file = shift(@content)) {
  $file = "$dirname/$file";
  ($mtime,$atime) =  (stat $file)[9,8];
  if ($atime > $mtime) {
    unlink($file);
    print logdatei "$file accessed deleted\n";
  }else{
    print logdatei "$file not accessed not deleted\n";
  }   
}

print logdatei
"---------------------------------------------------------------------------
-----\n";
close (logdatei);




+----------------------------------------------------------+
|         Max-Planck-Institut für Radioastronomie          |
|               Abt.1 (wissenschaftliche DV)               |
|                                                          |
|                      Frank Pascher                       |
+----------------------------------------------------------+
| Auf dem Huegel 69                Tel.: +49 (228) 525 359 |
| 53121 Bonn                       Fax.: +49 (228) 535 229 |
+----------------------------------------------------------+
|           Email: mailto:fpascher@mpifr-bonn.mpg.de       |
|             WWW: http://www.mpifr-bonn.mpg.de            |
| PGP Fingerprint: 13D1 8C86 57B3 2850 F158 4879 E5F3 7E20 |
+----------------------------------------------------------+ 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic