]> andersk Git - moira.git/blobdiff - gen/dhcp.pc
Command line printer manipulation client, and build goo.
[moira.git] / gen / dhcp.pc
index 2250a2eeb10bdbdcbc3496fac59b7685727783f6..19de4a3a69fead07ea0d0e107cdaba363d48a09d 100644 (file)
@@ -62,14 +62,24 @@ int main(int argc, char **argv)
 
   EXEC SQL WHENEVER SQLERROR DO sqlerr();
 
+  if (argc != 2)
+    {
+      fprintf(stderr, "usage: %s [outfile]\n", argv[0]);
+      exit(MR_ARGS);
+    }
+
   /* Get print spoolers for allow lists. */
-  EXEC SQL SELECT COUNT(service) INTO :alcount FROM serverhosts
-    WHERE service = 'PRINT';
+  EXEC SQL SELECT COUNT(service) INTO :alcount FROM serverhosts sh, machine m
+    WHERE (sh.service = 'PRINT' OR sh.service = 'CUPS-PRINT') 
+    AND sh.mach_id = m.mach_id 
+    AND m.status = 1 AND m.address != 'unassigned';
   allowlist = malloc(alcount * sizeof(*allowlist));
 
   EXEC SQL DECLARE csr_spool CURSOR FOR
     SELECT m.address, sh.value3 FROM machine m, serverhosts sh
-    WHERE m.mach_id = sh.mach_id AND sh.service = 'PRINT';
+    WHERE m.mach_id = sh.mach_id AND 
+    (sh.service = 'PRINT' OR sh.service = 'CUPS-PRINT')
+    AND m.status = 1 AND m.address != 'unassigned';
   EXEC SQL OPEN csr_spool;
   for (i = 0; i < alcount; i++)
     {
@@ -82,8 +92,7 @@ int main(int argc, char **argv)
   EXEC SQL CLOSE csr_spool;
 
   /* Now build the tar file. */
-  sprintf(filename, "%s/dhcp.out", DCM_DIR);
-  tf = tarfile_open(filename);
+  tf = tarfile_open(argv[1]);
 
   /* Build dhcpd.conf.print */
 
@@ -96,7 +105,6 @@ int main(int argc, char **argv)
     FROM printers pr, machine m, machine m2
     WHERE pr.type != 'ALIAS' AND pr.mach_id != 0
     AND pr.mach_id = m.mach_id AND pr.loghost = m2.mach_id
-    AND m.status = 1 AND m.address != 'unassigned'
     ORDER BY m.hwaddr;
   EXEC SQL OPEN csr_boot;
   while (1)
This page took 0.032633 seconds and 4 git commands to generate.