Handle hostnames with upper-case letters
[webmin.git] / init / uninstall.pl
1 # uninstall.pl
2 # Called when webmin is uninstalled
3
4 require 'init-lib.pl';
5
6 sub module_uninstall
7 {
8 local %miniserv;
9 &get_miniserv_config(\%miniserv);
10 return if (!$miniserv{'atboot'});
11
12 local $product = $config{'atboot_product'} || "webmin";
13 local $ucproduct = ucfirst($product);
14
15 if ($init_mode eq "osx") {
16         # Remove from hostconfig file
17         open(LOCAL, $config{'hostconfig'});
18         @local = <LOCAL>;
19         close(LOCAL);
20         $start = "WEBMIN=-";
21         &open_tempfile(LOCAL, ">$config{'hostconfig'}");
22         &print_tempfile(LOCAL, grep { !/^$start/ } @local);
23         &close_tempfile(LOCAL);
24         print STDERR "Deleted from $config{'hostconfig'}\n";
25         # get rid of the startup items
26         $paramlist = "$config{'darwin_setup'}/$ucproduct/$config{'plist'}";
27         $scriptfile = "$config{'darwin_setup'}/$ucproduct/$ucproduct";
28         print STDERR "Deleting $config{'darwin_setup'}/$ucproduct ..";
29         unlink ($paramlist);
30         unlink ($scriptfile);
31         print STDERR "\. ", rmdir ("$config{'darwin_setup'}/$ucproduct") ? "Success":"Failed", "\n";
32         }
33 elsif ($init_mode eq "local") {
34         # Remove from boot time rc script
35         open(LOCAL, $config{'local_script'});
36         @local = <LOCAL>;
37         close(LOCAL);
38         $start = "$config_directory/start";
39         &open_tempfile(LOCAL, ">$config{'local_script'}");
40         &print_tempfile(LOCAL, grep { !/^$start/ } @local);
41         &close_tempfile(LOCAL);
42         print STDERR "Deleted from bootup script $config{'local_script'}\n";
43         }
44 elsif ($init_mode eq "init") {
45         # Delete bootup action
46         foreach (&action_levels('S', $product)) {
47                 /^(\S+)\s+(\S+)\s+(\S+)$/;
48                 &delete_rl_action($product, $1, 'S');
49                 }
50         foreach (&action_levels('K', $product)) {
51                 /^(\S+)\s+(\S+)\s+(\S+)$/;
52                 &delete_rl_action($product, $1, 'K');
53                 }
54         $fn = &action_filename($product);
55         unlink($fn);
56         print STDERR "Deleted init script $fn\n";
57         }
58 elsif ($init_mode eq "win32") {
59         # Delete win32 service
60         &delete_win32_service($product);
61         }
62 }
63
64 1;
65