├── .github ├── img.png ├── FUNDING.yml ├── dependabot.yml ├── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md ├── SECURITY.md ├── CONTRIBUTING.md ├── PULL_REQUEST_TEMPLATE ├── README.md └── workflows │ └── image-deploy.yml ├── gradle ├── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties └── libs.versions.toml ├── agent ├── src │ └── main │ │ ├── resources │ │ └── server-icon.png │ │ └── kotlin │ │ └── dev │ │ └── httpmarco │ │ └── polocloud │ │ └── agent │ │ ├── utils │ │ ├── Reloadable.kt │ │ ├── JavaUtils.kt │ │ ├── IndexDetector.kt │ │ └── PortDetector.kt │ │ ├── runtime │ │ ├── k8s │ │ │ ├── KubernetesConstant.kt │ │ │ ├── KubernetesGroupStatus.kt │ │ │ ├── KubernetesService.kt │ │ │ ├── KubernetesExpender.kt │ │ │ ├── KubernetesGroup.kt │ │ │ ├── KubernetesFactory.kt │ │ │ ├── KubernetesRuntimeLoader.kt │ │ │ ├── KubernetesRuntime.kt │ │ │ ├── KubernetesRuntimeTemplateStorage.kt │ │ │ ├── KubernetesRuntimeConfigHolder.kt │ │ │ ├── KubernetesRuntimeGroupStorage.kt │ │ │ └── KubernetesRuntimeServiceStorage.kt │ │ ├── docker │ │ │ ├── DockerImageBuilder.kt │ │ │ ├── DockerThreadedRuntimeQueue.kt │ │ │ ├── DockerRuntimeGroupStorage.kt │ │ │ ├── DockerImage.kt │ │ │ ├── DockerRuntimeLoader.kt │ │ │ ├── DockerCloudInformationThread.kt │ │ │ ├── DockerConfigHolder.kt │ │ │ ├── DockerExpender.kt │ │ │ ├── DockerService.kt │ │ │ ├── DockerTemplateStorage.kt │ │ │ └── DockerRuntimeServiceStorage.kt │ │ ├── local │ │ │ ├── terminal │ │ │ │ ├── arguments │ │ │ │ │ ├── TerminalShortCut.kt │ │ │ │ │ ├── type │ │ │ │ │ │ ├── StringArrayArgument.kt │ │ │ │ │ │ ├── TextArgument.kt │ │ │ │ │ │ ├── GroupEditFlagArgument.kt │ │ │ │ │ │ ├── KeywordArgument.kt │ │ │ │ │ │ ├── GroupArgument.kt │ │ │ │ │ │ ├── ServiceArgument.kt │ │ │ │ │ │ ├── PlatformArgument.kt │ │ │ │ │ │ ├── MemoryArgument.kt │ │ │ │ │ │ ├── LocaleArgument.kt │ │ │ │ │ │ ├── YesNotArgument.kt │ │ │ │ │ │ ├── PlatformVersionArgument.kt │ │ │ │ │ │ └── IntArgument.kt │ │ │ │ │ ├── InputContext.kt │ │ │ │ │ └── TerminalArgument.kt │ │ │ │ ├── commands │ │ │ │ │ ├── CommandExecution.kt │ │ │ │ │ ├── impl │ │ │ │ │ │ ├── ShutdownCommand.kt │ │ │ │ │ │ ├── ClearCommand.kt │ │ │ │ │ │ ├── ReloadCommand.kt │ │ │ │ │ │ ├── HelpCommand.kt │ │ │ │ │ │ ├── TemplateCommand.kt │ │ │ │ │ │ ├── UpdaterCommand.kt │ │ │ │ │ │ ├── InfoCommand.kt │ │ │ │ │ │ └── PlatformCommand.kt │ │ │ │ │ ├── CommandSyntax.kt │ │ │ │ │ ├── Command.kt │ │ │ │ │ ├── CommandService.kt │ │ │ │ │ └── CommandParser.kt │ │ │ │ ├── setup │ │ │ │ │ ├── SetupStep.kt │ │ │ │ │ ├── impl │ │ │ │ │ │ ├── CustomPlatformSetup.kt │ │ │ │ │ │ └── OnboardingSetup.kt │ │ │ │ │ └── SetupController.kt │ │ │ │ ├── LoggingColor.kt │ │ │ │ ├── screen │ │ │ │ │ └── ServiceScreenController.kt │ │ │ │ └── JLine3Reading.kt │ │ │ ├── LocalRuntimeGroupStorage.kt │ │ │ ├── LocalConstants.kt │ │ │ ├── LocalRuntimeLoader.kt │ │ │ ├── tracking │ │ │ │ ├── OnlineTrack.kt │ │ │ │ └── ServiceLogTrack.kt │ │ │ ├── LocalCloudInformationThread.kt │ │ │ ├── LocalTemplate.kt │ │ │ ├── LocalService.kt │ │ │ ├── LocalRuntimeConfigHolder.kt │ │ │ ├── LocalServiceStatsThread.kt │ │ │ ├── LocalRuntimeExpender.kt │ │ │ ├── LocalRuntimeVersionChecker.kt │ │ │ └── LocalRuntimeServiceStorage.kt │ │ ├── abstracts │ │ │ ├── Track.kt │ │ │ └── AbstractServiceStatsThread.kt │ │ ├── RuntimeConfigHolder.kt │ │ ├── RuntimeLoader.kt │ │ ├── RuntimeGroupStorage.kt │ │ ├── RuntimeFactory.kt │ │ ├── RuntimeServiceStorage.kt │ │ ├── RuntimeTemplateStorage.kt │ │ └── RuntimeExpender.kt │ │ ├── i18n │ │ ├── I18nPolocloudAgent.kt │ │ ├── I18n.kt │ │ └── UTF8ResourceBundleControl.kt │ │ ├── detector │ │ ├── Detector.kt │ │ └── DetectorFactoryThread.kt │ │ ├── security │ │ └── SecurityProvider.kt │ │ ├── configuration │ │ ├── Config.kt │ │ ├── AgentConfig.kt │ │ └── serializer │ │ │ └── LocalSerializer.kt │ │ ├── player │ │ ├── PlayerStorage.kt │ │ ├── AbstractPolocloudPlayer.kt │ │ ├── PlayerActorService.kt │ │ ├── PlayerListener.kt │ │ └── PlayerStorageImpl.kt │ │ ├── events │ │ ├── EventSubscription.kt │ │ ├── EventGrpcService.kt │ │ └── EventService.kt │ │ ├── information │ │ ├── CloudInformationStorage.kt │ │ ├── CloudStatistic.kt │ │ └── CloudInformationGrpcService.kt │ │ ├── templates │ │ └── TemplateGrpcService.kt │ │ ├── platform │ │ ├── PlatformGrpcService.kt │ │ └── PlatformStorageImpl.kt │ │ ├── grpc │ │ └── GrpcServerEndpoint.kt │ │ ├── logging │ │ ├── LoggingAgent.kt │ │ └── LoggingLayout.kt │ │ ├── AgentShutdownHandler.kt │ │ └── AgentBoot.kt └── build.gradle.kts ├── crowdin.yml ├── updater ├── src │ └── main │ │ └── kotlin │ │ └── dev │ │ └── httpmarco │ │ └── polocloud │ │ └── updater │ │ ├── GitHubTag.kt │ │ ├── GitHubReader.kt │ │ └── Updater.kt └── build.gradle.kts ├── gradle.properties ├── platforms ├── src │ ├── main │ │ └── kotlin │ │ │ └── dev │ │ │ └── httpmarco │ │ │ └── polocloud │ │ │ └── platforms │ │ │ ├── exceptions │ │ │ ├── PlatformNotFoundException.kt │ │ │ ├── PlatformCacheMissingException.kt │ │ │ ├── PlatformVersionInvalidException.kt │ │ │ └── DuplicatedPlatformActionException.kt │ │ │ ├── bridge │ │ │ ├── BridgeType.kt │ │ │ └── BridgeConfig.kt │ │ │ ├── ServerPlatformForwarding.kt │ │ │ ├── tasks │ │ │ ├── TaskFileMode.kt │ │ │ ├── actions │ │ │ │ ├── PlatformAction.kt │ │ │ │ ├── PlatformFileDeleteAction.kt │ │ │ │ ├── PlatformFileReplacementAction.kt │ │ │ │ ├── PlatformFileWriteAction.kt │ │ │ │ ├── PlatformFileMoveAction.kt │ │ │ │ ├── PlatformExecuteCommandAction.kt │ │ │ │ ├── PlatformDownloadAction.kt │ │ │ │ ├── PlatformDirectoryDeleteAction.kt │ │ │ │ └── PlatformFileUnzipAction.kt │ │ │ ├── PlatformTask.kt │ │ │ ├── PlatformTaskPool.kt │ │ │ ├── PlatformTaskStep.kt │ │ │ └── PlatformTaskSerializer.kt │ │ │ ├── PlatformVersion.kt │ │ │ ├── PlatformVersionSerializer.kt │ │ │ ├── PlatformPool.kt │ │ │ ├── PlatformParameters.kt │ │ │ ├── metadata │ │ │ └── MetadataReader.kt │ │ │ ├── PlatformConst.kt │ │ │ └── PlatformDeserializer.kt │ └── test │ │ └── kotlin │ │ └── dev │ │ └── httpmarco │ │ └── polocloud │ │ └── platforms │ │ └── PlatformTest.kt └── build.gradle.kts ├── common ├── src │ └── main │ │ └── kotlin │ │ └── dev │ │ └── httpmarco │ │ └── polocloud │ │ └── common │ │ ├── json │ │ └── GsonContext.kt │ │ ├── math │ │ └── ResourceCalculator.kt │ │ ├── image │ │ └── ImageConverter.kt │ │ ├── os │ │ ├── CurrentOS.kt │ │ ├── OS.kt │ │ └── SystemResources.kt │ │ ├── language │ │ └── Language.kt │ │ ├── network │ │ └── NetworkAddress.kt │ │ ├── version │ │ └── Version.kt │ │ └── filesystem │ │ └── CopyDirectoryContent.kt └── build.gradle.kts ├── docker ├── setup.md └── Dockerfile ├── launcher └── src │ └── main │ └── java │ └── dev │ └── httpmarco │ └── polocloud │ └── launcher │ ├── lib │ ├── PolocloudLibNotFoundException.java │ └── PolocloudLib.java │ ├── PolocloudLauncher.java │ ├── dependencies │ ├── Dependency.java │ └── DependencyProvider.java │ ├── PolocloudParameters.java │ └── PolocloudProcess.java ├── settings.gradle.kts ├── .gitignore └── gradlew.bat /.github/img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thePolocloud/polocloud/HEAD/.github/img.png -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [HttpMarco] 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thePolocloud/polocloud/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /agent/src/main/resources/server-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thePolocloud/polocloud/HEAD/agent/src/main/resources/server-icon.png -------------------------------------------------------------------------------- /crowdin.yml: -------------------------------------------------------------------------------- 1 | files: 2 | - source: '**/i18n/*_en.properties' 3 | translation: /%original_path%/polocloud-agent_%two_letters_code%.properties 4 | -------------------------------------------------------------------------------- /updater/src/main/kotlin/dev/httpmarco/polocloud/updater/GitHubTag.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.updater 2 | 3 | data class GitHubTag(val name: String) 4 | -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/utils/Reloadable.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.utils 2 | 3 | interface Reloadable { 4 | 5 | fun reload() 6 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/k8s/KubernetesConstant.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime.k8s 2 | 3 | val KUBERNETES_NAMESPACE = "polocloud" -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/k8s/KubernetesGroupStatus.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime.k8s 2 | 3 | class KubernetesGroupStatus { 4 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | kotlin.code.style=official 2 | # Project 3 | forceSign=true 4 | 5 | # Gradle 6 | org.gradle.jvmargs=-Xmx4G 7 | org.gradle.daemon=true 8 | org.gradle.caching=true -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/docker/DockerImageBuilder.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime.docker 2 | 3 | class DockerImageBuilder { 4 | 5 | 6 | 7 | 8 | } -------------------------------------------------------------------------------- /platforms/src/main/kotlin/dev/httpmarco/polocloud/platforms/exceptions/PlatformNotFoundException.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.platforms.exceptions 2 | 3 | class PlatformNotFoundException { 4 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/i18n/I18nPolocloudAgent.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.i18n 2 | 3 | class I18nPolocloudAgent() : I18nProvider("i18n/polocloud-agent") { 4 | 5 | } -------------------------------------------------------------------------------- /platforms/src/main/kotlin/dev/httpmarco/polocloud/platforms/bridge/BridgeType.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.platforms.bridge 2 | 3 | enum class BridgeType { 4 | 5 | ON_PREMISE, 6 | OFF_PREMISE, 7 | 8 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/detector/Detector.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.detector 2 | 3 | interface Detector { 4 | 5 | fun tick() 6 | 7 | fun cycleLife() : Long 8 | 9 | } -------------------------------------------------------------------------------- /platforms/src/main/kotlin/dev/httpmarco/polocloud/platforms/ServerPlatformForwarding.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.platforms 2 | 3 | enum class ServerPlatformForwarding { 4 | 5 | MODERN, 6 | LEGACY; 7 | 8 | 9 | } -------------------------------------------------------------------------------- /platforms/src/main/kotlin/dev/httpmarco/polocloud/platforms/bridge/BridgeConfig.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.platforms.bridge 2 | 3 | data class BridgeConfig( 4 | val className: String, 5 | val type: BridgeType 6 | ) -------------------------------------------------------------------------------- /platforms/src/main/kotlin/dev/httpmarco/polocloud/platforms/tasks/TaskFileMode.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.platforms.tasks 2 | 3 | enum class TaskFileMode { 4 | 5 | EVERY, 6 | IF_EXISTS, 7 | IF_NOT_EXISTS 8 | 9 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/local/terminal/arguments/TerminalShortCut.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime.local.terminal.arguments 2 | 3 | data class TerminalShortCut(val key: Char, val value: String) { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /common/src/main/kotlin/dev/httpmarco/polocloud/common/json/GsonContext.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.common.json 2 | 3 | import com.google.gson.GsonBuilder 4 | 5 | var GSON = GsonBuilder().create() 6 | var PRETTY_GSON = GsonBuilder().setPrettyPrinting().create() -------------------------------------------------------------------------------- /platforms/src/main/kotlin/dev/httpmarco/polocloud/platforms/exceptions/PlatformCacheMissingException.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.platforms.exceptions 2 | 3 | import java.lang.RuntimeException 4 | 5 | class PlatformCacheMissingException : RuntimeException() { 6 | } -------------------------------------------------------------------------------- /docker/setup.md: -------------------------------------------------------------------------------- 1 | ### Setup Kubernetes Cluster 2 | 3 | FIRST CHANGE PATH IN docker-compose.yml FILE 4 | ``` 5 | docker run -d --name agent -p 8080:8080 -v C:\Users\mirco\Desktop\te\:/cloud/local -v /var/run/docker.sock:/var/run/docker.sock polocloud:development 6 | ``` 7 | 8 | -------------------------------------------------------------------------------- /platforms/src/main/kotlin/dev/httpmarco/polocloud/platforms/exceptions/PlatformVersionInvalidException.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.platforms.exceptions 2 | 3 | import java.lang.RuntimeException 4 | 5 | class PlatformVersionInvalidException : RuntimeException() { 6 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/security/SecurityProvider.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.security 2 | 3 | import java.util.UUID 4 | 5 | class SecurityProvider { 6 | 7 | val proxySecureToken = UUID.randomUUID().toString().substring(0,8) 8 | 9 | } -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Jun 03 17:03:21 CEST 2025 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/local/LocalRuntimeGroupStorage.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime.local 2 | 3 | import dev.httpmarco.polocloud.agent.runtime.abstracts.AbstractGroupStorage 4 | 5 | class LocalRuntimeGroupStorage : AbstractGroupStorage() { 6 | 7 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/local/LocalConstants.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime.local 2 | 3 | import kotlin.io.path.Path 4 | 5 | val LOCAL_TEMPLATE_PATH = Path("local/templates") 6 | val LOCAL_FACTORY_PATH = Path("temp") 7 | val LOCAL_STATIC_FACTORY_PATH = Path("static") -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/configuration/Config.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.configuration 2 | 3 | import dev.httpmarco.polocloud.agent.Agent 4 | 5 | interface Config { 6 | 7 | fun save(path: String) { 8 | Agent.runtime.configHolder().write(path, this) 9 | } 10 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/docker/DockerThreadedRuntimeQueue.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime.docker 2 | 3 | import dev.httpmarco.polocloud.agent.runtime.abstracts.AbstractThreadedRuntimeQueue 4 | 5 | class DockerThreadedRuntimeQueue : AbstractThreadedRuntimeQueue(){ 6 | 7 | 8 | 9 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/abstracts/Track.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime.abstracts 2 | 3 | abstract class Track { 4 | 5 | protected val threads = mutableListOf() 6 | 7 | abstract fun start() 8 | 9 | fun close() { 10 | threads.forEach { it.interrupt() } 11 | } 12 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/local/terminal/commands/CommandExecution.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime.local.terminal.commands 2 | 3 | import dev.httpmarco.polocloud.agent.runtime.local.terminal.arguments.InputContext 4 | 5 | fun interface CommandExecution { 6 | fun execute(inputContext: InputContext) 7 | } -------------------------------------------------------------------------------- /launcher/src/main/java/dev/httpmarco/polocloud/launcher/lib/PolocloudLibNotFoundException.java: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.launcher.lib; 2 | 3 | public class PolocloudLibNotFoundException extends RuntimeException { 4 | 5 | public PolocloudLibNotFoundException(String lib) { 6 | super("Lib not found: " + lib); 7 | 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /platforms/src/main/kotlin/dev/httpmarco/polocloud/platforms/exceptions/DuplicatedPlatformActionException.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.platforms.exceptions 2 | 3 | import java.lang.RuntimeException 4 | 5 | class DuplicatedPlatformActionException(val id: String) : RuntimeException("A platform action with the same name is already registered! $id") { 6 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/k8s/KubernetesService.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime.k8s 2 | 3 | import dev.httpmarco.polocloud.agent.groups.AbstractGroup 4 | import dev.httpmarco.polocloud.agent.services.AbstractService 5 | 6 | class KubernetesService(abstractGroup: AbstractGroup) : AbstractService(abstractGroup) { 7 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/local/terminal/setup/SetupStep.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime.local.terminal.setup 2 | 3 | import dev.httpmarco.polocloud.agent.runtime.local.terminal.arguments.TerminalArgument 4 | 5 | class SetupStep(val questionKey: String, val argument: TerminalArgument, val action: (T) -> Unit = {}) { 6 | 7 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/docker/DockerRuntimeGroupStorage.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime.docker 2 | 3 | import dev.httpmarco.polocloud.agent.runtime.abstracts.AbstractGroupStorage 4 | import kotlin.io.path.Path 5 | 6 | open class DockerRuntimeGroupStorage() : AbstractGroupStorage(Path(("local/groups"))) { 7 | 8 | 9 | } 10 | -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM eclipse-temurin:21-jre 2 | 3 | WORKDIR /cloud 4 | 5 | ARG POLOCLOUD_VERSION=dev 6 | ENV POLOCLOUD_VERSION=$POLOCLOUD_VERSION 7 | 8 | COPY ../launcher/build/libs/polocloud-launcher.jar /cloud/polocloud-launcher.jar 9 | 10 | # Stop-Signal explizit setzen 11 | STOPSIGNAL SIGTERM 12 | 13 | ENTRYPOINT ["java", "-jar", "/cloud/polocloud-launcher.jar"] 14 | -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/RuntimeConfigHolder.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime 2 | 3 | import dev.httpmarco.polocloud.agent.configuration.Config 4 | 5 | interface RuntimeConfigHolder { 6 | 7 | fun read(fileName: String, defaultValue: T) : T 8 | 9 | fun write(fileName: String, value: T) 10 | 11 | } -------------------------------------------------------------------------------- /common/src/main/kotlin/dev/httpmarco/polocloud/common/math/ResourceCalculator.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.common.math 2 | 3 | import java.math.BigDecimal 4 | import java.math.RoundingMode 5 | 6 | fun convertBytesToMegabytes(bytes: Long?): Double { 7 | return BigDecimal(bytes?.div((1024 * 1024)) ?: 0) 8 | .setScale(2, RoundingMode.HALF_UP) 9 | .toDouble() 10 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/RuntimeLoader.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime 2 | 3 | interface RuntimeLoader { 4 | 5 | /** 6 | * Check if the runtime is runnable. 7 | * This method should be overridden by the specific runtime implementations 8 | */ 9 | fun runnable(): Boolean 10 | 11 | fun instance(): Runtime 12 | 13 | } -------------------------------------------------------------------------------- /common/src/main/kotlin/dev/httpmarco/polocloud/common/image/ImageConverter.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.common.image 2 | 3 | import java.io.InputStream 4 | import java.util.* 5 | 6 | fun pngToBase64DataUrl(stream: InputStream): String { 7 | val bytes = stream.readBytes() 8 | val base64 = Base64.getEncoder().encodeToString(bytes) 9 | return "data:image/png;base64,$base64" 10 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/player/PlayerStorage.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.player 2 | 3 | import dev.httpmarco.polocloud.shared.player.SharedPlayerProvider 4 | import java.util.UUID 5 | 6 | interface PlayerStorage : SharedPlayerProvider { 7 | 8 | fun addPlayer(player: AbstractPolocloudPlayer) 9 | 10 | fun removePlayer(uniqueId: UUID) 11 | 12 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/events/EventSubscription.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.events 2 | 3 | import dev.httpmarco.polocloud.shared.service.Service 4 | import dev.httpmarco.polocloud.v1.proto.EventProviderOuterClass 5 | import io.grpc.stub.ServerCallStreamObserver 6 | 7 | class EventSubscription(val service: Service, val sub : ServerCallStreamObserver) { 8 | 9 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/local/LocalRuntimeLoader.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime.local 2 | 3 | import dev.httpmarco.polocloud.agent.runtime.RuntimeLoader 4 | 5 | class LocalRuntimeLoader : RuntimeLoader { 6 | 7 | override fun runnable(): Boolean { 8 | return true 9 | } 10 | 11 | override fun instance(): LocalRuntime { 12 | return LocalRuntime() 13 | } 14 | } -------------------------------------------------------------------------------- /platforms/src/main/kotlin/dev/httpmarco/polocloud/platforms/tasks/actions/PlatformAction.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.platforms.tasks.actions 2 | 3 | import dev.httpmarco.polocloud.platforms.PlatformParameters 4 | import dev.httpmarco.polocloud.platforms.tasks.PlatformTaskStep 5 | import java.nio.file.Path 6 | 7 | abstract class PlatformAction() { 8 | 9 | abstract fun run(file: Path, step: PlatformTaskStep, environment: PlatformParameters) 10 | 11 | 12 | } -------------------------------------------------------------------------------- /common/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | kotlin("jvm") version "2.3.0" 3 | } 4 | 5 | dependencies { 6 | implementation("com.google.guava:guava:33.5.0-jre") 7 | testImplementation(kotlin("test")) 8 | api(libs.gson) 9 | compileOnly(libs.polocloud.proto) 10 | } 11 | 12 | tasks.test { 13 | useJUnitPlatform() 14 | } 15 | 16 | kotlin { 17 | jvmToolchain(21) 18 | } 19 | 20 | tasks.jar { 21 | archiveFileName.set("polocloud-common-$version.jar") 22 | } -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | maven("https://maven.fabricmc.net/") 5 | } 6 | } 7 | 8 | plugins { 9 | id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0" 10 | } 11 | 12 | enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") 13 | 14 | rootProject.name = "polocloudv3" 15 | include("agent") 16 | include("platforms") 17 | include("launcher") 18 | include("common") 19 | include("updater") -------------------------------------------------------------------------------- /common/src/main/kotlin/dev/httpmarco/polocloud/common/os/CurrentOS.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.common.os 2 | 3 | val currentOS: OS by lazy { 4 | val osName = System.getProperty("os.name").lowercase() 5 | when { 6 | "windows" in osName -> OS.WIN 7 | "linux" in osName -> OS.LINUX 8 | "mac" in osName -> OS.MACOS 9 | else -> OS.UNKNOWN 10 | } 11 | } 12 | 13 | val currentCPUArchitecture by lazy { 14 | System.getProperty("os.arch") 15 | } -------------------------------------------------------------------------------- /platforms/src/main/kotlin/dev/httpmarco/polocloud/platforms/tasks/PlatformTask.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.platforms.tasks 2 | 3 | import dev.httpmarco.polocloud.platforms.PlatformParameters 4 | import java.nio.file.Path 5 | 6 | data class PlatformTask(val name: String, val steps: List) { 7 | 8 | fun runTask(servicePath: Path, environment: PlatformParameters) { 9 | this.steps.forEach { 10 | it.run(servicePath, environment) 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /platforms/src/main/kotlin/dev/httpmarco/polocloud/platforms/tasks/PlatformTaskPool.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.platforms.tasks 2 | 3 | object PlatformTaskPool { 4 | 5 | private val tasks = ArrayList() 6 | 7 | fun attach(task: PlatformTask) { 8 | tasks.add(task) 9 | } 10 | 11 | fun find(id: String): PlatformTask? { 12 | return tasks.firstOrNull { it.name == id } 13 | } 14 | 15 | fun size(): Int { 16 | return tasks.size 17 | } 18 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/configuration/AgentConfig.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.configuration 2 | 3 | import java.util.Locale 4 | 5 | data class AgentConfig( 6 | var locale: Locale = Locale.ENGLISH, 7 | var autoUpdate: Boolean = true, 8 | var port: Int = 8932, 9 | //var statusLine: Boolean = true, 10 | var maxConcurrentServersStarts: Int = 4, 11 | var maxCachingProcesses: Int = 4, 12 | var maxCPUPercentageToStart: Double = 75.0 13 | ) : Config -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/player/AbstractPolocloudPlayer.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.player 2 | 3 | import dev.httpmarco.polocloud.shared.player.PolocloudPlayer 4 | import java.util.UUID 5 | 6 | class AbstractPolocloudPlayer( 7 | name: String, 8 | uniqueId: UUID, 9 | currentServerName: String, 10 | currentProxyName: String 11 | ) : PolocloudPlayer( 12 | name, 13 | uniqueId, 14 | currentServerName, 15 | currentProxyName 16 | ) { 17 | 18 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/RuntimeGroupStorage.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime 2 | 3 | import dev.httpmarco.polocloud.agent.groups.AbstractGroup 4 | import dev.httpmarco.polocloud.agent.utils.Reloadable 5 | import dev.httpmarco.polocloud.shared.groups.SharedGroupProvider 6 | 7 | interface RuntimeGroupStorage : SharedGroupProvider, Reloadable { 8 | 9 | override fun reload() { 10 | // Default implementation does nothing 11 | } 12 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/local/terminal/commands/impl/ShutdownCommand.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime.local.terminal.commands.impl 2 | 3 | import dev.httpmarco.polocloud.agent.exitPolocloud 4 | import dev.httpmarco.polocloud.agent.runtime.local.terminal.commands.Command 5 | 6 | class ShutdownCommand : Command("shutdown", "Shuts down the agent", "stop") { 7 | 8 | init { 9 | defaultExecution { 10 | exitPolocloud() 11 | } 12 | } 13 | 14 | } -------------------------------------------------------------------------------- /updater/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | kotlin("jvm") version "2.3.0" 3 | } 4 | 5 | dependencies { 6 | testImplementation(kotlin("test")) 7 | compileOnly(projects.common) 8 | } 9 | 10 | tasks.jar { 11 | manifest { 12 | attributes( 13 | "Main-Class" to "dev.httpmarco.polocloud.updater.UpdaterRuntime", 14 | "POLOCLOUD_VERSION" to version 15 | ) 16 | } 17 | archiveFileName.set("polocloud-updater-$version.jar") 18 | } 19 | 20 | kotlin { 21 | jvmToolchain(21) 22 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/docker/DockerImage.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime.docker 2 | 3 | import com.github.dockerjava.api.DockerClient 4 | import dev.httpmarco.polocloud.shared.template.Template 5 | 6 | class DockerImage(val client: DockerClient, name: String) : Template(name) { 7 | 8 | override fun size(): String { 9 | val info = client.inspectImageCmd(name).exec() 10 | val sizeBytes = info.size ?: 0L 11 | 12 | return humanReadableSize(sizeBytes) 13 | } 14 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/utils/JavaUtils.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.utils 2 | 3 | import java.io.File 4 | 5 | class JavaUtils { 6 | 7 | fun isValidJavaPath(javaPath: String): Boolean { 8 | val javaExecutable = if (System.getProperty("os.name").startsWith("Windows")) { 9 | File(javaPath, "bin/java.exe") 10 | } else { 11 | File(javaPath, "bin/java") 12 | } 13 | 14 | return javaExecutable.exists() && javaExecutable.canExecute() 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /platforms/src/test/kotlin/dev/httpmarco/polocloud/platforms/PlatformTest.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.platforms 2 | 3 | import dev.httpmarco.polocloud.platforms.metadata.MetadataReader 4 | import dev.httpmarco.polocloud.platforms.metadata.MetadataTranslator 5 | import dev.httpmarco.polocloud.platforms.tasks.PlatformTaskPool 6 | import org.junit.jupiter.api.Test 7 | 8 | class PlatformTest { 9 | 10 | @Test 11 | fun loadPool() { 12 | PlatformPool 13 | 14 | 15 | assert(PlatformTaskPool.size() != 0) 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /common/src/main/kotlin/dev/httpmarco/polocloud/common/language/Language.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.common.language 2 | 3 | import dev.httpmarco.polocloud.common.os.currentOS 4 | 5 | enum class Language(private var fileSuffix: String?, val nativeExecutable: Boolean) { 6 | 7 | JAVA("jar", false), 8 | GO(null, true), 9 | RUST(null, true); 10 | 11 | fun suffix(): String { 12 | val suffix = if (nativeExecutable) currentOS.nativeExecutableSuffix else fileSuffix 13 | 14 | return if (suffix != null) ".$suffix" else "" 15 | } 16 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/local/terminal/arguments/type/StringArrayArgument.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime.local.terminal.arguments.type 2 | 3 | import dev.httpmarco.polocloud.agent.runtime.local.terminal.arguments.TerminalArgument 4 | import dev.httpmarco.polocloud.agent.runtime.local.terminal.arguments.InputContext 5 | 6 | class StringArrayArgument(key: String) : TerminalArgument(key) { 7 | 8 | override fun buildResult(input: String, context: InputContext): String { 9 | return input 10 | } 11 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/local/terminal/commands/impl/ClearCommand.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime.local.terminal.commands.impl 2 | 3 | import dev.httpmarco.polocloud.agent.runtime.local.terminal.JLine3Terminal 4 | import dev.httpmarco.polocloud.agent.runtime.local.terminal.commands.Command 5 | 6 | class ClearCommand(private val terminal : JLine3Terminal) : Command("clear", "Clears the terminal screen", "cc") { 7 | 8 | init { 9 | defaultExecution { 10 | terminal.clearScreen() 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/information/CloudInformationStorage.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.information 2 | 3 | import dev.httpmarco.polocloud.shared.information.CloudInformation 4 | import dev.httpmarco.polocloud.shared.information.SharedCloudInformationProvider 5 | 6 | interface CloudInformationStorage : SharedCloudInformationProvider { 7 | 8 | fun addCloudInformation(cloudInformation: CloudInformation) 9 | 10 | fun removeCloudInformation(cloudInformation: CloudInformation) 11 | 12 | fun saveCurrentCloudInformation() 13 | 14 | } -------------------------------------------------------------------------------- /platforms/src/main/kotlin/dev/httpmarco/polocloud/platforms/tasks/actions/PlatformFileDeleteAction.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.platforms.tasks.actions 2 | 3 | import dev.httpmarco.polocloud.platforms.PlatformParameters 4 | import dev.httpmarco.polocloud.platforms.tasks.PlatformTaskStep 5 | import java.nio.file.Path 6 | import kotlin.io.path.deleteIfExists 7 | 8 | class PlatformFileDeleteAction : PlatformAction() { 9 | override fun run( 10 | file: Path, 11 | step: PlatformTaskStep, 12 | environment: PlatformParameters 13 | ) { 14 | file.deleteIfExists() 15 | } 16 | } -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "gradle" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | target-branch: "development" 11 | schedule: 12 | interval: "daily" 13 | -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/RuntimeFactory.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime 2 | 3 | import dev.httpmarco.polocloud.agent.groups.AbstractGroup 4 | import dev.httpmarco.polocloud.agent.services.AbstractService 5 | import dev.httpmarco.polocloud.v1.services.ServiceSnapshot 6 | 7 | interface RuntimeFactory { 8 | 9 | fun bootApplication(service: @UnsafeVariance T) 10 | 11 | fun shutdownApplication(service: @UnsafeVariance T, shutdownCleanUp : Boolean = true): ServiceSnapshot 12 | 13 | fun generateInstance(group: AbstractGroup) : T 14 | 15 | } -------------------------------------------------------------------------------- /common/src/main/kotlin/dev/httpmarco/polocloud/common/os/OS.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.common.os 2 | 3 | enum class OS( 4 | val nativeExecutableSuffix: String?, 5 | val shellPrefix: Array, 6 | val currentDirectoryPrefix: String? 7 | ) { 8 | WIN("exe", arrayOf("cmd", "/c"), null), 9 | LINUX(null, arrayOf("sh", "-c"), "./"), 10 | MACOS(null, arrayOf("sh", "-c"), "./"), 11 | UNKNOWN(null, emptyArray(), null); 12 | 13 | fun executableCurrentDirectoryCommand(filename: String): Array { 14 | return arrayOf(*shellPrefix, "${currentDirectoryPrefix ?: ""}$filename") 15 | } 16 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/k8s/KubernetesExpender.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime.k8s 2 | 3 | import dev.httpmarco.polocloud.agent.runtime.RuntimeExpender 4 | 5 | class KubernetesExpender : RuntimeExpender { 6 | 7 | override fun executeCommand( 8 | service: KubernetesService, 9 | command: String 10 | ) : Boolean { 11 | TODO("Not yet implemented") 12 | } 13 | 14 | override fun readLogs( 15 | service: KubernetesService, 16 | lines: Int 17 | ): List { 18 | TODO("Not yet implemented") 19 | } 20 | } -------------------------------------------------------------------------------- /platforms/src/main/kotlin/dev/httpmarco/polocloud/platforms/tasks/PlatformTaskStep.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.platforms.tasks 2 | 3 | import dev.httpmarco.polocloud.platforms.PlatformParameters 4 | import dev.httpmarco.polocloud.platforms.tasks.actions.PlatformAction 5 | import java.nio.file.Path 6 | 7 | class PlatformTaskStep(val name: String, val description: String, val filename: String, val action: PlatformAction) { 8 | 9 | fun run(servicePath: Path, environment: PlatformParameters) { 10 | this.action.run(servicePath.resolve(environment.modifyValueWithEnvironment(filename)), this, environment) 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/utils/IndexDetector.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.utils 2 | 3 | import dev.httpmarco.polocloud.agent.Agent 4 | import dev.httpmarco.polocloud.agent.groups.AbstractGroup 5 | 6 | class IndexDetector { 7 | 8 | companion object { 9 | fun findIndex(group: AbstractGroup): Int { 10 | var id = 1 11 | while (Agent.runtime.serviceStorage().findAll().stream() 12 | .anyMatch { it.groupName == group.name && it.id == id } 13 | ) { 14 | id++ 15 | } 16 | return id 17 | } 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/k8s/KubernetesGroup.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime.k8s 2 | 3 | import dev.httpmarco.polocloud.shared.service.Service 4 | import io.fabric8.kubernetes.api.model.Namespaced 5 | import io.fabric8.kubernetes.client.CustomResource 6 | import io.fabric8.kubernetes.model.annotation.Group 7 | import io.fabric8.kubernetes.model.annotation.Kind 8 | import io.fabric8.kubernetes.model.annotation.Version 9 | 10 | @Kind("Group") 11 | @Version("v1") 12 | @Group("polocloud.de") 13 | class KubernetesGroup(val name: String) : CustomResource(), Namespaced { 14 | 15 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/local/terminal/setup/impl/CustomPlatformSetup.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime.local.terminal.setup.impl 2 | 3 | import dev.httpmarco.polocloud.agent.runtime.local.terminal.arguments.InputContext 4 | import dev.httpmarco.polocloud.agent.runtime.local.terminal.setup.Setup 5 | import dev.httpmarco.polocloud.platforms.Platform 6 | 7 | class CustomPlatformSetup : Setup("Custom platform setup") { 8 | 9 | override fun bindQuestion() { 10 | TODO("Not yet implemented") 11 | } 12 | 13 | override fun onComplete(result: InputContext): Platform { 14 | TODO("Not yet implemented") 15 | } 16 | } -------------------------------------------------------------------------------- /common/src/main/kotlin/dev/httpmarco/polocloud/common/network/NetworkAddress.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.common.network 2 | 3 | import java.net.Inet4Address 4 | import java.net.NetworkInterface 5 | import kotlin.collections.iterator 6 | 7 | fun localAddress(): String { 8 | val interfaces = NetworkInterface.getNetworkInterfaces() 9 | for (iface in interfaces) { 10 | if (!iface.isLoopback && iface.isUp) { 11 | for (addr in iface.inetAddresses) { 12 | if (addr is Inet4Address && !addr.isLoopbackAddress) { 13 | return addr.hostAddress 14 | } 15 | } 16 | } 17 | } 18 | return "null" 19 | } -------------------------------------------------------------------------------- /platforms/src/main/kotlin/dev/httpmarco/polocloud/platforms/tasks/actions/PlatformFileReplacementAction.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.platforms.tasks.actions 2 | 3 | import dev.httpmarco.polocloud.platforms.PlatformParameters 4 | import dev.httpmarco.polocloud.platforms.tasks.PlatformTaskStep 5 | import java.nio.file.Path 6 | import kotlin.io.path.createDirectories 7 | import kotlin.io.path.createFile 8 | 9 | class PlatformFileReplacementAction() : PlatformAction() { 10 | 11 | override fun run( 12 | file: Path, 13 | step: PlatformTaskStep, 14 | environment: PlatformParameters 15 | ) { 16 | file.parent.createDirectories() 17 | file.createFile() 18 | } 19 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/local/terminal/commands/impl/ReloadCommand.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime.local.terminal.commands.impl 2 | 3 | import dev.httpmarco.polocloud.agent.Agent 4 | import dev.httpmarco.polocloud.agent.i18n 5 | import dev.httpmarco.polocloud.agent.runtime.local.terminal.commands.Command 6 | 7 | class ReloadCommand : Command("reload", "Reloads the agent configuration") { 8 | 9 | init { 10 | defaultExecution { 11 | i18n.info("agent.terminal.command.reload") 12 | 13 | Agent.runtime.groupStorage().reload() 14 | 15 | i18n.info("agent.terminal.command.reload.successful") 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: "[FEATURE] Theme" 5 | labels: feature 6 | assignees: HttpMarco, RECHERGG 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /platforms/src/main/kotlin/dev/httpmarco/polocloud/platforms/tasks/actions/PlatformFileWriteAction.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.platforms.tasks.actions 2 | 3 | import dev.httpmarco.polocloud.platforms.PlatformParameters 4 | import dev.httpmarco.polocloud.platforms.tasks.PlatformTaskStep 5 | import java.nio.file.Files 6 | import java.nio.file.Path 7 | import kotlin.io.path.createDirectories 8 | 9 | class PlatformFileWriteAction(val content: String) : PlatformAction() { 10 | 11 | override fun run( 12 | file: Path, 13 | step: PlatformTaskStep, 14 | environment: PlatformParameters 15 | ) { 16 | file.parent.createDirectories() 17 | 18 | Files.writeString(file, environment.modifyValueWithEnvironment(content)) 19 | } 20 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/local/terminal/arguments/InputContext.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime.local.terminal.arguments 2 | 3 | class InputContext { 4 | private val contexts = HashMap() 5 | 6 | @Suppress("UNCHECKED_CAST") 7 | fun arg(argument: TerminalArgument): T { 8 | return contexts[argument.key] as T 9 | } 10 | 11 | fun contains(argument: TerminalArgument<*>): Boolean { 12 | return contexts.containsKey(argument.key) 13 | } 14 | 15 | fun append(argument: TerminalArgument<*>, value: Any?) { 16 | this.contexts[argument.key] = value 17 | } 18 | 19 | fun remove(argument: TerminalArgument<*>) { 20 | this.contexts.remove(argument.key) 21 | } 22 | } -------------------------------------------------------------------------------- /platforms/src/main/kotlin/dev/httpmarco/polocloud/platforms/tasks/actions/PlatformFileMoveAction.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.platforms.tasks.actions 2 | 3 | import dev.httpmarco.polocloud.platforms.PlatformParameters 4 | import dev.httpmarco.polocloud.platforms.tasks.PlatformTaskStep 5 | import java.nio.file.Path 6 | 7 | class PlatformFileMoveAction(val oldPath: String, val newPath: String) : PlatformAction() { 8 | override fun run( 9 | file: Path, 10 | step: PlatformTaskStep, 11 | environment: PlatformParameters 12 | ) { 13 | file.resolve(environment.modifyValueWithEnvironment(oldPath)).toFile() 14 | .renameTo( 15 | file.resolve(environment.modifyValueWithEnvironment(newPath)).toFile() 16 | ) 17 | } 18 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/abstracts/AbstractServiceStatsThread.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime.abstracts 2 | 3 | import dev.httpmarco.polocloud.agent.Agent 4 | 5 | abstract class AbstractServiceStatsThread : Thread("polocloud-local-cpu-detection") { 6 | 7 | @Suppress("UNCHECKED_CAST") 8 | override fun run() { 9 | while (true) { 10 | Agent.runtime.serviceStorage().findAll().forEach { 11 | detectService(it as T) 12 | } 13 | 14 | try { 15 | sleep(1000) 16 | } catch (_: InterruptedException) { 17 | interrupt() 18 | break 19 | } 20 | } 21 | } 22 | 23 | abstract fun detectService(service: T) 24 | } -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[BUG] Theme" 5 | labels: bug 6 | assignees: HttpMarco, RECHERGG 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 16 | **Expected behavior** 17 | A clear and concise description of what you expected to happen. 18 | 19 | **Screenshots** 20 | If applicable, add screenshots to help explain your problem. 21 | 22 | **System (please complete the following information):** 23 | - OS 24 | - Java Version 25 | - PoloCloud Version 26 | - Service information 27 | - Addons with Version 28 | 29 | **Additional context** 30 | Add any other context about the problem here. 31 | -------------------------------------------------------------------------------- /.github/SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | We always support our latest release. 6 | If an issue occurs in an older version, we may discontinue it and take it down. 7 | However, we do not provide updates or security patches for older versions. 8 | 9 | ## Reporting a Vulnerability 10 | 11 | If you believe you have discovered a security vulnerability, please notify us immediately. 12 | 13 | We take all valid reports seriously and will investigate them promptly to resolve any issues as quickly as possible. 14 | 15 | We prefer that you use GitHub’s private vulnerability reporting feature to disclose potential security issues in our open source software. 16 | 17 | To do so, please visit the **Security** tab of this repository and click the **“Report a vulnerability”** button. 18 | -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/RuntimeServiceStorage.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime 2 | 3 | import dev.httpmarco.polocloud.agent.services.AbstractService 4 | import dev.httpmarco.polocloud.shared.service.SharedServiceProvider 5 | 6 | interface RuntimeServiceStorage : SharedServiceProvider { 7 | 8 | fun deployService(service: S) 9 | 10 | fun deployAbstractService(abstractService: AbstractService) { 11 | deployService(implementedService(abstractService)) 12 | } 13 | 14 | fun dropService(service: S) 15 | 16 | fun dropAbstractService(abstractService: AbstractService) { 17 | dropService(implementedService(abstractService)) 18 | } 19 | 20 | fun implementedService(abstractService: AbstractService) : S 21 | 22 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/k8s/KubernetesFactory.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime.k8s 2 | 3 | import dev.httpmarco.polocloud.agent.groups.AbstractGroup 4 | import dev.httpmarco.polocloud.agent.runtime.RuntimeFactory 5 | import dev.httpmarco.polocloud.v1.services.ServiceSnapshot 6 | 7 | class KubernetesFactory : RuntimeFactory { 8 | override fun bootApplication(service: KubernetesService) { 9 | TODO("Not yet implemented") 10 | } 11 | 12 | override fun shutdownApplication(service: KubernetesService, shutdownCleanUp: Boolean): ServiceSnapshot { 13 | TODO("Not yet implemented") 14 | } 15 | 16 | override fun generateInstance(group: AbstractGroup): KubernetesService { 17 | TODO("Not yet implemented") 18 | } 19 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/local/tracking/OnlineTrack.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime.local.tracking 2 | 3 | import dev.httpmarco.polocloud.agent.runtime.abstracts.Track 4 | import dev.httpmarco.polocloud.agent.runtime.local.LocalService 5 | 6 | class OnlineTrack(private val localService: LocalService) : Track() { 7 | 8 | override fun start() { 9 | this.threads.add(Thread.startVirtualThread { 10 | try { 11 | localService.process?.waitFor() 12 | }catch (_: InterruptedException) { 13 | // we can ignore this exception; it means the process was interrupted 14 | } 15 | 16 | // When the process ends -> we can detect it here 17 | localService.shutdown() 18 | }) 19 | } 20 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | build/ 3 | !gradle/wrapper/gradle-wrapper.jar 4 | !**/src/main/**/build/ 5 | !**/src/test/**/build/ 6 | 7 | ### IntelliJ IDEA ### 8 | .idea/modules.xml 9 | .idea/jarRepositories.xml 10 | .idea/compiler.xml 11 | .idea/libraries/ 12 | *.iws 13 | *.iml 14 | *.ipr 15 | out/ 16 | !**/src/main/**/out/ 17 | !**/src/test/**/out/ 18 | .idea/** 19 | .idea 20 | platforms/src/main/resources/** 21 | 22 | ### Kotlin ### 23 | .kotlin 24 | 25 | ### Eclipse ### 26 | .apt_generated 27 | .classpath 28 | .factorypath 29 | .project 30 | .settings 31 | .springBeans 32 | .sts4-cache 33 | bin/ 34 | !**/src/main/**/bin/ 35 | !**/src/test/**/bin/ 36 | 37 | ### NetBeans ### 38 | /nbproject/private/ 39 | /nbbuild/ 40 | /dist/ 41 | /nbdist/ 42 | /.nb-gradle/ 43 | 44 | ### VS Code ### 45 | .vscode/ 46 | 47 | ### Mac OS ### 48 | .DS_Store 49 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to PoloCloud 2 | 3 | Thanks for your interest in improving PoloCloud! 4 | Please follow these quick guidelines: 5 | 6 | ## Reporting Bugs 7 | - Use the **Bug Report** template. 8 | - Describe the issue, steps to reproduce, and your system info. 9 | 10 | ## Requesting Features 11 | - Use the **Feature Request** template. 12 | - Explain why the feature is useful and how it should work. 13 | 14 | ## Pull Requests 15 | 1. Fork the repo and create a new branch. 16 | 2. Follow coding style and keep changes focused. 17 | 3. Test before submitting. 18 | 4. Describe your changes clearly in the PR. 19 | 5. **Always select the `development` branch** unless explicitly asked by a maintainer to target another branch. 20 | 21 | By contributing, you agree your work will be licensed under the PoloCloud license. 22 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE: -------------------------------------------------------------------------------- 1 | # Pull Request 2 | 3 | ## Description 4 | Please provide a brief description of what this pull request does and what issue it addresses. 5 | 6 | ## Changes 7 | - What changes were made? 8 | - What new features were added? 9 | - Were any bugs fixed? 10 | 11 | ## Motivation and Context 12 | Why is this change necessary? 13 | Does it address a specific issue? (If yes, please reference the issue number) 14 | 15 | ## How Has This Been Tested? 16 | Please describe the tests you ran to verify your changes. 17 | 18 | ## Checklist 19 | - [ ] Code follows the project style guidelines 20 | - [ ] Tests have been added/updated 21 | - [ ] Documentation has been updated (if necessary) 22 | - [ ] No new warnings or errors introduced 23 | 24 | ## Screenshots (if applicable) 25 | If there are UI changes, please include screenshots. 26 | -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/local/terminal/commands/CommandSyntax.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime.local.terminal.commands 2 | 3 | import dev.httpmarco.polocloud.agent.runtime.local.terminal.arguments.TerminalArgument 4 | import dev.httpmarco.polocloud.agent.runtime.local.terminal.arguments.type.KeywordArgument 5 | 6 | class CommandSyntax( 7 | val execution: CommandExecution, 8 | val description: String?, 9 | val arguments: MutableList> 10 | ) { 11 | fun usage(): String { 12 | return java.lang.String.join( 13 | " ", arguments.stream() 14 | .map { if (it is KeywordArgument) "&f" + it.key else "&8<&f" + it.key + "&8>" } 15 | .toList() 16 | ) + (if (description == null) "" else " &8- &7$description") 17 | } 18 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/local/terminal/commands/impl/HelpCommand.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime.local.terminal.commands.impl 2 | 3 | import dev.httpmarco.polocloud.agent.i18n 4 | import dev.httpmarco.polocloud.agent.logger 5 | import dev.httpmarco.polocloud.agent.runtime.local.terminal.commands.Command 6 | import dev.httpmarco.polocloud.agent.runtime.local.terminal.commands.CommandService 7 | 8 | class HelpCommand(private val commandService: CommandService) : Command("help", "Show all available commands", "?") { 9 | 10 | init { 11 | defaultExecution { 12 | i18n.info("agent.terminal.command.help.info") 13 | commandService.commands.forEach { 14 | logger.info(" &8- &f${it.name}&8: &7${it.description}") 15 | } 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/local/terminal/arguments/type/TextArgument.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime.local.terminal.arguments.type 2 | 3 | import dev.httpmarco.polocloud.agent.i18n 4 | import dev.httpmarco.polocloud.agent.runtime.local.terminal.arguments.TerminalArgument 5 | import dev.httpmarco.polocloud.agent.runtime.local.terminal.arguments.InputContext 6 | 7 | class TextArgument(key: String) : TerminalArgument(key) { 8 | 9 | override fun buildResult(input: String, context: InputContext): String { 10 | return input 11 | } 12 | 13 | override fun predication(rawInput: String): Boolean { 14 | return rawInput.isNotBlank() 15 | } 16 | 17 | override fun wrongReason(rawInput: String): String { 18 | return i18n.get("agent.terminal.setup.argument.text.empty") 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/docker/DockerRuntimeLoader.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime.docker 2 | 3 | import dev.httpmarco.polocloud.agent.i18n 4 | import dev.httpmarco.polocloud.agent.runtime.Runtime 5 | import dev.httpmarco.polocloud.agent.runtime.RuntimeLoader 6 | import java.nio.file.Files 7 | import java.nio.file.Paths 8 | 9 | class DockerRuntimeLoader : RuntimeLoader { 10 | 11 | override fun runnable(): Boolean { 12 | return try { 13 | return Files.exists(Paths.get("/.dockerenv")) || Files.exists(Paths.get("/run/.containerenv")) 14 | } catch (e: Exception) { 15 | i18n.debug("agent.runtime.docker.connection.failed", e.javaClass.simpleName, e.message) 16 | false 17 | } 18 | } 19 | 20 | override fun instance(): Runtime { 21 | return DockerRuntime() 22 | } 23 | } -------------------------------------------------------------------------------- /platforms/src/main/kotlin/dev/httpmarco/polocloud/platforms/tasks/actions/PlatformExecuteCommandAction.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.platforms.tasks.actions 2 | 3 | import dev.httpmarco.polocloud.common.os.currentOS 4 | import dev.httpmarco.polocloud.platforms.PlatformParameters 5 | import dev.httpmarco.polocloud.platforms.tasks.PlatformTaskStep 6 | import java.nio.file.Path 7 | 8 | class PlatformExecuteCommandAction(val command: String) : PlatformAction() { 9 | override fun run( 10 | file: Path, 11 | step: PlatformTaskStep, 12 | environment: PlatformParameters 13 | ) { 14 | val builder = ProcessBuilder() 15 | 16 | 17 | builder.command(*currentOS.shellPrefix, environment.modifyValueWithEnvironment(command)) 18 | builder.directory(file.toFile()) 19 | val process = builder.start() 20 | 21 | process.waitFor() 22 | } 23 | } -------------------------------------------------------------------------------- /agent/src/main/kotlin/dev/httpmarco/polocloud/agent/runtime/RuntimeTemplateStorage.kt: -------------------------------------------------------------------------------- 1 | package dev.httpmarco.polocloud.agent.runtime 2 | 3 | import dev.httpmarco.polocloud.agent.services.AbstractService 4 | import dev.httpmarco.polocloud.agent.utils.Reloadable 5 | import dev.httpmarco.polocloud.shared.template.SharedTemplateProvider 6 | import dev.httpmarco.polocloud.shared.template.Template 7 | 8 | interface RuntimeTemplateStorage : SharedTemplateProvider, Reloadable { 9 | 10 | fun availableTemplates() : List