]> andersk Git - moira.git/blobdiff - gen/www.pc
Dump statistics in the BIND 9 way.
[moira.git] / gen / www.pc
index c4e8ebd8aca0bb62b1751f75b419e976cefc7cc1..db0529a4a55a2150d59a47828bb9359bc7ae3f89 100644 (file)
@@ -55,7 +55,6 @@ int main(int argc, char **argv)
   FILE *outfsf;
   struct stat sb;
   char *c;
-  int flag;
 
   initialize_sms_error_table();
 
@@ -106,61 +105,38 @@ int main(int argc, char **argv)
   sprintf(wkgrp, "%s/group~", www_dir);
   sprintf(wkfs, "%s/filsys~", www_dir);
 
-  flag = 0;
-  if (stat(outfs, &sb) == 0)
+  fprintf(stderr, "%s: building fs database...\n", whoami);
+  if (!(outfsf = fopen(wkfs, "w")))
     {
-      if (ModDiff (&flag, "filesys", sb.st_mtime))
-        exit(MR_DATE);
+      fprintf(stderr, "%s: cannot open %s for writing (%s)\n", whoami,
+             wkfs, strerror(errno));
+      exit(MR_OCONFIG);
     }
-  if (flag < 0)
-    fprintf(stderr, "%s: %s does not need to be rebuilt.\n", whoami, outfs);
-  else
+  filsys(outfsf);
+  if (fclose(outfsf))
     {
-      fprintf(stderr, "%s: building fs database...\n", whoami);
-      if (!(outfsf = fopen(wkfs, "w")))
-       {
-         fprintf(stderr, "%s: cannot open %s for writing (%s)\n", whoami,
-                 wkfs, strerror(errno));
-         exit(MR_OCONFIG);
-       }
-      filsys(outfsf);
-      if (fclose(outfsf))
-       {
-         fprintf(stderr, "%s: close of %s failed (%s)", whoami,
-                 wkfs, strerror(errno));
-         exit(MR_CCONFIG);
-       }
-      fix_file(outfs);
+      fprintf(stderr, "%s: close of %s failed (%s)", whoami,
+             wkfs, strerror(errno));
+      exit(MR_CCONFIG);
     }
+  fix_file(outfs);
 
-  flag = 0;
-  if (stat(outgrp, &sb) == 0)
+  fprintf(stderr, "%s: building group database...\n", whoami);
+  if (!(outgrpf = fopen(wkgrp, "w")))
     {
-      if (ModDiff (&flag, "list", sb.st_mtime) ||
-         ModDiff (&flag, "users", sb.st_mtime))
-        exit(MR_DATE);
+      fprintf(stderr, "%s: cannot open %s for writing (%s)\n", whoami,
+             wkgrp, strerror(errno));
+      exit(MR_OCONFIG);
     }
-  if (flag < 0)
-    fprintf(stderr, "%s: %s does not need to be rebuilt.\n", whoami, outgrp);
-  else
+  group(outgrpf);
+  if (fclose(outgrpf))
     {
-      fprintf(stderr, "%s: building group database...\n", whoami);
-      if (!(outgrpf = fopen(wkgrp, "w")))
-       {
-         fprintf(stderr, "%s: cannot open %s for writing (%s)\n", whoami,
-                 wkgrp, strerror(errno));
-         exit(MR_OCONFIG);
-       }
-      group(outgrpf);
-      if (fclose(outgrpf))
-       {
-         fprintf(stderr, "%s: close of %s failed (%s)", whoami, wkgrp,
-                 strerror(errno));
-         exit(MR_CCONFIG);
-       }
-      fix_file(outgrp);
+      fprintf(stderr, "%s: close of %s failed (%s)", whoami, wkgrp,
+             strerror(errno));
+      exit(MR_CCONFIG);
     }
-
+  fix_file(outgrp);
+  
   fprintf(stderr, "%s: building tar file...\n", whoami);
   sprintf(cmd, "(cd %s; tar cf - . ) > %s.out", www_dir, www_dir);
   if (system(cmd))
@@ -175,6 +151,7 @@ void filsys(FILE *out)
   EXEC SQL BEGIN DECLARE SECTION;
   char label[FILESYS_LABEL_SIZE], path[FILESYS_NAME_SIZE];
   char type[FILESYS_TYPE_SIZE], key[FSGROUP_KEY_SIZE];
+  char alias[ALIAS_NAME_SIZE];
   int status, fid;
   EXEC SQL END DECLARE SECTION;
 
@@ -196,6 +173,7 @@ void filsys(FILE *out)
 
       if (!strcmp(strtrim(type), "FSGROUP"))
        {
+         *path = '\0';
          EXEC SQL DECLARE group_cursor CURSOR FOR
            SELECT f.name, g.key FROM filesys f, fsgroup g
            WHERE f.filsys_id = g.filsys_id AND f.type='AFS'
@@ -206,9 +184,30 @@ void filsys(FILE *out)
          EXEC SQL CLOSE group_cursor;
        }
 
+      EXEC SQL DECLARE alias_cursor CURSOR FOR
+       SELECT name INTO :alias FROM alias
+       WHERE type='FILESYS' AND trans=:label;
+
       if (!*strtrim(path))
        continue;
+      for (c = label; *c; c++)
+       *c = tolower(*c);
       fprintf(out, "%s:%s\n", label, path);
+
+      EXEC SQL OPEN alias_cursor;
+      while (1)
+       {
+         EXEC SQL FETCH alias_cursor INTO :alias;
+         if (sqlca.sqlcode)
+           break;
+         
+         if (!*strtrim(alias))
+           continue;
+         for (c = alias; *c; c++)
+           *c = tolower(*c);
+         fprintf(out, "%s:%s\n", alias, path);
+       }
+      EXEC SQL CLOSE alias_cursor;
     }
 
   EXEC SQL CLOSE filsys_cursor;
@@ -235,7 +234,8 @@ void group(FILE *out)
   EXEC SQL WHENEVER SQLERROR GOTO sqlerr;
 
   EXEC SQL DECLARE user_cursor CURSOR FOR
-    SELECT login FROM users WHERE status=1 ORDER by login;
+    SELECT login FROM users WHERE status=1 OR status=2 OR status=6 OR status=9
+    ORDER by login;
   EXEC SQL OPEN user_cursor;
 
   while (1)
@@ -244,8 +244,12 @@ void group(FILE *out)
       if (sqlca.sqlcode)
         break;
       strtrim(user);
+      if (!isalpha(*user))
+       continue;
+
       recsize = strlen(user) + 3;
       first = 1;
+      fprintf(out, "%s:xjOhFdLKGK84w:", user);
 
       EXEC SQL DECLARE member_cursor CURSOR FOR
        SELECT DISTINCT l.name from list l, imembers i, users u
@@ -261,8 +265,6 @@ void group(FILE *out)
          if (sqlca.sqlcode)
            break;
          strtrim(list);
-         if (first)
-           fprintf(out, "%s:xjOhFdLKGK84w:", user);
          fprintf(out, "%s%s", first ? "" : ",", list);
          recsize += strlen(list) + 1;
          first = 0;
@@ -276,8 +278,7 @@ void group(FILE *out)
       EXEC SQL CLOSE member_cursor;
       EXEC SQL COMMIT;
 
-      if (!first)
-        fprintf(out, "\n");
+      fprintf(out, "\n");
     }
 
   EXEC SQL CLOSE user_cursor;
This page took 0.036889 seconds and 4 git commands to generate.