Configuration Management
File parsing and configuration management in FeatherPanel spells
Configuration Management
FeatherPanel's spell system provides powerful configuration file parsing and management capabilities. This allows spells to automatically modify configuration files before server startup, ensuring proper server configuration without manual intervention.
Configuration File Parsing
Supported File Formats
FeatherPanel supports parsing and modifying several configuration file formats:
1. Properties Files
Java properties files and similar key-value formats:
server-port=25565
server-ip=0.0.0.0
max-players=20
enable-query=true2. YAML Files
YAML configuration files with support for complex structures:
server:
port: 25565
ip: 0.0.0.0
max-players: 20
query:
enabled: true
port: 255653. JSON Files
JSON configuration files with object and array support:
{
"server": {
"port": 25565,
"ip": "0.0.0.0",
"max-players": 20,
"query": {
"enabled": true,
"port": 25565
}
}
}4. INI Files
INI configuration files with section support:
[server]
port=25565
ip=0.0.0.0
max-players=20
[query]
enabled=true
port=255655. XML Files
XML configuration files with element and attribute support:
<server>
<port>25565</port>
<ip>0.0.0.0</ip>
<max-players>20</max-players>
<query enabled="true" port="25565" />
</server>Configuration Parsers
Properties Parser
For Java properties files and similar key-value formats:
{
"config_files": {
"server.properties": {
"parser": "properties",
"find": {
"server-port": "{{SERVER_PORT}}",
"server-ip": "0.0.0.0",
"max-players": "{{MAX_PLAYERS}}",
"enable-query": "true"
}
}
}
}Example Properties File:
# Server Configuration
server-port=25565
server-ip=0.0.0.0
max-players=20
enable-query=true
query.port=25565
level-name=world
gamemode=survival
difficulty=normalYAML Parser
For YAML files with support for complex structures and wildcards:
{
"config_files": {
"config.yml": {
"parser": "yaml",
"find": {
"server.port": "{{SERVER_PORT}}",
"server.ip": "0.0.0.0",
"server.max-players": "{{MAX_PLAYERS}}",
"listeners[0].query_enabled": true,
"listeners[0].query_port": "{{SERVER_PORT}}",
"listeners[0].host": "0.0.0.0:{{SERVER_PORT}}",
"servers.*.address": {
"127.0.0.1": "{{config.docker.interface}}",
"localhost": "{{config.docker.interface}}"
}
}
}
}
}Example YAML File:
server:
port: 25565
ip: 0.0.0.0
max-players: 20
query:
enabled: true
port: 25565
listeners:
- query_enabled: true
query_port: 25565
host: 0.0.0.0:25565
servers:
main:
address: 127.0.0.1
port: 25565
backup:
address: localhost
port: 25566JSON Parser
For JSON files with support for objects, arrays, and wildcards:
{
"config_files": {
"config.json": {
"parser": "json",
"find": {
"server.port": "{{SERVER_PORT}}",
"server.ip": "0.0.0.0",
"server.max-players": "{{MAX_PLAYERS}}",
"plugins.*.enabled": true,
"plugins.*.config.port": "{{SERVER_PORT}}"
}
}
}
}Example JSON File:
{
"server": {
"port": 25565,
"ip": "0.0.0.0",
"max-players": 20
},
"plugins": [
{
"name": "plugin1",
"enabled": true,
"config": {
"port": 25565
}
},
{
"name": "plugin2",
"enabled": true,
"config": {
"port": 25565
}
}
]
}INI Parser
For INI files with section support:
{
"config_files": {
"config.ini": {
"parser": "ini",
"find": {
"server.port": "{{SERVER_PORT}}",
"server.ip": "0.0.0.0",
"server.max-players": "{{MAX_PLAYERS}}",
"query.enabled": "true",
"query.port": "{{SERVER_PORT}}"
}
}
}
}Example INI File:
[server]
port=25565
ip=0.0.0.0
max-players=20
[query]
enabled=true
port=25565
[database]
host=localhost
port=3306
name=minecraftXML Parser
For XML files with element and attribute support:
{
"config_files": {
"config.xml": {
"parser": "xml",
"find": {
"server.port": "{{SERVER_PORT}}",
"server.ip": "0.0.0.0",
"server.max-players": "{{MAX_PLAYERS}}",
"query.@enabled": "true",
"query.@port": "{{SERVER_PORT}}"
}
}
}
}Example XML File:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<server>
<port>25565</port>
<ip>0.0.0.0</ip>
<max-players>20</max-players>
</server>
<query enabled="true" port="25565" />
<database>
<host>localhost</host>
<port>3306</port>
<name>minecraft</name>
</database>
</configuration>Advanced Configuration Features
Wildcard Matching
Both YAML and JSON parsers support wildcard matching for arrays and objects:
YAML Wildcards
{
"config.yml": {
"parser": "yaml",
"find": {
"servers.*.address": "{{config.docker.interface}}",
"plugins.*.enabled": true,
"listeners[*].port": "{{SERVER_PORT}}"
}
}
}JSON Wildcards
{
"config.json": {
"parser": "json",
"find": {
"servers.*.address": "{{config.docker.interface}}",
"plugins.*.enabled": true,
"listeners[*].port": "{{SERVER_PORT}}"
}
}
}Multiple Find and Replace
You can define multiple find and replace operations for a single matching pattern:
{
"config.yml": {
"parser": "yaml",
"find": {
"servers.*.address": {
"127.0.0.1": "{{config.docker.interface}}",
"localhost": "{{config.docker.interface}}",
"0.0.0.0": "{{config.docker.interface}}"
}
}
}
}Conditional Configuration
You can use conditional logic based on environment variables:
{
"config.yml": {
"parser": "yaml",
"find": {
"server.mode": "{{SERVER_MODE}}",
"server.debug": "{{DEBUG_MODE}}",
"server.port": "{{SERVER_PORT}}"
}
}
}Variable Replacement
System Variables
Built-in variables available to all spells:
| Variable | Description | Example |
|---|---|---|
{{SERVER_MEMORY}} | Allocated memory in MB | 1024 |
{{SERVER_PORT}} | Primary server port | 25565 |
{{SERVER_IP}} | Server IP address | 127.0.0.1 |
{{TZ}} | Timezone setting | UTC |
{{P_SERVER_UUID}} | Server UUID | 539fdca8-4a08-4551-a8d2-8ee5475b50d9 |
{{P_SERVER_LOCATION}} | Server location | Example City |
{{P_SERVER_ALLOCATION_LIMIT}} | Allocation limit | 0 |
Custom Variables
User-defined variables from spell configuration:
{
"variables": [
{
"name": "Server JAR File",
"env_variable": "SERVER_JARFILE",
"default_value": "server.jar"
},
{
"name": "Max Players",
"env_variable": "MAX_PLAYERS",
"default_value": "20"
},
{
"name": "World Name",
"env_variable": "WORLD_NAME",
"default_value": "world"
}
]
}Environment Variables
Variables can be accessed in different contexts:
In Startup Commands
java -Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}}In Configuration Files
{
"server.properties": {
"parser": "properties",
"find": {
"max-players": "{{MAX_PLAYERS}}",
"level-name": "{{WORLD_NAME}}"
}
}
}In Shell Scripts
export SERVER_NAME="{{SERVER_NAME}}"
export MAX_PLAYERS="{{MAX_PLAYERS}}"Configuration Examples
Minecraft Server Configuration
{
"config_files": {
"server.properties": {
"parser": "properties",
"find": {
"server-port": "{{SERVER_PORT}}",
"server-ip": "0.0.0.0",
"max-players": "{{MAX_PLAYERS}}",
"level-name": "{{WORLD_NAME}}",
"gamemode": "{{GAMEMODE}}",
"difficulty": "{{DIFFICULTY}}",
"enable-query": "true",
"query.port": "{{SERVER_PORT}}",
"enable-rcon": "{{ENABLE_RCON}}",
"rcon.port": "{{RCON_PORT}}",
"rcon.password": "{{RCON_PASSWORD}}"
}
},
"bukkit.yml": {
"parser": "yaml",
"find": {
"settings.allow-end": "{{ALLOW_END}}",
"settings.spawn-limits.monsters": "{{MONSTER_LIMIT}}",
"settings.spawn-limits.animals": "{{ANIMAL_LIMIT}}"
}
}
}
}Discord Bot Configuration
{
"config_files": {
"config.json": {
"parser": "json",
"find": {
"token": "{{BOT_TOKEN}}",
"prefix": "{{BOT_PREFIX}}",
"owner": "{{BOT_OWNER}}",
"database.host": "{{DB_HOST}}",
"database.port": "{{DB_PORT}}",
"database.name": "{{DB_NAME}}",
"database.user": "{{DB_USER}}",
"database.password": "{{DB_PASSWORD}}"
}
}
}
}Web Server Configuration
{
"config_files": {
"nginx.conf": {
"parser": "file",
"find": {
"listen 80": "listen {{SERVER_PORT}}",
"server_name localhost": "server_name {{SERVER_NAME}}",
"root /var/www/html": "root {{WEB_ROOT}}"
}
},
"php.ini": {
"parser": "ini",
"find": {
"upload_max_filesize": "{{UPLOAD_MAX_FILESIZE}}",
"post_max_size": "{{POST_MAX_SIZE}}",
"memory_limit": "{{MEMORY_LIMIT}}"
}
}
}
}Best Practices
Configuration Design
- Use appropriate parsers for each file type
- Validate configuration before applying changes
- Handle missing variables gracefully
- Provide fallback values for optional settings
- Test file parsing with various configurations
Variable Management
- Use descriptive variable names and descriptions
- Set appropriate validation rules for each variable
- Provide helpful default values
- Group related variables logically
- Document variable usage and effects
File Organization
- Organize configuration files logically
- Use consistent naming conventions
- Document configuration options clearly
- Provide example configurations
- Handle file permissions properly
Error Handling
- Validate file syntax before parsing
- Handle missing files gracefully
- Provide meaningful error messages
- Log configuration changes for debugging
- Test error conditions thoroughly
Troubleshooting
Common Issues
Configuration Not Applied
- Verify file parser is correct for file type
- Check variable names match exactly (case-sensitive)
- Ensure files exist in container at specified paths
- Validate JSON syntax in config_files section
Variables Not Replaced
- Ensure variable names are uppercase and use underscores
- Check that variables are defined in spell configuration
- Verify default values are set for all variables
- Test variable replacement manually
File Parsing Errors
- Check file syntax is valid for the specified parser
- Verify file encoding is correct (UTF-8 recommended)
- Ensure file permissions allow reading
- Test parsing with sample files
Wildcard Matching Issues
- Verify wildcard syntax is correct for parser type
- Check that target elements exist in file structure
- Ensure wildcard patterns match actual file content
- Test wildcard matching with sample data
Debugging Tips
- Enable debug logging in FeatherPanel
- Check container logs for parsing errors
- Test variable replacement manually
- Validate file syntax with appropriate tools
- Use Docker exec to inspect files in running containers
This comprehensive configuration management system allows FeatherPanel spells to automatically handle complex configuration scenarios while maintaining flexibility and ease of use.