Annotation of wpscripts/ztransfer/main.pl, Revision 1.1.1.1
1.1 yason 1: #!/usr/bin/perl
2: # $Id: main.pl,v 1.1.1.10 2007/01/12 12:13:38 init Exp $
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:
10: our $ZFILESERVER_IP = '192.168.12.2';
11: our @ZMPOINTS = ('zV6', 'zV7', 'zV8');
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:
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: }
30:
31: # it seems like remote host is up and running ;)
32: log::stdout("$ZFILESERVER_IP is alive, this is good.");
33:
34:
35: # Check mount table for remote mounts
36: foreach $mpoint (@ZMPOINTS)
37: {
38: if ( ! `/sbin/mount | /usr/bin/grep $mpoint`)
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::jpegs();
65: send::zayavki();
66: send::probas();
67: send::tpps();
68:
69: db::disconnect();
70:
71: fileops::release_lock();
72:
73: #EOF
CVSweb