refactor unsafe operators & method installHugoByDeb
This commit is contained in:
parent
d31ffd07b7
commit
30d12734fb
3 changed files with 6 additions and 11 deletions
|
@ -1,6 +1,6 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="testquick" type="JUnit" factoryName="JUnit">
|
||||
<module name="org.domaindrivenarchitecture.provs.provs.test" />
|
||||
<module name="provs.test" />
|
||||
<option name="PACKAGE_NAME" value="org" />
|
||||
<option name="MAIN_CLASS_NAME" value="" />
|
||||
<option name="METHOD_NAME" value="" />
|
||||
|
|
|
@ -1,35 +1,30 @@
|
|||
package org.domaindrivenarchitecture.provs.desktop.infrastructure
|
||||
|
||||
import org.domaindrivenarchitecture.provs.framework.core.Prov
|
||||
import org.domaindrivenarchitecture.provs.framework.core.ProvResult
|
||||
import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.createDir
|
||||
import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.userHome
|
||||
import org.domaindrivenarchitecture.provs.framework.ubuntu.install.base.aptInstall
|
||||
import org.domaindrivenarchitecture.provs.framework.ubuntu.install.base.aptPurge
|
||||
import org.domaindrivenarchitecture.provs.framework.ubuntu.web.base.downloadFromURL
|
||||
|
||||
fun Prov.installHugoByDeb() = taskWithResult {
|
||||
fun Prov.installHugoByDeb() = task {
|
||||
val sha256sum = "46692ac9b79d5bc01b0f847f6dcf651d8630476de63e598ef61a8da9461d45cd"
|
||||
val requiredHugoVersion = "0.125.5"
|
||||
val filename = "hugo_extended_0.125.5_linux-amd64.deb"
|
||||
val downloadUrl = "-L https://github.com/gohugoio/hugo/releases/download/v$requiredHugoVersion/$filename"
|
||||
val downloadDir = "${userHome()}Downloads"
|
||||
val currentHugoVersion = cmdNoEval("hugo version").out
|
||||
val currentHugoVersion = cmdNoEval("hugo version").out ?: ""
|
||||
|
||||
if (needsHugoInstall(currentHugoVersion, requiredHugoVersion)) {
|
||||
if (isHugoInstalled(currentHugoVersion)) {
|
||||
if (currentHugoVersion!!.contains("snap")) {
|
||||
if (currentHugoVersion.contains("snap")) {
|
||||
cmd("snap remove hugo", sudo = true)
|
||||
} else {
|
||||
aptPurge("hugo")
|
||||
}
|
||||
}
|
||||
aptInstall("gnupg2")
|
||||
createDir(downloadDir)
|
||||
downloadFromURL(downloadUrl, filename, downloadDir, sha256sum = sha256sum)
|
||||
cmd("dpkg -i $downloadDir/$filename", sudo = true)
|
||||
} else {
|
||||
ProvResult(true)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -93,9 +93,9 @@ class RemoteProcessor(val host: InetAddress, val user: String, val password: Sec
|
|||
var session: Session? = null
|
||||
|
||||
try {
|
||||
session = ssh.startSession()
|
||||
session = ssh.startSession() ?: throw IllegalStateException("ERROR: Could not start ssh session.")
|
||||
|
||||
val cmd: Command = session!!.exec(cmdString)
|
||||
val cmd: Command = session.exec(cmdString)
|
||||
val out = BufferedReader(InputStreamReader(cmd.inputStream)).use { it.readText() }
|
||||
val err = BufferedReader(InputStreamReader(cmd.errorStream)).use { it.readText() }
|
||||
cmd.join(100, TimeUnit.SECONDS)
|
||||
|
|
Loading…
Reference in a new issue