Subversion Repositories wimsdev

Rev

Rev 8849 | Rev 15509 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. /*    Copyright (C) 1998-2003 XIAO, Gang of Universite de Nice - Sophia Antipolis
  2.  *
  3.  *  This program is free software; you can redistribute it and/or modify
  4.  *  it under the terms of the GNU General Public License as published by
  5.  *  the Free Software Foundation; either version 2 of the License, or
  6.  *  (at your option) any later version.
  7.  *
  8.  *  This program is distributed in the hope that it will be useful,
  9.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.  *  GNU General Public License for more details.
  12.  *
  13.  *  You should have received a copy of the GNU General Public License
  14.  *  along with this program; if not, write to the Free Software
  15.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16.  */
  17.  
  18. /* Daily housekeeping jobs. */
  19.  
  20. #include "wimslogd.h"
  21.  
  22. void housekeep(void)
  23. {
  24.   char fname[1024];
  25.   FILE *keeplog;
  26.  
  27.   if(strncmp(keepdate,nowstr,8)==0) return;
  28.   snprintf(fname,sizeof(fname),"%s/keepdate",tmpd);
  29.   keeplog=fopen(fname,"r");
  30.   if(keeplog==NULL) goto dokeep;
  31.   (void)fread(keepdate,8,1,keeplog); keepdate[8]=0; fclose(keeplog);
  32.   if(strncmp(keepdate,nowstr,8)==0) return;
  33.   dokeep:
  34.   keeplog=fopen(fname,"w");
  35.   if(keeplog!=NULL) {
  36.     fwrite(nowstr,8,1,keeplog);fclose(keeplog);
  37.   }
  38.   call_ssh(0,"bin/housekeep.daily &>%s/housekeep.log",tmpd);
  39. }
  40.  
  41. /* module update */
  42. void modupdate(void)
  43. {
  44.   char fname[1024];
  45.   FILE *muplog;
  46.  
  47.   if(strncmp(mupdate,nowstr,8)==0) return;
  48.   snprintf(fname,sizeof(fname),"%s/mupdate",tmpd);
  49.   muplog=fopen(fname,"r");
  50.   if(muplog==NULL) goto domup;
  51.   (void)fread(mupdate,8,1,muplog); mupdate[8]=0; fclose(muplog);
  52.   if(strncmp(mupdate,nowstr,8)==0) return;
  53.   domup:
  54.   muplog=fopen(fname,"w");
  55.   if(muplog!=NULL) {
  56.     fwrite(nowstr,8,1,muplog);fclose(muplog);
  57.   }
  58.   call_ssh(0,"bin/modupdate.auto &>%s/modupdate.log",tmpd);
  59. }
  60.  
  61. /* Daily backup. */
  62. void backup(void)
  63. {
  64.   FILE *backlog;
  65.  
  66.   if(strncmp(backdate,nowstr,8)==0) return;
  67.   backlog=fopen("backup/backdate","r");
  68.   if(backlog==NULL) goto dobackup;
  69.   (void)fread(backdate,8,1,backlog); backdate[8]=0; fclose(backlog);
  70.   if(strncmp(backdate,nowstr,8)==0) return;
  71.   dobackup:
  72.   call_ssh(0,"bin/backup &>%s/backup.log",tmpd);
  73. }
  74.