Back to index

wims  3.65+svn20090927
housekeep.c
Go to the documentation of this file.
00001 /*    Copyright (C) 1998-2003 XIAO, Gang of Universite de Nice - Sophia Antipolis
00002  *
00003  *  This program is free software; you can redistribute it and/or modify
00004  *  it under the terms of the GNU General Public License as published by
00005  *  the Free Software Foundation; either version 2 of the License, or
00006  *  (at your option) any later version.
00007  *
00008  *  This program is distributed in the hope that it will be useful,
00009  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  *  GNU General Public License for more details.
00012  *
00013  *  You should have received a copy of the GNU General Public License
00014  *  along with this program; if not, write to the Free Software
00015  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00016  */
00017 
00018        /* Daily housekeeping jobs. */
00019 void housekeep(void)
00020 {
00021     char fname[1024];
00022     FILE *keeplog;
00023     
00024     if(strncmp(keepdate,nowstr,8)==0) return;
00025     snprintf(fname,sizeof(fname),"%s/keepdate",tmpd);
00026     keeplog=fopen(fname,"r");
00027     if(keeplog==NULL) goto dokeep;
00028     fread(keepdate,8,1,keeplog); keepdate[8]=0; fclose(keeplog);
00029     if(strncmp(keepdate,nowstr,8)==0) return;
00030     dokeep:
00031     keeplog=fopen(fname,"w");
00032     if(keeplog!=NULL) {
00033        fwrite(nowstr,8,1,keeplog);fclose(keeplog);
00034     }
00035     call_ssh(0,"bin/housekeep.daily &>%s/housekeep.log",tmpd);
00036 }
00037 
00038        /* module update */
00039 void modupdate(void)
00040 {
00041     char fname[1024];
00042     FILE *muplog;
00043     
00044     if(strncmp(mupdate,nowstr,8)==0) return;
00045     snprintf(fname,sizeof(fname),"%s/mupdate",tmpd);
00046     muplog=fopen(fname,"r");
00047     if(muplog==NULL) goto domup;
00048     fread(mupdate,8,1,muplog); mupdate[8]=0; fclose(muplog);
00049     if(strncmp(mupdate,nowstr,8)==0) return;
00050     domup:
00051     muplog=fopen(fname,"w");
00052     if(muplog!=NULL) {
00053        fwrite(nowstr,8,1,muplog);fclose(muplog);
00054     }
00055     call_ssh(0,"bin/modupdate.auto &>%s/modupdate.log",tmpd);
00056 }
00057 
00058        /* Daily backup. */
00059 void backup(void)
00060 {
00061     FILE *backlog;
00062     
00063     if(strncmp(backdate,nowstr,8)==0) return;
00064     backlog=fopen("backup/backdate","r");
00065     if(backlog==NULL) goto dobackup;
00066     fread(backdate,8,1,backlog); backdate[8]=0; fclose(backlog);
00067     if(strncmp(backdate,nowstr,8)==0) return;
00068     dobackup:
00069     call_ssh(0,"bin/backup &>%s/backup.log",tmpd);
00070 }
00071