]>
Commit | Line | Data |
---|---|---|
d2543f8c | 1 | /* $Header$ |
2 | * | |
3 | * SMS database consistency checker | |
4 | * | |
5 | * (c) Copyright 1988 by the Massachusetts Institute of Technology. | |
6 | * For copying and distribution information, please see the file | |
7 | * <mit-copyright.h>. | |
8 | */ | |
9 | ||
10 | #include <mit-copyright.h> | |
11 | #include <stdio.h> | |
12 | #include <strings.h> | |
13 | #include <signal.h> | |
14 | #include "dbck.h" | |
15 | ||
16 | ||
17 | int debug = 1; | |
18 | int mode = MODE_ASK; | |
19 | int fast = 0; | |
20 | struct hash *users, *machines, *clusters, *lists, *filesys, *nfsphys, *strings; | |
21 | ##int dcmenable; | |
22 | int cleanup(); | |
23 | ||
24 | ||
25 | main(argc, argv) | |
26 | int argc; | |
27 | char **argv; | |
28 | { | |
29 | char **arg = argv; | |
30 | ## char *database; | |
31 | int ingerr(); | |
32 | int countonly = 0; | |
33 | ||
34 | database = "sms"; | |
35 | ||
36 | while (++arg - argv < argc) { | |
37 | if (**arg == '-') | |
38 | switch ((*arg)[1]) { | |
39 | case 'd': | |
40 | debug = atoi((*arg)[2] ? *arg+2 : *++arg); | |
41 | break; | |
42 | case 'n': | |
43 | mode = MODE_NO; | |
44 | break; | |
45 | case 'y': | |
46 | mode = MODE_YES; | |
47 | break; | |
48 | case 'p': | |
49 | mode = MODE_PREEN; | |
50 | break; | |
51 | case 'a': | |
52 | mode = MODE_ASK; | |
53 | break; | |
54 | case 'c': | |
55 | countonly++; | |
56 | break; | |
57 | case 'f': | |
58 | fast++; | |
59 | break; | |
60 | } | |
61 | else | |
62 | database = *arg; | |
63 | } | |
64 | if (countonly) | |
65 | printf("Only doing counts\n"); | |
66 | else if (fast) | |
67 | printf("Doing fast version (skipping some checks)\n"); | |
68 | if (mode == MODE_NO) | |
69 | printf("Will NOT modify the database\n"); | |
70 | else if (mode == MODE_PREEN) | |
71 | printf("Will fix simple things without asking\n"); | |
72 | else if (mode == MODE_YES) | |
73 | printf("Will fix everything without asking\n"); | |
74 | if (debug) | |
75 | printf("Debug level is %d\n", debug); | |
76 | ||
77 | signal(SIGHUP, cleanup); | |
78 | signal(SIGQUIT, cleanup); | |
79 | signal(SIGINT, cleanup); | |
80 | ||
81 | IIseterr(ingerr); | |
82 | printf("Opening database %s...", database); | |
83 | fflush(stdout); | |
84 | ## ingres database | |
85 | printf("done\n"); | |
86 | ## retrieve (dcmenable = values.value) where values.name = "dcm_enable" | |
87 | dprintf("DCM disabled (was %d)\n", dcmenable); | |
88 | ## replace values (value = 0) where values.name = "dcm_enable" | |
89 | ||
90 | ## begin transaction | |
91 | ||
92 | if (!countonly) { | |
93 | phase1(); | |
94 | phase2(); | |
95 | phase3(); | |
96 | } else { | |
97 | printf("Skipping to counts\n"); | |
98 | count_only_setup(); | |
99 | } | |
100 | phase4(); | |
101 | ||
102 | ## end transaction | |
103 | ## replace values (value = dcmenable) where values.name = "dcm_enable" | |
104 | printf("Done.\n"); | |
105 | ## exit | |
106 | exit(0); | |
107 | } | |
108 | ||
109 | ingerr(num) | |
110 | int *num; | |
111 | { | |
112 | printf("An ingres error occuurred, code %d\n", *num); | |
113 | printf("Aborting...\n"); | |
114 | ## abort | |
115 | exit(1); | |
116 | } | |
117 | ||
118 | ||
119 | int cleanup() | |
120 | ##{ | |
121 | printf("Signal caught, aborting transaction\n"); | |
122 | ## abort | |
123 | ## replace values (value = dcmenable) where values.name = "dcm_enable" | |
124 | ## exit | |
125 | exit(0); | |
126 | ##} |