add syspec jar
This commit is contained in:
parent
394dc9edf2
commit
a0f6fb135c
4 changed files with 103 additions and 55 deletions
115
build.gradle
115
build.gradle
|
@ -1,5 +1,5 @@
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.6.10'
|
ext.kotlin_version = "1.6.10"
|
||||||
ext.CI_PROJECT_ID = System.env.CI_PROJECT_ID
|
ext.CI_PROJECT_ID = System.env.CI_PROJECT_ID
|
||||||
|
|
||||||
repositories { mavenCentral() }
|
repositories { mavenCentral() }
|
||||||
|
@ -10,15 +10,15 @@ buildscript {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: 'org.jetbrains.kotlin.jvm'
|
apply plugin: "org.jetbrains.kotlin.jvm"
|
||||||
apply plugin: 'java-library'
|
apply plugin: "java-library"
|
||||||
apply plugin: 'java-test-fixtures'
|
apply plugin: "java-test-fixtures"
|
||||||
apply plugin: 'maven-publish'
|
apply plugin: "maven-publish"
|
||||||
apply plugin: 'kotlinx-serialization'
|
apply plugin: "kotlinx-serialization"
|
||||||
|
|
||||||
|
|
||||||
group = 'org.domaindrivenarchitecture.provs'
|
group = "org.domaindrivenarchitecture.provs"
|
||||||
version = '0.9.15-SNAPSHOT'
|
version = "0.9.15-SNAPSHOT"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
@ -48,7 +48,7 @@ test {
|
||||||
excludeTags(excludedTags)
|
excludeTags(excludedTags)
|
||||||
}
|
}
|
||||||
if (System.getenv("CI_JOB_TOKEN") != null) {
|
if (System.getenv("CI_JOB_TOKEN") != null) {
|
||||||
excludeTags('containernonci')
|
excludeTags("containernonci")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,25 +65,25 @@ java {
|
||||||
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version")
|
||||||
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
|
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version")
|
||||||
|
|
||||||
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2'
|
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2")
|
||||||
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-core:1.3.2'
|
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.3.2")
|
||||||
|
|
||||||
|
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-cli:0.3.4"
|
implementation("org.jetbrains.kotlinx:kotlinx-cli:0.3.4")
|
||||||
implementation 'com.charleskorn.kaml:kaml:0.40.0'
|
implementation("com.charleskorn.kaml:kaml:0.40.0")
|
||||||
|
|
||||||
implementation group: 'com.hierynomus', name: 'sshj', version: '0.32.0'
|
implementation("com.hierynomus:sshj:0.32.0")
|
||||||
|
|
||||||
api 'org.slf4j:slf4j-api:1.7.36'
|
api("org.slf4j:slf4j-api:1.7.36")
|
||||||
api 'ch.qos.logback:logback-classic:1.2.10'
|
api("ch.qos.logback:logback-classic:1.2.10")
|
||||||
api 'ch.qos.logback:logback-core:1.2.10'
|
api("ch.qos.logback:logback-core:1.2.10")
|
||||||
|
|
||||||
testFixturesApi 'org.junit.jupiter:junit-jupiter-api:5.8.2'
|
testFixturesApi("org.junit.jupiter:junit-jupiter-api:5.8.2")
|
||||||
testImplementation('io.mockk:mockk:1.12.2')
|
testImplementation("io.mockk:mockk:1.12.2")
|
||||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
|
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.2")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,18 +93,18 @@ task uberjarDesktop(type: Jar) {
|
||||||
|
|
||||||
dependsOn configurations.runtimeClasspath
|
dependsOn configurations.runtimeClasspath
|
||||||
from {
|
from {
|
||||||
configurations.runtimeClasspath.findAll { it.name.endsWith('jar') }.collect { zipTree(it) }
|
configurations.runtimeClasspath.findAll { it.name.endsWith("jar") }.collect { zipTree(it) }
|
||||||
} {
|
} {
|
||||||
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
|
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
|
||||||
exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA'
|
exclude "META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA"
|
||||||
}
|
}
|
||||||
|
|
||||||
manifest {
|
manifest {
|
||||||
attributes 'Implementation-Title': 'Uberjar of provs',
|
attributes "Implementation-Title": "Uberjar of provs",
|
||||||
'Implementation-Version': project.version,
|
"Implementation-Version": project.version,
|
||||||
'Main-Class': 'org.domaindrivenarchitecture.provs.desktop.application.ApplicationKt'
|
"Main-Class": "org.domaindrivenarchitecture.provs.desktop.application.ApplicationKt"
|
||||||
}
|
}
|
||||||
archiveFileName = 'provs-desktop.jar'
|
archiveFileName = "provs-desktop.jar"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -114,41 +114,52 @@ task uberjarServer(type: Jar) {
|
||||||
|
|
||||||
dependsOn configurations.runtimeClasspath
|
dependsOn configurations.runtimeClasspath
|
||||||
from {
|
from {
|
||||||
configurations.runtimeClasspath.findAll { it.name.endsWith('jar') }.collect { zipTree(it) }
|
configurations.runtimeClasspath.findAll { it.name.endsWith("jar") }.collect { zipTree(it) }
|
||||||
} {
|
} {
|
||||||
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
|
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
|
||||||
exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA'
|
exclude "META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA"
|
||||||
}
|
}
|
||||||
|
|
||||||
manifest {
|
manifest {
|
||||||
attributes 'Implementation-Title': 'Uberjar of provs',
|
attributes "Implementation-Title": "Uberjar of provs",
|
||||||
'Implementation-Version': project.version,
|
"Implementation-Version": project.version,
|
||||||
'Main-Class': 'org.domaindrivenarchitecture.provs.server.application.ApplicationKt'
|
"Main-Class": "org.domaindrivenarchitecture.provs.server.application.ApplicationKt"
|
||||||
}
|
}
|
||||||
archiveFileName = 'provs-server.jar'
|
archiveFileName = "provs-server.jar"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
task uberjarSyspec(type: Jar) {
|
||||||
|
|
||||||
|
from sourceSets.main.output
|
||||||
|
|
||||||
|
dependsOn configurations.runtimeClasspath
|
||||||
|
from {
|
||||||
|
configurations.runtimeClasspath.findAll { it.name.endsWith("jar") }.collect { zipTree(it) }
|
||||||
|
} {
|
||||||
|
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
|
||||||
|
exclude "META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA"
|
||||||
|
}
|
||||||
|
|
||||||
|
manifest {
|
||||||
|
attributes "Implementation-Title": "Uberjar of provs",
|
||||||
|
"Implementation-Version": project.version,
|
||||||
|
"Main-Class": "org.domaindrivenarchitecture.provs.syspec.application.ApplicationKt"
|
||||||
|
}
|
||||||
|
archiveFileName = "provs-syspec.jar"
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy jar to /usr/local/bin and make it executable
|
// copy jar to /usr/local/bin and make it executable
|
||||||
// Remark: to be able to use it you must have jarwrapper installed (sudo apt install jarwrapper)
|
// Remark: to be able to use it you must have jarwrapper installed (sudo apt install jarwrapper)
|
||||||
task installlocally {
|
task installlocally {
|
||||||
dependsOn(uberjarServer, uberjarDesktop)
|
dependsOn(uberjarServer, uberjarDesktop, uberjarSyspec)
|
||||||
doLast {
|
doLast {
|
||||||
exec {
|
exec { commandLine("sh", "-c", "sudo cp ~/repo/dda/provs/build/libs/provs-server.jar /usr/local/bin/") }
|
||||||
executable "sh"
|
exec { commandLine("sh", "-c", "sudo cp ~/repo/dda/provs/build/libs/provs-desktop.jar /usr/local/bin/") }
|
||||||
args '-c', 'sudo cp ~/repo/dda/provs/build/libs/provs-server.jar /usr/local/bin/'
|
exec { commandLine("sh", "-c", "sudo cp ~/repo/dda/provs/build/libs/provs-syspec.jar /usr/local/bin/") }
|
||||||
}
|
exec { commandLine("sh", "-c", "sudo chmod 755 /usr/local/bin/provs-server.jar") }
|
||||||
exec {
|
exec { commandLine("sh", "-c", "sudo chmod 755 /usr/local/bin/provs-desktop.jar") }
|
||||||
executable "sh"
|
exec { commandLine("sh", "-c", "sudo chmod 755 /usr/local/bin/provs-syspec.jar") }
|
||||||
args '-c', 'sudo cp ~/repo/dda/provs/build/libs/provs-desktop.jar /usr/local/bin/'
|
|
||||||
}
|
|
||||||
exec {
|
|
||||||
executable "sh"
|
|
||||||
args '-c', 'sudo chmod 755 /usr/local/bin/provs-server.jar'
|
|
||||||
}
|
|
||||||
exec {
|
|
||||||
executable "sh"
|
|
||||||
args '-c', 'sudo chmod 755 /usr/local/bin/provs-desktop.jar'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +182,7 @@ publishing {
|
||||||
url "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/packages/maven"
|
url "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/packages/maven"
|
||||||
name "GitLab"
|
name "GitLab"
|
||||||
credentials(HttpHeaderCredentials) {
|
credentials(HttpHeaderCredentials) {
|
||||||
name = 'Job-Token'
|
name = "Job-Token"
|
||||||
value = System.getenv("CI_JOB_TOKEN")
|
value = System.getenv("CI_JOB_TOKEN")
|
||||||
}
|
}
|
||||||
authentication {
|
authentication {
|
||||||
|
|
|
@ -17,7 +17,7 @@ fun main(args: Array<String>) {
|
||||||
|
|
||||||
val checkedArgs = if (args.isEmpty()) arrayOf("-h") else args
|
val checkedArgs = if (args.isEmpty()) arrayOf("-h") else args
|
||||||
|
|
||||||
val cmd = CliArgumentsParser("provs-server.jar").parseCommand(checkedArgs)
|
val cmd = CliArgumentsParser("provs-server.jar subcommand target").parseCommand(checkedArgs)
|
||||||
if (!cmd.isValid()) {
|
if (!cmd.isValid()) {
|
||||||
println("Arguments are not valid, pls try -h for help.")
|
println("Arguments are not valid, pls try -h for help.")
|
||||||
exitProcess(1)
|
exitProcess(1)
|
||||||
|
|
|
@ -5,7 +5,8 @@ import org.domaindrivenarchitecture.provs.syspec.domain.verifySpec
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a system check, either locally or on a remote machine depending on the given arguments.
|
* Runs a check according to the specification file (default file: syspec-config.yaml).
|
||||||
|
* The check is performed either locally or on a remote system depending on the given arguments.
|
||||||
*
|
*
|
||||||
* Get help with option -h
|
* Get help with option -h
|
||||||
*/
|
*/
|
||||||
|
@ -13,7 +14,7 @@ fun main(args: Array<String>) {
|
||||||
|
|
||||||
val checkedArgs = if (args.isEmpty()) arrayOf("-h") else args
|
val checkedArgs = if (args.isEmpty()) arrayOf("-h") else args
|
||||||
|
|
||||||
val cmd = CliArgumentsParser("provs-syspec.jar").parseCommand(checkedArgs)
|
val cmd = CliArgumentsParser("provs-syspec.jar target").parseCommand(checkedArgs)
|
||||||
|
|
||||||
createProvInstance(cmd.target).verifySpec(cmd.configFileName)
|
createProvInstance(cmd.target).verifySpec(cmd.configFileName)
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package org.domaindrivenarchitecture.provs.syspec.infrastructure
|
||||||
|
|
||||||
|
import org.domaindrivenarchitecture.provs.syspec.domain.SocketSpec
|
||||||
|
import org.domaindrivenarchitecture.provs.syspec.domain.SpecConfig
|
||||||
|
import org.domaindrivenarchitecture.provs.test.testLocal
|
||||||
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
|
internal class VerificationKtTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun test_verify_empty_SpecConfig() {
|
||||||
|
assert(testLocal().verifySpecConfig(SpecConfig()).success)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun test_verify_socketSpec_successfully() {
|
||||||
|
// given
|
||||||
|
val out: List<String> = ("Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process \n" +
|
||||||
|
"udp UNCONN 0 0 0.0.0.0:5353 0.0.0.0:* users:((\"avahi-daemon\",pid=906,fd=12)) uid:116 ino:25024 sk:3 <-> \n" +
|
||||||
|
"tcp LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:((\"sshd\",pid=1018,fd=3)) ino:29320 sk:a <-> \n").split("\n")
|
||||||
|
|
||||||
|
// when
|
||||||
|
val res = testLocal().task {
|
||||||
|
verifySocketSpec(SocketSpec("sshd", 22), out)
|
||||||
|
verifySocketSpec(SocketSpec("sshd", 23, running = false), out)
|
||||||
|
}
|
||||||
|
val res2 = testLocal().verifySocketSpec(SocketSpec("sshd", 23), out).success
|
||||||
|
val res3 = testLocal().verifySocketSpec(SocketSpec("sshd", 22, running = false), out).success
|
||||||
|
|
||||||
|
// then
|
||||||
|
assert(res.success)
|
||||||
|
assert(!res2)
|
||||||
|
assert(!res3)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue