Annotation of wpscripts/ztransfer/main.pl, Revision 1.3
1.1 yason 1: #!/usr/bin/perl
1.3 ! yason 2: # $Id: main.pl,v 1.2 2011/06/03 11:03:41 yason Exp $
1.1 yason 3: use db;
4: use send;
5: use fileops;
6: use network;
7: use log; # we need to critical log if remote host is down
8: use hash;
9:
1.3 ! yason 10: our $ZFILESERVER_IP = '192.168.16.1';
1.2 yason 11: our @ZMPOINTS = ('rmt_maket');
1.1 yason 12: our $mpoint;
13:
14: # according to manual of Perl's function system(),
15: # it is safer to autoflushing all out file disciptors
16: # cause of main process attempts to forcebly flush ones
17: # before any functions that may fork()
18: $| = 1;
19:
20: fileops::check_lock();
21: fileops::take_lock();
22: fileops::cleanup();
23:
24:
1.3 ! yason 25: #if( ! network::alive( $ZFILESERVER_IP ) )
! 26: #{
! 27: # log::critical("$ZFILESERVER_IP is not reached by ICMP, considering host is down, EXITING");
! 28: # # NOTREACHED
! 29: #}
1.1 yason 30:
31: # it seems like remote host is up and running ;)
1.3 ! yason 32: #log::stdout("$ZFILESERVER_IP is alive, this is good.");
1.1 yason 33:
34:
35: # Check mount table for remote mounts
36: foreach $mpoint (@ZMPOINTS)
37: {
1.3 ! yason 38: if ( ! `/bin/mount | /bin/grep $mpoint`)
1.1 yason 39: {
40: log::critical("$mpoint not mounted. I can't run without that one! EXITING");
41: # NOTREACHED
42: }
43: }
44: log::stdout("Remote filesystems are mounted. All checks passed.");
45:
46:
47: # load directory map and print some debug
48: $_ = hash::loadtable();
49: if ( $_ == -1)
50: {
51: # error opening file
52:
53: log::stdout("Error opening $hash::HASHFILE (maps will not be used)");
54: }
55: else
56: {
57: log::stdout("Using directory map file $hash::HASHFILE ($_ records)");
58: }
59:
60:
61: # XXX maybe not to keep connection while rar & copy ?
62: db::connect();
63:
64: send::zayavki();
65: send::probas();
66:
67: db::disconnect();
68:
69: fileops::release_lock();
70:
71: #EOF
CVSweb