mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-04-06 02:01:58 +02:00
released to steam beta testers
This commit is contained in:
@@ -20,7 +20,6 @@ import { getPlatform, handleIpc, isPortAvailable } from './utils';
|
||||
import {
|
||||
findServerJar,
|
||||
findSystemJRE,
|
||||
findUpdaterJar,
|
||||
getGuiDataFolder,
|
||||
getLogsFolder,
|
||||
getServerDataFolder,
|
||||
@@ -340,13 +339,6 @@ const spawnServer = async () => {
|
||||
logger.info({ skipServerIfRunning: options.skipServerIfRunning }, 'Server alredy running, skipping');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const updaterJar = findUpdaterJar();
|
||||
if (!updaterJar) {
|
||||
logger.info('updater jar not found, skippin');
|
||||
return;
|
||||
}
|
||||
|
||||
const serverJar = findServerJar();
|
||||
if (!serverJar) {
|
||||
@@ -364,10 +356,8 @@ const spawnServer = async () => {
|
||||
return;
|
||||
}
|
||||
|
||||
logger.info({ updaterJar }, 'found updater jar');
|
||||
logger.info({ serverJar }, 'found server jar');
|
||||
|
||||
const updater = spawn(javaBin, ['-Xmx128M', '-jar', updaterJar, 'run']);
|
||||
|
||||
const process = spawn(javaBin, ['-Xmx128M', '-jar', serverJar, 'run']);
|
||||
|
||||
|
||||
@@ -118,23 +118,4 @@ export const findServerJar = () => {
|
||||
.filter((p) => !!p)
|
||||
.map((p) => join(p!, 'slimevr.jar'))
|
||||
.find((p) => existsSync(p));
|
||||
};
|
||||
|
||||
export const findUpdaterJar = () => {
|
||||
const paths = [
|
||||
options.path ? path.resolve(options.path) : undefined,
|
||||
// AppImage passes the fakeroot in `APPDIR` env var.
|
||||
process.env['APPDIR']
|
||||
? path.resolve(join(process.env['APPDIR'], 'usr/share/slimevr/'))
|
||||
: undefined,
|
||||
path.dirname(app.getPath('exe')),
|
||||
|
||||
// For flatpack container
|
||||
path.resolve('/app/share/slimevr/'),
|
||||
path.resolve('/usr/share/slimevr/'),
|
||||
];
|
||||
return paths
|
||||
.filter((p) => !!p)
|
||||
.map((p) => join(p!, 'updater.jar'))
|
||||
.find((p) => existsSync(p));
|
||||
};
|
||||
};
|
||||
@@ -9,6 +9,7 @@ import dev.slimevr.bridge.Bridge
|
||||
import dev.slimevr.config.ConfigManager
|
||||
import dev.slimevr.desktop.firmware.DesktopSerialFlashingHandler
|
||||
import dev.slimevr.desktop.games.vrchat.DesktopVRCConfigHandler
|
||||
import dev.slimevr.desktop.install.drivers.InstallDrivers
|
||||
import dev.slimevr.desktop.platform.SteamVRBridge
|
||||
import dev.slimevr.desktop.platform.linux.UnixSocketBridge
|
||||
import dev.slimevr.desktop.platform.linux.UnixSocketRpcBridge
|
||||
@@ -99,6 +100,9 @@ fun main(args: Array<String>) {
|
||||
return
|
||||
}
|
||||
|
||||
val installDrivers = InstallDrivers()
|
||||
installDrivers.runUpdater()
|
||||
|
||||
val configDir = resolveConfig()
|
||||
LogManager.info("Using config dir: $configDir")
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package dev.slimevr.desktop.install.drivers
|
||||
|
||||
class InstallDrivers {
|
||||
|
||||
val os = System.getProperty("os.name").lowercase()
|
||||
|
||||
fun runUpdater() {
|
||||
|
||||
if (os.contains("linux")) {
|
||||
val linuxUpdater = Linux()
|
||||
val linuxFlavour = executeShellCommand("uname", "-n")
|
||||
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")
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package dev.slimevr.desktop.install.drivers
|
||||
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.call.body
|
||||
import io.ktor.client.engine.cio.CIO
|
||||
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
|
||||
import io.ktor.client.plugins.onDownload
|
||||
import io.ktor.client.plugins.timeout
|
||||
import io.ktor.client.request.get
|
||||
import io.ktor.client.request.prepareGet
|
||||
import io.ktor.client.statement.bodyAsChannel
|
||||
import io.ktor.http.contentLength
|
||||
import io.ktor.serialization.kotlinx.json.json
|
||||
import io.ktor.utils.io.jvm.javaio.copyTo
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.sync.Semaphore
|
||||
import kotlinx.coroutines.sync.withPermit
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonArray
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.io.IOException
|
||||
import java.lang.Exception
|
||||
import java.math.BigInteger
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Paths
|
||||
import java.security.MessageDigest
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipFile
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
fun executeShellCommand(vararg command: String): String = try {
|
||||
val process = ProcessBuilder(*command)
|
||||
.redirectErrorStream(true)
|
||||
.start()
|
||||
process.inputStream.bufferedReader().readText().also {
|
||||
process.waitFor()
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
"Error executing shell command: ${e.message}"
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package dev.slimevr.desktop.install.drivers
|
||||
|
||||
import java.nio.file.Paths
|
||||
import kotlin.io.path.Path
|
||||
import kotlin.io.path.exists
|
||||
|
||||
class Linux {
|
||||
|
||||
val path = Paths.get("").toAbsolutePath().toString()
|
||||
|
||||
fun updateLinux() {
|
||||
updateLinuxSteamVRDriver()
|
||||
feeder()
|
||||
updateUdev()
|
||||
}
|
||||
|
||||
fun updateLinuxSteamVRDriver() {
|
||||
val vrPathRegContents = executeShellCommand("${System.getProperty("user.home")}/.steam/steam/steamapps/common/SteamVR/bin/vrpathreg.sh")
|
||||
val isDriverRegistered = vrPathRegContents.contains("slimevr")
|
||||
if (!isDriverRegistered) {
|
||||
println("${Paths.get("").toAbsolutePath()}/$LINUXSTEAMVRDRIVERDIRECTORY/slimevr")
|
||||
executeShellCommand(
|
||||
"${System.getProperty("user.home")}/.steam/steam/steamapps/common/SteamVR/bin/vrpathreg.sh",
|
||||
"adddriver",
|
||||
"$path/$LINUXSTEAMVRDRIVERDIRECTORY/slimevr",
|
||||
)
|
||||
} else {
|
||||
println("steamVR driver is already registered. Skipping...")
|
||||
}
|
||||
}
|
||||
|
||||
fun feeder() {
|
||||
executeShellCommand("chmod", "+x", "$path/$LINUXFEEDERDIRECTORY/SlimeVR-Feeder-App")
|
||||
executeShellCommand("$path/$LINUXFEEDERDIRECTORY/SlimeVR-Feeder-App", "--install")
|
||||
println("feeder is registered.")
|
||||
}
|
||||
|
||||
fun updateUdev() {
|
||||
val file = Path("/etc/udev/rules.d/69-slimevr-devices.rules")
|
||||
if (file.exists()) {
|
||||
println("Udev rules already exist")
|
||||
return
|
||||
}
|
||||
val res = executeShellCommand("pkexec", "cp", "$path/69-slimevr-devices.rules", "/etc/udev/rules.d/69-slimevr-devices.rules")
|
||||
if (res.contains("Error")) {
|
||||
println("Error installing udev rules")
|
||||
} else {
|
||||
println("Successfully installed udev rules")
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
// Linux URLs
|
||||
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-Linux.zip"
|
||||
private const val LINUXFEEDERNAME = "SlimeVR-Feeder-App-Linux.zip"
|
||||
private const val LINUXFEEDERDIRECTORY = "SlimeVR-Feeder-App-Linux"
|
||||
private const val LINUXSERVERURL = "https://github.com/SlimeVR/SlimeVR-Server/releases/latest/download/SlimeVR-amd64.appimage"
|
||||
private const val LINUXSERVERNAME = "SlimeVR-amd64.appimage"
|
||||
private const val LINUXSERVERDIRECTORY = "slimevr-linux"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package dev.slimevr.desktop.install.drivers
|
||||
|
||||
import java.nio.file.Paths
|
||||
|
||||
class Windows {
|
||||
|
||||
val path = Paths.get("").toAbsolutePath().toString()
|
||||
|
||||
fun updateWindows() {
|
||||
// First check if everything is already installed. Install it if it isn't
|
||||
usbDrivers()
|
||||
steamVRDriver()
|
||||
feeder()
|
||||
}
|
||||
|
||||
fun usbDrivers() {
|
||||
|
||||
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")
|
||||
|
||||
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 feeder() {
|
||||
executeShellCommand("${path}\\${WINDOWSFEEDERDIRECTORY}\\SlimeVR-Feeder-App.exe", "--install")
|
||||
}
|
||||
|
||||
fun steamVRDriver() {
|
||||
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")
|
||||
val isDriverRegistered = vrPathRegContents.contains("WINDOWSSTEAMVRDRIVERDIRECTORY")
|
||||
if (isDriverRegistered) {
|
||||
println("steamVR driver is already registered. Skipping...")
|
||||
return
|
||||
}
|
||||
executeShellCommand(
|
||||
"${steamVRLocation}\\bin\\win64\\vrpathreg.exe",
|
||||
"adddriver",
|
||||
"${
|
||||
Paths.get(
|
||||
"",
|
||||
).toAbsolutePath()
|
||||
}\\${WINDOWSSTEAMVRDRIVERDIRECTORY}\\slimevr",
|
||||
)
|
||||
}
|
||||
|
||||
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"
|
||||
private const val WINDOWSFEEDERDIRECTORY = "SlimeVR-Feeder-App-win64"
|
||||
private const val WINDOWSSERVERURL = "https://github.com/SlimeVR/SlimeVR-Server/releases/latest/download/SlimeVR-win64.zip"
|
||||
private const val WINDOWSSERVERNAME = "slimevr-win64.zip"
|
||||
private const val WINDOWSSERVERDIRECTORY = "slimevr-win64"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user