3 # Save voicemail server options
5 require './vgetty-lib.pl';
7 &error_setup($text{'options_err'});
11 $in{'rings'} =~ /^\d+$/ || &error($text{'options_erings'});
12 $in{'rings'} >= 2 || &error($text{'options_erings2'});
13 $ans = &parse_answer_mode("ans");
14 $in{'maxlen'} =~ /^\d+$/ || &error($text{'options_emaxlen'});
15 $in{'minlen'} =~ /^\d+$/ || &error($text{'options_eminlen'});
16 $in{'thresh'} =~ /^\d+$/ || &error($text{'options_ethresh'});
17 if (!$in{'rgain_def'}) {
18 $in{'rgain'} =~ /^\d+$/ || &error($text{'options_ergain'});
19 $in{'rgain'} >= 0 && $in{'rgain'} <= 100 ||
20 &error($text{'options_ergain2'});
22 if (!$in{'tgain_def'}) {
23 $in{'tgain'} =~ /^\d+$/ || &error($text{'options_etgain'});
24 $in{'tgain'} >= 0 && $in{'tgain'} <= 100 ||
25 &error($text{'options_etgain2'});
27 defined(getpwnam($in{'owner'})) || &error($text{'options_eowner'});
28 defined(getgrnam($in{'group'})) || &error($text{'options_egroup'});
29 $in{'mode'} =~ /^0[0-7]{3}$/ || &error($text{'options_emode'});
30 if ($in{'prog_mode'} == 1) {
31 $in{'email'} =~ /^\S+$/ || &error($text{'options_eemail'});
33 elsif ($in{'prog_mode'} == 2) {
34 $in{'prog'} =~ /^(\S+)/ && &has_command($1) ||
35 &error($text{'options_eprog'});
38 # Write to config files
39 &lock_file($config{'vgetty_config'});
40 $rings = &find_value("rings", \@conf);
41 if ($in{'rings_port'}) {
42 local $tf = $rings =~ /^\// ? $rings : "/etc/rings";
43 &open_lock_tempfile(TF, ">$tf");
44 &print_tempfile(TF, $in{'rings'},"\n");
46 &save_directive(\@conf, "rings", $tf);
49 if ($rings =~ /^\//) {
54 &save_directive(\@conf, "rings", $in{'rings'});
56 $ans = &find_value("answer_mode", \@conf);
57 $mode = &parse_answer_mode("ans");
58 if ($in{'ans_port'}) {
59 local $tf = $ans =~ /^\// ? $ans : "/etc/answer";
60 &open_lock_tempfile(TF, ">$tf");
61 &print_tempfile(TF, "$mode\n");
63 &save_directive(\@conf, "answer_mode", $tf);
71 &save_directive(\@conf, "answer_mode", $mode);
74 &save_directive(\@conf, "rec_max_len", $in{'maxlen'});
75 &save_directive(\@conf, "rec_min_len", $in{'minlen'});
76 &save_directive(\@conf, "rec_remove_silence", $in{'silence'} ? "true" :"false");
77 &save_directive(\@conf, "rec_silence_threshold", $in{'thresh'});
78 &save_directive(\@conf, "receive_gain", $in{'rgain_def'} ? -1 : $in{'rgain'});
79 &save_directive(\@conf, "transmit_gain", $in{'tgain_def'} ? -1 : $in{'tgain'});
80 &save_directive(\@conf, "rec_always_keep", $in{'keep'} ? "true" : "false");
81 &save_directive(\@conf, "do_message_light", $in{'light'} ? "true" : "false");
82 &save_directive(\@conf, "phone_owner", $in{'owner'});
83 &save_directive(\@conf, "phone_group", $in{'group'});
84 &save_directive(\@conf, "phone_mode", $in{'mode'});
85 if ($in{'prog_mode'} == 1) {
86 # Need to create the email wrapper script
87 local $script = "$module_config_directory/email.pl";
88 $perl_path = &get_perl_path();
90 &open_tempfile(SCRIPT, ">$script");
91 &print_tempfile(SCRIPT, <<EOF
92 #!/bin/sh -- # -*- perl -*-
93 eval 'exec $perl_path -S \$0 \${1+"\$\@"}'
94 if \$running_under_some_shell;
95 open(CONF, "$config_directory/miniserv.conf");
97 \$root = \$1 if (/^root=(.*)/);
100 \$ENV{'WEBMIN_CONFIG'} = "$ENV{'WEBMIN_CONFIG'}";
101 \$ENV{'WEBMIN_VAR'} = "$ENV{'WEBMIN_VAR'}";
102 chdir("\$root/$module_name");
103 exec("\$root/$module_name/email.pl", \$ARGV[0]);
106 &close_tempfile(CMD);
107 chmod(0755, $script);
108 &unlock_file($script);
109 &save_directive(\@conf, "message_program", $script);
110 $config{'email_to'} = $in{'email'};
111 &save_module_config();
113 elsif ($in{'prog_mode'} == 2) {
114 &save_directive(\@conf, "message_program", $in{'prog'});
117 &save_directive(\@conf, "message_program", "");
120 &unlock_file($config{'vgetty_config'});
121 &webmin_log("options");