X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2FConf.pm;h=25c6743012cc4f4d20170420b33692a56c79440f;hp=7a4a719667f3ea4817f1a9b81eab025595a488e2;hb=e1ef1693e6942bbf82ee088f782d871a3b5eefee;hpb=b35b650a6078d645d6f97620f3c79ae941915dd9 diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 7a4a71966..25c674301 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -2,6 +2,7 @@ package FS::Conf; use vars qw($default_dir @config_items $DEBUG ); use IO::File; +use File::Basename; use FS::ConfItem; $DEBUG = 0; @@ -25,6 +26,10 @@ FS::Conf - Freeside configuration values @list = $conf->config('key'); $bool = $conf->exists('key'); + $conf->touch('key'); + $conf->set('key' => 'value'); + $conf->delete('key'); + @config_items = $conf->config_items; =head1 DESCRIPTION @@ -67,7 +72,7 @@ sub dir { $1; } -=item config +=item config KEY Returns the configuration value or values (depending on context) for key. @@ -90,7 +95,7 @@ sub config { } } -=item exists +=item exists KEY Returns true if the specified key exists, even if the corresponding value is undefined. @@ -103,7 +108,9 @@ sub exists { -e "$dir/$file"; } -=item touch +=item touch KEY + +Creates the specified configuration key if it does not exist. =cut @@ -116,7 +123,9 @@ sub touch { } } -=item set +=item set KEY VALUE + +Sets the specified configuration key to the given value. =cut @@ -125,7 +134,7 @@ sub set { my $dir = $self->dir; $value =~ /^(.*)$/s; $value = $1; - unless ( $self->config($file) eq $value ) { + unless ( join("\n", @{[ $self->config($file) ]}) eq $value ) { warn "[FS::Conf] SET $file\n" if $DEBUG; # warn "$dir" if is_tainted($dir); # warn "$dir" if is_tainted($file); @@ -139,7 +148,9 @@ sub set { # return ! eval { join('',@_), kill 0; 1; }; # } -=item delete +=item delete KEY + +Deletes the specified configuration key. =cut @@ -160,16 +171,27 @@ L. =cut sub config_items { -# my $self = shift; - @config_items; + my $self = shift; + #quelle kludge + @config_items, + map { + my $basename = basename($_); + $basename =~ /^(.*)$/; + $basename = $1; + new FS::ConfItem { + 'key' => $basename, + 'section' => 'billing', + 'description' => 'Alternate template file for invoices. See the billing documentation for details.', + 'type' => 'textarea', + } + } glob($self->dir. '/invoice_template_*') + ; } =back =head1 BUGS -Write access (touch, set, delete) should be documented. - If this was more than just crud that will never be useful outside Freeside I'd worry that config_items is freeside-specific and icky. @@ -185,12 +207,19 @@ httemplate/docs/config.html { 'key' => 'address', - 'section' => 'depreciated', + 'section' => 'deprecated', 'description' => 'This configuration option is no longer used. See invoice_template instead.', 'type' => 'text', }, { + 'key' => 'alerter_template', + 'section' => 'billing', + 'description' => 'Template file for billing method expiration alerts. See the billing documentation for details.', + 'type' => 'textarea', + }, + + { 'key' => 'apacheroot', 'section' => 'apache', 'description' => 'The directory containing Apache virtual hosts', @@ -220,15 +249,15 @@ httemplate/docs/config.html { 'key' => 'bindprimary', - 'section' => 'BIND', - 'description' => 'Your BIND primary nameserver. This enables export of /var/named/named.conf and zone files into /var/named', + 'section' => 'deprecated', + 'description' => 'DEPRECATED, add a bind export instead. Your BIND primary nameserver. This enables export of /var/named/named.conf and zone files into /var/named', 'type' => 'text', }, { 'key' => 'bindsecondaries', - 'section' => 'BIND', - 'description' => 'Your BIND secondary nameservers, one per line. This enables export of /var/named/named.conf', + 'section' => 'deprecated', + 'description' => 'DEPRECATED, add a bind_slave export instead. Your BIND secondary nameservers, one per line. This enables export of /var/named/named.conf', 'type' => 'textarea', }, @@ -240,9 +269,16 @@ httemplate/docs/config.html }, { + 'key' => 'business-onlinepayment-description', + 'section' => 'billing', + 'description' => 'String passed as the description field to Business::OnlinePayment. Evaluated as a double-quoted perl string, with the following variables available: $agent (the agent name), and $pkgs (a comma-separated list of packages to which the invoiced being charged applies)', + 'type' => 'text', + }, + + { 'key' => 'bsdshellmachines', - 'section' => 'shell', - 'description' => 'Your BSD flavored shell (and mail) machines, one per line. This enables export of `/etc/passwd\' and `/etc/master.passwd\'.', + 'section' => 'deprecated', + 'description' => 'DEPRECATED, add a bsdshell export instead. Your BSD flavored shell (and mail) machines, one per line. This enables export of `/etc/passwd\' and `/etc/master.passwd\'.', 'type' => 'textarea', }, @@ -262,15 +298,15 @@ httemplate/docs/config.html { 'key' => 'cyrus', - 'section' => 'mail', - 'description' => 'Integration with Cyrus IMAP Server, three lines: IMAP server, admin username, and admin password. Cyrus::IMAP::Admin should be installed locally and the connection to the server secured.', + 'section' => 'deprecated', + 'description' => 'DEPRECATED, add a cyrus export instead. This option used to integrate with Cyrus IMAP Server, three lines: IMAP server, admin username, and admin password. Cyrus::IMAP::Admin should be installed locally and the connection to the server secured.', 'type' => 'textarea', }, { 'key' => 'cp_app', - 'section' => 'mail', - 'description' => 'Integration with Critial Path Account Provisioning Protocol, four lines: "host:port", username, password, and workgroup (for new users).', + 'section' => 'deprecated', + 'description' => 'DEPRECATED, add a cp export instead. This option used to integrate with Critial Path Account Provisioning Protocol, four lines: "host:port", username, password, and workgroup (for new users).', 'type' => 'textarea', }, @@ -284,8 +320,8 @@ httemplate/docs/config.html { 'key' => 'deletepayments', 'section' => 'UI', - 'description' => 'Enable deletion of unclosed payments. Be very careful! Only delete payments that were data-entry errors, not adjustments.', - 'type' => 'checkbox', + 'description' => 'Enable deletion of unclosed payments. Be very careful! Only delete payments that were data-entry errors, not adjustments. Optionally specify one or more comma-separated email addresses to be notified when a payment is deleted.', + 'type' => [qw( checkbox text )], }, { @@ -304,7 +340,7 @@ httemplate/docs/config.html { 'key' => 'domain', - 'section' => 'depreciated', + 'section' => 'deprecated', 'description' => 'Your domain name.', 'type' => 'text', }, @@ -312,7 +348,7 @@ httemplate/docs/config.html { 'key' => 'editreferrals', 'section' => 'UI', - 'description' => 'Enable referral modification for existing customers', + 'description' => 'Enable advertising source modification for existing customers', 'type' => 'checkbox', }, @@ -367,29 +403,29 @@ httemplate/docs/config.html { 'key' => 'icradiusmachines', - 'section' => 'radius', - 'description' => 'Turn this option on to enable radcheck and radreply table population - by default in the Freeside database, or in the database specified by the icradius_secrets config option (the radcheck and radreply tables needs to be created manually). You do not need to use MySQL for your Freeside database to export to an ICRADIUS/FreeRADIUS MySQL database with this option.
ADDITIONAL DEPRECATED FUNCTIONALITY (instead use MySQL replication or point icradius_secrets to the external database) - your ICRADIUS machines or FreeRADIUS (with MySQL authentication) machines, one per line. Machines listed in this file will have the radcheck table exported to them. Each line should contain four items, separted by whitespace: machine name, MySQL database name, MySQL username, and MySQL password. For example: "radius.isp.tld radius_db radius_user passw0rd"
', + 'section' => 'deprecated', + 'description' => 'DEPRECATED, add an sqlradius export instead. This option used to enable radcheck and radreply table population - by default in the Freeside database, or in the database specified by the icradius_secrets config option (the radcheck and radreply tables needs to be created manually). You do not need to use MySQL for your Freeside database to export to an ICRADIUS/FreeRADIUS MySQL database with this option.
ADDITIONAL DEPRECATED FUNCTIONALITY (instead use MySQL replication or point icradius_secrets to the external database) - your ICRADIUS machines or FreeRADIUS (with MySQL authentication) machines, one per line. Machines listed in this file will have the radcheck table exported to them. Each line should contain four items, separted by whitespace: machine name, MySQL database name, MySQL username, and MySQL password. For example: "radius.isp.tld radius_db radius_user passw0rd"
', 'type' => [qw( checkbox textarea )], }, { 'key' => 'icradius_mysqldest', - 'section' => 'radius', - 'description' => 'DEPRECATED (instead use MySQL replication or point icradius_secrets to the external database) - Destination directory for the MySQL databases, on the ICRADIUS/FreeRADIUS machines. Defaults to "/usr/local/var/".', + 'section' => 'deprecated', + 'description' => 'DEPRECATED, add an sqlradius https://billing.crosswind.net/freeside/browse/part_export.cgi">export instead. Used to be the destination directory for the MySQL databases, on the ICRADIUS/FreeRADIUS machines. Defaults to "/usr/local/var/".', 'type' => 'text', }, { 'key' => 'icradius_mysqlsource', - 'section' => 'radius', - 'description' => 'DEPRECATED (instead use MySQL replication or point icradius_secrets to the external database) - Source directory for for the MySQL radcheck table files, on the Freeside machine. Defaults to "/usr/local/var/freeside".', + 'section' => 'deprecated', + 'description' => 'DEPRECATED, add an sqlradius https://billing.crosswind.net/freeside/browse/part_export.cgi">export instead. Used to be the source directory for for the MySQL radcheck table files, on the Freeside machine. Defaults to "/usr/local/var/freeside".', 'type' => 'text', }, { 'key' => 'icradius_secrets', - 'section' => 'radius', - 'description' => 'Optionally specifies a database for ICRADIUS/FreeRADIUS export. Three lines: DBI data source, username and password.', + 'section' => 'deprecated', + 'description' => 'DEPRECATED, add an sqlradius https://billing.crosswind.net/freeside/browse/part_export.cgi">export instead. This option used to specify a database for ICRADIUS/FreeRADIUS export. Three lines: DBI data source, username and password.', 'type' => 'textarea', }, @@ -416,8 +452,8 @@ httemplate/docs/config.html { 'key' => 'maildisablecatchall', - 'section' => 'depreciated', - 'description' => 'DEPRECIATED, now the default. Turning this option on used to disable the requirement that each virtual domain have a catch-all mailbox.', + 'section' => 'deprecated', + 'description' => 'DEPRECATED, now the default. Turning this option on used to disable the requirement that each virtual domain have a catch-all mailbox.', 'type' => 'checkbox', }, @@ -430,22 +466,48 @@ httemplate/docs/config.html { 'key' => 'mxmachines', - 'section' => 'BIND', + 'section' => 'deprecated', 'description' => 'MX entries for new domains, weight and machine, one per line, with trailing `.\'', 'type' => 'textarea', }, { 'key' => 'nsmachines', - 'section' => 'BIND', + 'section' => 'deprecated', 'description' => 'NS nameservers for new domains, one per line, with trailing `.\'', 'type' => 'textarea', }, { + 'key' => 'defaultrecords', + 'section' => 'BIND', + 'description' => 'DNS entries to add automatically when creating a domain', + 'type' => 'editlist', + 'editlist_parts' => [ { type=>'text' }, + { type=>'immutable', value=>'IN' }, + { type=>'select', + select_enum=>{ map { $_=>$_ } qw(A CNAME MX NS)} }, + { type=> 'text' }, ], + }, + + { + 'key' => 'arecords', + 'section' => 'deprecated', + 'description' => 'A list of tab seperated CNAME records to add automatically when creating a domain', + 'type' => 'textarea', + }, + + { + 'key' => 'cnamerecords', + 'section' => 'deprecated', + 'description' => 'A list of tab seperated CNAME records to add automatically when creating a domain', + 'type' => 'textarea', + }, + + { 'key' => 'nismachines', - 'section' => 'shell', - 'description' => 'Your NIS master (not slave master) machines, one per line. This enables export of `/etc/global/passwd\' and `/etc/global/shadow\'.', + 'section' => 'deprecated', + 'description' => 'DEPRECATED. Your NIS master (not slave master) machines, one per line. This enables export of `/etc/global/passwd\' and `/etc/global/shadow\'.', 'type' => 'textarea', }, @@ -472,8 +534,8 @@ httemplate/docs/config.html { 'key' => 'radiusmachines', - 'section' => 'radius', - 'description' => 'Your RADIUS authentication machines, one per line. This enables export of `/etc/raddb/users\'.', + 'section' => 'deprecated', + 'description' => 'DEPRECATED, add an sqlradius export instead. This option used to export to be: your RADIUS authentication machines, one per line. This enables export of `/etc/raddb/users\'.', 'type' => 'textarea', }, @@ -491,6 +553,14 @@ httemplate/docs/config.html # }, { + 'key' => 'report_template', + 'section' => 'required', + 'description' => 'Required template file for reports. See the billing documentation for details.', + 'type' => 'textarea', + }, + + + { 'key' => 'maxsearchrecordsperpage', 'section' => 'UI', 'description' => 'If set, number of search records to return per page.', @@ -534,37 +604,37 @@ httemplate/docs/config.html { 'key' => 'shellmachine', - 'section' => 'shell', - 'description' => 'A single machine with user home directories mounted. This enables home directory creation, renaming and archiving/deletion. In conjunction with `qmailmachines\', it also enables `.qmail-extension\' file maintenance.', + 'section' => 'deprecated', + 'description' => 'DEPRECATED, add a shellcommands export instead. This option used to contain a single machine with user home directories mounted. This enables home directory creation, renaming and archiving/deletion. In conjunction with `qmailmachines\', it also enables `.qmail-extension\' file maintenance.', 'type' => 'text', }, { 'key' => 'shellmachine-useradd', - 'section' => 'shell', - 'description' => 'The command(s) to run on shellmachine when an account is created. If the shellmachine option is set but this option is not, useradd -d $dir -m -s $shell -u $uid $username is the default. If this option is set but empty, cp -pr /etc/skel $dir; chown -R $uid.$gid $dir is the default instead. Otherwise the value is evaluated as a double-quoted perl string, with the following variables available: $username, $uid, $gid, $dir, and $shell.', + 'section' => 'deprecated', + 'description' => 'DEPRECATED, add a shellcommands export instead. This option used to contain command(s) to run on shellmachine when an account is created. If the shellmachine option is set but this option is not, useradd -d $dir -m -s $shell -u $uid $username is the default. If this option is set but empty, cp -pr /etc/skel $dir; chown -R $uid.$gid $dir is the default instead. Otherwise the value is evaluated as a double-quoted perl string, with the following variables available: $username, $uid, $gid, $dir, and $shell.', 'type' => [qw( checkbox text )], }, { 'key' => 'shellmachine-userdel', - 'section' => 'shell', - 'description' => 'The command(s) to run on shellmachine when an account is deleted. If the shellmachine option is set but this option is not, userdel $username is the default. If this option is set but empty, rm -rf $dir is the default instead. Otherwise the value is evaluated as a double-quoted perl string, with the following variables available: $username and $dir.', + 'section' => 'deprecated', + 'description' => 'DEPRECATED, add a shellcommands export instead. This option used to contain command(s) to run on shellmachine when an account is deleted. If the shellmachine option is set but this option is not, userdel $username is the default. If this option is set but empty, rm -rf $dir is the default instead. Otherwise the value is evaluated as a double-quoted perl string, with the following variables available: $username and $dir.', 'type' => [qw( checkbox text )], }, { 'key' => 'shellmachine-usermod', - 'section' => 'shell', - 'description' => 'The command(s) to run on shellmachine when an account is modified. If the shellmachine option is set but this option is empty, [ -d $old_dir ] && mv $old_dir $new_dir || ( chmod u+t $old_dir; mkdir $new_dir; cd $old_dir; find . -depth -print | cpio -pdm $new_dir; chmod u-t $new_dir; chown -R $uid.$gid $new_dir; rm -rf $old_dir ) is the default. Otherwise the contents of the file are treated as a double-quoted perl string, with the following variables available: $old_dir, $new_dir, $uid and $gid.', + 'section' => 'deprecated', + 'description' => 'DEPRECATED, add a shellcommands export instead. This option used to contain command(s) to run on shellmachine when an account is modified. If the shellmachine option is set but this option is empty, [ -d $old_dir ] && mv $old_dir $new_dir || ( chmod u+t $old_dir; mkdir $new_dir; cd $old_dir; find . -depth -print | cpio -pdm $new_dir; chmod u-t $new_dir; chown -R $uid.$gid $new_dir; rm -rf $old_dir ) is the default. Otherwise the contents of the file are treated as a double-quoted perl string, with the following variables available: $old_dir, $new_dir, $uid and $gid.', #'type' => [qw( checkbox text )], 'type' => 'text', }, { 'key' => 'shellmachines', - 'section' => 'shell', - 'description' => 'Your Linux and System V flavored shell (and mail) machines, one per line. This enables export of `/etc/passwd\' and `/etc/shadow\' files.', + 'section' => 'deprecated', + 'description' => 'DEPRECATED, add a sysvshell export instead. Your Linux and System V flavored shell (and mail) machines, one per line. This enables export of `/etc/passwd\' and `/etc/shadow\' files.', 'type' => 'textarea', }, @@ -647,15 +717,15 @@ httemplate/docs/config.html { 'key' => 'radiusprepend', - 'section' => 'radius', - 'description' => 'The contents will be prepended to the top of the RADIUS users file (text exports only).', + 'section' => 'deprecated', + 'description' => 'DEPRECATED, real-time text radius now edits an existing file in place - just (turn off freeside-queued and) edit your RADIUS users file directly. The contents used to be be prepended to the top of the RADIUS users file (text exports only).', 'type' => 'textarea', }, { 'key' => 'textradiusprepend', - 'section' => 'depreciated', - 'description' => 'DEPRECIATED, use RADIUS check attributes instead. This option will be removed soon. The contents will be prepended to the first line of a user\'s RADIUS entry in text exports.', + 'section' => 'deprecated', + 'description' => 'DEPRECATED, use RADIUS check attributes instead. The contents used to be prepended to the first line of a user\'s RADIUS entry in text exports.', 'type' => 'text', }, @@ -709,6 +779,20 @@ httemplate/docs/config.html }, { + 'key' => 'username-nounderscore', + 'section' => 'username', + 'description' => 'Disallow underscores in usernames', + 'type' => 'checkbox', + }, + + { + 'key' => 'username-nodash', + 'section' => 'username', + 'description' => 'Disallow dashes in usernames', + 'type' => 'checkbox', + }, + + { 'key' => 'username-uppercase', 'section' => 'username', 'description' => 'Allow uppercase characters in usernames', @@ -726,16 +810,16 @@ httemplate/docs/config.html { 'key' => 'vpopmailmachines', - 'section' => 'mail', - 'description' => 'Your vpopmail pop toasters, one per line. Each line is of the form "machinename vpopdir vpopuid vpopgid". For example: poptoaster.domain.tld /home/vpopmail 508 508 Note: vpopuid and vpopgid are values taken from the vpopmail machine\'s /etc/passwd', + 'section' => 'deprecated', + 'description' => 'DEPRECATED, add a cp export instead. This option used to contain your vpopmail pop toasters, one per line. Each line is of the form "machinename vpopdir vpopuid vpopgid". For example: poptoaster.domain.tld /home/vpopmail 508 508 Note: vpopuid and vpopgid are values taken from the vpopmail machine\'s /etc/passwd', 'type' => 'textarea', }, { 'key' => 'vpopmailrestart', 'section' => 'mail', - 'description' => 'If defined, the command which is run on vpopmail machines after files are copied. An example can be found in eg/vpopmailrestart of the source distribution.', - 'type' => 'text', + 'description' => 'If defined, the shell commands to run on vpopmail machines after files are copied. An example can be found in eg/vpopmailrestart of the source distribution.', + 'type' => 'textarea', }, { @@ -746,6 +830,13 @@ httemplate/docs/config.html }, { + 'key' => 'safe-part_bill_event', + 'section' => 'UI', + 'description' => 'Validates invoice event expressions against a preset list. Useful for webdemos, annoying to powerusers.', + 'type' => 'checkbox', + }, + + { 'key' => 'show_ss', 'section' => 'UI', 'description' => 'Turns on display/collection of SS# in the web interface.', @@ -759,6 +850,122 @@ httemplate/docs/config.html 'type' => 'checkbox', }, + { + 'key' => 'legacy_link', + 'section' => 'UI', + 'description' => 'Display options in the web interface to link legacy pre-Freeside services.', + 'type' => 'checkbox', + }, + + { + 'key' => 'queue_dangerous_controls', + 'section' => 'UI', + 'description' => 'Enable queue modification controls on account pages and for new jobs. Unless you are a developer working on new export code, you should probably leave this off to avoid causing provisioning problems.', + 'type' => 'checkbox', + }, + + { + 'key' => 'security_phrase', + 'section' => 'password', + 'description' => 'Enable the tracking of a "security phrase" with each account. Not recommended, as it is vulnerable to social engineering.', + 'type' => 'checkbox', + }, + + { + 'key' => 'locale', + 'section' => 'UI', + 'description' => 'Message locale', + 'type' => 'select', + 'select_enum' => [ qw(en_US) ], + }, + + { + 'key' => 'signup_server-payby', + 'section' => '', + 'description' => 'Acceptable payment types for the signup server', + 'type' => 'selectmultiple', + 'select_enum' => [ qw(CARD PREPAY BILL COMP) ], + }, + + { + 'key' => 'signup_server-email', + 'section' => '', + 'description' => 'Comma-separated list of email addresses to receive notification of signups via the signup server.', + 'type' => 'text', + }, + + + { + 'key' => 'show-msgcat-codes', + 'section' => 'UI', + 'description' => 'Show msgcat codes in error messages. Turn this option on before reporting errors to the mailing list.', + 'type' => 'checkbox', + }, + + { + 'key' => 'signup_server-realtime', + 'section' => '', + 'description' => 'Run billing for signup server signups immediately, and suspend accounts which subsequently have a balance.', + 'type' => 'checkbox', + }, + + { + 'key' => 'declinetemplate', + 'section' => 'billing', + 'description' => 'Template file for credit card decline emails.', + 'type' => 'textarea', + }, + + { + 'key' => 'emaildecline', + 'section' => 'billing', + 'description' => 'Enable emailing of credit card decline notices.', + 'type' => 'checkbox', + }, + + { + 'key' => 'require_cardname', + 'section' => 'billing', + 'description' => 'Require an "Exact name on card" to be entered explicitly; don\'t default to using the first and last name.', + 'type' => 'checkbox', + }, + + { + 'key' => 'enable_taxclasses', + 'section' => 'billing', + 'description' => 'Enable per-package tax classes', + 'type' => 'checkbox', + }, + + { + 'key' => 'welcome_email', + 'section' => '', + 'description' => 'Template file for welcome email. Welcome emails are sent to the customer email invoice destination(s) each time a svc_acct record is created. See the Text::Template documentation for details on the template substitution language. The following variables are available: $username, $password, $first, $last and $pkg.', + 'type' => 'textarea', + }, + + { + 'key' => 'welcome_email-from', + 'section' => '', + 'description' => 'From: address header for welcome email', + 'type' => 'text', + }, + + { + 'key' => 'welcome_email-subject', + 'section' => '', + 'description' => 'Subject: header for welcome email', + 'type' => 'text', + }, + + { + 'key' => 'welcome_email-mimetype', + 'section' => '', + 'description' => 'MIME type for welcome email', + 'type' => 'select', + 'select_enum' => [ 'text/plain', 'text/html' ], + }, + ); 1;