Fix to show only related config options for current boot system

This commit is contained in:
Ilia Ross
2026-06-12 23:59:36 +02:00
parent 2024a48acf
commit 53c3ee1c5d
6 changed files with 73 additions and 13 deletions

View File

@@ -5,7 +5,7 @@ order=Show boot order of actions?,1,1-Yes,0-No
status_check=Show current status of actions,1,2-On index and action pages,1-On action page only,0-No
sort_mode=Sort actions by,1,1-Boot order,0-Name
line2=System configuration,11
init_mode=Boot system,4,-Detect automatically,init-SysV init,upstart-Upstart,systemd-Systemd,osx-MacOS,rc-FreeBSD RC scripts,win32-Windows services,local-Single boot script
init_mode=Boot system,4,-Detect automatically,systemd-Systemd,init-SysV init,openrc-OpenRC,upstart-Upstart,local-Single boot script,rc-FreeBSD RC scripts,launchd-macOS launchd,osx-Legacy macOS StartupItems,win32-Windows services
init_base=Directory in which runlevel directories are located,0
init_dir=Directory containing master init scripts,0
order_digits=Number of digits in action order,0
@@ -17,8 +17,8 @@ shutdown_command=Command to shutdown the system,0
inittab_id=inittab ID for bootup runlevel,0
rc_dir=FreeBSD rc scripts directories,3,None
rc_conf=FreeBSD configuration files,3,None
line3=OSX system configuration,11
startup_dirs=Darwin StartupItems directories,0
line3=macOS StartupItems configuration,11
startup_dirs=macOS StartupItems directories,0
darwin_setup=Directory for custom StartupItems,0
hostconfig=Darwin hostconfig file,0
hostconfig=Legacy hostconfig file,0
plist=Name of plist in a StartupItems directory,0

View File

@@ -5,7 +5,7 @@ order=Mostra l'ordre d'engegada de les accions,1,1-Sí,0-No
status_check=Mostra l'estat actual de les accions,1,2-A les pàgines d'índex i de l'acció,1-Només a la pàgina de l'acció,0-No
sort_mode=Ordena les accions per,1,1-Ordre d'engegada,0-Nom
line2=Configuració del sistema,11
init_mode=Engegada del sistema,4,-Detecta-ho automàticament,init-Init de SysV,upstart-Upstart,systemd-Systemd,osx-MacOS,rc-Scripts RC de FreeBSD,win32-Serveis Windows,local-Script únic d'engegada
init_mode=Engegada del sistema,4,-Detecta-ho automàticament,systemd-Systemd,init-Init de SysV,openrc-OpenRC,upstart-Upstart,local-Script únic d'engegada,rc-Scripts RC de FreeBSD,launchd-macOS launchd,osx-Legacy macOS StartupItems,win32-Serveis Windows
init_base=Directori on s'allotgen els directoris de nivells d'execució,0
init_dir=Directori que conté els scripts init mestres,0
order_digits=Nombre de dígits de l'ordre de l'acció,0

View File

@@ -5,7 +5,7 @@ order=Zeige die Aktionen in Reihenfolge des Starts an?,1,1-Ja,0-Nein
status_check=Zeige aktuellen Status der Aktionen,1,2-Auf Index- und Aktionen-Seite,1-Nur auf der Aktionen-Seite,0-Nein
sort_mode=Sortiere Aktionen nach,1,1-Boot-Reihenfolge,0-Name
line2=Systemkonfiguration,11
init_mode=Boot-System,4,-automatisch erkennen,init-SysV init,upstart-Upstart,systemd-Systemd,osx-MacOS,rc-FreeBSD RC Script,win32-Windows-Dienste,local-Single Bootskript
init_mode=Boot-System,4,-automatisch erkennen,systemd-Systemd,init-SysV init,openrc-OpenRC,upstart-Upstart,local-Single Bootskript,rc-FreeBSD RC Script,launchd-macOS launchd,osx-Legacy macOS StartupItems,win32-Windows-Dienste
init_base=Verzeichnis, in dem die Runlevel-Verzeichnisse liegen,0
init_dir=Verzeichnis, in dem das Haupt-Skript liegt,0
order_digits=Anzahl Ziffern in Aktionsreihenfolge,0

View File

@@ -5,7 +5,7 @@ order=Vis handlingenes oppstartsrekkefølge?1,1-Ja,0-Nei
status_check=Vis handlingenes gjeldende status,1,2-På indeks- og handlingssider,1-Bare på handlingssider,0-Nei
sort_mode=Sorter handlinger etter,1,1-Oppstartrekkefølge,0-Navn
line2=System konfigurasjon,11
init_mode=Oppstartssystem,4,-Oppdag automatisk,init-SysV init,upstart-Upstart,systemd-Systemd,osx-MacOS,rc-FreeBSD RC scripts,win32-Windows tjenester,local-Enkelt oppstartsscript
init_mode=Oppstartssystem,4,-Oppdag automatisk,systemd-Systemd,init-SysV init,openrc-OpenRC,upstart-Upstart,local-Enkelt oppstartsscript,rc-FreeBSD RC scripts,launchd-macOS launchd,osx-Legacy macOS StartupItems,win32-Windows tjenester
init_base=Katalog hvor kjøretids-kataloger finnes,0
init_dir=Katalog som inneholder master init scripts,0
order_digits=Antall sifre i handlingssortering,0

View File

@@ -28,9 +28,9 @@ use WebminCore;
This variable is set based on the bootup system in use. Possible values are :
=item osx - MacOSX hostconfig files, for older versions
=item osx - Legacy macOS StartupItems and hostconfig files
=item launchd - MacOS Launchd, for newer versions
=item launchd - macOS launchd, for newer versions
=item rc - FreeBSD 6+ RC files
@@ -3142,11 +3142,70 @@ return $name =~ /\./ ? $name : "com.webmin.".$name;
}
# config_pre_load(mod-info, [mod-order])
# Check if some config options are conditional
# Hides config options that do not apply to the detected boot system.
sub config_pre_load
{
my ($modconf_info, $modconf_order) = @_;
$modconf_info->{'desc'} =~ s/2-[^,]+,// if ($init_mode eq "systemd");
return if (ref($modconf_info) ne 'HASH');
if ($init_mode eq "systemd" && $modconf_info->{'desc'}) {
# Systemd has no runlevels, so keep only the plain yes/no choices.
$modconf_info->{'desc'} =~ s/2-[^,]+,//;
}
my %keep = map { $_, 1 } &init_config_options_for_mode($init_mode);
foreach my $key (keys %$modconf_info) {
delete($modconf_info->{$key}) if (!$keep{$key});
}
if (ref($modconf_order) eq 'ARRAY') {
@$modconf_order = grep { $keep{$_} } @$modconf_order;
}
&hide_single_init_config_section($modconf_info, $modconf_order);
}
# init_config_options_for_mode(mode)
# Returns config.info keys that should be visible for a boot system.
sub init_config_options_for_mode
{
my ($mode) = @_;
my @display = ( 'expert', 'desc', 'order', 'status_check', 'sort_mode' );
my @common = ( 'init_mode', 'reboot_command', 'shutdown_command' );
my @sysv = ( @common, 'init_base', 'init_dir', 'order_digits',
'boot_levels', 'local_script', 'local_down', 'inittab_id' );
return ( 'line1', 'desc', 'line2', @common )
if ($mode eq 'systemd');
return ( 'line1', @display, 'line2', @sysv )
if ($mode eq 'init' || $mode eq 'upstart' || $mode eq 'openrc');
return ( 'line2', @common, 'local_script', 'local_down',
'rc_dir', 'rc_conf' )
if ($mode eq 'rc');
return ( 'line2', @common, 'local_script', 'local_down' )
if ($mode eq 'local');
return ( 'line2', @common, 'line3', 'startup_dirs', 'darwin_setup',
'hostconfig', 'plist' )
if ($mode eq 'osx');
return ( 'line2', @common )
if ($mode eq 'launchd' || $mode eq 'win32');
return ( 'line1', @display, 'line2', @sysv, 'rc_dir', 'rc_conf',
'line3', 'startup_dirs', 'darwin_setup', 'hostconfig', 'plist' );
}
# hide_single_init_config_section(&config-info, [&config-order])
# Removes the lone section header when filtering leaves only one group.
sub hide_single_init_config_section
{
my ($modconf_info, $modconf_order) = @_;
my @sections = grep {
exists($modconf_info->{$_}) &&
(split(/,/, $modconf_info->{$_}))[1] == 11
} keys %$modconf_info;
return if (@sections != 1);
delete($modconf_info->{$sections[0]});
if (ref($modconf_order) eq 'ARRAY') {
@$modconf_order = grep { $_ ne $sections[0] } @$modconf_order;
}
}
1;

View File

@@ -188,13 +188,14 @@ change_title=Switch Runlevel
change_cmd=Switching to runlevel $1 with command $2. This may take some time, and Webmin might not be available anymore after switching.
mode_init=SysV init
mode_osx=MacOS
mode_osx=Legacy macOS StartupItems
mode_local=Single boot script
mode_win32=Windows services
mode_rc=FreeBSD RC scripts
mode_upstart=Upstart
mode_systemd=Systemd
mode_launchd=LaunchD
mode_launchd=macOS launchd
mode_openrc=OpenRC
upstart_title1=Create Upstart Service
upstart_title2=Edit Upstart Service