Compare commits
1 Commits
working-fl
...
cd6100548c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cd6100548c |
6
.gitignore
vendored
6
.gitignore
vendored
@@ -22,9 +22,3 @@
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
replay_pid*
|
||||
|
||||
# IDE Stuff
|
||||
.vscode/*
|
||||
.vscode/
|
||||
*.vscode
|
||||
.vscode
|
||||
@@ -1,38 +0,0 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
public class BlockSize {
|
||||
|
||||
public static String blockSizeString = "";
|
||||
|
||||
static String blockSize(Scanner UserInput) {
|
||||
System.out.println("Choose a block size (Default: 4M)");
|
||||
System.out.println("512KB (1), 1M (2), 2M (3), 4M (4), 8M (5), 16M (6)");
|
||||
String blockSizeInput = UserInput.nextLine();
|
||||
|
||||
switch (blockSizeInput) {
|
||||
case "1":
|
||||
blockSizeString = "512KB";
|
||||
break;
|
||||
case "2":
|
||||
blockSizeString = "1M";
|
||||
break;
|
||||
case "3":
|
||||
blockSizeString = "2M";
|
||||
break;
|
||||
case "4":
|
||||
blockSizeString = "4M";
|
||||
break;
|
||||
case "5":
|
||||
blockSizeString = "8M";
|
||||
break;
|
||||
case "6":
|
||||
blockSizeString = "16M";
|
||||
break;
|
||||
default:
|
||||
blockSizeString = "4M";
|
||||
break;
|
||||
}
|
||||
System.out.println("Using blocksize of: " + blockSizeString);
|
||||
return blockSizeString;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
public class FilePathAdd {
|
||||
|
||||
public static String ImagePath = "";
|
||||
|
||||
protected static String filePath(Scanner UserInput) {
|
||||
System.out.println("Please enter the FULL Path of your ISO / Image. ()");
|
||||
ImagePath = UserInput.nextLine();
|
||||
System.out.println("Using File: " + ImagePath);
|
||||
return ImagePath;
|
||||
}
|
||||
}
|
||||
21
Flasher.java
21
Flasher.java
@@ -1,21 +0,0 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Flasher {
|
||||
public static void flasher(Scanner UserInput) {
|
||||
|
||||
String input = "";
|
||||
|
||||
System.out.println("The programm wil use the following configuration, do you want to flash with this? (y/n)");
|
||||
System.out.println(" - To be flashed device: " + StorageDeviceLister.fullPath);
|
||||
System.out.println(" - To be used path: " + FilePathAdd.ImagePath);
|
||||
System.out.println(" - To bed used blocksize: " + BlockSize.blockSizeString);
|
||||
System.out.println(" - To be used oflag: " + OflagHandler.oflagHandleString);
|
||||
input = UserInput.nextLine();
|
||||
if (YesNo.check(input)) {
|
||||
System.out.println("Flashing...");
|
||||
} else {
|
||||
System.out.println("Canceling...");
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
public class Greeting {
|
||||
public static void greeting() {
|
||||
System.out.println("Welcome to cflash!");
|
||||
System.out.println("Would you like to flash an image (Y/n)");
|
||||
}
|
||||
}
|
||||
24
Main.java
24
Main.java
@@ -1,24 +0,0 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
Scanner UserInput = new Scanner(System.in);
|
||||
|
||||
Greeting.greeting();
|
||||
String input = UserInput.nextLine();
|
||||
|
||||
if (YesNo.check(input)) {
|
||||
System.out.println("Please choose the to be flashed device (f. e. sda)");
|
||||
} else {
|
||||
System.out.println("Canceling...");
|
||||
System.exit(0);
|
||||
}
|
||||
StorageDeviceLister.deviceList(UserInput);
|
||||
FilePathAdd.filePath(UserInput);
|
||||
BlockSize.blockSize(UserInput);
|
||||
OflagHandler.handleOflag(UserInput);
|
||||
Flasher.flasher(UserInput);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
public class OflagHandler {
|
||||
|
||||
public static String oflagHandleString = "";
|
||||
|
||||
static String handleOflag(Scanner UserInput) {
|
||||
System.out.println("Okay, next up please define your oflag (Default: direct)");
|
||||
System.out.println("Available flags: direct (1), dsync (2), sync (3), nocache (4)");
|
||||
String oflagHandleInput = UserInput.nextLine();
|
||||
|
||||
switch (oflagHandleInput) {
|
||||
case "1":
|
||||
oflagHandleString = "direct";
|
||||
break;
|
||||
case "2":
|
||||
oflagHandleString = "dsync";
|
||||
break;
|
||||
case "3":
|
||||
oflagHandleString = "sync";
|
||||
break;
|
||||
case "4":
|
||||
oflagHandleString = "nocache";
|
||||
break;
|
||||
default:
|
||||
oflagHandleString = "direct";
|
||||
break;
|
||||
}
|
||||
System.out.println("Using oflag: " + oflagHandleString);
|
||||
return oflagHandleString;
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ Java program using `dd` to make flashing iso and image files easier on the termi
|
||||
3. You will be prompted to choose a byte size (default: 4M)
|
||||
4. You will be prompted to enter your oflag (default: direct)
|
||||
5. You will be asked if you are absolutely sure that you want to continue (flashing will wipe all data)
|
||||
- Alternative: using `cflash [device] [iso-path] [block-size] [oflag]` will skip the first question and instantly ask you, if you're absolutely sure you want to continue.
|
||||
- Alternative: using `cflash [device] [iso-path] [block-size] [oflag]` will skip the questions and instantly ask you, if you're absolutely sure you want to continue.
|
||||
- Once confirmed, the flash will start and a small progress bar will appear showing the flashing progress.
|
||||
- After completion, the program will detect the OS from the iso and wish you a great time with your new OS. (Example: "Done! Have fun with your new Linux installation!)
|
||||
- **IMPORTANT**: Since dd needs sudo rights, ensure you have root priviliges.
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class StorageDeviceLister {
|
||||
|
||||
public static String device = "";
|
||||
public static String fullPath = "";
|
||||
|
||||
protected static String deviceList(Scanner UserInput) {
|
||||
|
||||
try {
|
||||
ProcessBuilder pb = new ProcessBuilder("lsblk");
|
||||
Process process = pb.start();
|
||||
|
||||
BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(process.getInputStream())
|
||||
);
|
||||
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
System.out.println(line);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String device = UserInput.nextLine();
|
||||
System.out.println("Using device: " + "/dev/" + device);
|
||||
fullPath = "/dev/" + device;
|
||||
return fullPath;
|
||||
}
|
||||
}
|
||||
16
YesNo.java
16
YesNo.java
@@ -1,16 +0,0 @@
|
||||
public class YesNo {
|
||||
public static boolean check(String input) {
|
||||
switch (input) {
|
||||
case "Y":
|
||||
return true;
|
||||
case "y":
|
||||
return true;
|
||||
case "":
|
||||
return true;
|
||||
case "n":
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user