source: subversion/applications/utils/tagwatch/cron_tagwatch @ 34613

Last change on this file since 34613 was 28539, checked in by Dirk Stoecker, 7 years ago

fix photo copy

  • Property svn:executable set to *
File size: 2.0 KB
Line 
1#! /usr/bin/perl
2
3my $BASETMP="/osm/tagwatch/tmp";
4my $WEBDIR="/osm/tagwatch/webpage/";
5my $HOME="/osm/tagwatch/tagwatch_svn";
6my $TWD;
7my @cfg =();
8system "rm","-r","$BASETMP/html";
9system "rm","-r","$BASETMP/osmfiles";
10system "rm","-r","$BASETMP/osmarender";
11system "rm -r $BASETMP/cache/outp*";
12unlink "/osm/stampfiles/tagwatch_is_NOT_running.stamp";
13if(open FILE,">","/osm/stampfiles/tagwatch_is_running.stamp")
14{
15  print FILE $$;
16  close FILE;
17}
18foreach my $arg (@ARGV)
19{
20  eval
21  {
22  chdir $HOME;
23  my $a = `date`; chomp $a; print "$a Start $arg\n";
24
25  my $cfg = `cat cron_$arg.conf`;
26  ($TWD) = ($cfg =~ /basedir *= *(.*)/);
27  my ($HTML) = ($cfg =~ /output_folder *= *(.*)/);
28  my ($OSMA) = ($cfg =~ /osmarender_folder *= *(.*)/);
29  my ($OSM) = ($cfg =~ /osmfile_folder *= *(.*)/);
30  my $FILE="upload_tw_$arg.tbz2";
31  if(!$TWD || !$HTML || !$OSMA || !$OSM)
32  {
33    die "Could not read data.";
34  }
35
36  # start building
37  system "./tagwatch.pl","config_file=cron_$arg.conf",@cfg;
38
39  my $a = `date`; chomp $a; print "$a Start uploading $arg\n";
40  # start upload
41  if(!chdir "$TWD/$HTML")
42  {
43    print "$TWD .. $HTML\n";
44    print "$TWD/$HTML\n";
45    system "pwd";
46    system "ls";
47    die "Could not change directory.";
48  }
49  my $a = `date`; chomp $a; print "$a Copy files $arg\n";
50  foreach my $name (glob("*"))
51  {
52    if(-d $name && -e "$WEBDIR/$name")
53    {
54      if($name eq "photos")
55      {
56        system "mv -f $name/* $WEBDIR/$name/";
57      }
58      else
59      {
60        system "mv $WEBDIR/$name ${name}_old_$$";
61        system "mv -f $name $WEBDIR";
62        system "rm -r ${name}_old_$$";
63      }
64    }
65    else
66    {
67      system "mv -f $name $WEBDIR";
68    }
69  }
70  system "rm -r $TWD/$HTML/*";
71  $a = `date`; chomp $a; print "$a End $arg\n";
72  push(@cfg, "use_WikiTag_Cache=yes");
73  push(@cfg, "use_Photo_Cache=yes");
74  push(@cfg, "use_WikiSettings_Cache=yes");
75  };
76  print $@ if $@;
77}
78chdir $HOME;
79system "rm","-r",$TWD if $TWD;
80unlink "/osm/stampfiles/tagwatch_is_running.stamp";
81close FILE if open FILE,">","/osm/stampfiles/tagwatch_is_NOT_running.stamp";
Note: See TracBrowser for help on using the repository browser.