4 * 5.80 to 5.90 migration utility for network files
12 #include <sys/types.h>
26 int main(int argc, char **argv)
39 char roomfilename[SIZ];
41 char nodefilename[SIZ];
44 "This utility migrates your network settings (room sharing with other\n"
45 "Citadel systems) from 5.80 to 5.90. You should only do this ONCE. It\n"
46 "will ERASE your 5.80 configuration files when it is finished, and it will\n"
47 "ERASE any 5.90 configuration files that you have already set up.\n\n"
48 "Are you sure you want to do this? ");
51 if (tolower(buf[0]) != 'y') exit(0);
55 attach_to_server(argc, argv, hostbuf, portbuf);
57 printf("%s\n", &buf[4]);
58 if ( (buf[0]!='2') && (strncmp(buf,"551",3)) ) {
59 fprintf(stderr, "%s: %s\n", argv[0], &buf[4]);
63 sprintf(buf, "IPGM %d", config.c_ipgm_secret);
66 fprintf(stderr, "%s\n", &buf[4]);
71 if (chdir("network/systems") != 0) {
72 perror("cannot chdir network/systems");
76 strcpy(roomfilename, tmpnam(NULL));
77 roomfp = fopen(roomfilename, "w");
79 perror("cannot open temp file");
83 strcpy(nodefilename, tmpnam(NULL));
84 nodefp = fopen(nodefilename, "w");
86 perror("cannot open temp file");
92 perror("cannot open directory");
96 while (d = readdir(dp), d != NULL) {
98 if ( (d->d_name[0] != '.') && strcasecmp(d->d_name, "CVS")) {
99 fp = fopen(d->d_name, "r");
102 printf("\n*** Processing '%s'\n", d->d_name);
104 fprintf(nodefp, "%s|", d->d_name);
105 printf("Enter shared secret: ");
107 fprintf(nodefp, "%s|", buf);
108 printf("Enter host name/IP : ");
110 fprintf(nodefp, "%s|", buf);
111 printf("Enter port number : ");
113 fprintf(nodefp, "%s\n", buf);
115 while (fgets(room, sizeof room, fp),
116 fscanf(fp, "%ld\n", &thighest),
118 room[strlen(room) - 1] = 0;
119 fprintf(roomfp, "%s|%s\n",
121 if (thighest > highest) {
133 /* Point of no return */
135 /* Set up the node table */
136 printf("Creating neighbor node table\n");
137 sprintf(buf, "CONF putsys|%s", IGNETCFG);
141 nodefp = fopen(nodefilename, "r");
142 if (nodefp != NULL) {
143 while (fgets(buf, sizeof buf, nodefp) != NULL) {
144 buf[strlen(buf)-1] = 0;
152 printf("%s\n", &buf[4]);
156 /* Now go through the table looking for node names to enter */
158 sprintf(buf, "cat %s |awk '{ FS=\"|\"; print $2 }' |sort -f |uniq -i",
160 roomfp = popen(buf, "r");
161 if (roomfp == NULL) {
162 perror("cannot open pipe");
163 unlink(roomfilename);
166 while (fgets(room, sizeof room, roomfp) != NULL) {
167 room[strlen(room)-1] = 0;
168 if (strlen(room) > 0) {
169 printf("Room <%s>\n", room);
175 unlink(roomfilename);
176 unlink(nodefilename);