refactrored desktop mappings
This commit is contained in:
parent
b265824b63
commit
a608382a58
1 changed files with 71 additions and 69 deletions
|
@ -15,15 +15,11 @@ import org.domaindrivenarchitecture.provs.framework.ubuntu.user.base.whoami
|
||||||
|
|
||||||
|
|
||||||
fun provisionDesktop(prov: Prov, cmd: DesktopCliCommand) {
|
fun provisionDesktop(prov: Prov, cmd: DesktopCliCommand) {
|
||||||
val submodules = cmd.submodules
|
|
||||||
// retrieve config
|
// retrieve config
|
||||||
val conf = if (cmd.configFile != null) getConfig(cmd.configFile.fileName) else DesktopConfig()
|
val conf = if (cmd.configFile != null) getConfig(cmd.configFile.fileName) else DesktopConfig()
|
||||||
|
|
||||||
if (submodules == null) {
|
prov.provisionDesktopImpl(cmd.type, conf.ssh?.keyPair(), conf.gpg?.keyPair(), conf.gitUserName, conf.gitEmail, cmd.submodules)
|
||||||
prov.provisionDesktop(cmd.type, conf.ssh?.keyPair(), conf.gpg?.keyPair(), conf.gitUserName, conf.gitEmail)
|
|
||||||
} else {
|
|
||||||
prov.provisionDesktopSubmodules(submodules)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,107 +31,113 @@ fun provisionDesktop(prov: Prov, cmd: DesktopCliCommand) {
|
||||||
*
|
*
|
||||||
* Prerequisites: user must be able to sudo without entering the password
|
* Prerequisites: user must be able to sudo without entering the password
|
||||||
*/
|
*/
|
||||||
fun Prov.provisionDesktop(
|
fun Prov.provisionDesktopImpl(
|
||||||
desktopType: DesktopType = DesktopType.BASIC,
|
desktopType: DesktopType = DesktopType.BASIC,
|
||||||
ssh: KeyPair? = null,
|
ssh: KeyPair? = null,
|
||||||
gpg: KeyPair? = null,
|
gpg: KeyPair? = null,
|
||||||
gitUserName: String? = null,
|
gitUserName: String? = null,
|
||||||
gitEmail: String? = null,
|
gitEmail: String? = null,
|
||||||
|
submodules: List<String>?
|
||||||
) = task {
|
) = task {
|
||||||
|
|
||||||
// TODO: jem - 2022-06-30: why?? We got already a typed var!
|
// TODO: jem - 2022-06-30: why?? We got already a typed var!
|
||||||
DesktopType.valueOf(desktopType.name) // throws exception when desktopType.name is unknown
|
DesktopType.valueOf(desktopType.name) // throws exception when desktopType.name is unknown
|
||||||
|
|
||||||
validatePrecondition()
|
validatePrecondition()
|
||||||
provisionBaseDesktop(gpg, ssh, gitUserName, gitEmail)
|
provisionBaseDesktop(gpg, ssh, gitUserName, gitEmail, submodules)
|
||||||
|
|
||||||
if (desktopType == DesktopType.OFFICE || desktopType == DesktopType.IDE) {
|
if (desktopType == DesktopType.OFFICE || desktopType == DesktopType.IDE) {
|
||||||
provisionOfficeDesktop()
|
provisionOfficeDesktop(submodules)
|
||||||
}
|
}
|
||||||
if (desktopType == DesktopType.IDE) {
|
if (desktopType == DesktopType.IDE) {
|
||||||
provisionIdeDesktop()
|
provisionIdeDesktop(submodules)
|
||||||
}
|
}
|
||||||
ProvResult(true)
|
ProvResult(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Prov.validatePrecondition() {
|
fun Prov.validatePrecondition() {
|
||||||
if (!currentUserCanSudo()) {
|
if (!currentUserCanSudo()) {
|
||||||
throw Exception("Current user ${whoami()} cannot execute sudo without entering a password! This is necessary to execute provisionDesktop")
|
throw Exception("Current user ${whoami()} cannot execute sudo without entering a password! This is necessary to execute provisionDesktop")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Prov.provisionIdeDesktop() {
|
fun Prov.provisionIdeDesktop(submodules: List<String>?) {
|
||||||
aptInstall(JAVA)
|
if (submodules != null) {
|
||||||
aptInstall(OPEN_VPM)
|
aptInstall(JAVA)
|
||||||
aptInstall(OPENCONNECT)
|
aptInstall(OPEN_VPM)
|
||||||
aptInstall(VPNC)
|
aptInstall(OPENCONNECT)
|
||||||
installDocker()
|
aptInstall(VPNC)
|
||||||
|
installDocker()
|
||||||
|
|
||||||
// IDEs
|
// IDEs
|
||||||
installVSC("python", "clojure")
|
installVSC("python", "clojure")
|
||||||
aptInstall(CLOJURE_TOOLS)
|
aptInstall(CLOJURE_TOOLS)
|
||||||
installShadowCljs()
|
installShadowCljs()
|
||||||
installIntelliJ()
|
installIntelliJ()
|
||||||
installDevOps()
|
installDevOps()
|
||||||
provisionPython()
|
provisionPython()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Prov.provisionOfficeDesktop() {
|
fun Prov.provisionMSDesktop(submodules: List<String>?) {
|
||||||
aptInstall(ZIP_UTILS)
|
if (submodules?.contains(DesktopSubmodule.TEAMS.name.lowercase()) == true) {
|
||||||
aptInstall(BROWSER)
|
installMsTeams()
|
||||||
aptInstall(EMAIL_CLIENT)
|
} else {
|
||||||
installDeltaChat()
|
|
||||||
aptInstall(OFFICE_SUITE)
|
|
||||||
aptInstall(CLIP_TOOLS)
|
|
||||||
installZimWiki()
|
|
||||||
installGopass()
|
|
||||||
aptInstallFromPpa("nextcloud-devs", "client", "nextcloud-client")
|
|
||||||
|
|
||||||
optional {
|
|
||||||
aptInstall(DRAWING_TOOLS)
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
aptInstall(SPELLCHECKING_DE)
|
fun Prov.provisionOfficeDesktop(submodules: List<String>?) {
|
||||||
|
if (submodules != null) {
|
||||||
|
aptInstall(ZIP_UTILS)
|
||||||
|
aptInstall(BROWSER)
|
||||||
|
aptInstall(EMAIL_CLIENT)
|
||||||
|
installDeltaChat()
|
||||||
|
aptInstall(OFFICE_SUITE)
|
||||||
|
aptInstall(CLIP_TOOLS)
|
||||||
|
installZimWiki()
|
||||||
|
installGopass()
|
||||||
|
aptInstallFromPpa("nextcloud-devs", "client", "nextcloud-client")
|
||||||
|
|
||||||
|
optional {
|
||||||
|
aptInstall(DRAWING_TOOLS)
|
||||||
|
}
|
||||||
|
|
||||||
|
aptInstall(SPELLCHECKING_DE)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Prov.provisionBaseDesktop(
|
private fun Prov.provisionBaseDesktop(
|
||||||
gpg: KeyPair?,
|
gpg: KeyPair?,
|
||||||
ssh: KeyPair?,
|
ssh: KeyPair?,
|
||||||
gitUserName: String?,
|
gitUserName: String?,
|
||||||
gitEmail: String?
|
gitEmail: String?,
|
||||||
|
submodules: List<String>?
|
||||||
) {
|
) {
|
||||||
aptInstall(KEY_MANAGEMENT)
|
if (submodules != null) {
|
||||||
aptInstall(VERSION_MANAGEMENT)
|
aptInstall(KEY_MANAGEMENT)
|
||||||
aptInstall(NETWORK_TOOLS)
|
aptInstall(VERSION_MANAGEMENT)
|
||||||
aptInstall(SCREEN_TOOLS)
|
aptInstall(NETWORK_TOOLS)
|
||||||
aptInstall(KEY_MANAGEMENT_GUI)
|
aptInstall(SCREEN_TOOLS)
|
||||||
aptInstall(PASSWORD_TOOLS)
|
aptInstall(KEY_MANAGEMENT_GUI)
|
||||||
aptInstall(OS_ANALYSIS)
|
aptInstall(PASSWORD_TOOLS)
|
||||||
aptInstall(BASH_UTILS)
|
aptInstall(OS_ANALYSIS)
|
||||||
|
aptInstall(BASH_UTILS)
|
||||||
|
|
||||||
provisionKeys(gpg, ssh)
|
provisionKeys(gpg, ssh)
|
||||||
provisionGit(gitUserName ?: whoami(), gitEmail, gpg?.let { gpgFingerprint(it.publicKey.plain()) })
|
provisionGit(gitUserName ?: whoami(), gitEmail, gpg?.let { gpgFingerprint(it.publicKey.plain()) })
|
||||||
|
|
||||||
installVirtualBoxGuestAdditions()
|
installVirtualBoxGuestAdditions()
|
||||||
installRedshift()
|
installRedshift()
|
||||||
configureRedshift()
|
configureRedshift()
|
||||||
|
|
||||||
aptPurge(
|
aptPurge(
|
||||||
"remove-power-management xfce4-power-manager " +
|
"remove-power-management xfce4-power-manager " +
|
||||||
"xfce4-power-manager-plugins xfce4-power-manager-data"
|
"xfce4-power-manager-plugins xfce4-power-manager-data"
|
||||||
)
|
)
|
||||||
aptPurge("abiword gnumeric")
|
aptPurge("abiword gnumeric")
|
||||||
aptPurge("popularity-contest")
|
aptPurge("popularity-contest")
|
||||||
|
|
||||||
configureNoSwappiness()
|
configureNoSwappiness()
|
||||||
configureBash()
|
configureBash()
|
||||||
}
|
|
||||||
|
|
||||||
private fun Prov.provisionDesktopSubmodules(
|
|
||||||
submodules: List<String>,
|
|
||||||
) = task {
|
|
||||||
|
|
||||||
if (submodules.contains(DesktopSubmodule.TEAMS.name.lowercase())) {
|
|
||||||
installMsTeams()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue