51 lines
1.8 KiB
Kotlin
51 lines
1.8 KiB
Kotlin
package nl.astraeus.vst.chip
|
|
|
|
import java.io.File
|
|
import java.io.FileInputStream
|
|
import java.util.*
|
|
|
|
object Settings {
|
|
var runningAsRoot: Boolean = false
|
|
var port = 9000
|
|
var sslPort = 8443
|
|
var connectionTimeout = 30000
|
|
|
|
var jdbcDriver = "nl.astraeus.jdbc.Driver"
|
|
var jdbcConnectionUrl = "jdbc:stat:webServerPort=6001:jdbc:sqlite:data/srp.db"
|
|
var jdbcUser = "sa"
|
|
var jdbcPassword = ""
|
|
|
|
var adminUser = "rnentjes"
|
|
var adminPassword = "9/SG_Bd}9gWz~?j\\A.U]n9]OO"
|
|
|
|
fun getPropertiesFromFile(filename: String): Properties? {
|
|
val propertiesFile = File(filename)
|
|
return if (propertiesFile.exists()) {
|
|
val properties = Properties()
|
|
FileInputStream(propertiesFile).use {
|
|
properties.load(it)
|
|
}
|
|
properties
|
|
} else {
|
|
null
|
|
}
|
|
}
|
|
|
|
fun readProperties(args: Array<String>) {
|
|
val filename = if (args.isNotEmpty()) args[0] else "srp.properties"
|
|
val properties = getPropertiesFromFile(filename) ?: return // return if properties couldn't be loaded
|
|
|
|
runningAsRoot = properties.getProperty("runningAsRoot", runningAsRoot.toString()).toBoolean()
|
|
port = properties.getProperty("port", port.toString()).toInt()
|
|
sslPort = properties.getProperty("sslPort", sslPort.toString()).toInt()
|
|
connectionTimeout = properties.getProperty("connectionTimeout", connectionTimeout.toString()).toInt()
|
|
jdbcDriver = properties.getProperty("jdbcDriver", jdbcDriver)
|
|
jdbcConnectionUrl = properties.getProperty("jdbcConnectionUrl", jdbcConnectionUrl)
|
|
jdbcUser = properties.getProperty("jdbcUser", jdbcUser)
|
|
jdbcPassword = properties.getProperty("jdbcPassword", jdbcPassword)
|
|
|
|
adminUser = properties.getProperty("adminUser", adminUser)
|
|
adminPassword = properties.getProperty("adminPassword", adminPassword)
|
|
}
|
|
}
|