Windows functionality! with sshfs-win
This commit is contained in:
parent
1e164d8239
commit
af7739ed60
7 changed files with 133 additions and 15 deletions
10
.idea/codeStyles/Project.xml
Normal file
10
.idea/codeStyles/Project.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<JetCodeStyleSettings>
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</JetCodeStyleSettings>
|
||||
<codeStyleSettings language="kotlin">
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
5
.idea/codeStyles/codeStyleConfig.xml
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
</state>
|
||||
</component>
|
|
@ -5,7 +5,7 @@
|
|||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleHome" value="" />
|
||||
<option name="gradleJvm" value="temurin-19" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
|
|
|
@ -7,8 +7,8 @@ Built in Kotlin, and utilizes [Jexer](https://git.ouroboros.group/limepotato/jex
|
|||
|
||||
## Installation Instructions:
|
||||
### Linux:
|
||||
1. install `sshpass` && `sshfs` (TODO://Automated script? annoying)
|
||||
1. install `openssh-askpass` && `sshfs`
|
||||
2. download and run and enjoy wowzises
|
||||
### Windows:
|
||||
1. install [sshfs-win](https://github.com/winfsp/sshfs-win) && [this?](https://github.com/PowerShell/Win32-OpenSSH/issues/1943)
|
||||
1. install [sshfs-win](https://github.com/winfsp/sshfs-win)
|
||||
2. run and enjoy wowwoww
|
|
@ -26,6 +26,14 @@ fun getOS(): OS? {
|
|||
}
|
||||
}
|
||||
|
||||
val osName =
|
||||
when (getOS())
|
||||
{
|
||||
OS.WINDOWS -> "WINDOWS"
|
||||
OS.MAC -> "MAC"
|
||||
OS.LINUX -> "LINUX"
|
||||
else -> throw Exception("Operating System could not be detected!")
|
||||
}
|
||||
|
||||
// Set Jexer backend type
|
||||
// Possible answers: SWING, XTERM, ECMA48
|
||||
|
@ -46,6 +54,5 @@ val backendType =
|
|||
class Application : TApplication(backendType, 80, 40, 18) {
|
||||
init {
|
||||
WelcomeWindow(this)
|
||||
|
||||
}
|
||||
}
|
|
@ -1,9 +1,43 @@
|
|||
package org.bm00.DataAccessor.windows
|
||||
|
||||
import jexer.*
|
||||
import jexer.TWindow.CENTERED
|
||||
import jexer.TAction
|
||||
import jexer.TApplication
|
||||
import jexer.TWindow
|
||||
import jexer.layout.StretchLayoutManager
|
||||
import java.awt.SystemColor.text
|
||||
import org.bm00.DataAccessor.osName
|
||||
import java.util.*
|
||||
|
||||
|
||||
enum class OS {
|
||||
WINDOWS, LINUX, MAC
|
||||
}
|
||||
|
||||
fun getOS(): OS? {
|
||||
val isJexer = System.getProperty("jexer.Swing")
|
||||
val os = System.getProperty("os.name").lowercase(Locale.getDefault())
|
||||
return when {
|
||||
os.contains("win") -> {
|
||||
OS.WINDOWS
|
||||
}
|
||||
os.contains("nix") || os.contains("nux") || os.contains("aix") -> {
|
||||
OS.LINUX
|
||||
}
|
||||
os.contains("mac") -> {
|
||||
OS.MAC
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
val osName =
|
||||
when (getOS())
|
||||
{
|
||||
OS.WINDOWS -> "WINDOWS"
|
||||
OS.MAC -> "MAC"
|
||||
OS.LINUX -> "LINUX"
|
||||
else -> throw Exception("Operating System could not be detected!")
|
||||
}
|
||||
|
||||
|
||||
class LoginWindow private constructor(parent: TApplication, flags: Int) :
|
||||
TWindow(parent, "Login", 0, 0, 36, 19, flags) {
|
||||
|
@ -13,7 +47,15 @@ class LoginWindow private constructor(parent: TApplication, flags: Int) :
|
|||
// enterAction - function to call when enter key is pressed
|
||||
object : TAction() {
|
||||
override fun DO() {
|
||||
loginActivity()
|
||||
if (osName == "LINUX") {
|
||||
loginActivityLinux()
|
||||
}
|
||||
else if (osName == "WINDOWS") {
|
||||
loginActivityWindows()
|
||||
}
|
||||
else {
|
||||
TODO()
|
||||
}
|
||||
}
|
||||
},
|
||||
// updateAction - function to call when the text is updated
|
||||
|
@ -28,7 +70,15 @@ class LoginWindow private constructor(parent: TApplication, flags: Int) :
|
|||
// enterAction - function to call when enter key is pressed
|
||||
object : TAction() {
|
||||
override fun DO() {
|
||||
loginActivity()
|
||||
if (osName == "LINUX") {
|
||||
loginActivityLinux()
|
||||
}
|
||||
else if (osName == "WINDOWS") {
|
||||
loginActivityWindows()
|
||||
}
|
||||
else {
|
||||
TODO()
|
||||
}
|
||||
}
|
||||
},
|
||||
// updateAction - function to call when the text is updated
|
||||
|
@ -39,11 +89,9 @@ class LoginWindow private constructor(parent: TApplication, flags: Int) :
|
|||
}
|
||||
);
|
||||
|
||||
fun loginActivity() {
|
||||
fun loginActivityLinux() {
|
||||
var usernameDetail = loginField.text
|
||||
var serverDetail = serverField.text
|
||||
//TODO: https://github.com/winfsp/sshfs-win for sshfs?
|
||||
// and https://microsoft.github.io/Git-Credential-Manager-for-Windows/Docs/Askpass.html for askpass????
|
||||
//openssh-askpass as well
|
||||
val createMntPnt =
|
||||
ProcessBuilder("mkdir", "/tmp/osda_mount")
|
||||
|
@ -62,6 +110,34 @@ class LoginWindow private constructor(parent: TApplication, flags: Int) :
|
|||
.start()
|
||||
.waitFor()
|
||||
}
|
||||
|
||||
fun loginActivityWindows() {
|
||||
var usernameDetail = loginField.text
|
||||
var serverDetail = serverField.text
|
||||
var passwordBox = inputBox("Password", "Please enter your remote password")
|
||||
var passwordDetail = passwordBox.text
|
||||
//TODO: https://github.com/winfsp/sshfs-win for sshfs?
|
||||
// and https://github.com/git-ecosystem/git-credential-manager/ for askpass????
|
||||
// `net use X: \\sshfs\username@servername`
|
||||
val remoteMount =
|
||||
ProcessBuilder(
|
||||
"net",
|
||||
"use",
|
||||
"O:",
|
||||
"\\\\sshfs\\$usernameDetail@$serverDetail",
|
||||
"$passwordDetail"
|
||||
/*
|
||||
"net",
|
||||
"use",
|
||||
"X:",
|
||||
"\\\\sshfs\\$usernameDetail@$serverDetail:/home/$usernameDetail"*/
|
||||
)
|
||||
.redirectOutput(ProcessBuilder.Redirect.INHERIT)
|
||||
.redirectError(ProcessBuilder.Redirect.INHERIT)
|
||||
.start()
|
||||
.waitFor()
|
||||
}
|
||||
|
||||
init {
|
||||
setLayoutManager(
|
||||
StretchLayoutManager(
|
||||
|
@ -75,7 +151,15 @@ class LoginWindow private constructor(parent: TApplication, flags: Int) :
|
|||
addButton("Login", CENTERED + 9, CENTERED + 8,
|
||||
object : TAction() {
|
||||
override fun DO() {
|
||||
loginActivity()
|
||||
if (osName == "LINUX") {
|
||||
loginActivityLinux()
|
||||
}
|
||||
else if (osName == "WINDOWS") {
|
||||
loginActivityWindows()
|
||||
}
|
||||
else {
|
||||
TODO()
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
|
@ -29,13 +29,25 @@ class WelcomeWindow private constructor(parent: TApplication, flags: Int) :
|
|||
addButton("Exit...", CENTERED + 28, CENTERED,
|
||||
object : TAction() {
|
||||
override fun DO() {
|
||||
val unmount =
|
||||
if (org.bm00.DataAccessor.osName == "LINUX") {
|
||||
ProcessBuilder("umount", "/tmp/osda_mount")
|
||||
.redirectOutput(ProcessBuilder.Redirect.INHERIT)
|
||||
.redirectError(ProcessBuilder.Redirect.INHERIT)
|
||||
.start()
|
||||
.waitFor()
|
||||
System.exit(0)
|
||||
System.exit(0)
|
||||
}
|
||||
else if (org.bm00.DataAccessor.osName == "WINDOWS") {
|
||||
ProcessBuilder("net", "use", "O:", "/delete")
|
||||
.redirectOutput(ProcessBuilder.Redirect.INHERIT)
|
||||
.redirectError(ProcessBuilder.Redirect.INHERIT)
|
||||
.start()
|
||||
.waitFor()
|
||||
System.exit(0)
|
||||
}
|
||||
else {
|
||||
System.exit(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue