4 * 5.80 to 5.90 migration utility for network files
12 #include <sys/types.h>
21 struct mn_roomlist *next;
30 int main(int argc, char **argv)
43 char roomfilename[SIZ];
45 char nodefilename[SIZ];
46 struct mn_roomlist *mn = NULL;
47 struct mn_roomlist *mnptr = NULL;
50 "This utility migrates your network settings (room sharing with other\n"
51 "Citadel systems) from 5.80 to 5.90. You should only do this ONCE. It\n"
52 "will ERASE your 5.80 configuration files when it is finished, and it will\n"
53 "ERASE any 5.90 configuration files that you have already set up.\n\n"
54 "Are you sure you want to do this? ");
57 if (tolower(buf[0]) != 'y') exit(0);
61 attach_to_server(argc, argv, hostbuf, portbuf);
63 printf("%s\n", &buf[4]);
64 if ( (buf[0]!='2') && (strncmp(buf,"551",3)) ) {
65 fprintf(stderr, "%s: %s\n", argv[0], &buf[4]);
69 sprintf(buf, "IPGM %d", config.c_ipgm_secret);
72 fprintf(stderr, "%s\n", &buf[4]);
77 if (chdir("network/systems") != 0) {
78 perror("cannot chdir network/systems");
82 strcpy(roomfilename, tmpnam(NULL));
83 roomfp = fopen(roomfilename, "w");
85 perror("cannot open temp file");
89 strcpy(nodefilename, tmpnam(NULL));
90 nodefp = fopen(nodefilename, "w");
92 perror("cannot open temp file");
98 perror("cannot open directory");
102 while (d = readdir(dp), d != NULL) {
104 if ( (d->d_name[0] != '.') && strcasecmp(d->d_name, "CVS")) {
105 fp = fopen(d->d_name, "r");
108 printf("\n*** Processing '%s'\n", d->d_name);
110 fprintf(nodefp, "%s|", d->d_name);
111 printf("Enter shared secret: ");
113 if (buf[0] == 0) strcpy(buf, config.c_net_password);
114 fprintf(nodefp, "%s|", buf);
115 printf("Enter host name/IP : ");
117 if (buf[0] == 0) sprintf(buf, "%s.citadel.org",
119 fprintf(nodefp, "%s|", buf);
120 printf("Enter port number : ");
122 if (buf[0] == 0) strcpy(buf, "504");
123 fprintf(nodefp, "%s\n", buf);
125 fgets(buf, sizeof buf, fp);
126 printf("skipping: %s", buf);
127 while (fgets(room, sizeof room, fp),
128 (fgets(buf, sizeof buf, fp) != NULL) ) {
129 thighest = atol(buf),
130 room[strlen(room) - 1] = 0;
131 fprintf(roomfp, "%s|%s\n",
133 if (thighest > highest) {
145 /* Point of no return */
147 /* Set up the node table */
148 printf("Creating neighbor node table\n");
149 sprintf(buf, "CONF putsys|%s", IGNETCFG);
153 nodefp = fopen(nodefilename, "r");
154 if (nodefp != NULL) {
155 while (fgets(buf, sizeof buf, nodefp) != NULL) {
156 buf[strlen(buf)-1] = 0;
164 printf("%s\n", &buf[4]);
168 /* Now go through the table looking for node names to enter */
170 sprintf(buf, "cat %s |awk '{ FS=\"|\"; print $2 }' |sort -f |uniq -i",
172 roomfp = popen(buf, "r");
173 if (roomfp == NULL) {
174 perror("cannot open pipe");
175 unlink(roomfilename);
178 while (fgets(room, sizeof room, roomfp) != NULL) {
179 room[strlen(room)-1] = 0;
180 if (strlen(room) > 0) {
181 mnptr = (struct mn_roomlist *)
182 malloc(sizeof (struct mn_roomlist));
183 strcpy(mnptr->roomname, room);
191 /* Enter configurations for each room... */
193 printf("Room <%s>\n", mn->roomname);
195 sprintf(buf, "GOTO %s", mn->roomname);
198 if (buf[0] != '2') goto roomerror;
202 if (buf[0] != '4') goto roomerror;
204 sprintf(buf, "lastsent|%ld", highest);
207 roomfp = fopen(roomfilename, "r");
208 if (roomfp != NULL) {
209 while (fgets(buf, sizeof buf, roomfp) != NULL) {
210 buf[strlen(buf)-1] = 0;
211 extract(node, buf, 0);
212 extract(room, buf, 1);
213 if (!strcasecmp(room, mn->roomname)) {
215 "ignet_push_share|%s", node);
224 roomerror: /* free this record */
230 unlink(roomfilename);
231 unlink(nodefilename);