add option to disable secureboot

This commit is contained in:
Husky
2025-10-12 16:56:33 -04:00
parent 21573ce3fb
commit d8592cddc7
4 changed files with 27 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
kick_message: "<red>Server did not startup properly, please contact an @Admin!</red>"
# enable or disable secureboot
enable: ${CIV_SECUREBOOT_ENABLE}
# Plugin names that SecureBoot will require to be enabled
required_plugins:
- "CivModCore"
- "testpluginthatdoesnotexist"

View File

@@ -89,6 +89,8 @@ services:
CIV_RABBITMQ_USERNAME: rabbitmq
CIV_RABBITMQ_PASSWORD: rabbitmq
CIV_SECUREBOOT_ENABLE: 'false'
JVM_OPTS: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005
CIV_WATCHDOG_TIMEOUT_TIME: 6000
CIV_FORWARDING_SECRET: '1234'

View File

@@ -28,6 +28,8 @@ enum PluginStatus {
@SuppressWarnings("UnstableApiUsage")
public final class SecureBootPlugin extends JavaPlugin implements Listener {
private boolean enabled = true;
private final Map<String, PluginStatus> pluginState = Collections.synchronizedMap(new TreeMap<>(String.CASE_INSENSITIVE_ORDER));
private final MiniMessage mm = MiniMessage.miniMessage();
private @NotNull Component kickMessage = Component.text("Server is in maintenance mode.");
@@ -36,6 +38,13 @@ public final class SecureBootPlugin extends JavaPlugin implements Listener {
@Override
public void onLoad() {
saveDefaultConfig();
enabled = getConfig().getBoolean("enable", true);
if (!enabled) {
getSLF4JLogger().info("SecureBoot is disabled in config, skipping checks.");
return;
}
// ensure required plugins have a status
getConfig().getStringList("required_plugins").forEach((plugin) -> this.pluginState.put(plugin, PluginStatus.AWAITING_STATUS));
getSLF4JLogger().debug("Awaiting status for: {}", String.join(", ", this.pluginState.keySet()));
@@ -47,6 +56,10 @@ public final class SecureBootPlugin extends JavaPlugin implements Listener {
@Override
public void onEnable() {
if (!enabled) {
return;
}
Bukkit.getPluginManager().registerEvents(this, this);
// add all plugins loaded by the server

View File

@@ -1,6 +1,9 @@
# kick message sent to users if secureboot finds a required plugin missing or disabled
kick_message: "<red>Server did not startup properly, please contact an @Admin!</red>"
# enable or disable secureboot
enable: true
# Plugin names that SecureBoot will require to be enabled
required_plugins:
- "CivModCore"