mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-12-06 00:32:35 -08:00
Moved updater to its own package, made everything less bad, added ktor for querying versions
This commit is contained in:
1 parent
a1205d398a
commit
971dd2c43f
9 files changed
+321
-244
No files matched your search
@@ -18,3 +18,4 @@ spotlessVersion=8.0.0
|
||||
shadowJarVersion=8.3.2
|
||||
buildconfigVersion=5.5.0
|
||||
grgitVersion=5.2.2
|
||||
ktor_version=3.0.3
|
||||
@@ -54,6 +54,8 @@ allprojects {
|
||||
}
|
||||
}
|
||||
|
||||
val ktor_version: String by project
|
||||
|
||||
dependencies {
|
||||
implementation(project(":server:core"))
|
||||
implementation(project(":solarxr-protocol"))
|
||||
@@ -67,6 +69,8 @@ dependencies {
|
||||
exclude(group = "com.fazecast", module = "android")
|
||||
}
|
||||
implementation("org.hid4java:hid4java:0.8.0")
|
||||
implementation("io.ktor:ktor-client-core:${ktor_version}")
|
||||
implementation("io.ktor:ktor-client-cio:${ktor_version}")
|
||||
}
|
||||
|
||||
tasks.shadowJar {
|
||||
|
||||
@@ -15,6 +15,7 @@ import dev.slimevr.desktop.platform.linux.UnixSocketRpcBridge
|
||||
import dev.slimevr.desktop.platform.windows.WindowsNamedPipeBridge
|
||||
import dev.slimevr.desktop.serial.DesktopSerialHandler
|
||||
import dev.slimevr.desktop.tracking.trackers.hid.DesktopHIDManager
|
||||
import dev.slimevr.desktop.updater.Updater
|
||||
import dev.slimevr.tracking.trackers.Tracker
|
||||
import io.eiren.util.OperatingSystem
|
||||
import io.eiren.util.collections.FastList
|
||||
@@ -47,11 +48,6 @@ fun main(args: Array<String>) {
|
||||
System.setProperty("awt.useSystemAAFontSettings", "on")
|
||||
System.setProperty("swing.aatext", "true")
|
||||
|
||||
//Check if first boot
|
||||
// Run install if first boot
|
||||
val updater = Updater()
|
||||
updater.runUpdater()
|
||||
|
||||
|
||||
val parser: CommandLineParser = DefaultParser()
|
||||
val formatter = HelpFormatter()
|
||||
|
||||
@@ -1,239 +0,0 @@
|
||||
package dev.slimevr.desktop
|
||||
|
||||
|
||||
import java.io.BufferedInputStream
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.FileOutputStream
|
||||
import java.io.IOException
|
||||
import java.net.URL
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Paths
|
||||
import java.nio.file.StandardCopyOption
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipInputStream
|
||||
|
||||
|
||||
|
||||
class Updater {
|
||||
|
||||
val os = System.getProperty("os.name").lowercase()
|
||||
|
||||
fun runUpdater() {
|
||||
if (os.contains("linux")) {
|
||||
println("Running linux updater")
|
||||
updateLinux()
|
||||
}
|
||||
else if (os.contains("windows")) {
|
||||
println("Running windows updater")
|
||||
updateWindows()
|
||||
}
|
||||
else if (os.contains("darwin")) {
|
||||
println("I dunno")
|
||||
}
|
||||
else {
|
||||
println("guess I'll die")
|
||||
}
|
||||
println("Done Updating")
|
||||
}
|
||||
|
||||
fun executeShellCommand(vararg command: String): String {
|
||||
return try {
|
||||
val process = ProcessBuilder(*command)
|
||||
.redirectErrorStream(true)
|
||||
.start()
|
||||
process.inputStream.bufferedReader().readText().also {
|
||||
process.waitFor()
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
"Error executing shell command: ${e.message}"
|
||||
}
|
||||
}
|
||||
|
||||
fun downloadFile(url: URL, filename: String) {
|
||||
println("Downloading $filename from $url")
|
||||
try {
|
||||
val bufferedInputStream = BufferedInputStream(url.openStream())
|
||||
val fileOutputStream = FileOutputStream(WINDOWSSTEAMVRDRIVERNAME)
|
||||
val dataBuffer = ByteArray(1024)
|
||||
var bytesRead = bufferedInputStream.read(dataBuffer, 0, 1024)
|
||||
while (bytesRead != -1) {
|
||||
fileOutputStream.write(dataBuffer, 0, bytesRead)
|
||||
bytesRead = bufferedInputStream.read(dataBuffer, 0, 1024)
|
||||
}
|
||||
val inputStream = url.openStream()
|
||||
Files.copy(inputStream, Paths.get(filename), StandardCopyOption.REPLACE_EXISTING)
|
||||
} catch ( e: IOException) {
|
||||
println("Error downloading file, ${e.message}")
|
||||
}
|
||||
}
|
||||
//Guard against zip slip
|
||||
fun newFile(destinationPath: File, zipEntry: ZipEntry): File {
|
||||
val destFile = File(destinationPath, zipEntry.name)
|
||||
|
||||
val destinationDirPath = destinationPath.getCanonicalPath()
|
||||
val destinationFilePath = destFile.getCanonicalPath()
|
||||
|
||||
if (!destinationFilePath.startsWith(destinationDirPath + File.separator)) {
|
||||
throw IOException("Entry is outside of the target dir: ${zipEntry.name}")
|
||||
}
|
||||
|
||||
return destFile
|
||||
}
|
||||
|
||||
fun unzip(file: String, destDir: String) {
|
||||
try {
|
||||
val zipFile = File(destDir)
|
||||
val dataBuffer = ByteArray(1024)
|
||||
val zis = ZipInputStream(FileInputStream(file))
|
||||
var zipEntry = zis.nextEntry
|
||||
|
||||
while (zipEntry != null) {
|
||||
val file = newFile(zipFile, zipEntry)
|
||||
if (zipEntry.isDirectory) {
|
||||
if (!file.isDirectory && !file.mkdirs()) {
|
||||
throw IOException("Failed to create directory: $file")
|
||||
} else {
|
||||
val parent = file.parentFile
|
||||
if (!parent.isDirectory && !parent.mkdirs()) {
|
||||
throw IOException("Failed to create directory: $parent")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
val fileOutputStream = FileOutputStream(file)
|
||||
var len = zis.read(dataBuffer, 0, 1024)
|
||||
while (len > 0) {
|
||||
fileOutputStream.write(dataBuffer, 0, len)
|
||||
len = zis.read(dataBuffer, 0, len)
|
||||
}
|
||||
fileOutputStream.close()
|
||||
}
|
||||
zipEntry = zis.nextEntry
|
||||
}
|
||||
|
||||
zis.closeEntry()
|
||||
zis.close()
|
||||
} catch (e: Exception) {
|
||||
println("Error during unzip: ${e.message}")
|
||||
}
|
||||
}
|
||||
|
||||
fun updateWindows() {
|
||||
//First check if everything is already installed. Install it if it isn't
|
||||
checkForInstalledUsbDriverWindows()
|
||||
updateWindowsSteamVRDriver()
|
||||
}
|
||||
|
||||
fun updateLinux() {
|
||||
updateLinuxSteamVRDriver()
|
||||
}
|
||||
|
||||
|
||||
fun checkForInstalledUsbDriverWindows() {
|
||||
val installedDriversList = executeShellCommand("powershell.exe", "pnputil /enum-drivers")
|
||||
val ch341ser = installedDriversList.contains("ch341ser.inf")
|
||||
val ch343ser = installedDriversList.contains("ch343ser.inf")
|
||||
val silabser = installedDriversList.contains("silabser.inf")
|
||||
val path = Paths.get("").toAbsolutePath().toString()
|
||||
|
||||
|
||||
if (ch341ser && ch343ser && silabser) {
|
||||
println("drivers already installed!")
|
||||
return
|
||||
}
|
||||
|
||||
println("Cannot find one of the drivers, installing drivers")
|
||||
val driverinstallOutput = executeShellCommand("$path\\installusbdrivers.bat")
|
||||
println(driverinstallOutput)
|
||||
}
|
||||
|
||||
|
||||
fun checkForUpdates() {
|
||||
|
||||
}
|
||||
|
||||
fun updateWindowsServer() {
|
||||
|
||||
}
|
||||
|
||||
fun updateWindowsUSBDrivers() {
|
||||
|
||||
}
|
||||
|
||||
fun updateWindowsSteamVRDriver() {
|
||||
val steamVRLocation = executeShellCommand("powershell.exe", "-Command", "(Get-ItemProperty \'HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App 250820\').InstallLocation").trim()
|
||||
if (!steamVRLocation.contains("SteamVR")) {
|
||||
println("SteamVR not installed, cannot install SlimeVR Steam driver.")
|
||||
return;
|
||||
}
|
||||
val vrPathRegContents = executeShellCommand("${steamVRLocation}\\bin\\win64\\vrpathreg.exe", "finddriver", "slimevr")
|
||||
println(vrPathRegContents)
|
||||
val isDriverRegistered = vrPathRegContents.contains("WINDOWSSTEAMVRDRIVERDIRECTORY")
|
||||
println(isDriverRegistered)
|
||||
if (isDriverRegistered) {
|
||||
println("steamVR driver is already registered. Skipping...")
|
||||
return
|
||||
}
|
||||
println("Installing SteamVR Driver")
|
||||
println("Downloading SteamVR driver")
|
||||
downloadFile(URL(WINDOWSSTEAMVRDRIVERURL), WINDOWSSTEAMVRDRIVERNAME)
|
||||
unzip(WINDOWSSTEAMVRDRIVERNAME, WINDOWSSTEAMVRDRIVERDIRECTORY)
|
||||
println("Driver downloaded")
|
||||
println("Registering driver with steamvr")
|
||||
executeShellCommand(
|
||||
"${steamVRLocation}\\bin\\win64\\vrpathreg.exe", "adddriver", "${
|
||||
Paths.get(
|
||||
""
|
||||
).toAbsolutePath()
|
||||
}\\${WINDOWSSTEAMVRDRIVERDIRECTORY}\\slimevr"
|
||||
)
|
||||
}
|
||||
|
||||
fun updateLinuxServer() {
|
||||
|
||||
}
|
||||
|
||||
fun updateUdev() {
|
||||
|
||||
}
|
||||
|
||||
fun updateLinuxSteamVRDriver() {
|
||||
val vrPathRegContents = executeShellCommand("${System.getProperty("user.home")}/.steam/steam/steamapps/common/SteamVR/bin/vrpathreg.sh")
|
||||
val isDriverRegistered = vrPathRegContents.contains("LINUXSTEAMVRDRIVERDIRECTORY")
|
||||
if (!isDriverRegistered) {
|
||||
println("Downloading driver")
|
||||
downloadFile(URL(LINUXSTEAMVRDRIVERURL), LINUXSTEAMVRDRIVERNAME)
|
||||
unzip(LINUXSTEAMVRDRIVERNAME, LINUXSTEAMVRDRIVERDIRECTORY)
|
||||
println("Driver downloaded")
|
||||
println("Registering driver with steamvr")
|
||||
executeShellCommand(
|
||||
"${System.getProperty("user.home")}/.steam/steam/steamapps/common/SteamVR/bin/vrpathreg.sh adddriver ${
|
||||
Paths.get(
|
||||
""
|
||||
).toAbsolutePath()
|
||||
}/${LINUXSTEAMVRDRIVERDIRECTORY}/slimevr"
|
||||
)
|
||||
} else {
|
||||
println("steamVR driver is already registered. Skipping...")
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
//Windows URL's
|
||||
private const val WINDOWSSTEAMVRDRIVERURL = "https://github.com/SlimeVR/SlimeVR-OpenVR-Driver/releases/latest/download/slimevr-openvr-driver-win64.zip"
|
||||
private const val WINDOWSSTEAMVRDRIVERNAME = "slimevr-openvr-driver-win64.zip"
|
||||
private const val WINDOWSSTEAMVRDRIVERDIRECTORY = "slimevr-openvr-driver-win64"
|
||||
private const val WINDOWSFEEDERURL = "https://github.com/SlimeVR/SlimeVR-Feeder-App/releases/latest/download/SlimeVR-Feeder-App-win64.zip"
|
||||
private const val WINDOWSFEEDERNAME = "SlimeVR-Feeder-App-win64.zip"
|
||||
|
||||
//Linux URL's
|
||||
private const val LINUXSTEAMVRDRIVERURL = "https://github.com/SlimeVR/SlimeVR-OpenVR-Driver/releases/latest/download/slimevr-openvr-driver-x64-linux.zip"
|
||||
private const val LINUXSTEAMVRDRIVERNAME = "slimevr-openvr-driver-x64-linux.zip"
|
||||
private const val LINUXSTEAMVRDRIVERDIRECTORY = "slimevr-openvr-driver-x64-linux"
|
||||
private const val LINUXFEEDERURL = "https://github.com/SlimeVR/SlimeVR-Feeder-App/releases/latest/download/SlimeVR-Feeder-App-linux64.zip"
|
||||
private const val LINUXFEEDERNAME = "SlimeVR-Feeder-App-linux64.zip"
|
||||
private const val LINUXFEEDERDIRECTORY = "SlimeVR-Feeder-App-linux64"
|
||||
|
||||
//MacOS URL's
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package dev.slimevr.desktop.updater
|
||||
|
||||
import dev.slimevr.desktop.updater.downloadFile
|
||||
import dev.slimevr.desktop.updater.executeShellCommand
|
||||
import dev.slimevr.desktop.updater.unzip
|
||||
import java.net.URL
|
||||
import java.nio.file.Paths
|
||||
|
||||
class Linux {
|
||||
|
||||
fun updateLinux() {
|
||||
updateLinuxSteamVRDriver()
|
||||
}
|
||||
|
||||
fun updateLinuxSteamVRDriver() {
|
||||
val vrPathRegContents = executeShellCommand("${System.getProperty("user.home")}/.steam/steam/steamapps/common/SteamVR/bin/vrpathreg.sh")
|
||||
val isDriverRegistered = vrPathRegContents.contains("LINUXSTEAMVRDRIVERDIRECTORY")
|
||||
if (!isDriverRegistered) {
|
||||
println("Downloading driver")
|
||||
downloadFile(URL(LINUXSTEAMVRDRIVERURL), LINUXSTEAMVRDRIVERNAME)
|
||||
unzip(LINUXSTEAMVRDRIVERNAME, LINUXSTEAMVRDRIVERDIRECTORY)
|
||||
println("Driver downloaded")
|
||||
println("Registering driver with steamvr")
|
||||
executeShellCommand(
|
||||
"${System.getProperty("user.home")}/.steam/steam/steamapps/common/SteamVR/bin/vrpathreg.sh adddriver ${
|
||||
Paths.get(
|
||||
""
|
||||
).toAbsolutePath()
|
||||
}/${LINUXSTEAMVRDRIVERDIRECTORY}/slimevr"
|
||||
)
|
||||
} else {
|
||||
println("steamVR driver is already registered. Skipping...")
|
||||
}
|
||||
}
|
||||
|
||||
fun updateLinuxServer() {
|
||||
|
||||
}
|
||||
|
||||
fun updateUdev() {
|
||||
|
||||
}
|
||||
|
||||
companion object {
|
||||
//Linux URL's
|
||||
private const val LINUXSTEAMVRDRIVERURL = "https://github.com/SlimeVR/SlimeVR-OpenVR-Driver/releases/latest/download/slimevr-openvr-driver-x64-linux.zip"
|
||||
private const val LINUXSTEAMVRDRIVERNAME = "slimevr-openvr-driver-x64-linux.zip"
|
||||
private const val LINUXSTEAMVRDRIVERDIRECTORY = "slimevr-openvr-driver-x64-linux"
|
||||
private const val LINUXFEEDERURL = "https://github.com/SlimeVR/SlimeVR-Feeder-App/releases/latest/download/SlimeVR-Feeder-App-linux64.zip"
|
||||
private const val LINUXFEEDERNAME = "SlimeVR-Feeder-App-linux64.zip"
|
||||
private const val LINUXFEEDERDIRECTORY = "SlimeVR-Feeder-App-linux64"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package dev.slimevr.desktop.updater
|
||||
|
||||
import dev.slimevr.desktop.GIT_CLEAN
|
||||
import dev.slimevr.desktop.GIT_COMMIT_HASH
|
||||
import dev.slimevr.desktop.GIT_VERSION_TAG
|
||||
import kotlin.text.ifEmpty
|
||||
|
||||
val VERSION =
|
||||
(GIT_VERSION_TAG.ifEmpty { GIT_COMMIT_HASH }) +
|
||||
if (GIT_CLEAN) "" else "-dirty"
|
||||
|
||||
suspend fun main(args: Array<String>) {
|
||||
|
||||
println("Running updater")
|
||||
val updater = Updater()
|
||||
updater.runUpdater()
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package dev.slimevr.desktop.updater
|
||||
|
||||
import java.io.BufferedInputStream
|
||||
import java.io.BufferedReader
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.FileOutputStream
|
||||
import java.io.IOException
|
||||
import java.io.InputStreamReader
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.URL
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Paths
|
||||
import java.nio.file.StandardCopyOption
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipInputStream
|
||||
import io.ktor.client.*
|
||||
import io.ktor.client.engine.cio.*
|
||||
import io.ktor.client.request.*
|
||||
import io.ktor.client.statement.*
|
||||
|
||||
|
||||
class Updater {
|
||||
|
||||
val os = System.getProperty("os.name").lowercase()
|
||||
|
||||
suspend fun runUpdater() {
|
||||
|
||||
val latestVersion: Int = queryLatestVersion()
|
||||
val currentVersion = VERSION
|
||||
|
||||
|
||||
//Compare versions
|
||||
|
||||
if (os.contains("linux")) {
|
||||
println("Running linux updater")
|
||||
val linuxUpdater = Linux()
|
||||
linuxUpdater.updateLinux()
|
||||
}
|
||||
else if (os.contains("windows")) {
|
||||
println("Running windows updater")
|
||||
val windowsUpdater = Windows()
|
||||
windowsUpdater.updateWindows()
|
||||
|
||||
}
|
||||
else if (os.contains("darwin")) {
|
||||
println("I dunno")
|
||||
}
|
||||
else {
|
||||
println("guess I'll die")
|
||||
}
|
||||
println("Done Updating")
|
||||
}
|
||||
|
||||
|
||||
|
||||
suspend fun queryLatestVersion(): Int {
|
||||
val client = HttpClient(CIO)
|
||||
val response: HttpResponse = client.get("https://api.github.com/repos/slimevr/slimevr-server/releases/latest")
|
||||
println(response)
|
||||
client.close()
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package dev.slimevr.desktop.updater
|
||||
|
||||
import java.io.BufferedInputStream
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.FileOutputStream
|
||||
import java.io.IOException
|
||||
import java.net.URL
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Paths
|
||||
import java.nio.file.StandardCopyOption
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipInputStream
|
||||
|
||||
|
||||
fun executeShellCommand(vararg command: String): String {
|
||||
return try {
|
||||
val process = ProcessBuilder(*command)
|
||||
.redirectErrorStream(true)
|
||||
.start()
|
||||
process.inputStream.bufferedReader().readText().also {
|
||||
process.waitFor()
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
"Error executing shell command: ${e.message}"
|
||||
}
|
||||
}
|
||||
|
||||
fun downloadFile(url: URL, filename: String) {
|
||||
println("Downloading $filename from $url")
|
||||
try {
|
||||
val bufferedInputStream = BufferedInputStream(url.openStream())
|
||||
val fileOutputStream = FileOutputStream(filename)
|
||||
val dataBuffer = ByteArray(1024)
|
||||
var bytesRead = bufferedInputStream.read(dataBuffer, 0, 1024)
|
||||
while (bytesRead != -1) {
|
||||
fileOutputStream.write(dataBuffer, 0, bytesRead)
|
||||
bytesRead = bufferedInputStream.read(dataBuffer, 0, 1024)
|
||||
}
|
||||
val inputStream = url.openStream()
|
||||
Files.copy(inputStream, Paths.get(filename), StandardCopyOption.REPLACE_EXISTING)
|
||||
} catch ( e: IOException) {
|
||||
println("Error downloading file, ${e.message}")
|
||||
}
|
||||
}
|
||||
//Guard against zip slip
|
||||
fun newFile(destinationPath: File, zipEntry: ZipEntry): File {
|
||||
val destFile = File(destinationPath, zipEntry.name)
|
||||
|
||||
val destinationDirPath = destinationPath.getCanonicalPath()
|
||||
val destinationFilePath = destFile.getCanonicalPath()
|
||||
|
||||
if (!destinationFilePath.startsWith(destinationDirPath + File.separator)) {
|
||||
throw IOException("Entry is outside of the target dir: ${zipEntry.name}")
|
||||
}
|
||||
|
||||
return destFile
|
||||
}
|
||||
|
||||
fun unzip(file: String, destDir: String) {
|
||||
try {
|
||||
val zipFile = File(destDir)
|
||||
val dataBuffer = ByteArray(1024)
|
||||
val zis = ZipInputStream(FileInputStream(file))
|
||||
var zipEntry = zis.nextEntry
|
||||
|
||||
while (zipEntry != null) {
|
||||
val file = newFile(zipFile, zipEntry)
|
||||
if (zipEntry.isDirectory) {
|
||||
if (!file.isDirectory && !file.mkdirs()) {
|
||||
throw IOException("Failed to create directory: $file")
|
||||
} else {
|
||||
val parent = file.parentFile
|
||||
if (!parent.isDirectory && !parent.mkdirs()) {
|
||||
throw IOException("Failed to create directory: $parent")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
val fileOutputStream = FileOutputStream(file)
|
||||
var len = zis.read(dataBuffer, 0, 1024)
|
||||
while (len > 0) {
|
||||
fileOutputStream.write(dataBuffer, 0, len)
|
||||
len = zis.read(dataBuffer, 0, len)
|
||||
}
|
||||
fileOutputStream.close()
|
||||
}
|
||||
zipEntry = zis.nextEntry
|
||||
}
|
||||
|
||||
zis.closeEntry()
|
||||
zis.close()
|
||||
} catch (e: Exception) {
|
||||
println("Error during unzip: ${e.message}")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package dev.slimevr.desktop.updater
|
||||
|
||||
import dev.slimevr.desktop.updater.downloadFile
|
||||
import dev.slimevr.desktop.updater.executeShellCommand
|
||||
import dev.slimevr.desktop.updater.unzip
|
||||
import java.net.URL
|
||||
import java.nio.file.Paths
|
||||
|
||||
class Windows {
|
||||
|
||||
|
||||
fun updateWindows() {
|
||||
//First check if everything is already installed. Install it if it isn't
|
||||
checkForInstalledUsbDriverWindows()
|
||||
updateWindowsGui()
|
||||
updateWindowsServer()
|
||||
updateWindowsSteamVRDriver()
|
||||
}
|
||||
|
||||
fun checkForInstalledUsbDriverWindows() {
|
||||
val installedDriversList =
|
||||
executeShellCommand("powershell.exe", "pnputil /enum-drivers")
|
||||
val ch341ser = installedDriversList.contains("ch341ser.inf")
|
||||
val ch343ser = installedDriversList.contains("ch343ser.inf")
|
||||
val silabser = installedDriversList.contains("silabser.inf")
|
||||
val path = Paths.get("").toAbsolutePath().toString()
|
||||
|
||||
|
||||
if (ch341ser && ch343ser && silabser) {
|
||||
println("drivers already installed!")
|
||||
return
|
||||
}
|
||||
|
||||
println("Cannot find one of the drivers, installing drivers")
|
||||
val driverinstallOutput = executeShellCommand("$path\\installusbdrivers.bat")
|
||||
println(driverinstallOutput)
|
||||
}
|
||||
|
||||
fun updateWindowsSteamVRDriver() {
|
||||
val steamVRLocation = executeShellCommand("powershell.exe", "-Command", "(Get-ItemProperty \'HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App 250820\').InstallLocation").trim()
|
||||
if (!steamVRLocation.contains("SteamVR")) {
|
||||
println("SteamVR not installed, cannot install SlimeVR Steam driver.")
|
||||
return;
|
||||
}
|
||||
val vrPathRegContents = executeShellCommand("${steamVRLocation}\\bin\\win64\\vrpathreg.exe", "finddriver", "slimevr")
|
||||
println(vrPathRegContents)
|
||||
val isDriverRegistered = vrPathRegContents.contains("WINDOWSSTEAMVRDRIVERDIRECTORY")
|
||||
println(isDriverRegistered)
|
||||
if (isDriverRegistered) {
|
||||
println("steamVR driver is already registered. Skipping...")
|
||||
return
|
||||
}
|
||||
println("Installing SteamVR Driver")
|
||||
println("Downloading SteamVR driver")
|
||||
downloadFile(URL(WINDOWSSTEAMVRDRIVERURL), WINDOWSSTEAMVRDRIVERNAME)
|
||||
unzip(WINDOWSSTEAMVRDRIVERNAME, WINDOWSSTEAMVRDRIVERDIRECTORY)
|
||||
println("Driver downloaded")
|
||||
println("Registering driver with steamvr")
|
||||
executeShellCommand(
|
||||
"${steamVRLocation}\\bin\\win64\\vrpathreg.exe", "adddriver", "${
|
||||
Paths.get(
|
||||
""
|
||||
).toAbsolutePath()
|
||||
}\\${WINDOWSSTEAMVRDRIVERDIRECTORY}\\slimevr"
|
||||
)
|
||||
}
|
||||
|
||||
fun updateWindowsServer() {
|
||||
|
||||
}
|
||||
|
||||
fun updateWindowsGui() {
|
||||
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val WINDOWSSTEAMVRDRIVERURL = "https://github.com/SlimeVR/SlimeVR-OpenVR-Driver/releases/latest/download/slimevr-openvr-driver-win64.zip"
|
||||
private const val WINDOWSSTEAMVRDRIVERNAME = "slimevr-openvr-driver-win64.zip"
|
||||
private const val WINDOWSSTEAMVRDRIVERDIRECTORY = "slimevr-openvr-driver-win64"
|
||||
private const val WINDOWSFEEDERURL = "https://github.com/SlimeVR/SlimeVR-Feeder-App/releases/latest/download/SlimeVR-Feeder-App-win64.zip"
|
||||
private const val WINDOWSFEEDERNAME = "SlimeVR-Feeder-App-win64.zip"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user