4 * 5.80 to 5.90 migration utility for network files
12 #include <sys/types.h>
24 struct mn_roomlist *next;
33 int main(int argc, char **argv)
46 char roomfilename[SIZ];
48 char nodefilename[SIZ];
49 struct mn_roomlist *mn = NULL;
50 struct mn_roomlist *mnptr = NULL;
53 "This utility migrates your network settings (room sharing with other\n"
54 "Citadel systems) from 5.80 to 5.90. You should only do this ONCE. It\n"
55 "will ERASE your 5.80 configuration files when it is finished, and it will\n"
56 "ERASE any 5.90 configuration files that you have already set up.\n\n"
57 "Are you sure you want to do this? ");
60 if (tolower(buf[0]) != 'y') exit(0);
64 attach_to_server(argc, argv, hostbuf, portbuf);
66 printf("%s\n", &buf[4]);
67 if ( (buf[0]!='2') && (strncmp(buf,"551",3)) ) {
68 fprintf(stderr, "%s: %s\n", argv[0], &buf[4]);
72 sprintf(buf, "IPGM %d", config.c_ipgm_secret);
75 fprintf(stderr, "%s\n", &buf[4]);
80 if (chdir("network/systems") != 0) {
81 perror("cannot chdir network/systems");
85 strcpy(roomfilename, tmpnam(NULL));
86 roomfp = fopen(roomfilename, "w");
88 perror("cannot open temp file");
92 strcpy(nodefilename, tmpnam(NULL));
93 nodefp = fopen(nodefilename, "w");
95 perror("cannot open temp file");
101 perror("cannot open directory");
105 while (d = readdir(dp), d != NULL) {
107 if ( (d->d_name[0] != '.') && strcasecmp(d->d_name, "CVS")) {
108 fp = fopen(d->d_name, "r");
111 printf("\n*** Processing '%s'\n", d->d_name);
113 fprintf(nodefp, "%s|", d->d_name);
114 printf("Enter shared secret: ");
116 if (buf[0] == 0) strcpy(buf, config.c_net_password);
117 fprintf(nodefp, "%s|", buf);
118 printf("Enter host name/IP : ");
120 if (buf[0] == 0) sprintf(buf, "%s.citadel.org",
122 fprintf(nodefp, "%s|", buf);
123 printf("Enter port number : ");
125 if (buf[0] == 0) strcpy(buf, "504");
126 fprintf(nodefp, "%s\n", buf);
128 fgets(buf, sizeof buf, fp);
129 printf("skipping: %s", buf);
130 while (fgets(room, sizeof room, fp),
131 (fgets(buf, sizeof buf, fp) != NULL) ) {
132 thighest = atol(buf),
133 room[strlen(room) - 1] = 0;
134 fprintf(roomfp, "%s|%s\n",
136 if (thighest > highest) {
148 /* Point of no return */
150 /* Set up the node table */
151 printf("Creating neighbor node table\n");
152 sprintf(buf, "CONF putsys|%s", IGNETCFG);
156 nodefp = fopen(nodefilename, "r");
157 if (nodefp != NULL) {
158 while (fgets(buf, sizeof buf, nodefp) != NULL) {
159 buf[strlen(buf)-1] = 0;
167 printf("%s\n", &buf[4]);
171 /* Now go through the table looking for node names to enter */
173 sprintf(buf, "cat %s |awk -F \"|\" '{ print $2 }' |sort -f |uniq -i",
175 roomfp = popen(buf, "r");
176 if (roomfp == NULL) {
177 perror("cannot open pipe");
178 unlink(roomfilename);
181 while (fgets(room, sizeof room, roomfp) != NULL) {
182 room[strlen(room)-1] = 0;
183 if (strlen(room) > 0) {
184 mnptr = (struct mn_roomlist *)
185 malloc(sizeof (struct mn_roomlist));
186 strcpy(mnptr->roomname, room);
194 /* Enter configurations for each room... */
196 printf("Room <%s>\n", mn->roomname);
198 sprintf(buf, "GOTO %s", mn->roomname);
201 printf("%s\n", &buf[4]);
202 if (buf[0] != '2') goto roomerror;
206 if (buf[0] != '4') goto roomerror;
208 sprintf(buf, "lastsent|%ld", highest);
211 roomfp = fopen(roomfilename, "r");
212 if (roomfp != NULL) {
213 while (fgets(buf, sizeof buf, roomfp) != NULL) {
214 buf[strlen(buf)-1] = 0;
215 extract(node, buf, 0);
216 extract(room, buf, 1);
217 if (!strcasecmp(room, mn->roomname)) {
219 "ignet_push_share|%s", node);
228 roomerror: /* free this record */
234 unlink(roomfilename);
235 unlink(nodefilename);
238 "If this conversion was successful, you do not need your\n"
239 "old network configuration files. Delete them now? "
243 if (tolower(buf[0]) != 'y') exit(0);
246 system("rm -fr ./network/systems");
247 system("rm -f ./network/mail.sysinfo");
248 system("rm -f ./network/internetmail.config");