Ignore:
Timestamp:
Oct 20, 2005, 2:35:15 PM (14 years ago)
Author:
andree
Message:

Various changes to get archiving to NFS work in interactive mode. It
wasn't really like were were bugs, it appeared more like it was simply
not finished.

Side note: I believe that bkpinfo->isodir and bkpinfo->prefix were the
wrong way round in libmondo-archive.c and I've swapped them.

Location:
trunk/mondo/mondo/common
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/mondo/mondo/common/libmondo-archive.c

    r68 r75  
    12171217    paranoid_free(data_disks_file);
    12181218
    1219     asprintf(&command, "rm -f %s/%s-[1-9]*.iso", bkpinfo->prefix,
    1220              bkpinfo->isodir);
     1219    asprintf(&command, "rm -f %s/%s/%s-[1-9]*.iso", bkpinfo->isodir,
     1220                 bkpinfo->nfs_remote_dir, bkpinfo->prefix);
    12211221    paranoid_system(command);
    12221222    paranoid_free(command);
  • trunk/mondo/mondo/common/libmondo-devices.c

    r59 r75  
    260260extern struct s_bkpinfo *g_bkpinfo_DONTUSETHIS;
    261261extern char *g_erase_tmpdir_and_scratchdir;
     262extern char *g_selfmounted_isodir;
    262263
    263264static char g_cdrw_drive_is_here[MAX_STR_LEN / 4] = "";
     
    18201821    char *command;
    18211822    char *comment;
     1823    char *prompt;
    18221824    int i;
    18231825    FILE *fin;
     
    18271829    malloc_string(command);
    18281830    malloc_string(comment);
     1831    malloc_string(prompt);
    18291832    assert(bkpinfo != NULL);
    18301833    sz_size[0] = '\0';
     
    20992102                }
    21002103            }
    2101             sprintf(command, "mount | grep %s | cut -d' ' -f3",
    2102                     bkpinfo->nfs_mount);
     2104            // check whether already mounted - we better remove
     2105                        // surrounding spaces and trailing '/' for this
     2106            strip_spaces (bkpinfo->nfs_mount);
     2107            if (bkpinfo->nfs_mount[strlen(bkpinfo->nfs_mount) - 1] == '/')
     2108              bkpinfo->nfs_mount[strlen(bkpinfo->nfs_mount) - 1] = '\0';
     2109            sprintf(command, "mount | grep \"%s \" | cut -d' ' -f3",
     2110                   bkpinfo->nfs_mount);
    21032111            strcpy(bkpinfo->isodir,
    21042112                   call_program_and_get_last_line_of_output(command));
     
    21142122        }
    21152123        if (!is_this_device_mounted(bkpinfo->nfs_mount)) {
    2116             sprintf(bkpinfo->isodir, "/tmp/isodir");
    2117             run_program_and_log_output("mkdir -p /tmp/isodir", 5);
    2118             sprintf(tmp, "mount %s -t nfs -o nolock /tmp/isodir",
    2119                     bkpinfo->nfs_mount);
    2120             run_program_and_log_output(tmp, 5);
     2124          sprintf(bkpinfo->isodir, "/tmp/isodir.mondo.%d", (int)(random()%32768));
     2125          sprintf(command, "mkdir -p %s", bkpinfo->isodir);
     2126          run_program_and_log_output(command, 5);
     2127          sprintf(tmp, "mount %s -t nfs %s", bkpinfo->nfs_mount, bkpinfo->isodir);
     2128          run_program_and_log_output(tmp, 5);
     2129          malloc_string(g_selfmounted_isodir);
     2130          strcpy(g_selfmounted_isodir, bkpinfo->isodir);
    21212131        }
    21222132        if (!is_this_device_mounted(bkpinfo->nfs_mount)) {
     
    21332143        }
    21342144        strcpy(bkpinfo->nfs_remote_dir, tmp);
     2145        // check whether writable - we better remove surrounding spaces for this
     2146        strip_spaces (bkpinfo->nfs_remote_dir);
     2147        sprintf (command, "echo hi > %s/%s/.dummy.txt", bkpinfo->isodir,
     2148                      bkpinfo->nfs_remote_dir);
     2149        while (run_program_and_log_output (command, FALSE)) {
     2150          strcpy(tmp, bkpinfo->nfs_remote_dir);
     2151          asprintf (&prompt,
     2152                "Directory '%s' under mountpoint '%s' does not exist or is not writable. You can fix this or change the directory and retry or cancel the backup.",
     2153                bkpinfo->nfs_remote_dir, bkpinfo->isodir);
     2154          if(!popup_and_get_string ("Directory", prompt, tmp, MAX_STR_LEN)) {
     2155            log_to_screen("User has chosen not to backup the PC");
     2156            finish(1);
     2157          }
     2158          strcpy(bkpinfo->nfs_remote_dir, tmp);
     2159          // check whether writable - we better remove surrounding spaces for this */
     2160          strip_spaces (bkpinfo->nfs_remote_dir);
     2161          asprintf (&command, "echo hi > %s/%s/.dummy.txt", bkpinfo->isodir,
     2162                        bkpinfo->nfs_remote_dir);
     2163        }
    21352164        for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
    21362165            bkpinfo->media_size[i] = 650;
     
    23472376    paranoid_free(command);
    23482377    paranoid_free(comment);
     2378    paranoid_free(prompt);
    23492379    return (0);
    23502380}
  • trunk/mondo/mondo/common/libmondo-tools.c

    r72 r75  
    712712            }
    713713        }
     714        store_nfs_config (bkpinfo);
    714715    }
    715716
  • trunk/mondo/mondo/common/newt-specific.c

    r59 r75  
    9595    bool g_called_by_xmondo = FALSE;    ///< @bug Unneeded w/current XMondo.
    9696    char *g_erase_tmpdir_and_scratchdir;    ///< The command to run to erase the tmpdir and scratchdir at the end of Mondo.
     97char *g_selfmounted_isodir; ///< Holds the NFS mountpoint if mounted via mondoarchive.
    9798
    9899/* @} - end of globalGroup */
     
    257258            "-------FATAL ERROR---------";
    258259        char *tmp;
     260        char *command;
    259261        static bool already_exiting = FALSE;
    260262        int i;
     
    262264        /*@ end vars **************************************************** */
    263265
     266        malloc_string(command);
    264267        set_signals(FALSE);     // link to external func
    265268        g_exiting = TRUE;
     
    304307        if (g_erase_tmpdir_and_scratchdir[0]) {
    305308            run_program_and_log_output(g_erase_tmpdir_and_scratchdir, 5);
     309        }
     310
     311        if (g_selfmounted_isodir) {
     312          asprintf(&command, "umount %s", g_selfmounted_isodir);
     313          run_program_and_log_output(command, 5);
     314          asprintf(&command, "rmdir %s", g_selfmounted_isodir);
     315          run_program_and_log_output(command, 5);
    306316        }
    307317
     
    359369    void
    360370     finish(int signal) {
    361 
    362         /*  if (signal==0) { popup_and_OK("Please press <enter> to quit."); } */
     371            char *command;
     372            malloc_string(command);
     373       
     374            /*  if (signal==0) { popup_and_OK("Please press <enter> to quit."); } */
    363375
    364376        /* newtPopHelpLine(); */
     
    371383        if (g_erase_tmpdir_and_scratchdir) {
    372384            run_program_and_log_output(g_erase_tmpdir_and_scratchdir, 1);
     385        }
     386        if (g_selfmounted_isodir) {
     387          asprintf(&command, "umount %s", g_selfmounted_isodir);
     388          run_program_and_log_output(command, 1);
     389          asprintf(&command, "rmdir %s", g_selfmounted_isodir);
     390          run_program_and_log_output(command, 1);
    373391        }
    374392//  iamhere("foo");
Note: See TracChangeset for help on using the changeset viewer.