3 Functions for the Foobar Web Server. This is an example Webmin module for a
4 simple fictional webserver.
11 =head2 list_foobar_websites()
13 Returns a list of all websites served by the Foobar webserver, as hash
14 references with C<domain> and C<directory> keys.
17 sub list_foobar_websites
21 open(CONF, $config{'foobar_conf'});
25 my ($dom, $dir) = split(/\s+/, $_);
27 push(@rv, { 'domain' => $dom,
37 =head2 create_foobar_website(&site)
39 Adds a new website, specified by the C<site> hash reference parameter, which
40 must contain C<domain> and C<directory> keys.
43 sub create_foobar_website
46 open_tempfile(CONF, ">>$config{'foobar_conf'}");
47 print_tempfile(CONF, $site->{'domain'}." ".$site->{'directory'}."\n");
51 =head2 modify_foobar_website(&site)
53 Updates a website specified by the C<site> hash reference parameter, which
54 must be a modified entry returned from the C<list_foobar_websites> function.
57 sub modify_foobar_website
60 my $lref = read_file_lines($config{'foobar_conf'});
61 $lref->[$site->{'line'}] = $site->{'domain'}." ".$site->{'directory'};
62 flush_file_lines($config{'foobar_conf'});
65 =head2 delete_foobar_website(&site)
67 Deletes a website, specified by the C<site> hash reference parameter, which
68 must have been one of the elements returned by C<list_foobar_websites>
71 sub delete_foobar_website
74 my $lref = read_file_lines($config{'foobar_conf'});
75 splice(@$lref, $site->{'line'}, 1);
76 flush_file_lines($config{'foobar_conf'});
79 =head2 apply_configuration()
81 Signal the Foobar webserver process to re-read it's configuration files.
84 sub apply_configuration
86 kill_byname_logged('HUP', 'foobard');