- 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;
+ if (!cmdexit) {
+ char *ptr;
+ time_t last_update = time(NULL);
+ while (ptr = fgets(buf, SIZ, sourcefp), (ptr != NULL)) {
+ ptr = strchr(buf, '\n');
+ if (ptr) *ptr = 0; // remove the newline character
+ ++linecount;
+ if (!strncasecmp(buf, "<progress>", 10)) {
+ printf("\033[8;75H\033[33m%d\033[0m\033[20;0H\n", atoi(&buf[10]));
+ }
+ if (time(NULL) != last_update) {
+ last_update = time(NULL);
+ printf("\033[8;29H\033[33m%d\033[0m\033[20;0H\n", linecount);
+ }
+ serv_puts(local_admin_socket, buf);