Porting Webmin to a New Operating System

Because Webmin deals with system configuration files that differ in format and location between versions of Unix, it needs to have a substantial amount of build-in knowledge of the locations of files and program on each supported operating system.

For example, many Unix variants include a package for the Apache webserver, but use different paths for its configuration files. Redhat Linux has them in /etc/httpd/conf, but FreeBSD uses /usr/local/etc/apache. As the "Module Configuration" section explains, the Apache module contains many different files starting with config-, each of which contains module configuration settings for a particular operating system (and version). At install time, one is selected and copied to /etc/webmin/apache/config to be used by the module.

Almost all modules contain several such configuration files, except those that are completely independent of the operating system in use. For example, the System and Server Status module does not actually configure any other server or service whose location may different, and so has only a single config file.

As well as the config- files, some modules put code that differs between operating systems into a separate Perl library that is read at run time. For example, the Disk Quotas module contains libraries like redhat-linux-lib.pl, solaris-lib.pl and so on, one for each OS that the module supports. Each contains functions specific to that operating system. Some other modules (like Running Processes) have multiple -lib.pl files, but not one for each operating system. Instead, the configuration for each OS specifies which one to use, as many Unix variants have similar ps commands (which is what that module deals with).

Quite a few modules are available only on certain operating systems, such as Partitions on Local Disks (fdisk). Modules like this have an os_support= line in their module.info file (covered in the "Required Files" section).

If you want to port Webmin to some currently unsupported operating system or Linux distribution, there are two ways that it can be done. If the OS is identical to one that is already supported by Webmin, you just need to add a line to the os_list.txt file in Webmin's root directory. Many Linux distributions use the exact same configuration file formats and locations as one of the more popular Linux variants (like Redhat or Debian). If this is the case with the OS that you want to support, you just need to add a line like :

Foobar Linux	1.0	redhat-linux	7.3	`cat /etc/foobar-release 2>&1` =~ /Foobar.*1\.0/i
As you can see, the line is made up of five fields, separated by tabs. They are :
  • The operating system name visible to the user.
  • The version number visible to the user.
  • Webmin's internal code for the operating system, which you can find by looking at other entries in the file. This determines which actual config- files are used at installation time, and which modules are visible.
  • Webmin's internal version number for the operating system. Again, this is what actually determines which config- files to use when the OS is chosen.
  • A fragment of Perl code that is run at installation time to check for this operating system. If it evaluates to some some non-zero value, Webmin will never ask the user to choose his OS from a list when setup.sh is run. If you want the RPM version to be installable on this OS, this field must be filled in so that the RPM installation script can detect it - otherwise the install will fail.

If however your OS is completely different to any currently supported, a complete port to it will need to be done. This is fairly complex, as each module needs to be ported individually. The steps to follow are :

  1. Add a new line to os_list.txt for each version of the new OS, with it's own unique operating system code. For example, the line might look like :
    FooNix	1.0	foonix	1.0	`uname -a` =~ /FooNix 1.0/i
    

  2. In each module that you want to port, edit the module.info file and add your OS code (such as foonix) to the os_support line, if there is one.

  3. Also in each module to port, create a new config-foonix file containing the settings for your OS. If the module does not have multiple config- files, this may not be necessary (because it works the same on every operating system).

  4. If a module uses -lib.pl files, create one for your OS that implements all of the functions in the correct way.

  5. In the top-level Webmin directory, create a config-foonix file with the correct settings for your OS. In particular, the path, ld_path and find_pid_command fields must be set correctly.

Once all this is done, you should be able to run ./setup.sh, select the new OS and all of the configuration files will be copied into /etc/webmin correctly.

Finally, if you want your new OS port to be included in the main Webmin distribution, tar up all of the files that you changed or created and email them to me at jcameron@webmin.com .