This commit is contained in:
Lars Westermann 2019-06-06 17:24:19 +02:00
parent 1b84ab88e3
commit 990cdaf1a4
Signed by: lars.westermann
GPG key ID: 9D417FA5BB9D5E1D
3 changed files with 73 additions and 59 deletions

View file

@ -8,53 +8,49 @@ import io.ktor.application.Application
import io.ktor.server.engine.embeddedServer
import io.ktor.server.netty.Netty
import kotlinx.coroutines.runBlocking
import java.nio.file.Files
object Main {
@Suppress("UnusedMainParameter")
@JvmStatic
fun main(args: Array<String>) {
Resources.init()
@Suppress("UnusedMainParameter")
fun main(args: Array<String>) {
Resources.init()
Connection.init()
Connection.init()
// twitter()
// twitter()
runBlocking {
if (UserRepository.all().isEmpty()) {
runBlocking {
if (UserRepository.all().isEmpty()) {
println("Please create a root user")
println("Please create a root user")
var username: String? = null
while (username == null) {
print("Username: ")
username = readLine()
}
var password: String? = null
while (password == null) {
print("Password: ")
password = System.console()?.readPassword()?.toString() ?: readLine()
}
println("Create root user '$username' with pw '${"*".repeat(password.length)}'")
UserRepository.create(
User(
null,
username,
hashPassword(password),
setOf(Permission.ADMIN)
)
)
var username: String? = null
while (username == null) {
print("Username: ")
username = readLine()
}
}
embeddedServer(
factory = Netty,
port = Configuration.Server.port,
host = Configuration.Server.host,
module = Application::main
).start(wait = true)
var password: String? = null
while (password == null) {
print("Password: ")
password = System.console()?.readPassword()?.toString() ?: readLine()
}
println("Create root user '$username' with pw '${"*".repeat(password.length)}'")
UserRepository.create(
User(
null,
username,
hashPassword(password),
setOf(Permission.ADMIN)
)
)
}
}
embeddedServer(
factory = Netty,
port = Configuration.Server.port,
host = Configuration.Server.host,
module = Application::main
).start(wait = true)
}

View file

@ -27,6 +27,9 @@ object Resources {
return
}
destination.toFile().deleteRecursively()
val fileSystem: FileSystem?
val src: Path = if (uri.scheme == "jar") {
fileSystem = FileSystems.newFileSystem(uri, mutableMapOf<String, Any?>())