You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
provs/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/VirtualBoxGuest.kt

25 lines
986 B
Kotlin

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.install.base.aptInstall
import org.domaindrivenarchitecture.provs.framework.ubuntu.user.base.whoami
fun Prov.installVirtualBoxGuestAdditions() = def {
// if running in a VirtualBox vm
if (!chk("lspci | grep VirtualBox")) {
return@def ProvResult(true, "Not running in a VirtualBox")
}
if (chk("VBoxService --version")) {
return@def ProvResult(true, "VBoxService already installed")
}
// install guest additions
cmd("sudo add-apt-repository multiverse")
aptInstall("virtualbox-guest-x11") // virtualbox-guest-dkms")
// and add user to group vboxsf e.g. to be able to use shared folders
whoami()?.let { cmd("sudo usermod -G vboxsf -a " + it) }
?: ProvResult(true)
}