Allow user to set remote directory

This commit is contained in:
nelle 2024-02-19 01:31:27 -07:00
parent 374b2d1c6d
commit 190050915e
2 changed files with 20 additions and 9 deletions

View file

@ -91,8 +91,19 @@ class LoginWindow private constructor(parent: TApplication, flags: Int) :
//Called if on Linux and the login has been initiated //Called if on Linux and the login has been initiated
fun loginActivityLinux() { fun loginActivityLinux() {
var usernameDetail = loginField.text val usernameDetail = loginField.text
var serverDetail = serverField.text val serverDetail = serverField.text
val remoteDir = inputBox("Remote Directory", "What directory on the server would you like to mount?")
val remoteDirDetail = remoteDir.text
/* Have to figure out a way to unmount this.
val localDir = if (remoteDir.isOk) {
inputBox("Local Directory", "What directory on the local machine would you like to mount to?")
}
else {
return
}
val localDirDetail = localDir.text
*/
// Create directory using bash // Create directory using bash
ProcessBuilder("mkdir", "/tmp/kotRemote_mount") ProcessBuilder("mkdir", "/tmp/kotRemote_mount")
.redirectOutput(ProcessBuilder.Redirect.INHERIT) .redirectOutput(ProcessBuilder.Redirect.INHERIT)
@ -102,7 +113,7 @@ class LoginWindow private constructor(parent: TApplication, flags: Int) :
// mount remote directory via sshfs // mount remote directory via sshfs
ProcessBuilder( ProcessBuilder(
"sshfs", "sshfs",
"$usernameDetail@$serverDetail:/home/$usernameDetail", "$usernameDetail@$serverDetail:$remoteDirDetail",
"/tmp/kotRemote_mount" "/tmp/kotRemote_mount"
) )
.redirectOutput(ProcessBuilder.Redirect.INHERIT) .redirectOutput(ProcessBuilder.Redirect.INHERIT)
@ -113,18 +124,18 @@ class LoginWindow private constructor(parent: TApplication, flags: Int) :
//Called if on Windows and the login has been initiated //Called if on Windows and the login has been initiated
fun loginActivityWindows() { fun loginActivityWindows() {
var usernameDetail = loginField.text val usernameDetail = loginField.text
var serverDetail = serverField.text val serverDetail = serverField.text
// Due to the way sshfs-win works, we will additionally ask the user for a password // Due to the way sshfs-win works, we will additionally ask the user for a password
var passwordBox = inputBox("Password", "Please enter your remote password") val passwordBox = inputBox("Password", "Please enter your remote password")
var passwordDetail = passwordBox.text val passwordDetail = passwordBox.text
// use the windows network mount command to mount via sshfs-win // use the windows network mount command to mount via sshfs-win
ProcessBuilder( ProcessBuilder(
"net", "net",
"use", "use",
"O:", "O:",
"\\\\sshfs\\$usernameDetail@$serverDetail:/home/$usernameDetail", "\\\\sshfs\\$usernameDetail@$serverDetail:/home/$usernameDetail",
"$passwordDetail" passwordDetail
) )
.redirectOutput(ProcessBuilder.Redirect.INHERIT) .redirectOutput(ProcessBuilder.Redirect.INHERIT)
.redirectError(ProcessBuilder.Redirect.INHERIT) .redirectError(ProcessBuilder.Redirect.INHERIT)

View file

@ -22,7 +22,7 @@ class WelcomeWindow private constructor(parent: TApplication, flags: Int) :
) )
// Close program, after detecting OS and unmounting the filesystem if necessary. // Close program, after detecting OS and unmounting the filesystem if necessary.
addButton("Exit...", CENTERED + 28, CENTERED - 2, val exitButton = addButton("Exit...", CENTERED + 28, CENTERED - 2,
object : TAction() { object : TAction() {
override fun DO() { override fun DO() {
if (xyz.limepot.kotRemote.osName == "LINUX") { if (xyz.limepot.kotRemote.osName == "LINUX") {