USE `vokesscp`;


##############################################################################################################################################################################################
# Initial data                                                                                                                                                                               #
##############################################################################################################################################################################################


# Configuration
INSERT INTO `vokesscp`.`configuration` (`key`, `value`) VALUES
    ('accountBasePath', '/var/www'),            # Max length: 100 chars
    ('nonSSHShell', '/bin/false'),
    ('sshShell', '/bin/bash'),
    ('sftpShell', '/bin/bash'),
    ('trafficStatisticTotalMonths', 12),        # Months to keep traffic statistics
    ('trafficStatisticDetailedMonths', 3),      # Months to keep detailed traffic statistics (3 means current month + 2 before)
                                                # ("3" detailed, "12" overall means 3 months (current + 2) details and 9 months history)
    ('trafficStatisticApacheDetailDays', 14),   # Days to keep detailed traffic statistics for Apache (3 means current day + 2 before)
    ('trafficStatisticFTPDetailDays', 14),      # Days to keep detailed traffic statistics for ProFTPd (3 means current day + 2 before)
    ('trafficStatisticSFTPDetailDays', 14),     # Days to keep detailed traffic statistics for SFTP (3 means current day + 2 before)
    ('trafficStatisticMailDetailDays', 3),      # Days to keep detailed traffic statistics for Postfix (3 means current day + 2 before)
    ('trafficStatisticMySQLDetailDays', 3),     # Days to keep detailed traffic statistics for MySQL (3 means current day + 2 before)
    ('apacheVirtualhostTemplate', '    ServerAdmin server-admin@%domain%
    DocumentRoot "%accountBasePath%/%account%/domains/%domain%/html/"
    ErrorLog "%accountBasePath%/%account%/domains/%domain%/logfiles/error.log"
    LogLevel warn
    CustomLog "%accountBasePath%/%account%/domains/%domain%/logfiles/access.log" common
    
    <IfModule mod_rewrite.c>
        RewriteLog "%accountBasePath%/%account%/domains/%domain%/logfiles/rewrite.log"
        RewriteLogLevel 0
    </IfModule>
    
    <IfModule mpm_itk_module>
        AssignUserId %account% %account%
    </IfModule>
    
    <IfModule mod_suexec.c>
        SuexecUserGroup %account% %account%
    </IfModule>

    <If "\'%phpEnabled%\' == \'true\'">
        <IfModule mod_fcgid.c>
            AddHandler fcgid-script .php .php4 .php5 .phps
            Include /etc/apache2/CGIAuth/CGIAuth.conf

            FcgidWrapper "%accountBasePath%/%account%/domains/%domain%/configuration/php/php-starter -b 8 -i %accountBasePath%/%account%/domains/%domain%/configuration/php/" .php
            FcgidWrapper "%accountBasePath%/%account%/domains/%domain%/configuration/php/php-starter -b 8 -i %accountBasePath%/%account%/domains/%domain%/configuration/php/ -s" .phps
            FcgidWrapper "%accountBasePath%/%account%/domains/%domain%/configuration/php/php-starter -b 5 -i %accountBasePath%/%account%/domains/%domain%/configuration/php/" .php4
            FcgidWrapper "%accountBasePath%/%account%/domains/%domain%/configuration/php/php-starter -b 5 -i %accountBasePath%/%account%/domains/%domain%/configuration/php/" .php5
            FcgidWrapper "%accountBasePath%/%account%/domains/%domain%/configuration/php/php-starter -b 7 -i %accountBasePath%/%account%/domains/%domain%/configuration/php/" .php7
            FcgidWrapper "%accountBasePath%/%account%/domains/%domain%/configuration/php/php-starter -b 8 -i %accountBasePath%/%account%/domains/%domain%/configuration/php/" .php8
        </IfModule>
    </If>
    
    <If "\'%perlEnabled%\' == \'true\'">
        AddHandler cgi-script .pl .cgi
    </If>
    
    Alias /apacheerrordocs/ "%accountBasePath%/%account%/domains/%domain%/configuration/errordocs/"
    <Directory "%accountBasePath%/%account%/domains/%domain%/configuration/errordocs/">
        AllowOverride None
        Options IncludesNoExec
        AddOutputFilter Includes html
        AddHandler type-map var
        Order allow,deny
        Allow from all
        LanguagePriority de en cs es fr it nl sv pt-br ro
        ForceLanguagePriority Prefer Fallback
    </Directory>
    
    <Directory "%accountBasePath%/%account%/domains/%domain%/html/">
        Options FollowSymLinks MultiViews SymLinksIfOwnerMatch
        <If "\'%phpEnabled%\' == \'true\' || \'%perlEnabled%\' == \'true\'">
            Options +ExecCGI
        </If>
        
        AllowOverride AuthConfig Indexes Limit FileInfo
        RLimitCPU 30 60
        RLimitMEM 134217728 171966464
        RLimitNPROC 5 10
        Order allow,deny
        Allow from all
        AcceptPathInfo On
    </Directory>'),
    ('apacheSSLTemplate', '    SSLEngine on
    SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
    SSLCertificateFile %accountBasePath%/%account%/domains/%domain%/configuration/ssl/certificate.crt
    SSLCertificateKeyFile %accountBasePath%/%account%/domains/%domain%/configuration/ssl/certificate.key
    <FilesMatch "\.(cgi|pl|shtml|shtm|phtml|phtm|php|php5|php4|py|rb)$">
        SSLOptions +StdEnvVars
    </FilesMatch>
    BrowserMatch ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
    
    Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains"'),
    ('postfixAutoreplyDomain', 'vokesscp-autoreply-domain'),
    ('postfixAutoreplyDestination', 'response:[127.0.0.1]:10026'),
    ('postfixVmailUserId', 5000),
    ('postfixVmailGroupId', 5000),
    ('fail2banRequiredHitsForBlock', 3),
    ('fail2banRequiredHitsForBlockInPeriod', 7),
    ('sslLetsEncryptSubscriberAgreementUrl', 'https://letsencrypt.org/repository/'),
    ('internetxContext', ''),
    ('internetxUsername', ''),
    ('internetxPassword', '');


# Global values for spamassassin
INSERT INTO `vokesscp`.`spamassassin_userpreferences` (`accountKey`, `postfixAliasKey`, `username`, `preference`, `value`) VALUES
      (NULL, NULL, '$GLOBAL', 'add_header all', 'Status _YESNO_; score=_SCORE_; required=_REQD_; bayes=_BAYES_; tests=_TESTSSCORES(,)_'),
      (NULL, NULL, '$GLOBAL', 'bayes_auto_learn', '1'),
      (NULL, NULL, '$GLOBAL', 'ok_locales', 'all'),
      (NULL, NULL, '$GLOBAL', 'ok_languages', 'all'),
      (NULL, NULL, '$GLOBAL', 'report_safe', '1'),                                                    # 0: only add headers, 1: attach original mail, show report, 2: convert mail to plaintext
      (NULL, NULL, '$GLOBAL', 'required_hits', '5.00'),
      (NULL, NULL, '$GLOBAL', 'rewrite_header subject', '[Possible spam: _HITS_] '),
      (NULL, NULL, '$GLOBAL', 'score USER_IN_WHITELIST', '-10'),
      (NULL, NULL, '$GLOBAL', 'score USER_IN_BLACKLIST', '10'),
      (NULL, NULL, '$GLOBAL', 'skip_rbl_checks', '0'),                                                # 0: do not skip, 1: skip
      (NULL, NULL, '$GLOBAL', 'use_auto_whitelist', '1'),
      (NULL, NULL, '$GLOBAL', 'use_bayes', '1'),
      (NULL, NULL, '$GLOBAL', 'use_bayes_rules', '1'),
      (NULL, NULL, '$GLOBAL', 'use_pyzor', '1'),
      (NULL, NULL, '$GLOBAL', 'use_razor2', '1');


# Insert some default values for bayes
INSERT INTO `vokesscp`.`bayes_global_vars` (`variable`, `value`) VALUES ('VERSION', '3');




