3 # Create an empty named.conf file and start the name server
5 require './bind8-lib.pl';
6 &error_setup($text{'boot_err'});
9 $config{'named_conf'} =~ /^(\S+)\/([^\/]+)$/;
11 $pid_file = $config{'pid_file'} || "/var/run/named.pid";
12 &lock_file(&make_chroot($config{'named_conf'}));
13 &lock_file(&make_chroot("$conf_directory/db.cache"));
14 $conf_temp = &transname("webmin.named.conf");
15 open(BOOT, ">$conf_temp");
16 print BOOT "options {\n";
17 print BOOT "\tdirectory \"$conf_directory\";\n";
18 print BOOT "\tpid-file \"$pid_file\";\n";
21 $chroot = &get_chroot();
22 if ($chroot && !-d $chroot) {
25 if (!-d &make_chroot($conf_directory)) {
26 mkdir(&make_chroot($conf_directory), 0755);
28 if ($config{'master_dir'} && !-d &make_chroot($config{'master_dir'})) {
29 mkdir(&make_chroot($config{'master_dir'}), 0755);
31 if ($config{'slave_dir'} && !-d &make_chroot($config{'slave_dir'})) {
32 mkdir(&make_chroot($config{'slave_dir'}), 0777);
34 if ($pid_file =~ /^(.*)\//) {
36 if (!-d &make_chroot($pid_dir)) {
37 mkdir(&make_chroot($pid_dir), 0777);
40 if (!-r &make_chroot($pid_file)) {
41 &open_tempfile(PID, ">".&make_chroot($pid_file));
43 &set_ownership(&make_chroot($pid_file));
46 # Create an empty root domain file... no need to do anything here
48 elsif ($in{real} == 1) {
49 # Try to download the root servers file from
50 # ftp://rs.internic.net/domain/named.root
51 $err = &download_root_zone("$conf_directory/db.cache");
52 &error($err) if ($err);
53 print BOOT "zone \".\" {\n";
54 print BOOT "\ttype hint;\n";
55 print BOOT "\tfile \"$conf_directory/db.cache\";\n";
59 elsif ($in{real} == 2) {
60 # Use builtin db.cache
61 &execute_command("cp ./db.cache ".&make_chroot("$conf_directory/db.cache"));
62 print BOOT "zone \".\" {\n";
63 print BOOT "\ttype hint;\n";
64 print BOOT "\tfile \"$conf_directory/db.cache\";\n";
69 ©_source_dest($conf_temp, &make_chroot($config{'named_conf'}));
71 &unlock_file(&make_chroot("$conf_directory/db.cache"));
72 &unlock_file(&make_chroot($config{'named_conf'}));
73 &set_ownership(&make_chroot("$conf_directory/db.cache"))
74 if ($in{'real'} == 2 || $in{'real'} == 1);
75 &set_ownership(&make_chroot($config{'named_conf'}));
77 &redirect("start.cgi");