+ snprintf(cmd, sizeof cmd, "ssh -S %s %s@%s %s MIGR listdirs",
+ socket_path, remote_user, remote_host, remote_sendcommand);
+ sourcefp = popen(cmd, "r");
+ if (!sourcefp) {
+ printf("\n%s\n\n", strerror(errno));
+ exitcode = 2;
+ goto THEEND;
+ }
+ while ((fgets(buf, sizeof buf, sourcefp)) && (strcmp(buf, "000"))) {
+ buf[strlen(buf)-1] = 0;
+
+ if (!strncasecmp(buf, "bio|", 4)) {
+ snprintf(cmd, sizeof cmd, "rsync -va --rsh='ssh -S %s' %s@%s:%s/ %s/",
+ socket_path, remote_user, remote_host, &buf[4], ctdl_bio_dir);
+ }
+ else if (!strncasecmp(buf, "files|", 6)) {
+ snprintf(cmd, sizeof cmd, "rsync -va --rsh='ssh -S %s' %s@%s:%s/ %s/",
+ socket_path, remote_user, remote_host, &buf[6], ctdl_file_dir);
+ }
+ else if (!strncasecmp(buf, "userpics|", 9)) {
+ snprintf(cmd, sizeof cmd, "rsync -va --rsh='ssh -S %s' %s@%s:%s/ %s/",
+ socket_path, remote_user, remote_host, &buf[9], ctdl_usrpic_dir);
+ }
+ else if (!strncasecmp(buf, "messages|", 9)) {
+ snprintf(cmd, sizeof cmd, "rsync -va --rsh='ssh -S %s' %s@%s:%s/ %s/",
+ socket_path, remote_user, remote_host, &buf[9], ctdl_message_dir);
+ }
+ else if (!strncasecmp(buf, "netconfigs|", 11)) {
+ snprintf(cmd, sizeof cmd, "rsync -va --rsh='ssh -S %s' %s@%s:%s/ %s/",
+ socket_path, remote_user, remote_host, &buf[11], ctdl_netcfg_dir);
+ }
+ else if (!strncasecmp(buf, "keys|", 5)) {
+ snprintf(cmd, sizeof cmd, "rsync -va --rsh='ssh -S %s' %s@%s:%s/ %s/",
+ socket_path, remote_user, remote_host, &buf[5], ctdl_key_dir);
+ }
+ else if (!strncasecmp(buf, "images|", 7)) {
+ snprintf(cmd, sizeof cmd, "rsync -va --rsh='ssh -S %s' %s@%s:%s/ %s/",
+ socket_path, remote_user, remote_host, &buf[7], ctdl_image_dir);
+ }
+ else if (!strncasecmp(buf, "info|", 5)) {
+ snprintf(cmd, sizeof cmd, "rsync -va --rsh='ssh -S %s' %s@%s:%s/ %s/",
+ socket_path, remote_user, remote_host, &buf[5], ctdl_info_dir);
+ }
+ else {
+ strcpy(cmd, "false"); /* cheap and sleazy way to throw an error */
+ }
+ printf("%s\n", cmd);
+ cmdexit = system(cmd);
+ if (cmdexit != 0) {
+ exitcode += cmdexit;
+ }
+ }
+ pclose(sourcefp);
+
+THEEND: if (exitcode == 0) {
+ printf("\n\n *** Citadel migration was successful! *** \n\n");
+ }
+ else {
+ printf("\n\n *** Citadel migration was unsuccessful. *** \n\n");
+ }
+ printf("\nShutting down the socket connection...\n\n");
+ snprintf(cmd, sizeof cmd, "ssh -S %s -N -O exit %s@%s",
+ socket_path, remote_user, remote_host);
+ cmdexit = system(cmd);
+ printf("\n");
+ if (cmdexit != 0) {
+ printf("There was an error shutting down the socket.\n\n");
+ exitcode = cmdexit;
+ }
+
+ unlink(socket_path);
+ exit(exitcode);