gt:         while (bootloop == 0) {
context: package gui;
  
  import java.io.*;
  import java.util.Scanner;
  
  public class restore implements Runnable {
  
      meph meph;
      static String finalpart;
      static String message;
  
      public static void setFinalpart(String data) {
          finalpart = data;
      }
  
      public static void setMessage(String data) {
          message = data;
      }
  
      public static String getMessage() {
          return message;
      }
      public static boolean interupt = true;
  
      public static String getFinalpart() {
          return finalpart;
      }
  
      public static void backupdate() {
          MephUtil.writernoappend("/tmp/bdate", "date +%m%d%k%M%Y > /tmp/date");
          MephUtil.shell("bash /tmp/bdate");
      }
  
      public static void restoredate() {
          MephUtil.writernoappend("/tmp/cdate", "date `cat /tmp/date`");
          MephUtil.shell("bash /tmp/cdate");
      }
  
      public static void fsck() {
          Menu.halfmenu();
          MephUtil.messageparser("\nRunning FSCK on root partition....\n\n");
          MephUtil.shell("fsck -y " + Settings.getGentoo_root_part());
      }
  
      public static void formatdevice(String filesystem, String partition, String label,
              String messages) {
          if (filesystem.contains(("swap"))) {
              try {
                  MephUtil.messageparser("\n" + messages);
                  String format = "";
                  String formatstring = ("mkswap " + partition + " -L " + label);
                  Process formatroot = Runtime.getRuntime().exec(formatstring);
                  BufferedReader bformatroot = new BufferedReader(
                          new InputStreamReader(formatroot.getInputStream()));
                  while ((format = bformatroot.readLine()) != null) {
                      MephUtil.messageparser("\n" + format);
                  }
              } catch (IOException asds) {
              }
          } else {
              try {
                  MephUtil.messageparser("\n" + messages);
                  String format = "";
                  String formatstring = ("mkfs." + filesystem + " -I 128 " + partition + " -L " + label);
                  Process formatroot = Runtime.getRuntime().exec(formatstring);
                  BufferedReader bformatroot = new BufferedReader(
                          new InputStreamReader(formatroot.getInputStream()));
                  while ((format = bformatroot.readLine()) != null) {
                      MephUtil.messageparser("\n" + format);
                  }
              } catch (IOException asds) {
              }
          }
      }
  
      public static void tune2fs(String label, String uuid, String part) {
  
          try {
              String rread = null;
              Process setuuid = Runtime.getRuntime().exec(
                      "tune2fs -L " + label + " -U " + uuid + " " + part);
              BufferedReader brrr = new BufferedReader(new InputStreamReader(
                      setuuid.getInputStream()));
              while ((rread = brrr.readLine()) != null) {
                  MephUtil.messageparser("\n" + rread);
              }
          } catch (Exception ads) {
          }
      }
  
      public static void devicefinder(int what) {
          //1 = boot
          //2 = home
          //3 = root
          try {
              int counter = 0;
              String read = null;
              int length = 0;
              int length2 = 0;
              int length3 = 0;
              Process fdisk = Runtime.getRuntime().exec("cat /proc/partitions");
              BufferedReader bfdisk = new BufferedReader(new InputStreamReader(
                      fdisk.getInputStream()));
              while ((read = bfdisk.readLine()) != null) {
                  length = read.length();
                  if (length > 2) {
                      length2 = length - 1;
                      length3 = length2 - 3;
                      if (what == 2) {
                          if (read.substring(length2, length).contains(Settings.getHomepart().substring(8, 9))) {
                              Settings.setGentoo_home("/dev/" + read.substring(length3, length2));
                              Settings.setGentoo_home_part(Settings.getGentoo_home() + read.substring(length2, length));
                              break;
                          }
                      }
                      if (what == 1) {
                          if (read.substring(length2, length).contains(Settings.getBootpart().substring(8, 9))) {
                              Settings.setGentoo_boot("/dev/" + read.substring(length3, length2));
                              Settings.setGentoo_boot_part(Settings.getGentoo_boot() + read.substring(length2, length));
                              break;
                          }
                      }
                      if (what == 3) {
                          if (read.substring(length2, length).contains(Settings.getTar_root_part().substring(8, 9))) {
                              Settings.setGentoo_root("/dev/" + read.substring(length3, length2));
                              Settings.setGentoo_root_part(Settings.getGentoo_root() + read.substring(length2, length));
                              break;
                          }
                      }
                      if (what == 4) {
                          if (read.substring(length2, length).contains(Settings.getTar_swap_part().substring(8, 9))) {
                              Settings.setGentoo_root("/dev/" + read.substring(length3, length2));
                              Settings.setSwapPart(Settings.getGentoo_root() + read.substring(length2, length));
                              break;
                          }
                      }
                  }
              }
          } catch (IOException adsa) {
          }
      }
  
      public static void loaddevices(String cdfile, String data) {
          String curDir = System.getProperty("user.dir");
          Settings.setCDlocation(curDir + "/");
          try {
              FileReader frr = new FileReader(Settings.getLocation() + cdfile);
              BufferedReader bfrr = new BufferedReader(frr);
              String read = null;
              String findstring = null;
              int cdcounter = 1;
              while ((read = bfrr.readLine()) != null) {
  
                  if (data.contains("restoredata")) {
                      Settings.setFindkernel(read);
                  }
                  if (data.contains("location")) {
                      Settings.setCDlocation(read);
                  }
                  if (data.contains("tarinfo")) {
                      Settings.setTarinfo(read);
                  }
                  if (data.contains("raid")) {
                      Settings.setRAID(read);
                  }
                  if (data.contains("rid")) {
                      Settings.setUuid(read);
                  }
                  if (data.contains("homefs")) {
                      Settings.setHomefs(read);
                  }
                  if (data.contains("imagedata")) {
                      Settings.setImage(read);
                  }
                  if (data.contains("filesystem")) {
                      Settings.setFilesystem(read);
                  }
                  if (data.contains("bootfs")) {
                      Settings.setBootfs(read);
                  }
                  if (data.contains("bid")) {
                      Settings.setBuuid(read);
                  }
                  if (data.contains("hid")) {
                      Settings.setHuuid(read);
                  }
                  if (data.contains("homelabel")) {
                      Settings.setHomelabel(read);
                  }
                  if (data.contains("bootlabel")) {
                      Settings.setBootlabel(read);
                  }
                  if (data.contains("rlabel")) {
                      Settings.setRootlabel(read);
                  }
                  if (data.contains("initrd")) {
                      Settings.setInitrd(read);
                  }
                  if (data.contains("bootpart")) {
                      Settings.setBootpart(read);
                  }
                  if (data.contains("spart")) {
                      Settings.setTar_swap_part(read);
                  }
                  if (data.contains("sid")) {
                      Settings.setSwapuuid(read);
                  }
                  if (data.contains("slabel")) {
                      Settings.setSwapLabel(read);
                  }
                  if (data.contains("lvm")) {
                      Settings.setLVM(read);
                  }
                  if (data.contains("getnet")) {
                      Settings.setGetnet(read);
                  }
                  if (data.contains("homepart")) {
                      Settings.setHomepart(read);
                  }
                  if (data.contains("main")) {
                      Settings.setRootpart(read);
                      Settings.setTar_root(read.substring(0, 8));
                      Settings.setTar_root_part(read);
                  }
  
                  if (data.contains("part")) {
                      Settings.setPart(read);
                  }
  
                  if (data.contains("account")) {
                      Settings.setAccount(read);
                  }
              }
              bfrr.close();
          } catch (Exception adas) {
          }
      }
  
      public static void checkmakedev() {
          MephUtil.filechecker("/mephisto/dev/console");
          MephUtil.filechecker("/mephisto/dev/null");
      }
  
      // CREATES /DEV/NULL
      public static void makedev() {
          MephUtil.shell("mknod -m 660 /mephisto/dev/null c 1 3");
          MephUtil.shell("mknod -m 660 /mephisto/dev/console c 5 1");
      }
  
      public static void information() {
          Menu.halfmenu();
          StringBuffer devicelisting = new StringBuffer();
          devicelisting.append("Information regarding your previous system backup that may be useful for the restore process:");
          if (Settings.getBootpart() != null) {
              devicelisting.append("\nBoot Partition: " + Settings.getBootpart());
          }
          if (Settings.getHomepart() != null) {
              devicelisting.append("\nHome Partition: " + Settings.getHomepart());
          }
          if (Settings.getTar_root_part() != null) {
              devicelisting.append("\nRoot Partition: " + Settings.getTar_root_part());
          }
          if (Settings.getTar_swap_part() != null) {
              devicelisting.append("\nSwap Partition: " + Settings.getTar_swap_part());
          }
          Menu.pause(devicelisting.toString());
      }
  
      public static void restore() {
          if (!Settings.getRoot()) {
              Menu.halfmenu();
              Menu.pause("\n\nError: You must be root for this action.");
              return;
          }
  
          if (Settings.getQuickerimagesystem() == 1) {
          } else {
              int proceede = 0;
              Menu.halfmenu();
              Menu.pause("Welcome to the Mephisto Backup Recovery Disk.\n\nThe recovery process will help you do the following:\n1. Format partitions.\n2. Mount partitions.\n3. Extract backup image.\n4. Configure kernel and bootloader.\nMephisto will follow the root partition layout from the existing pc.\n\n Please ensure that this system has the same partition layout or the restore process will fail.\n\n LVM configurations \nwill have to be done manually with the LVM utility.\n\n");
          }
          // CHECKS FOR A FILE ON THE LIVECD TO ENSURE THAT SOMEONE ILL NOT FSCK
          // THEIR SYSTEM UP
          MephUtil.filechecker(Settings.getLocation() + "/main");
          // SETS THE DATE IN THE FUTURE TO RESOLVE TAR FROM HANGING DUE TO DATE
          // ISSUES
  
          File datecheck = new File("/tmp/bdate");
          if (datecheck.exists()) {
          } else {
              backupdate();
          }
          MephUtil.shell("date 122512012020");
          // GATHERS THE ROOT PARTITION DEVICE FROM THE ORIGINAL SYSTEM
  
          // Loads all the device information from the existing installation.
          //below does not work, with or without the loop.
  //Must find a way to read the location!
          for (int run = 0; run != 5; run++) {
              loaddevices("getnet", "getnet");
              loaddevices("main", "main");
              loaddevices("filesystem", "filesystem");
              loaddevices("rootfs", "rootfs");
              loaddevices("rid", "rid");
              loaddevices("bootpart", "bootpart");
              loaddevices("homepart", "homepart");
              loaddevices("hid", "hid");
              loaddevices("imagedata", "imagedata");
              loaddevices("bid", "bid");
              loaddevices("homelabel", "homelabel");
              loaddevices("bootlabel", "bootlabel");
              loaddevices("rlabel", "rlabel");
              loaddevices("bootfs", "bootfs");
              loaddevices("homefs", "homefs");
              loaddevices("restoredata", "restoredata");
              loaddevices("tarinfo", "tarinfo");
              loaddevices("initrd", "initrd");
              loaddevices("raid", "raid");
              loaddevices("part", "part");
              loaddevices("account", "account");
              loaddevices("spart", "spart");
              loaddevices("slabel", "slabel");
              loaddevices("sid", "sid");
              loaddevices("lvm", "lvm");
          }
  
          // RUNS FDISK TO SET AND VERFIY THE ROOT PARTITION ACCORDING TO THE LIVE
          // CD PARTITION LAYOUT
          information();
  
          if (Settings.getTar_root() == null) {
              Menu.halfmenu();
              Menu.pause("Error: Root device is NULL");
              System.exit(-1);
          }
          if (Settings.getTar_root_part() == null) {
              Menu.halfmenu();
              Menu.pause("Error: Root partition is NULL");
  
              System.exit(-1);
          }
  
          if (Settings.getTar_swap_part() != null) {
              devicefinder(4);
              if (Settings.getTar_swap_part().length() > 10) {
                  Settings.setSwapPart(Settings.getTar_swap_part());
              } else {
                  MephUtil.shell("ln -s " + Settings.getSwapPart() + " " + Settings.getTar_swap_part());
              }
          }
  
          devicefinder(3);
  
          if (Settings.getRAID() == null) {
              Settings.setRAID("no");
          }
          if (Settings.getLVM() == null) {
              Settings.setLVM("no");
          }
  
          if (Settings.getRAID().contains("yes")) {
              if (Settings.getTar_root_part().contains("md")) {
                  Settings.setGentoo_root_part(Settings.getTar_root_part());
                  Settings.setGentoo_root(Settings.getTar_root());
              }
          } else if (Settings.getLVM().contains("yes")) {
              if (Settings.getTar_root_part().length() > 10) {
                  Settings.setGentoo_root_part(Settings.getTar_root_part());
                  Settings.setGentoo_root(Settings.getTar_root());
  
              }
          } else {
  
              // LINKING IS DONE HERE.
              //Creates a link from the current root device to the original root device.
              MephUtil.shell(
                      "ln -s " + Settings.getGentoo_root() + " " + Settings.getTar_root());
              MephUtil.shell(
                      "ln -s " + Settings.getGentoo_root_part() + " " + Settings.getTar_root_part());
          }
  
          // IF BOOT WAS DETECTED, CONFIGURATION AND DEVICE
          // LINKING IS DONE HERE.
          int bootloop = 0;
  