if ($init_mode eq "osx") {
# Darwin System
- &open_tempfile(LOCAL, ">>$config{'hostconfig'}");
- &print_tempfile(LOCAL, "WEBMIN=-YES-\n");
- &close_tempfile(LOCAL);
-
- $paramlist = "$config{'darwin_setup'}/$ucproduct/$config{'plist'}";
- $scriptfile = "$config{'darwin_setup'}/$ucproduct/$ucproduct";
-
- # On a Virgin darwin system, $config{'darwin_setup'} may not yet exist
- -d "$config{'darwin_setup'}/$ucproduct" || do {
- if ( -d "$config{'darwin_setup'}" ) {
- mkdir ("$config{'darwin_setup'}/$ucproduct", 0755);
- } else {
- mkdir ("$config{'darwin_setup'}", 0755);
- mkdir ("$config{'darwin_setup'}/$ucproduct",0755);
- }
- } until -d "$config{'darwin_setup'}/$ucproduct";
-
- &open_tempfile(PLIST, ">$paramlist");
- &print_tempfile(PLIST, "{\n");
- &print_tempfile(PLIST, "\t\tDescription\t\t= \"$ucproduct system administration daemon\";\n");
- &print_tempfile(PLIST, "\t\tProvides\t\t= (\"$ucproduct\");\n");
- &print_tempfile(PLIST, "\t\tRequires\t\t= (\"Resolver\");\n");
- &print_tempfile(PLIST, "\t\tOrderPreference\t\t= \"None\";\n");
- &print_tempfile(PLIST, "\t\tMessages =\n");
- &print_tempfile(PLIST, "\t\t{\n");
- &print_tempfile(PLIST, "\t\t\tstart\t= \"Starting $ucproduct Server\";\n");
- &print_tempfile(PLIST, "\t\t\tstop\t= \"Stopping $ucproduct Server\";\n");
- &print_tempfile(PLIST, "\t\t};\n");
- &print_tempfile(PLIST, "}\n");
- &close_tempfile(PLIST);
-
- # Create Bootup Script
- &open_tempfile(STARTUP, ">$scriptfile");
- &print_tempfile(STARTUP, "#!/bin/sh\n\n");
- &print_tempfile(STARTUP, ". /etc/rc.common\n\n");
- &print_tempfile(STARTUP, "if [ \"\${WEBMIN:=-NO-}\" = \"-YES-\" ]; then\n");
- &print_tempfile(STARTUP, "\tConsoleMessage \"Starting $ucproduct\"\n");
- &print_tempfile(STARTUP, "\t$config_directory/start >/dev/null 2>&1 </dev/null\n");
- &print_tempfile(STARTUP, "fi\n");
- &close_tempfile(STARTUP);
- chmod(0750, $scriptfile);
+ &enable_at_boot("webmin", "Webmin administration server",
+ "/etc/webmin/start >/dev/null 2>&1 </dev/null",
+ "/etc/webmin/stop");
}
elsif ($init_mode eq "local") {
# Add to the boot time rc script
return !$rc ? 0 :
$rc->{'enabled'} ? 2 : 1;
}
+elsif ($init_mode eq "osx") {
+ # Look for a hostconfig entry
+ local $ucname = uc($_[0]);
+ local %hc;
+ &read_env_file($config{'hostconfig'}, \%hc);
+ return $hc{$ucname} eq '-YES-' ? 2 :
+ $hc{$ucname} eq '-NO-' ? 1 : 0;
+ }
}
# enable_at_boot(action, description, startcode, stopcode, statuscode)
}
&unlock_rc_files();
}
+elsif ($init_mode eq "osx") {
+ # Add hostconfig file entry
+ local $ucname = uc($_[0]);
+ local %hc;
+ &lock_file($config{'hostconfig'});
+ &read_env_file($config{'hostconfig'}, \%hc);
+ if (!$hc{$ucname}) {
+ # Need to create action
+ local $ucfirst = ucfirst($_[0]);
+ local $dir = "$config{'darwin_setup'}/$ucfirst";
+ local $paramlist = "$dir/$config{'plist'}";
+ local $scriptfile = "$dir/$ucfirst";
+
+ # Create dirs if missing
+ if (!-d $config{'darwin_setup'}) {
+ &make_dir($config{'darwin_setup'}, 0755);
+ }
+ if (!-d $dir) {
+ &make_dir($dir, 0755);
+ }
+
+ # Make params list file
+ &open_lock_tempfile(PLIST, ">$paramlist");
+ &print_tempfile(PLIST, "{\n");
+ &print_tempfile(PLIST, "\t\tDescription\t\t= \"$_[1]\";\n");
+ &print_tempfile(PLIST, "\t\tProvides\t\t= (\"$ucfirst\");\n");
+ &print_tempfile(PLIST, "\t\tRequires\t\t= (\"Resolver\");\n");
+ &print_tempfile(PLIST, "\t\tOrderPreference\t\t= \"None\";\n");
+ &print_tempfile(PLIST, "\t\tMessages =\n");
+ &print_tempfile(PLIST, "\t\t{\n");
+ &print_tempfile(PLIST, "\t\t\tstart\t= \"Starting $ucfirst\";\n");
+ &print_tempfile(PLIST, "\t\t\tstop\t= \"Stopping $ucfirst\";\n");
+ &print_tempfile(PLIST, "\t\t};\n");
+ &print_tempfile(PLIST, "}\n");
+ &close_tempfile(PLIST);
+
+ # Create Bootup Script
+ &open_lock_tempfile(STARTUP, ">$scriptfile");
+ &print_tempfile(STARTUP, "#!/bin/sh\n\n");
+ &print_tempfile(STARTUP, ". /etc/rc.common\n\n");
+ &print_tempfile(STARTUP, "if [ \"\${$ucname:=-NO-}\" = \"-YES-\" ]; then\n");
+ &print_tempfile(STARTUP, "\tConsoleMessage \"Starting $ucfirst\"\n");
+ &print_tempfile(STARTUP, "\t$_[2]\n");
+ &print_tempfile(STARTUP, "fi\n");
+ &close_tempfile(STARTUP);
+ &set_ownership_permissions(undef, undef, 0750, $scriptfile);
+ }
+
+ # Update hostconfig file
+ $hc{$ucname} = '-YES-';
+ &write_env_file($config{'hostconfig'}, \%hc);
+ &unlock_file($config{'hostconfig'});
+ }
}
# disable_at_boot(action)
&disable_rc_script($_[0]);
&unlock_rc_files();
}
+elsif ($init_mode eq "osx") {
+ # Disable in hostconfig
+ local $ucname = uc($_[0]);
+ local %hc;
+ &lock_file($config{'hostconfig'});
+ &read_env_file($config{'hostconfig'}, \%hc);
+ if ($hc{$ucname} eq '-YES-' || $hc{$ucname} eq '-AUTOMATIC-') {
+ $hc{$ucname} = '-NO-';
+ &write_env_file($config{'hostconfig'}, \%hc);
+ }
+ &unlock_file($config{'hostconfig'});
+ }
}
# start_action(name)