From 43d7825b689ad228e59e6204cb3aa5958eb55679 Mon Sep 17 00:00:00 2001 From: ZonD Eighty Date: Thu, 27 Dec 2012 12:48:20 +0400 Subject: [PATCH 01/11] Translation begins... --- web/add/cron/index.php | 154 ++--- web/add/db/index.php | 152 ++--- web/add/dns/index.php | 342 +++++----- web/add/ip/index.php | 173 +++-- web/add/mail/index.php | 356 +++++----- web/add/package/index.php | 328 +++++----- web/add/user/index.php | 202 +++--- web/add/web/index.php | 652 ++++++++++--------- web/delete/backup/index.php | 68 +- web/delete/cron/index.php | 68 +- web/delete/db/index.php | 68 +- web/delete/dns/index.php | 126 ++-- web/delete/ip/index.php | 58 +- web/delete/mail/index.php | 124 ++-- web/delete/package/index.php | 56 +- web/delete/user/index.php | 56 +- web/delete/web/index.php | 120 ++-- web/edit/cron/index.php | 170 ++--- web/edit/db/index.php | 158 ++--- web/edit/dns/index.php | 420 ++++++------ web/edit/ip/index.php | 238 +++---- web/edit/mail/index.php | 740 ++++++++++----------- web/edit/package/index.php | 380 +++++------ web/edit/user/index.php | 550 ++++++++-------- web/edit/web/index.php | 1182 +++++++++++++++++----------------- web/inc/i18n/en.php | 15 + web/inc/i18n/ru.php | 82 +++ web/inc/main.php | 297 +++++---- web/suspend/cron/index.php | 64 +- web/suspend/db/index.php | 68 +- web/suspend/dns/index.php | 126 ++-- web/suspend/mail/index.php | 122 ++-- web/suspend/user/index.php | 60 +- web/suspend/web/index.php | 66 +- web/unsuspend/cron/index.php | 64 +- web/unsuspend/dns/index.php | 124 ++-- web/unsuspend/mail/index.php | 120 ++-- web/unsuspend/user/index.php | 56 +- web/unsuspend/web/index.php | 62 +- 39 files changed, 4188 insertions(+), 4079 deletions(-) create mode 100644 web/inc/i18n/en.php create mode 100644 web/inc/i18n/ru.php diff --git a/web/add/cron/index.php b/web/add/cron/index.php index 8dea0444e..597c0916a 100644 --- a/web/add/cron/index.php +++ b/web/add/cron/index.php @@ -1,77 +1,77 @@ - $error) { - if ( $i == 0 ) { - $error_msg = $error; - } else { - $error_msg = $error_msg.", ".$error; - } - } - $_SESSION['error_msg'] = "Error: field ".$error_msg." can not be blank."; - } else { - // Add Cron Job - exec (VESTA_CMD."v-add-cron-job ".$user." ".$v_min." ".$v_hour." ".$v_day." ".$v_month." ".$v_wday." ".$v_cmd, $output, $return_var); - $v_type = $_POST['v_type']; - $v_charset = $_POST['v_charset']; - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - unset($v_password); - unset($output); - } else { - $_SESSION['ok_msg'] = "OK: cron job has been created successfully."; - unset($v_min); - unset($v_hour); - unset($v_day); - unset($v_month); - unset($v_wday); - unset($v_cmd); - unset($output); - } - } - } - exec (VESTA_CMD."v-list-database-types 'json'", $output, $return_var); - $db_types = json_decode(implode('', $output), true); - unset($output); - - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_cron.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); -//} - -// Footer -include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); + $error) { + if ( $i == 0 ) { + $error_msg = $error; + } else { + $error_msg = $error_msg.", ".$error; + } + } + $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); + } else { + // Add Cron Job + exec (VESTA_CMD."v-add-cron-job ".$user." ".$v_min." ".$v_hour." ".$v_day." ".$v_month." ".$v_wday." ".$v_cmd, $output, $return_var); + $v_type = $_POST['v_type']; + $v_charset = $_POST['v_charset']; + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + unset($v_password); + unset($output); + } else { + $_SESSION['ok_msg'] = _("OK: cron job has been created successfully."); + unset($v_min); + unset($v_hour); + unset($v_day); + unset($v_month); + unset($v_wday); + unset($v_cmd); + unset($output); + } + } + } + exec (VESTA_CMD."v-list-database-types 'json'", $output, $return_var); + $db_types = json_decode(implode('', $output), true); + unset($output); + + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_cron.html'); + unset($_SESSION['error_msg']); + unset($_SESSION['ok_msg']); +//} + +// Footer +include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/add/db/index.php b/web/add/db/index.php index e23f205ed..46b61dd69 100644 --- a/web/add/db/index.php +++ b/web/add/db/index.php @@ -1,76 +1,76 @@ - $error) { - if ( $i == 0 ) { - $error_msg = $error; - } else { - $error_msg = $error_msg.", ".$error; - } - } - $_SESSION['error_msg'] = "Error: field ".$error_msg." can not be blank."; - } else { - // Add Database - $v_type = escapeshellarg($_POST['v_type']); - $v_charset = escapeshellarg($_POST['v_charset']); - exec (VESTA_CMD."v-add-database ".$user." ".$v_database." ".$v_dbuser." ".$v_password." ".$v_type." 'default' ".$v_charset, $output, $return_var); - $v_type = $_POST['v_type']; - $v_charset = $_POST['v_charset']; - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - unset($v_password); - unset($output); - } else { - $_SESSION['ok_msg'] = "OK: database ".$user."_".$_POST['v_database']." has been created successfully."; - unset($v_database); - unset($v_dbuser); - unset($v_password); - unset($v_type); - unset($v_charset); - unset($output); - } - } - } - exec (VESTA_CMD."v-list-database-types 'json'", $output, $return_var); - $db_types = json_decode(implode('', $output), true); - unset($output); - - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_db.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); -//} - -// Footer -include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); + $error) { + if ( $i == 0 ) { + $error_msg = $error; + } else { + $error_msg = $error_msg.", ".$error; + } + } + $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); + } else { + // Add Database + $v_type = escapeshellarg($_POST['v_type']); + $v_charset = escapeshellarg($_POST['v_charset']); + exec (VESTA_CMD."v-add-database ".$user." ".$v_database." ".$v_dbuser." ".$v_password." ".$v_type." 'default' ".$v_charset, $output, $return_var); + $v_type = $_POST['v_type']; + $v_charset = $_POST['v_charset']; + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + unset($v_password); + unset($output); + } else { + $_SESSION['ok_msg'] = _('DATABASE_CREATED_OK',$user."_".$_POST['v_database'],$user."_".$_POST['v_database']); + unset($v_database); + unset($v_dbuser); + unset($v_password); + unset($v_type); + unset($v_charset); + unset($output); + } + } + } + exec (VESTA_CMD."v-list-database-types 'json'", $output, $return_var); + $db_types = json_decode(implode('', $output), true); + unset($output); + + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_db.html'); + unset($_SESSION['error_msg']); + unset($_SESSION['ok_msg']); +//} + +// Footer +include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/add/dns/index.php b/web/add/dns/index.php index b47fef76c..9d7597372 100644 --- a/web/add/dns/index.php +++ b/web/add/dns/index.php @@ -1,171 +1,171 @@ - $error) { - if ( $i == 0 ) { - $error_msg = $error; - } else { - $error_msg = $error_msg.", ".$error; - } - } - $_SESSION['error_msg'] = "Error: field ".$error_msg." can not be blank."; - } else { - - // Add DNS - exec (VESTA_CMD."v-add-dns-domain ".$user." ".$v_domain." ".$v_ip." ".$v_template." ".$v_ns1." ".$v_ns2." ".$v_ns3." ".$ns4, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - - // Change Expiriation date - if ((!empty($_POST['v_exp'])) && ($_POST['v_exp'] != date('Y-m-d', strtotime('+1 year')))) { - $v_exp = escapeshellarg($_POST['v_exp']); - exec (VESTA_CMD."v-change-dns-domain-exp ".$user." ".$v_domain." ".$v_exp, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - } - - // Change TTL - if ((!empty($_POST['v_ttl'])) && ($_POST['v_ttl'] != '14400')) { - $v_ttl = escapeshellarg($_POST['v_ttl']); - exec (VESTA_CMD."v-change-dns-domain-ttl ".$user." ".$v_domain." ".$v_ttl, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - } - - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = "OK: domain ".$_POST[v_domain]." has been created successfully."; - unset($v_domain); - } - } - } - - - // DNS Record - if (!empty($_POST['ok_rec'])) { - // Check input - if (empty($_POST['v_domain'])) $errors[] = 'domain'; - if (empty($_POST['v_rec'])) $errors[] = 'record'; - if (empty($_POST['v_type'])) $errors[] = 'type'; - if (empty($_POST['v_val'])) $errors[] = 'value'; - - // Protect input - $v_domain = escapeshellarg($_POST['v_domain']); - $v_rec = escapeshellarg($_POST['v_rec']); - $v_type = escapeshellarg($_POST['v_type']); - $v_val = escapeshellarg($_POST['v_val']); - $v_priority = escapeshellarg($_POST['v_priority']); - - // Check for errors - if (!empty($errors[0])) { - foreach ($errors as $i => $error) { - if ( $i == 0 ) { - $error_msg = $error; - } else { - $error_msg = $error_msg.", ".$error; - } - } - $_SESSION['error_msg'] = "Error: field ".$error_msg." can not be blank."; - } else { - // Add DNS Record - exec (VESTA_CMD."v-add-dns-domain-record ".$user." ".$v_domain." ".$v_rec." ".$v_type." ".$v_val." ".$v_priority, $output, $return_var); - $v_type = $_POST['v_type']; - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = "OK: record ".$_POST[v_rec].".".$_POST[v_domain]." has been created successfully."; - unset($v_domain); - unset($v_rec); - unset($v_val); - unset($v_priority); - } - } - } - - - if ((empty($_GET['domain'])) && (empty($_POST['domain']))) { - exec (VESTA_CMD."v-get-user-value ".$user." 'TEMPLATE'", $output, $return_var); - $template = $output[0] ; - unset($output); - - exec (VESTA_CMD."v-list-dns-templates json", $output, $return_var); - $templates = json_decode(implode('', $output), true); - unset($output); - - if ((empty($v_ns1)) && (empty($v_ns2))) { - exec (VESTA_CMD."v-list-user-ns ".$user." json", $output, $return_var); - $nameservers = json_decode(implode('', $output), true); - $v_ns1 = $nameservers[0]; - $v_ns2 = $nameservers[1]; - $v_ns3 = $nameservers[2]; - $v_ns4 = $nameservers[3]; - unset($output); - } - if (empty($v_ttl)) $v_ttl = 14400; - if (empty($v_exp)) $v_exp = date('Y-m-d', strtotime('+1 year')); - if ($_SESSION['user'] == 'admin') { - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_dns.html'); - } else { - include($_SERVER['DOCUMENT_ROOT'].'/templates/user/add_dns.html'); - } - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); - } else { - $v_domain = $_GET['domain']; - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_dns_rec.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); - } -//} - -// Footer -include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); + $error) { + if ( $i == 0 ) { + $error_msg = $error; + } else { + $error_msg = $error_msg.", ".$error; + } + } + $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); + } else { + + // Add DNS + exec (VESTA_CMD."v-add-dns-domain ".$user." ".$v_domain." ".$v_ip." ".$v_template." ".$v_ns1." ".$v_ns2." ".$v_ns3." ".$ns4, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + + // Change Expiriation date + if ((!empty($_POST['v_exp'])) && ($_POST['v_exp'] != date('Y-m-d', strtotime('+1 year')))) { + $v_exp = escapeshellarg($_POST['v_exp']); + exec (VESTA_CMD."v-change-dns-domain-exp ".$user." ".$v_domain." ".$v_exp, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + + // Change TTL + if ((!empty($_POST['v_ttl'])) && ($_POST['v_ttl'] != '14400')) { + $v_ttl = escapeshellarg($_POST['v_ttl']); + exec (VESTA_CMD."v-change-dns-domain-ttl ".$user." ".$v_domain." ".$v_ttl, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = _('DOMAIN_CREATED_OK',$_POST[v_domain],$_POST[v_domain]); + unset($v_domain); + } + } + } + + + // DNS Record + if (!empty($_POST['ok_rec'])) { + // Check input + if (empty($_POST['v_domain'])) $errors[] = 'domain'; + if (empty($_POST['v_rec'])) $errors[] = 'record'; + if (empty($_POST['v_type'])) $errors[] = 'type'; + if (empty($_POST['v_val'])) $errors[] = 'value'; + + // Protect input + $v_domain = escapeshellarg($_POST['v_domain']); + $v_rec = escapeshellarg($_POST['v_rec']); + $v_type = escapeshellarg($_POST['v_type']); + $v_val = escapeshellarg($_POST['v_val']); + $v_priority = escapeshellarg($_POST['v_priority']); + + // Check for errors + if (!empty($errors[0])) { + foreach ($errors as $i => $error) { + if ( $i == 0 ) { + $error_msg = $error; + } else { + $error_msg = $error_msg.", ".$error; + } + } + $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); + } else { + // Add DNS Record + exec (VESTA_CMD."v-add-dns-domain-record ".$user." ".$v_domain." ".$v_rec." ".$v_type." ".$v_val." ".$v_priority, $output, $return_var); + $v_type = $_POST['v_type']; + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = _('RECORD_CREATED_OK',$_POST[v_rec],$_POST[v_domain]); + unset($v_domain); + unset($v_rec); + unset($v_val); + unset($v_priority); + } + } + } + + + if ((empty($_GET['domain'])) && (empty($_POST['domain']))) { + exec (VESTA_CMD."v-get-user-value ".$user." 'TEMPLATE'", $output, $return_var); + $template = $output[0] ; + unset($output); + + exec (VESTA_CMD."v-list-dns-templates json", $output, $return_var); + $templates = json_decode(implode('', $output), true); + unset($output); + + if ((empty($v_ns1)) && (empty($v_ns2))) { + exec (VESTA_CMD."v-list-user-ns ".$user." json", $output, $return_var); + $nameservers = json_decode(implode('', $output), true); + $v_ns1 = $nameservers[0]; + $v_ns2 = $nameservers[1]; + $v_ns3 = $nameservers[2]; + $v_ns4 = $nameservers[3]; + unset($output); + } + if (empty($v_ttl)) $v_ttl = 14400; + if (empty($v_exp)) $v_exp = date('Y-m-d', strtotime('+1 year')); + if ($_SESSION['user'] == 'admin') { + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_dns.html'); + } else { + include($_SERVER['DOCUMENT_ROOT'].'/templates/user/add_dns.html'); + } + unset($_SESSION['error_msg']); + unset($_SESSION['ok_msg']); + } else { + $v_domain = $_GET['domain']; + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_dns_rec.html'); + unset($_SESSION['error_msg']); + unset($_SESSION['ok_msg']); + } +//} + +// Footer +include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/add/ip/index.php b/web/add/ip/index.php index 4e3b1f47f..a3071adfb 100644 --- a/web/add/ip/index.php +++ b/web/add/ip/index.php @@ -1,87 +1,86 @@ - $error) { - if ( $i == 0 ) { - $error_msg = $error; - } else { - $error_msg = $error_msg.", ".$error; - } - } - $_SESSION['error_msg'] = "Error: field ".$error_msg." can not be blank."; - } else { - // Add IP - $v_interface = escapeshellarg($_POST['v_interface']); - $v_owner = $_POST['v_owner']; - exec (VESTA_CMD."v-add-sys-ip ".$v_ip." ".$v_netmask." ".$v_interface." ".$v_owner." '".$ip_status."' ".$v_name, $output, $return_var); - $v_owner = $_POST['v_owner']; - $v_interface = $_POST['v_interface']; - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - unset($v_password); - unset($output); - } else { - $_SESSION['ok_msg'] = "OK: ip ".$_POST['v_ip']." has been created successfully."; - unset($v_ip); - unset($v_netmask); - unset($v_name); - unset($output); - } - } - } - exec (VESTA_CMD."v-list-sys-interfaces 'json'", $output, $return_var); - $interfaces = json_decode(implode('', $output), true); - unset($output); - - exec (VESTA_CMD."v-list-sys-users 'json'", $output, $return_var); - $users = json_decode(implode('', $output), true); - unset($output); - - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_ip.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); -} - -// Footer -include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); + $error) { + if ( $i == 0 ) { + $error_msg = $error; + } else { + $error_msg = $error_msg.", ".$error; + } + } + $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); + } else { + // Add IP + $v_interface = escapeshellarg($_POST['v_interface']); + $v_owner = $_POST['v_owner']; + exec (VESTA_CMD."v-add-sys-ip ".$v_ip." ".$v_netmask." ".$v_interface." ".$v_owner." '".$ip_status."' ".$v_name, $output, $return_var); + $v_owner = $_POST['v_owner']; + $v_interface = $_POST['v_interface']; + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + unset($v_password); + unset($output); + } else { + $_SESSION['ok_msg'] = _('IP_CREATED_OK',$_POST['v_ip'],$_POST['v_ip']); + unset($v_ip); + unset($v_netmask); + unset($v_name); + unset($output); + } + } + } + exec (VESTA_CMD."v-list-sys-interfaces 'json'", $output, $return_var); + $interfaces = json_decode(implode('', $output), true); + unset($output); + + exec (VESTA_CMD."v-list-sys-users 'json'", $output, $return_var); + $users = json_decode(implode('', $output), true); + unset($output); + + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_ip.html'); + unset($_SESSION['error_msg']); + unset($_SESSION['ok_msg']); +} + +// Footer +include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/add/mail/index.php b/web/add/mail/index.php index 59dac6b71..6ce745591 100644 --- a/web/add/mail/index.php +++ b/web/add/mail/index.php @@ -1,178 +1,178 @@ - $error) { - if ( $i == 0 ) { - $error_msg = $error; - } else { - $error_msg = $error_msg.", ".$error; - } - } - $_SESSION['error_msg'] = "Error: field ".$error_msg." can not be blank."; - } else { - - // Add mail domain - exec (VESTA_CMD."v-add-mail-domain ".$user." ".$v_domain." ".$v_antispam." ".$v_antivirus." ".$v_dkim, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = "OK: domain ".$_POST[v_domain]." has been created successfully."; - unset($v_domain); - } - } - } - - - // Mail Account - if (!empty($_POST['ok_acc'])) { - // Check input - if (empty($_POST['v_domain'])) $errors[] = 'domain'; - if (empty($_POST['v_account'])) $errors[] = 'account'; - if (empty($_POST['v_password'])) $errors[] = 'password'; - - // Protect input - $v_domain = escapeshellarg($_POST['v_domain']); - $v_account = escapeshellarg($_POST['v_account']); - $v_password = escapeshellarg($_POST['v_password']); - $v_quota = escapeshellarg($_POST['v_quota']); - $v_aliases = $_POST['v_aliases']; - $v_fwd = $_POST['v_fwd']; - - if (empty($_POST['v_quota'])) $v_quota = 0; - if ((!empty($_POST['v_quota'])) || (!empty($_POST['v_aliases'])) || (!empty($_POST['v_fwd'])) ) $v_adv = 'yes'; - - // Check for errors - if (!empty($errors[0])) { - foreach ($errors as $i => $error) { - if ( $i == 0 ) { - $error_msg = $error; - } else { - $error_msg = $error_msg.", ".$error; - } - } - $_SESSION['error_msg'] = "Error: field ".$error_msg." can not be blank."; - } else { - // Add Mail Account - exec (VESTA_CMD."v-add-mail-account ".$user." ".$v_domain." ".$v_account." ".$v_password." ".$v_quota, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - - // Add Aliases - if ((!empty($_POST['v_aliases'])) && (empty($_SESSION['error_msg']))) { - $valiases = preg_replace("/\n/", " ", $_POST['v_aliases']); - $valiases = preg_replace("/,/", " ", $valiases); - $valiases = preg_replace('/\s+/', ' ',$valiases); - $valiases = trim($valiases); - $aliases = explode(" ", $valiases); - foreach ($aliases as $alias) { - $alias = escapeshellarg($alias); - if (empty($_SESSION['error_msg'])) { - exec (VESTA_CMD."v-add-mail-account-alias ".$user." ".$v_domain." ".$v_account." ".$alias, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - } - unset($output); - } - } - - // Add Forwads - if ((!empty($_POST['v_fwd'])) && (empty($_SESSION['error_msg']))) { - $vfwd = preg_replace("/\n/", " ", $_POST['v_fwd']); - $vfwd = preg_replace("/,/", " ", $vfwd); - $vfwd = preg_replace('/\s+/', ' ',$vfwd); - $vfwd = trim($vfwd); - $fwd = explode(" ", $vfwd); - foreach ($fwd as $forward) { - $forward = escapeshellarg($forward); - if (empty($_SESSION['error_msg'])) { - exec (VESTA_CMD."v-add-mail-account-forward ".$user." ".$v_domain." ".$v_account." ".$forward, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - } - unset($output); - } - } - - unset($output); - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = "OK: account ".$_POST['v_account']."@".$_POST[v_domain]." has been created successfully."; - unset($v_account); - unset($v_password); - unset($v_password); - unset($v_aliases); - unset($v_fwd); - unset($v_quota); - } - } - } - - - if ((empty($_GET['domain'])) && (empty($_POST['domain']))) { - $v_domain = $_GET['domain']; - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_mail.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); - } else { - $v_domain = $_GET['domain']; - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_mail_acc.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); - } -//} - -// Footer -include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); + $error) { + if ( $i == 0 ) { + $error_msg = $error; + } else { + $error_msg = $error_msg.", ".$error; + } + } + $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); + } else { + + // Add mail domain + exec (VESTA_CMD."v-add-mail-domain ".$user." ".$v_domain." ".$v_antispam." ".$v_antivirus." ".$v_dkim, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = _("DOMAIN_MAIL_CREATED_OK",$_POST[v_domain],$_POST[v_domain]); + unset($v_domain); + } + } + } + + + // Mail Account + if (!empty($_POST['ok_acc'])) { + // Check input + if (empty($_POST['v_domain'])) $errors[] = _('domain'); + if (empty($_POST['v_account'])) $errors[] = _('account'); + if (empty($_POST['v_password'])) $errors[] = _('password'); + + // Protect input + $v_domain = escapeshellarg($_POST['v_domain']); + $v_account = escapeshellarg($_POST['v_account']); + $v_password = escapeshellarg($_POST['v_password']); + $v_quota = escapeshellarg($_POST['v_quota']); + $v_aliases = $_POST['v_aliases']; + $v_fwd = $_POST['v_fwd']; + + if (empty($_POST['v_quota'])) $v_quota = 0; + if ((!empty($_POST['v_quota'])) || (!empty($_POST['v_aliases'])) || (!empty($_POST['v_fwd'])) ) $v_adv = 'yes'; + + // Check for errors + if (!empty($errors[0])) { + foreach ($errors as $i => $error) { + if ( $i == 0 ) { + $error_msg = $error; + } else { + $error_msg = $error_msg.", ".$error; + } + } + $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); + } else { + // Add Mail Account + exec (VESTA_CMD."v-add-mail-account ".$user." ".$v_domain." ".$v_account." ".$v_password." ".$v_quota, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + + // Add Aliases + if ((!empty($_POST['v_aliases'])) && (empty($_SESSION['error_msg']))) { + $valiases = preg_replace("/\n/", " ", $_POST['v_aliases']); + $valiases = preg_replace("/,/", " ", $valiases); + $valiases = preg_replace('/\s+/', ' ',$valiases); + $valiases = trim($valiases); + $aliases = explode(" ", $valiases); + foreach ($aliases as $alias) { + $alias = escapeshellarg($alias); + if (empty($_SESSION['error_msg'])) { + exec (VESTA_CMD."v-add-mail-account-alias ".$user." ".$v_domain." ".$v_account." ".$alias, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + } + unset($output); + } + } + + // Add Forwads + if ((!empty($_POST['v_fwd'])) && (empty($_SESSION['error_msg']))) { + $vfwd = preg_replace("/\n/", " ", $_POST['v_fwd']); + $vfwd = preg_replace("/,/", " ", $vfwd); + $vfwd = preg_replace('/\s+/', ' ',$vfwd); + $vfwd = trim($vfwd); + $fwd = explode(" ", $vfwd); + foreach ($fwd as $forward) { + $forward = escapeshellarg($forward); + if (empty($_SESSION['error_msg'])) { + exec (VESTA_CMD."v-add-mail-account-forward ".$user." ".$v_domain." ".$v_account." ".$forward, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + } + unset($output); + } + } + + unset($output); + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = _('MAIL_ACCOUNT_CREATED_OK',$_POST['v_account'],$_POST[v_domain],$_POST['v_account'],$_POST[v_domain]); + unset($v_account); + unset($v_password); + unset($v_password); + unset($v_aliases); + unset($v_fwd); + unset($v_quota); + } + } + } + + + if ((empty($_GET['domain'])) && (empty($_POST['domain']))) { + $v_domain = $_GET['domain']; + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_mail.html'); + unset($_SESSION['error_msg']); + unset($_SESSION['ok_msg']); + } else { + $v_domain = $_GET['domain']; + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_mail_acc.html'); + unset($_SESSION['error_msg']); + unset($_SESSION['ok_msg']); + } +//} + +// Footer +include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/add/package/index.php b/web/add/package/index.php index cd093c836..0dd4a25a7 100644 --- a/web/add/package/index.php +++ b/web/add/package/index.php @@ -1,164 +1,164 @@ - $error) { - if ( $i == 0 ) { - $error_msg = $error; - } else { - $error_msg = $error_msg.", ".$error; - } - } - $_SESSION['error_msg'] = "Error: field ".$error_msg." can not be blank."; - } else { - exec ('mktemp -d', $output, $return_var); - $tmpdir = $output[0]; - unset($output); - - // Create package - $pkg = "TEMPLATE=".$v_template."\n"; - $pkg .= "WEB_DOMAINS=".$v_web_domains."\n"; - $pkg .= "WEB_ALIASES=".$v_web_aliases."\n"; - $pkg .= "DNS_DOMAINS=".$v_dns_domains."\n"; - $pkg .= "DNS_RECORDS=".$v_dns_records."\n"; - $pkg .= "MAIL_DOMAINS=".$v_mail_domains."\n"; - $pkg .= "MAIL_ACCOUNTS=".$v_mail_accounts."\n"; - $pkg .= "DATABASES=".$v_databases."\n"; - $pkg .= "CRON_JOBS=".$v_cron_jobs."\n"; - $pkg .= "DISK_QUOTA=".$v_disk_quota."\n"; - $pkg .= "BANDWIDTH=".$v_bandwidth."\n"; - $pkg .= "NS=".$v_ns."\n"; - $pkg .= "SHELL=".$v_shell."\n"; - $pkg .= "BACKUPS=".$v_backups."\n"; - $pkg .= "TIME=".$v_time."\n"; - $pkg .= "DATE=".$v_date."\n"; - - // Write package - $fp = fopen($tmpdir."/".$_POST['v_package'].".pkg", 'w'); - fwrite($fp, $pkg); - fclose($fp); - - // Add new package - if (empty($_SESSION['error_msg'])) { - exec (VESTA_CMD."v-add-user-package ".$tmpdir." ".$v_package, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - } - - // Remove tmpdir - exec ('rm -rf '.$tmpdir, $output, $return_var); - unset($output); - - // Check output - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = "OK: package ".$_POST['v_package']." has been created successfully."; - unset($v_package); - } - - } - } - - - exec (VESTA_CMD."v-list-web-templates json", $output, $return_var); - check_error($return_var); - $templates = json_decode(implode('', $output), true); - unset($output); - - exec (VESTA_CMD."v-list-sys-shells json", $output, $return_var); - check_error($return_var); - $shells = json_decode(implode('', $output), true); - unset($output); - - // Set default values - if (empty($v_template)) $v_template = 'default'; - if (empty($v_shell)) $v_shell = 'nologin'; - if (empty($v_web_domains)) $v_web_domains = "'0'"; - if (empty($v_web_aliases)) $v_web_aliases = "'0'"; - if (empty($v_dns_domains)) $v_dns_domains = "'0'"; - if (empty($v_dns_records)) $v_dns_records = "'0'"; - if (empty($v_mail_domains)) $v_mail_domains = "'0'"; - if (empty($v_mail_accounts)) $v_mail_accounts = "'0'"; - if (empty($v_databases)) $v_databases = "'0'"; - if (empty($v_cron_jobs)) $v_cron_jobs = "'0'"; - if (empty($v_backups)) $v_backups = "'0'"; - if (empty($v_disk_quota)) $v_disk_quota = "'0'"; - if (empty($v_bandwidth)) $v_bandwidth = "'0'"; - if (empty($v_ns1)) $v_ns1 = 'ns1.example.ltd'; - if (empty($v_ns2)) $v_ns2 = 'ns2.example.ltd'; - - - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_package.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); -} - -// Footer -include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); + $error) { + if ( $i == 0 ) { + $error_msg = $error; + } else { + $error_msg = $error_msg.", ".$error; + } + } + $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); + } else { + exec ('mktemp -d', $output, $return_var); + $tmpdir = $output[0]; + unset($output); + + // Create package + $pkg = "TEMPLATE=".$v_template."\n"; + $pkg .= "WEB_DOMAINS=".$v_web_domains."\n"; + $pkg .= "WEB_ALIASES=".$v_web_aliases."\n"; + $pkg .= "DNS_DOMAINS=".$v_dns_domains."\n"; + $pkg .= "DNS_RECORDS=".$v_dns_records."\n"; + $pkg .= "MAIL_DOMAINS=".$v_mail_domains."\n"; + $pkg .= "MAIL_ACCOUNTS=".$v_mail_accounts."\n"; + $pkg .= "DATABASES=".$v_databases."\n"; + $pkg .= "CRON_JOBS=".$v_cron_jobs."\n"; + $pkg .= "DISK_QUOTA=".$v_disk_quota."\n"; + $pkg .= "BANDWIDTH=".$v_bandwidth."\n"; + $pkg .= "NS=".$v_ns."\n"; + $pkg .= "SHELL=".$v_shell."\n"; + $pkg .= "BACKUPS=".$v_backups."\n"; + $pkg .= "TIME=".$v_time."\n"; + $pkg .= "DATE=".$v_date."\n"; + + // Write package + $fp = fopen($tmpdir."/".$_POST['v_package'].".pkg", 'w'); + fwrite($fp, $pkg); + fclose($fp); + + // Add new package + if (empty($_SESSION['error_msg'])) { + exec (VESTA_CMD."v-add-user-package ".$tmpdir." ".$v_package, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + + // Remove tmpdir + exec ('rm -rf '.$tmpdir, $output, $return_var); + unset($output); + + // Check output + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = _('PACKAGE_CREATED_OK',$_POST['v_package'],$_POST['v_package']); + unset($v_package); + } + + } + } + + + exec (VESTA_CMD."v-list-web-templates json", $output, $return_var); + check_error($return_var); + $templates = json_decode(implode('', $output), true); + unset($output); + + exec (VESTA_CMD."v-list-sys-shells json", $output, $return_var); + check_error($return_var); + $shells = json_decode(implode('', $output), true); + unset($output); + + // Set default values + if (empty($v_template)) $v_template = 'default'; + if (empty($v_shell)) $v_shell = 'nologin'; + if (empty($v_web_domains)) $v_web_domains = "'0'"; + if (empty($v_web_aliases)) $v_web_aliases = "'0'"; + if (empty($v_dns_domains)) $v_dns_domains = "'0'"; + if (empty($v_dns_records)) $v_dns_records = "'0'"; + if (empty($v_mail_domains)) $v_mail_domains = "'0'"; + if (empty($v_mail_accounts)) $v_mail_accounts = "'0'"; + if (empty($v_databases)) $v_databases = "'0'"; + if (empty($v_cron_jobs)) $v_cron_jobs = "'0'"; + if (empty($v_backups)) $v_backups = "'0'"; + if (empty($v_disk_quota)) $v_disk_quota = "'0'"; + if (empty($v_bandwidth)) $v_bandwidth = "'0'"; + if (empty($v_ns1)) $v_ns1 = 'ns1.example.ltd'; + if (empty($v_ns2)) $v_ns2 = 'ns2.example.ltd'; + + + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_package.html'); + unset($_SESSION['error_msg']); + unset($_SESSION['ok_msg']); +} + +// Footer +include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/add/user/index.php b/web/add/user/index.php index 521e8b7b6..e7dce33cd 100644 --- a/web/add/user/index.php +++ b/web/add/user/index.php @@ -1,103 +1,99 @@ - $error) { - if ( $i == 0 ) { - $error_msg = $error; - } else { - $error_msg = $error_msg.", ".$error; - } - } - $_SESSION['error_msg'] = "Error: field ".$error_msg." can not be blank."; - } - - if (empty($_SESSION['error_msg'])) { - exec (VESTA_CMD."v-add-user ".$v_username." ".$v_password." ".$v_email." ".$v_package." ".$v_fname." ".$v_lname, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } else { - if (empty($v_notify)) { - $to = $_POST['v_email']; - $subject = "Welcome to Vesta Control Panel"; - $hostname = exec('hostname'); - $from = "Vesta Control Panel "; - if (!empty($_POST['v_fname'])) { - $mailtext = "Hello ".$_POST['v_fname']." ".$_POST['v_lname'].",\n"; - } else { - $mailtext = "Hello,\n"; - } - $mailtext .= "Your account has been created successfully and is ready to use.\n\n"; - $mailtext .= "https://".$_SERVER['HTTP_HOST']."/login/\n"; - $mailtext .= "username: ".$_POST['v_username']."\n"; - $mailtext .= "password: ".$_POST['v_password']."\n\n"; - $mailtext .= "--\nVesta Control Panel\n"; - send_email($to, $subject, $mailtext, $from); - } - - $_SESSION['ok_msg'] = "OK: user ".$_POST[v_username]." has been created successfully."; - unset($v_username); - unset($v_password); - unset($v_email); - unset($v_fname); - unset($v_lname); - } - unset($output); - } - } - - exec (VESTA_CMD."v-list-user-packages json", $output, $return_var); - check_error($return_var); - $data = json_decode(implode('', $output), true); - unset($output); - - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_user.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); -} - -// Footer -include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); + $error) { + if ( $i == 0 ) { + $error_msg = $error; + } else { + $error_msg = $error_msg.", ".$error; + } + } + $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); + } + + if (empty($_SESSION['error_msg'])) { + exec (VESTA_CMD."v-add-user ".$v_username." ".$v_password." ".$v_email." ".$v_package." ".$v_fname." ".$v_lname, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } else { + if (empty($v_notify)) { + $to = $_POST['v_email']; + $subject = _("Welcome to Vesta Control Panel"); + $hostname = exec('hostname'); + $from = _('MAIL_FROM',$hostname); + if (!empty($_POST['v_fname'])) { + $mailtext = _('GREETINGS_GORDON_FREEMAN',$_POST['v_fname'],$_POST['v_lname']); + } else { + $mailtext = _('GREETINGS'); + } + $mailtext .= _('ACCOUNT_READY',$_SERVER['HTTP_HOST'],$_POST['v_username'],$_POST['v_password']); + send_email($to, $subject, $mailtext, $from); + } + + $_SESSION['ok_msg'] = _('ACCOUNT_CREATED_OK',$_POST[v_username],$_POST[v_username]); + unset($v_username); + unset($v_password); + unset($v_email); + unset($v_fname); + unset($v_lname); + } + unset($output); + } + } + + exec (VESTA_CMD."v-list-user-packages json", $output, $return_var); + check_error($return_var); + $data = json_decode(implode('', $output), true); + unset($output); + + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_user.html'); + unset($_SESSION['error_msg']); + unset($_SESSION['ok_msg']); +} + +// Footer +include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/add/web/index.php b/web/add/web/index.php index 716ccb3c9..92abdc9cd 100644 --- a/web/add/web/index.php +++ b/web/add/web/index.php @@ -1,328 +1,324 @@ - $error) { - if ( $i == 0 ) { - $error_msg = $error; - } else { - $error_msg = $error_msg.", ".$error; - } - } - $_SESSION['error_msg'] = "Error: field ".$error_msg." can not be blank."; - } - - if (empty($_SESSION['error_msg'])) { - // Add WEB - exec (VESTA_CMD."v-add-web-domain ".$user." ".$v_domain." ".$v_ip." ".$v_template." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - - // Add DNS - if (($_POST['v_dns'] == 'on') && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-add-dns-domain ".$user." ".$v_domain." ".$v_ip, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - } - - // Add Mail - if (($_POST['v_mail'] == 'on') && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-add-mail-domain ".$user." ".$v_domain, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - } - - // Add Aliases - if ((!empty($_POST['v_aliases'])) && (empty($_SESSION['error_msg']))) { - $valiases = preg_replace("/\n/", " ", $_POST['v_aliases']); - $valiases = preg_replace("/,/", " ", $valiases); - $valiases = preg_replace('/\s+/', ' ',$valiases); - $valiases = trim($valiases); - $aliases = explode(" ", $valiases); - foreach ($aliases as $alias) { - if ($alias == 'www.'.$_POST['v_domain']) { - $www_alias = 'yes'; - } else { - $alias = escapeshellarg($alias); - if (empty($_SESSION['error_msg'])) { - exec (VESTA_CMD."v-add-web-domain-alias ".$user." ".$v_domain." ".$alias." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - } - unset($output); - if (($_POST['v_dns'] == 'on') && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-add-dns-on-web-alias ".$user." ".$v_domain." ".$alias." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - } - } - } - } - if ((empty($www_alias)) && (empty($_SESSION['error_msg']))) { - $alias = preg_replace("/^www./i", "", $_POST['v_domain']); - $alias = 'www.'.$alias; - $alias = escapeshellarg($alias); - exec (VESTA_CMD."v-delete-web-domain-alias ".$user." ".$v_domain." ".$alias." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - } - - - // Add Nginx - if (($_POST['v_nginx'] == 'on') && (empty($_SESSION['error_msg']))) { - $ext = str_replace(' ', '', $v_nginx_ext); - $ext = escapeshellarg($ext); - exec (VESTA_CMD."v-add-web-domain-nginx ".$user." ".$v_domain." 'default' ".$ext." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - } - - // Add SSL - if (!empty($_POST['v_ssl'])) { - exec ('mktemp -d', $output, $return_var); - $tmpdir = $output[0]; - - // Certificate - if (!empty($_POST['v_ssl_crt'])) { - $fp = fopen($tmpdir."/".$_POST['v_domain'].".crt", 'w'); - fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_crt'])); - fwrite($fp, "\n"); - fclose($fp); - } - - // Key - if (!empty($_POST['v_ssl_key'])) { - $fp = fopen($tmpdir."/".$_POST['v_domain'].".key", 'w'); - fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_key'])); - fwrite($fp, "\n"); - fclose($fp); - } - - // CA - if (!empty($_POST['v_ssl_ca'])) { - $fp = fopen($tmpdir."/".$_POST['v_domain'].".ca", 'w'); - fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_ca'])); - fwrite($fp, "\n"); - fclose($fp); - } - - $v_ssl_home = escapeshellarg($_POST['v_ssl_home']); - exec (VESTA_CMD."v-add-web-domain-ssl ".$user." ".$v_domain." ".$tmpdir." ".$v_ssl_home." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - } - - // Add WebStats - if ((!empty($_POST['v_stats'])) && ($_POST['v_stats'] != 'none' ) && (empty($_SESSION['error_msg']))) { - $v_stats = escapeshellarg($_POST['v_stats']); - exec (VESTA_CMD."v-add-web-domain-stats ".$user." ".$v_domain." ".$v_stats, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - - if ((!empty($_POST['v_stats_user'])) && (empty($_SESSION['error_msg']))) { - $v_stats_user = escapeshellarg($_POST['v_stats_user']); - $v_stats_password = escapeshellarg($_POST['v_stats_password']); - exec (VESTA_CMD."v-add-web-domain-stats-user ".$user." ".$v_domain." ".$v_stats_user." ".$v_stats_password, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($v_stats_user); - unset($v_stats_password); - unset($output); - } - } - - - // Add FTP - if ((!empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) { - $v_ftp_user = escapeshellarg($_POST['v_ftp_user']); - $v_ftp_password = escapeshellarg($_POST['v_ftp_password']); - exec (VESTA_CMD."v-add-web-domain-ftp ".$user." ".$v_domain." ".$v_ftp_user." ".$v_ftp_password, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } else { - if (!empty($v_ftp_email)) { - $to = $_POST['v_ftp_email']; - $subject = "FTP login credentials"; - $hostname = exec('hostname'); - $from = "Vesta Control Panel "; - $mailtext .= "Your ftp account has been created successfully and is ready to use.\n\n"; - $mailtext .= "hostname: ".$_POST['v_domain']."\n"; - $mailtext .= "username: ".$user."_".$_POST['v_ftp_user']."\n"; - $mailtext .= "password: ".$_POST['v_ftp_password']."\n\n"; - $mailtext .= "--\nVesta Control Panel\n"; - send_email($to, $subject, $mailtext, $from); - unset($v_ftp_email); - } - } - unset($v_ftp); - unset($v_ftp_user); - unset($v_ftp_password); - unset($output); - } - - if (($_POST['v_dns'] == 'on') && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-restart-dns", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - } - - if (empty($_SESSION['error_msg'])) { - exec (VESTA_CMD."v-restart-web", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $_SESSION['ok_msg'] = "OK: domain ".$_POST[v_domain]." has been created successfully."; - unset($v_domain); - unset($v_aliases); - unset($v_ssl); - unset($v_ssl_crt); - unset($v_ssl_key); - unset($v_ssl_ca); - } - } - } - - exec (VESTA_CMD."v-list-user-ips ".$user." json", $output, $return_var); - $ips = json_decode(implode('', $output), true); - unset($output); - - exec (VESTA_CMD."v-get-user-value ".$user." 'TEMPLATE'", $output, $return_var); - $template = $output[0] ; - unset($output); - - exec (VESTA_CMD."v-list-web-templates json", $output, $return_var); - $templates = json_decode(implode('', $output), true); - unset($output); - - exec (VESTA_CMD."v-list-web-stats json", $output, $return_var); - $stats = json_decode(implode('', $output), true); - unset($output); - -// Are you admin? -if ($_SESSION['user'] == 'admin') { - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_web.html'); -} else { - include($_SERVER['DOCUMENT_ROOT'].'/templates/user/add_web.html'); -} - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); -//} - -// Footer -include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); + $error) { + if ( $i == 0 ) { + $error_msg = $error; + } else { + $error_msg = $error_msg.", ".$error; + } + } + $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); + } + + if (empty($_SESSION['error_msg'])) { + // Add WEB + exec (VESTA_CMD."v-add-web-domain ".$user." ".$v_domain." ".$v_ip." ".$v_template." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + + // Add DNS + if (($_POST['v_dns'] == 'on') && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-add-dns-domain ".$user." ".$v_domain." ".$v_ip, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + + // Add Mail + if (($_POST['v_mail'] == 'on') && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-add-mail-domain ".$user." ".$v_domain, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + + // Add Aliases + if ((!empty($_POST['v_aliases'])) && (empty($_SESSION['error_msg']))) { + $valiases = preg_replace("/\n/", " ", $_POST['v_aliases']); + $valiases = preg_replace("/,/", " ", $valiases); + $valiases = preg_replace('/\s+/', ' ',$valiases); + $valiases = trim($valiases); + $aliases = explode(" ", $valiases); + foreach ($aliases as $alias) { + if ($alias == 'www.'.$_POST['v_domain']) { + $www_alias = 'yes'; + } else { + $alias = escapeshellarg($alias); + if (empty($_SESSION['error_msg'])) { + exec (VESTA_CMD."v-add-web-domain-alias ".$user." ".$v_domain." ".$alias." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + } + unset($output); + if (($_POST['v_dns'] == 'on') && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-add-dns-on-web-alias ".$user." ".$v_domain." ".$alias." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + } + } + } + if ((empty($www_alias)) && (empty($_SESSION['error_msg']))) { + $alias = preg_replace("/^www./i", "", $_POST['v_domain']); + $alias = 'www.'.$alias; + $alias = escapeshellarg($alias); + exec (VESTA_CMD."v-delete-web-domain-alias ".$user." ".$v_domain." ".$alias." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + } + + + // Add Nginx + if (($_POST['v_nginx'] == 'on') && (empty($_SESSION['error_msg']))) { + $ext = str_replace(' ', '', $v_nginx_ext); + $ext = escapeshellarg($ext); + exec (VESTA_CMD."v-add-web-domain-nginx ".$user." ".$v_domain." 'default' ".$ext." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + + // Add SSL + if (!empty($_POST['v_ssl'])) { + exec ('mktemp -d', $output, $return_var); + $tmpdir = $output[0]; + + // Certificate + if (!empty($_POST['v_ssl_crt'])) { + $fp = fopen($tmpdir."/".$_POST['v_domain'].".crt", 'w'); + fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_crt'])); + fwrite($fp, "\n"); + fclose($fp); + } + + // Key + if (!empty($_POST['v_ssl_key'])) { + $fp = fopen($tmpdir."/".$_POST['v_domain'].".key", 'w'); + fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_key'])); + fwrite($fp, "\n"); + fclose($fp); + } + + // CA + if (!empty($_POST['v_ssl_ca'])) { + $fp = fopen($tmpdir."/".$_POST['v_domain'].".ca", 'w'); + fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_ca'])); + fwrite($fp, "\n"); + fclose($fp); + } + + $v_ssl_home = escapeshellarg($_POST['v_ssl_home']); + exec (VESTA_CMD."v-add-web-domain-ssl ".$user." ".$v_domain." ".$tmpdir." ".$v_ssl_home." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + + // Add WebStats + if ((!empty($_POST['v_stats'])) && ($_POST['v_stats'] != 'none' ) && (empty($_SESSION['error_msg']))) { + $v_stats = escapeshellarg($_POST['v_stats']); + exec (VESTA_CMD."v-add-web-domain-stats ".$user." ".$v_domain." ".$v_stats, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + + if ((!empty($_POST['v_stats_user'])) && (empty($_SESSION['error_msg']))) { + $v_stats_user = escapeshellarg($_POST['v_stats_user']); + $v_stats_password = escapeshellarg($_POST['v_stats_password']); + exec (VESTA_CMD."v-add-web-domain-stats-user ".$user." ".$v_domain." ".$v_stats_user." ".$v_stats_password, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($v_stats_user); + unset($v_stats_password); + unset($output); + } + } + + + // Add FTP + if ((!empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) { + $v_ftp_user = escapeshellarg($_POST['v_ftp_user']); + $v_ftp_password = escapeshellarg($_POST['v_ftp_password']); + exec (VESTA_CMD."v-add-web-domain-ftp ".$user." ".$v_domain." ".$v_ftp_user." ".$v_ftp_password, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } else { + if (!empty($v_ftp_email)) { + $to = $_POST['v_ftp_email']; + $subject = _("FTP login credentials"); + $hostname = exec('hostname'); + $from = _('MAIL_FROM',$hostname); + $mailtext .= _('FTP_ACCOUNT_READY',$_POST['v_domain'],$user,$_POST['v_ftp_user'],$_POST['v_ftp_password']); + send_email($to, $subject, $mailtext, $from); + unset($v_ftp_email); + } + } + unset($v_ftp); + unset($v_ftp_user); + unset($v_ftp_password); + unset($output); + } + + if (($_POST['v_dns'] == 'on') && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-restart-dns", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + + if (empty($_SESSION['error_msg'])) { + exec (VESTA_CMD."v-restart-web", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $_SESSION['ok_msg'] = _('HOSTING_DOMAIN_CREATED_OK',$_POST[v_domain],$_POST[v_domain]); + unset($v_domain); + unset($v_aliases); + unset($v_ssl); + unset($v_ssl_crt); + unset($v_ssl_key); + unset($v_ssl_ca); + } + } + } + + exec (VESTA_CMD."v-list-user-ips ".$user." json", $output, $return_var); + $ips = json_decode(implode('', $output), true); + unset($output); + + exec (VESTA_CMD."v-get-user-value ".$user." 'TEMPLATE'", $output, $return_var); + $template = $output[0] ; + unset($output); + + exec (VESTA_CMD."v-list-web-templates json", $output, $return_var); + $templates = json_decode(implode('', $output), true); + unset($output); + + exec (VESTA_CMD."v-list-web-stats json", $output, $return_var); + $stats = json_decode(implode('', $output), true); + unset($output); + +// Are you admin? +if ($_SESSION['user'] == 'admin') { + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_web.html'); +} else { + include($_SERVER['DOCUMENT_ROOT'].'/templates/user/add_web.html'); +} + unset($_SESSION['error_msg']); + unset($_SESSION['ok_msg']); +//} + +// Footer +include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/delete/backup/index.php b/web/delete/backup/index.php index af7ee41a8..24f377460 100644 --- a/web/delete/backup/index.php +++ b/web/delete/backup/index.php @@ -1,34 +1,34 @@ -', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - -//} - -$back = $_SESSION['back']; -if (!empty($back)) { - header("Location: ".$back); - exit; -} - -header("Location: /list/backup/"); -exit; +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + +//} + +$back = $_SESSION['back']; +if (!empty($back)) { + header("Location: ".$back); + exit; +} + +header("Location: /list/backup/"); +exit; diff --git a/web/delete/cron/index.php b/web/delete/cron/index.php index d5568fe46..c6a5c0d53 100644 --- a/web/delete/cron/index.php +++ b/web/delete/cron/index.php @@ -1,34 +1,34 @@ -', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - -//} - -$back = $_SESSION['back']; -if (!empty($back)) { - header("Location: ".$back); - exit; -} - -header("Location: /list/cron/"); -exit; +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + +//} + +$back = $_SESSION['back']; +if (!empty($back)) { + header("Location: ".$back); + exit; +} + +header("Location: /list/cron/"); +exit; diff --git a/web/delete/db/index.php b/web/delete/db/index.php index 44f6a513b..56c227848 100644 --- a/web/delete/db/index.php +++ b/web/delete/db/index.php @@ -1,34 +1,34 @@ -', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - -//} - -$back = $_SESSION['back']; -if (!empty($back)) { - header("Location: ".$back); - exit; -} - -header("Location: /list/db/"); -exit; +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + +//} + +$back = $_SESSION['back']; +if (!empty($back)) { + header("Location: ".$back); + exit; +} + +header("Location: /list/db/"); +exit; diff --git a/web/delete/dns/index.php b/web/delete/dns/index.php index 417bb3677..f06390dbe 100644 --- a/web/delete/dns/index.php +++ b/web/delete/dns/index.php @@ -1,63 +1,63 @@ -', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - - $back = $_SESSION['back']; - if (!empty($back)) { - header("Location: ".$back); - exit; - } - header("Location: /list/dns/"); - exit; - } - - // DNS record - if ((!empty($_GET['domain'])) && (!empty($_GET['record_id']))) { - $v_username = escapeshellarg($user); - $v_domain = escapeshellarg($_GET['domain']); - $v_record_id = escapeshellarg($_GET['record_id']); - exec (VESTA_CMD."v-delete-dns-domain-record ".$v_username." ".$v_domain." ".$v_record_id, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $back = $_SESSION['back']; - if (!empty($back)) { - header("Location: ".$back); - exit; - } - header("Location: /list/dns/?domain=".$_GET['domain']); - exit; - } -//} - -$back = $_SESSION['back']; -if (!empty($back)) { - header("Location: ".$back); - exit; -} - -header("Location: /list/dns/"); -exit; +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + + $back = $_SESSION['back']; + if (!empty($back)) { + header("Location: ".$back); + exit; + } + header("Location: /list/dns/"); + exit; + } + + // DNS record + if ((!empty($_GET['domain'])) && (!empty($_GET['record_id']))) { + $v_username = escapeshellarg($user); + $v_domain = escapeshellarg($_GET['domain']); + $v_record_id = escapeshellarg($_GET['record_id']); + exec (VESTA_CMD."v-delete-dns-domain-record ".$v_username." ".$v_domain." ".$v_record_id, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $back = $_SESSION['back']; + if (!empty($back)) { + header("Location: ".$back); + exit; + } + header("Location: /list/dns/?domain=".$_GET['domain']); + exit; + } +//} + +$back = $_SESSION['back']; +if (!empty($back)) { + header("Location: ".$back); + exit; +} + +header("Location: /list/dns/"); +exit; diff --git a/web/delete/ip/index.php b/web/delete/ip/index.php index 44419f915..47d45d71e 100644 --- a/web/delete/ip/index.php +++ b/web/delete/ip/index.php @@ -1,29 +1,29 @@ -', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - -} - -$back = $_SESSION['back']; -if (!empty($back)) { - header("Location: ".$back); - exit; -} - -header("Location: /list/ip/"); -exit; +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + +} + +$back = $_SESSION['back']; +if (!empty($back)) { + header("Location: ".$back); + exit; +} + +header("Location: /list/ip/"); +exit; diff --git a/web/delete/mail/index.php b/web/delete/mail/index.php index 4879b1e99..ddff24845 100644 --- a/web/delete/mail/index.php +++ b/web/delete/mail/index.php @@ -1,62 +1,62 @@ -', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $back = $_SESSION['back']; - if (!empty($back)) { - header("Location: ".$back); - exit; - } - header("Location: /list/mail/"); - exit; - } - - // Mail account - if ((!empty($_GET['domain'])) && (!empty($_GET['account']))) { - $v_username = escapeshellarg($user); - $v_domain = escapeshellarg($_GET['domain']); - $v_account = escapeshellarg($_GET['account']); - exec (VESTA_CMD."v-delete-mail-account ".$v_username." ".$v_domain." ".$v_account, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $back = $_SESSION['back']; - if (!empty($back)) { - header("Location: ".$back); - exit; - } - header("Location: /list/mail/?domain=".$_GET['domain']); - exit; - } -//} - -$back = $_SESSION['back']; -if (!empty($back)) { - header("Location: ".$back); - exit; -} - -header("Location: /list/mail/"); -exit; +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $back = $_SESSION['back']; + if (!empty($back)) { + header("Location: ".$back); + exit; + } + header("Location: /list/mail/"); + exit; + } + + // Mail account + if ((!empty($_GET['domain'])) && (!empty($_GET['account']))) { + $v_username = escapeshellarg($user); + $v_domain = escapeshellarg($_GET['domain']); + $v_account = escapeshellarg($_GET['account']); + exec (VESTA_CMD."v-delete-mail-account ".$v_username." ".$v_domain." ".$v_account, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $back = $_SESSION['back']; + if (!empty($back)) { + header("Location: ".$back); + exit; + } + header("Location: /list/mail/?domain=".$_GET['domain']); + exit; + } +//} + +$back = $_SESSION['back']; +if (!empty($back)) { + header("Location: ".$back); + exit; +} + +header("Location: /list/mail/"); +exit; diff --git a/web/delete/package/index.php b/web/delete/package/index.php index d7dc6069e..d255972fb 100644 --- a/web/delete/package/index.php +++ b/web/delete/package/index.php @@ -1,28 +1,28 @@ -', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); -} - -$back = $_SESSION['back']; -if (!empty($back)) { - header("Location: ".$back); - exit; -} - -header("Location: /list/package/"); -exit; +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); +} + +$back = $_SESSION['back']; +if (!empty($back)) { + header("Location: ".$back); + exit; +} + +header("Location: /list/package/"); +exit; diff --git a/web/delete/user/index.php b/web/delete/user/index.php index ca08147b0..ade17d089 100644 --- a/web/delete/user/index.php +++ b/web/delete/user/index.php @@ -1,28 +1,28 @@ -', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); -} - -$back = $_SESSION['back']; -if (!empty($back)) { - header("Location: ".$back); - exit; -} - -header("Location: /list/user/"); -exit; +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); +} + +$back = $_SESSION['back']; +if (!empty($back)) { + header("Location: ".$back); + exit; +} + +header("Location: /list/user/"); +exit; diff --git a/web/delete/web/index.php b/web/delete/web/index.php index c088f0413..cba00b02b 100644 --- a/web/delete/web/index.php +++ b/web/delete/web/index.php @@ -1,60 +1,60 @@ -', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - - // DNS - if ($return_var == 0) { - exec (VESTA_CMD."v-list-dns-domain ".$v_username." ".$v_domain." json", $output, $lreturn_var); - if ($lreturn_var == 0 ) { - exec (VESTA_CMD."v-delete-dns-domain ".$v_username." ".$v_domain, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - } - } - - // Mail - if ($return_var == 0) { - exec (VESTA_CMD."v-list-mail-domain ".$v_username." ".$v_domain." json", $output, $lreturn_var); - if ($lreturn_var == 0 ) { - exec (VESTA_CMD."v-delete-mail-domain ".$v_username." ".$v_domain, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - } - } -} - -$back = $_SESSION['back']; -if (!empty($back)) { - header("Location: ".$back); - exit; -} - -header("Location: /list/web/"); -exit; +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + + // DNS + if ($return_var == 0) { + exec (VESTA_CMD."v-list-dns-domain ".$v_username." ".$v_domain." json", $output, $lreturn_var); + if ($lreturn_var == 0 ) { + exec (VESTA_CMD."v-delete-dns-domain ".$v_username." ".$v_domain, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + } + + // Mail + if ($return_var == 0) { + exec (VESTA_CMD."v-list-mail-domain ".$v_username." ".$v_domain." json", $output, $lreturn_var); + if ($lreturn_var == 0 ) { + exec (VESTA_CMD."v-delete-mail-domain ".$v_username." ".$v_domain, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + } +} + +$back = $_SESSION['back']; +if (!empty($back)) { + header("Location: ".$back); + exit; +} + +header("Location: /list/web/"); +exit; diff --git a/web/edit/cron/index.php b/web/edit/cron/index.php index b061071a8..646f7af60 100644 --- a/web/edit/cron/index.php +++ b/web/edit/cron/index.php @@ -1,85 +1,85 @@ -', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } else { - $data = json_decode(implode('', $output), true); - unset($output); - $v_username = $user; - $v_job = $_GET['job']; - $v_min = $data[$v_job]['MIN']; - $v_hour = $data[$v_job]['HOUR']; - $v_day = $data[$v_job]['DAY']; - $v_month = $data[$v_job]['MONTH']; - $v_wday = $data[$v_job]['WDAY']; - $v_cmd = $data[$v_job]['CMD']; - $v_date = $data[$v_job]['DATE']; - $v_time = $data[$v_job]['TIME']; - $v_suspended = $data[$v_job]['SUSPENDED']; - if ( $v_suspended == 'yes' ) { - $v_status = 'suspended'; - } else { - $v_status = 'active'; - } - - // Action - if (!empty($_POST['save'])) { - $v_username = $user; - // Change job - if (($v_min != $_POST['v_min']) || ($v_hour != $_POST['v_hour']) || ($v_day != $_POST['v_day']) || ($v_month != $_POST['v_month']) || ($v_wday != $_POST['v_wday']) || ($v_cmd != $_POST['v_cmd']) &&(empty($_SESSION['error_msg']))) { - $v_min = escapeshellarg($_POST['v_min']); - $v_hour = escapeshellarg($_POST['v_hour']); - $v_day = escapeshellarg($_POST['v_day']); - $v_month = escapeshellarg($_POST['v_month']); - $v_wday = escapeshellarg($_POST['v_wday']); - $v_cmd = escapeshellarg($_POST['v_cmd']); - exec (VESTA_CMD."v-change-cron-job ".$v_username." ".$v_job." ".$v_min." ".$v_hour." ".$v_day." ".$v_month." ".$v_wday." ".$v_cmd, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_cmd = $_POST['v_cmd']; - } - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = "OK: changes has been saved."; - } - } - } - - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_cron.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); -//} - -// Footer -include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } else { + $data = json_decode(implode('', $output), true); + unset($output); + $v_username = $user; + $v_job = $_GET['job']; + $v_min = $data[$v_job]['MIN']; + $v_hour = $data[$v_job]['HOUR']; + $v_day = $data[$v_job]['DAY']; + $v_month = $data[$v_job]['MONTH']; + $v_wday = $data[$v_job]['WDAY']; + $v_cmd = $data[$v_job]['CMD']; + $v_date = $data[$v_job]['DATE']; + $v_time = $data[$v_job]['TIME']; + $v_suspended = $data[$v_job]['SUSPENDED']; + if ( $v_suspended == 'yes' ) { + $v_status = 'suspended'; + } else { + $v_status = 'active'; + } + + // Action + if (!empty($_POST['save'])) { + $v_username = $user; + // Change job + if (($v_min != $_POST['v_min']) || ($v_hour != $_POST['v_hour']) || ($v_day != $_POST['v_day']) || ($v_month != $_POST['v_month']) || ($v_wday != $_POST['v_wday']) || ($v_cmd != $_POST['v_cmd']) &&(empty($_SESSION['error_msg']))) { + $v_min = escapeshellarg($_POST['v_min']); + $v_hour = escapeshellarg($_POST['v_hour']); + $v_day = escapeshellarg($_POST['v_day']); + $v_month = escapeshellarg($_POST['v_month']); + $v_wday = escapeshellarg($_POST['v_wday']); + $v_cmd = escapeshellarg($_POST['v_cmd']); + exec (VESTA_CMD."v-change-cron-job ".$v_username." ".$v_job." ".$v_min." ".$v_hour." ".$v_day." ".$v_month." ".$v_wday." ".$v_cmd, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_cmd = $_POST['v_cmd']; + } + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = "OK: changes has been saved."; + } + } + } + + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_cron.html'); + unset($_SESSION['error_msg']); + unset($_SESSION['ok_msg']); +//} + +// Footer +include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/edit/db/index.php b/web/edit/db/index.php index f63411e26..a62cd5404 100644 --- a/web/edit/db/index.php +++ b/web/edit/db/index.php @@ -1,79 +1,79 @@ -', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } else { - $data = json_decode(implode('', $output), true); - unset($output); - $v_username = $user; - $v_database = $_GET['database']; - $v_dbuser = $data[$v_database]['DBUSER']; - $v_password = "••••••••"; - $v_host = $data[$v_database]['HOST']; - $v_type = $data[$v_database]['TYPE']; - $v_charset = $data[$v_database]['CHARSET']; - $v_date = $data[$v_database]['DATE']; - $v_time = $data[$v_database]['TIME']; - $v_suspended = $data[$v_database]['SUSPENDED']; - if ( $v_suspended == 'yes' ) { - $v_status = 'suspended'; - } else { - $v_status = 'active'; - } - - // Action - if (!empty($_POST['save'])) { - $v_username = $user; - // Change password - if (($v_password != $_POST['v_password']) && (empty($_SESSION['error_msg']))) { - $v_password = escapeshellarg($_POST['v_password']); - exec (VESTA_CMD."v-change-database-password ".$v_username." ".$v_database." ".$v_password, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - $v_password = "••••••••"; - unset($output); - } - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = "OK: changes has been saved."; - } - } - } - - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_db.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); -//} - -// Footer -include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } else { + $data = json_decode(implode('', $output), true); + unset($output); + $v_username = $user; + $v_database = $_GET['database']; + $v_dbuser = $data[$v_database]['DBUSER']; + $v_password = "••••••••"; + $v_host = $data[$v_database]['HOST']; + $v_type = $data[$v_database]['TYPE']; + $v_charset = $data[$v_database]['CHARSET']; + $v_date = $data[$v_database]['DATE']; + $v_time = $data[$v_database]['TIME']; + $v_suspended = $data[$v_database]['SUSPENDED']; + if ( $v_suspended == 'yes' ) { + $v_status = 'suspended'; + } else { + $v_status = 'active'; + } + + // Action + if (!empty($_POST['save'])) { + $v_username = $user; + // Change password + if (($v_password != $_POST['v_password']) && (empty($_SESSION['error_msg']))) { + $v_password = escapeshellarg($_POST['v_password']); + exec (VESTA_CMD."v-change-database-password ".$v_username." ".$v_database." ".$v_password, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $v_password = "••••••••"; + unset($output); + } + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = "OK: changes has been saved."; + } + } + } + + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_db.html'); + unset($_SESSION['error_msg']); + unset($_SESSION['ok_msg']); +//} + +// Footer +include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/edit/dns/index.php b/web/edit/dns/index.php index 043bf5c66..b0a619085 100644 --- a/web/edit/dns/index.php +++ b/web/edit/dns/index.php @@ -1,210 +1,210 @@ -', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } else { - $data = json_decode(implode('', $output), true); - unset($output); - - $v_username = $user; - $v_domain = $_GET['domain']; - $v_ip = $data[$v_domain]['IP']; - $v_template = $data[$v_domain]['TPL']; - $v_ttl = $data[$v_domain]['TTL']; - $v_exp = $data[$v_domain]['EXP']; - $v_soa = $data[$v_domain]['SOA']; - $v_date = $data[$v_domain]['DATE']; - $v_time = $data[$v_domain]['TIME']; - $v_suspended = $data[$v_domain]['SUSPENDED']; - if ( $v_suspended == 'yes' ) { - $v_status = 'suspended'; - } else { - $v_status = 'active'; - } - - exec (VESTA_CMD."v-list-dns-templates json", $output, $return_var); - $templates = json_decode(implode('', $output), true); - unset($output); - } - - // Action - if (!empty($_POST['save'])) { - $v_domain = escapeshellarg($_POST['v_domain']); - - // IP - if (($v_ip != $_POST['v_ip']) && (empty($_SESSION['error_msg']))) { - $v_ip = escapeshellarg($_POST['v_ip']); - exec (VESTA_CMD."v-change-dns-domain-ip ".$v_username." ".$v_domain." ".$v_ip." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - $restart_dns = 'yes'; - unset($output); - } - - // Template - if (( $_SESSION['user'] == 'admin') && ($v_template != $_POST['v_template']) && (empty($_SESSION['error_msg']))) { - $v_template = escapeshellarg($_POST['v_template']); - exec (VESTA_CMD."v-change-dns-domain-tpl ".$v_username." ".$v_domain." ".$v_template." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $restart_dns = 'yes'; - } - - // SOA - if (($v_soa != $_POST['v_soa']) && (empty($_SESSION['error_msg']))) { - $v_soa = escapeshellarg($_POST['v_soa']); - exec (VESTA_CMD."v-change-dns-domain-soa ".$v_username." ".$v_domain." ".$v_soa." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $restart_dns = 'yes'; - } - - // EXP - if (($v_exp != $_POST['v_exp']) && (empty($_SESSION['error_msg']))) { - $v_exp = escapeshellarg($_POST['v_exp']); - exec (VESTA_CMD."v-change-dns-domain-exp ".$v_username." ".$v_domain." ".$v_exp." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $restart_dns = 'yes'; - } - - // TTL - if (($v_ttl != $_POST['v_ttl']) && (empty($_SESSION['error_msg']))) { - $v_ttl = escapeshellarg($_POST['v_ttl']); - exec (VESTA_CMD."v-change-dns-domain-ttl ".$v_username." ".$v_domain." ".$v_ttl." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $restart_dns = 'yes'; - } - - // Restart dns - if (!empty($restart_dns) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-restart-dns", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - } - - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = "OK: changes has been saved."; - } - - } - if ($_SESSION['user'] == 'admin') { - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_dns.html'); - } else { - include($_SERVER['DOCUMENT_ROOT'].'/templates/user/edit_dns.html'); - } - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); - } else { - $v_domain = escapeshellarg($_GET['domain']); - $v_record_id = escapeshellarg($_GET['record_id']); - exec (VESTA_CMD."v-list-dns-domain-records ".$user." ".$v_domain." 'json'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } else { - $data = json_decode(implode('', $output), true); - unset($output); - $v_username = $user; - $v_domain = $_GET['domain']; - $v_record_id = $_GET['record_id']; - $v_rec = $data[$v_record_id]['RECORD']; - $v_type = $data[$v_record_id]['TYPE']; - $v_val = $data[$v_record_id]['VALUE']; - $v_priority = $data[$v_record_id]['PRIORITY']; - $v_suspended = $data[$v_record_id]['SUSPENDED']; - if ( $v_suspended == 'yes' ) { - $v_status = 'suspended'; - } else { - $v_status = 'active'; - } - $v_date = $data[$v_record_id]['DATE']; - $v_time = $data[$v_record_id]['TIME']; - } - - // Action - if (!empty($_POST['save'])) { - $v_domain = escapeshellarg($_POST['v_domain']); - $v_record_id = escapeshellarg($_POST['v_record_id']); - - if (($v_val != $_POST['v_val']) || ($v_priority != $_POST['v_priority']) && (empty($_SESSION['error_msg']))) { - $v_val = escapeshellarg($_POST['v_val']); - $v_priority = escapeshellarg($_POST['v_priority']); - exec (VESTA_CMD."v-change-dns-domain-record ".$v_username." ".$v_domain." ".$v_record_id." ".$v_val." ".$v_priority, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - $v_val = $_POST['v_val']; - $restart_dns = 'yes'; - unset($output); - } - - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = "OK: changes has been saved."; - } - - } - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_dns_rec.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); - } -//} - -// Footer -include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } else { + $data = json_decode(implode('', $output), true); + unset($output); + + $v_username = $user; + $v_domain = $_GET['domain']; + $v_ip = $data[$v_domain]['IP']; + $v_template = $data[$v_domain]['TPL']; + $v_ttl = $data[$v_domain]['TTL']; + $v_exp = $data[$v_domain]['EXP']; + $v_soa = $data[$v_domain]['SOA']; + $v_date = $data[$v_domain]['DATE']; + $v_time = $data[$v_domain]['TIME']; + $v_suspended = $data[$v_domain]['SUSPENDED']; + if ( $v_suspended == 'yes' ) { + $v_status = 'suspended'; + } else { + $v_status = 'active'; + } + + exec (VESTA_CMD."v-list-dns-templates json", $output, $return_var); + $templates = json_decode(implode('', $output), true); + unset($output); + } + + // Action + if (!empty($_POST['save'])) { + $v_domain = escapeshellarg($_POST['v_domain']); + + // IP + if (($v_ip != $_POST['v_ip']) && (empty($_SESSION['error_msg']))) { + $v_ip = escapeshellarg($_POST['v_ip']); + exec (VESTA_CMD."v-change-dns-domain-ip ".$v_username." ".$v_domain." ".$v_ip." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $restart_dns = 'yes'; + unset($output); + } + + // Template + if (( $_SESSION['user'] == 'admin') && ($v_template != $_POST['v_template']) && (empty($_SESSION['error_msg']))) { + $v_template = escapeshellarg($_POST['v_template']); + exec (VESTA_CMD."v-change-dns-domain-tpl ".$v_username." ".$v_domain." ".$v_template." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $restart_dns = 'yes'; + } + + // SOA + if (($v_soa != $_POST['v_soa']) && (empty($_SESSION['error_msg']))) { + $v_soa = escapeshellarg($_POST['v_soa']); + exec (VESTA_CMD."v-change-dns-domain-soa ".$v_username." ".$v_domain." ".$v_soa." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $restart_dns = 'yes'; + } + + // EXP + if (($v_exp != $_POST['v_exp']) && (empty($_SESSION['error_msg']))) { + $v_exp = escapeshellarg($_POST['v_exp']); + exec (VESTA_CMD."v-change-dns-domain-exp ".$v_username." ".$v_domain." ".$v_exp." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $restart_dns = 'yes'; + } + + // TTL + if (($v_ttl != $_POST['v_ttl']) && (empty($_SESSION['error_msg']))) { + $v_ttl = escapeshellarg($_POST['v_ttl']); + exec (VESTA_CMD."v-change-dns-domain-ttl ".$v_username." ".$v_domain." ".$v_ttl." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $restart_dns = 'yes'; + } + + // Restart dns + if (!empty($restart_dns) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-restart-dns", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + } + + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = "OK: changes has been saved."; + } + + } + if ($_SESSION['user'] == 'admin') { + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_dns.html'); + } else { + include($_SERVER['DOCUMENT_ROOT'].'/templates/user/edit_dns.html'); + } + unset($_SESSION['error_msg']); + unset($_SESSION['ok_msg']); + } else { + $v_domain = escapeshellarg($_GET['domain']); + $v_record_id = escapeshellarg($_GET['record_id']); + exec (VESTA_CMD."v-list-dns-domain-records ".$user." ".$v_domain." 'json'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } else { + $data = json_decode(implode('', $output), true); + unset($output); + $v_username = $user; + $v_domain = $_GET['domain']; + $v_record_id = $_GET['record_id']; + $v_rec = $data[$v_record_id]['RECORD']; + $v_type = $data[$v_record_id]['TYPE']; + $v_val = $data[$v_record_id]['VALUE']; + $v_priority = $data[$v_record_id]['PRIORITY']; + $v_suspended = $data[$v_record_id]['SUSPENDED']; + if ( $v_suspended == 'yes' ) { + $v_status = 'suspended'; + } else { + $v_status = 'active'; + } + $v_date = $data[$v_record_id]['DATE']; + $v_time = $data[$v_record_id]['TIME']; + } + + // Action + if (!empty($_POST['save'])) { + $v_domain = escapeshellarg($_POST['v_domain']); + $v_record_id = escapeshellarg($_POST['v_record_id']); + + if (($v_val != $_POST['v_val']) || ($v_priority != $_POST['v_priority']) && (empty($_SESSION['error_msg']))) { + $v_val = escapeshellarg($_POST['v_val']); + $v_priority = escapeshellarg($_POST['v_priority']); + exec (VESTA_CMD."v-change-dns-domain-record ".$v_username." ".$v_domain." ".$v_record_id." ".$v_val." ".$v_priority, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $v_val = $_POST['v_val']; + $restart_dns = 'yes'; + unset($output); + } + + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = "OK: changes has been saved."; + } + + } + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_dns_rec.html'); + unset($_SESSION['error_msg']); + unset($_SESSION['ok_msg']); + } +//} + +// Footer +include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/edit/ip/index.php b/web/edit/ip/index.php index 0d701a87c..bdc0b370d 100644 --- a/web/edit/ip/index.php +++ b/web/edit/ip/index.php @@ -1,119 +1,119 @@ -', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } else { - $data = json_decode(implode('', $output), true); - unset($output); - $v_username = $user; - $v_ip = $_GET['ip']; - $v_netmask = $data[$v_ip]['NETMASK']; - $v_interace = $data[$v_ip]['INTERFACE']; - $v_name = $data[$v_ip]['NAME']; - $v_ipstatus = $data[$v_ip]['STATUS']; - if ($v_ipstatus == 'dedicated') $v_dedicated = 'yes'; - $v_owner = $data[$v_ip]['OWNER']; - $v_date = $data[$v_ip]['DATE']; - $v_time = $data[$v_ip]['TIME']; - $v_suspended = $data[$v_ip]['SUSPENDED']; - if ( $v_suspended == 'yes' ) { - $v_status = 'suspended'; - } else { - $v_status = 'active'; - } - - exec (VESTA_CMD."v-list-sys-users 'json'", $output, $return_var); - $users = json_decode(implode('', $output), true); - unset($output); - - // Action - if (!empty($_POST['save'])) { - $v_username = $user; - $v_ip = escapeshellarg($_POST['v_ip']); - - // Change Status - if (($v_ipstatus == 'shared') && (empty($_POST['v_shared'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-change-sys-ip-status ".$v_ip." 'dedicated'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_dedicated = 'yes'; - } - if (($v_ipstatus == 'dedicated') && (!empty($_POST['v_shared'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-change-sys-ip-status ".$v_ip." 'shared'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - unset($v_dedicated); - } - - // Change owner - if (($v_owner != $_POST['v_owner']) && (empty($_SESSION['error_msg']))) { - $v_owner = escapeshellarg($_POST['v_owner']); - exec (VESTA_CMD."v-change-sys-ip-owner ".$v_ip." ".$v_owner, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - $v_owner = $_POST['v_owner']; - unset($output); - } - - // Change Name - if (($v_name != $_POST['v_name']) && (empty($_SESSION['error_msg']))) { - $v_name = escapeshellarg($_POST['v_name']); - exec (VESTA_CMD."v-change-sys-ip-name ".$v_ip." ".$v_name, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - } - - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = "OK: changes has been saved."; - } - } - } - - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_ip.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); -} - -// Footer -include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } else { + $data = json_decode(implode('', $output), true); + unset($output); + $v_username = $user; + $v_ip = $_GET['ip']; + $v_netmask = $data[$v_ip]['NETMASK']; + $v_interace = $data[$v_ip]['INTERFACE']; + $v_name = $data[$v_ip]['NAME']; + $v_ipstatus = $data[$v_ip]['STATUS']; + if ($v_ipstatus == 'dedicated') $v_dedicated = 'yes'; + $v_owner = $data[$v_ip]['OWNER']; + $v_date = $data[$v_ip]['DATE']; + $v_time = $data[$v_ip]['TIME']; + $v_suspended = $data[$v_ip]['SUSPENDED']; + if ( $v_suspended == 'yes' ) { + $v_status = 'suspended'; + } else { + $v_status = 'active'; + } + + exec (VESTA_CMD."v-list-sys-users 'json'", $output, $return_var); + $users = json_decode(implode('', $output), true); + unset($output); + + // Action + if (!empty($_POST['save'])) { + $v_username = $user; + $v_ip = escapeshellarg($_POST['v_ip']); + + // Change Status + if (($v_ipstatus == 'shared') && (empty($_POST['v_shared'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-change-sys-ip-status ".$v_ip." 'dedicated'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_dedicated = 'yes'; + } + if (($v_ipstatus == 'dedicated') && (!empty($_POST['v_shared'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-change-sys-ip-status ".$v_ip." 'shared'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + unset($v_dedicated); + } + + // Change owner + if (($v_owner != $_POST['v_owner']) && (empty($_SESSION['error_msg']))) { + $v_owner = escapeshellarg($_POST['v_owner']); + exec (VESTA_CMD."v-change-sys-ip-owner ".$v_ip." ".$v_owner, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $v_owner = $_POST['v_owner']; + unset($output); + } + + // Change Name + if (($v_name != $_POST['v_name']) && (empty($_SESSION['error_msg']))) { + $v_name = escapeshellarg($_POST['v_name']); + exec (VESTA_CMD."v-change-sys-ip-name ".$v_ip." ".$v_name, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = "OK: changes has been saved."; + } + } + } + + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_ip.html'); + unset($_SESSION['error_msg']); + unset($_SESSION['ok_msg']); +} + +// Footer +include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/edit/mail/index.php b/web/edit/mail/index.php index ca3c152b9..cab7a11ee 100644 --- a/web/edit/mail/index.php +++ b/web/edit/mail/index.php @@ -1,370 +1,370 @@ -', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } else { - $data = json_decode(implode('', $output), true); - unset($output); - $v_username = $user; - $v_domain = $_GET['domain']; - $v_antispam = $data[$v_domain]['ANTISPAM']; - $v_antivirus = $data[$v_domain]['ANTIVIRUS']; - $v_dkim = $data[$v_domain]['DKIM']; - $v_catchall = $data[$v_domain]['CATCHALL']; - $v_date = $data[$v_domain]['DATE']; - $v_time = $data[$v_domain]['TIME']; - $v_suspended = $data[$v_domain]['SUSPENDED']; - if ( $v_suspended == 'yes' ) { - $v_status = 'suspended'; - } else { - $v_status = 'active'; - } - } - - // Action - if (!empty($_POST['save'])) { - $v_domain = escapeshellarg($_POST['v_domain']); - - // Antispam - if (($v_antispam == 'yes') && (empty($_POST['v_antispam'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-delete-mail-domain-antispam ".$v_username." ".$v_domain, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - $v_antispam = 'no'; - unset($output); - } - if (($v_antispam == 'no') && (!empty($_POST['v_antispam'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-add-mail-domain-antispam ".$v_username." ".$v_domain, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - $v_antispam = 'yes'; - unset($output); - } - - // Antivirus - if (($v_antivirus == 'yes') && (empty($_POST['v_antivirus'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-delete-mail-domain-antivirus ".$v_username." ".$v_domain, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - $v_antivirus = 'no'; - unset($output); - } - if (($v_antivirus == 'no') && (!empty($_POST['v_antivirus'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-add-mail-domain-antivirus ".$v_username." ".$v_domain, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - $v_antivirus = 'yes'; - unset($output); - } - - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = "OK: changes has been saved."; - } - - // DKIM - if (($v_dkim == 'yes') && (empty($_POST['v_dkim'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-delete-mail-domain-dkim ".$v_username." ".$v_domain, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - $v_dkim = 'no'; - unset($output); - } - if (($v_dkim == 'no') && (!empty($_POST['v_dkim'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-add-mail-domain-dkim ".$v_username." ".$v_domain, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - $v_dkim = 'yes'; - unset($output); - } - - // Catchall - if ((!empty($v_catchall)) && (empty($_POST['v_catchall'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-delete-mail-domain-catchall ".$v_username." ".$v_domain, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - $v_catchall = ''; - unset($output); - } - - if ((!empty($v_catchall)) && (!empty($_POST['v_catchall'])) && (empty($_SESSION['error_msg']))) { - if ($v_catchall != $_POST['v_catchall']) { - $v_catchall = escapeshellarg($_POST['v_catchall']); - exec (VESTA_CMD."v-change-mail-domain-catchall ".$v_username." ".$v_domain." ".$v_catchall, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - } - } - - if ((empty($v_catchall)) && (!empty($_POST['v_catchall'])) && (empty($_SESSION['error_msg']))) { - $v_catchall = escapeshellarg($_POST['v_catchall']); - exec (VESTA_CMD."v-add-mail-domain-catchall ".$v_username." ".$v_domain." ".$v_catchall, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - } - - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = "OK: changes has been saved."; - } - } - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_mail.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); - } else { - - $v_username = $user; - $v_domain = escapeshellarg($_GET['domain']); - $v_account = escapeshellarg($_GET['account']); - exec (VESTA_CMD."v-list-mail-account ".$user." ".$v_domain." ".$v_account." 'json'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } else { - $data = json_decode(implode('', $output), true); - unset($output); - $v_username = $user; - $v_domain = $_GET['domain']; - $v_account = $_GET['account']; - $v_password = "••••••••"; - $v_aliases = str_replace(',', "\n", $data[$v_account]['ALIAS']); - $valiases = explode(",", $data[$v_account]['ALIAS']); - $v_fwd = str_replace(',', "\n", $data[$v_account]['FWD']); - $vfwd = explode(",", $data[$v_account]['FWD']); - $v_quota = $data[$v_account]['QUOTA']; - $v_autoreply = $data[$v_account]['AUTOREPLY']; - if ( $v_autoreply == 'yes' ) { - exec (VESTA_CMD."v-list-mail-account-autoreply ".$user." '".$v_domain."' '".$v_account."' json", $output, $return_var); - $autoreply_str = json_decode(implode('', $output), true); - unset($output); - $v_autoreply_message = $autoreply_str[$v_account]['MSG']; - } - $v_suspended = $data[$v_account]['SUSPENDED']; - if ( $v_suspended == 'yes' ) { - $v_status = 'suspended'; - } else { - $v_status = 'active'; - } - $v_date = $data[$v_account]['DATE']; - $v_time = $data[$v_account]['TIME']; - } - - // Action - if (!empty($_POST['save'])) { - $v_domain = escapeshellarg($_POST['v_domain']); - $v_account = escapeshellarg($_POST['v_account']); - - // Password - if (($v_password != $_POST['v_password']) && (empty($_SESSION['error_msg']))) { - $v_password = escapeshellarg($_POST['v_password']); - exec (VESTA_CMD."v-change-mail-account-password ".$v_username." ".$v_domain." ".$v_account." ".$v_password, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - $v_password = "••••••••"; - unset($output); - } - - // Quota - if (($v_quota != $_POST['v_quota']) && (empty($_SESSION['error_msg']))) { - if (empty($_POST['v_quota'])) { - $v_quota = 0; - } else { - $v_quota = escapeshellarg($_POST['v_quota']); - } - exec (VESTA_CMD."v-change-mail-account-quota ".$v_username." ".$v_domain." ".$v_account." ".$v_quota, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - } - - - // Aliases - if (empty($_SESSION['error_msg'])) { - $waliases = preg_replace("/\n/", " ", $_POST['v_aliases']); - $waliases = preg_replace("/,/", " ", $waliases); - $waliases = preg_replace('/\s+/', ' ',$waliases); - $waliases = trim($waliases); - $aliases = explode(" ", $waliases); - $v_aliases = str_replace(' ', "\n", $waliases); - $result = array_diff($valiases, $aliases); - foreach ($result as $alias) { - if ((empty($_SESSION['error_msg'])) && (!empty($alias))) { - exec (VESTA_CMD."v-delete-mail-account-alias ".$v_username." ".$v_domain." ".$v_account." '".$alias."'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - } - } - $result = array_diff($aliases, $valiases); - foreach ($result as $alias) { - if ((empty($_SESSION['error_msg'])) && (!empty($alias))) { - exec (VESTA_CMD."v-add-mail-account-alias ".$v_username." ".$v_domain." ".$v_account." '".$alias."'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - } - } - } - - // Forwarders - if (empty($_SESSION['error_msg'])) { - $wfwd = preg_replace("/\n/", " ", $_POST['v_fwd']); - $wfwd = preg_replace("/,/", " ", $wfwd); - $wfwd = preg_replace('/\s+/', ' ',$wfwd); - $wfwd = trim($wfwd); - $fwd = explode(" ", $wfwd); - $v_fwd = str_replace(' ', "\n", $wfwd); - $result = array_diff($vfwd, $fwd); - foreach ($result as $forward) { - if ((empty($_SESSION['error_msg'])) && (!empty($forward))) { - exec (VESTA_CMD."v-delete-mail-account-forward ".$v_username." ".$v_domain." ".$v_account." '".$forward."'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - } - } - $result = array_diff($fwd, $vfwd); - foreach ($result as $forward) { - if ((empty($_SESSION['error_msg'])) && (!empty($forward))) { - exec (VESTA_CMD."v-add-mail-account-forward ".$v_username." ".$v_domain." ".$v_account." '".$forward."'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - } - } - } - - // Autoreply - if (($v_autoreply == 'yes') && (empty($_POST['v_autoreply'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-delete-mail-account-autoreply ".$v_username." ".$v_domain." ".$v_account, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_autoreply = 'no'; - $v_autoreply_message = ''; - } - if (($v_autoreply == 'yes') && (!empty($_POST['v_autoreply'])) && (empty($_SESSION['error_msg']))) { - if ( $v_autoreply_message != str_replace("\r\n", "\n", $_POST['v_autoreply_message'])) { - $v_autoreply_message = str_replace("\r\n", "\n", $_POST['v_autoreply_message']); - $v_autoreply_message = escapeshellarg($v_autoreply_message); - exec (VESTA_CMD."v-add-mail-account-autoreply ".$v_username." ".$v_domain." ".$v_account." ".$v_autoreply_message, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_autoreply_message = $_POST['v_autoreply_message']; - } - } - - if (($v_autoreply == 'no') && (!empty($_POST['v_autoreply'])) && (empty($_SESSION['error_msg']))) { - if (empty($_POST['v_autoreply_message'])) $_SESSION['error_msg'] = "Error: field atoreply message can not be blank."; - if (empty($_SESSION['error_msg'])) { - $v_autoreply_message = str_replace("\r\n", "\n", $_POST['v_autoreply_message']); - $v_autoreply_message = escapeshellarg($v_autoreply_message); - exec (VESTA_CMD."v-add-mail-account-autoreply ".$v_username." ".$v_domain." ".$v_account." ".$v_autoreply_message, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_autoreply = 'yes'; - $v_autoreply_message = $_POST['v_autoreply_message']; - } - } - - - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = "OK: changes has been saved."; - } - - } - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_mail_acc.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); - } -//} - -// Footer -include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } else { + $data = json_decode(implode('', $output), true); + unset($output); + $v_username = $user; + $v_domain = $_GET['domain']; + $v_antispam = $data[$v_domain]['ANTISPAM']; + $v_antivirus = $data[$v_domain]['ANTIVIRUS']; + $v_dkim = $data[$v_domain]['DKIM']; + $v_catchall = $data[$v_domain]['CATCHALL']; + $v_date = $data[$v_domain]['DATE']; + $v_time = $data[$v_domain]['TIME']; + $v_suspended = $data[$v_domain]['SUSPENDED']; + if ( $v_suspended == 'yes' ) { + $v_status = 'suspended'; + } else { + $v_status = 'active'; + } + } + + // Action + if (!empty($_POST['save'])) { + $v_domain = escapeshellarg($_POST['v_domain']); + + // Antispam + if (($v_antispam == 'yes') && (empty($_POST['v_antispam'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-delete-mail-domain-antispam ".$v_username." ".$v_domain, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $v_antispam = 'no'; + unset($output); + } + if (($v_antispam == 'no') && (!empty($_POST['v_antispam'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-add-mail-domain-antispam ".$v_username." ".$v_domain, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $v_antispam = 'yes'; + unset($output); + } + + // Antivirus + if (($v_antivirus == 'yes') && (empty($_POST['v_antivirus'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-delete-mail-domain-antivirus ".$v_username." ".$v_domain, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $v_antivirus = 'no'; + unset($output); + } + if (($v_antivirus == 'no') && (!empty($_POST['v_antivirus'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-add-mail-domain-antivirus ".$v_username." ".$v_domain, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $v_antivirus = 'yes'; + unset($output); + } + + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = "OK: changes has been saved."; + } + + // DKIM + if (($v_dkim == 'yes') && (empty($_POST['v_dkim'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-delete-mail-domain-dkim ".$v_username." ".$v_domain, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $v_dkim = 'no'; + unset($output); + } + if (($v_dkim == 'no') && (!empty($_POST['v_dkim'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-add-mail-domain-dkim ".$v_username." ".$v_domain, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $v_dkim = 'yes'; + unset($output); + } + + // Catchall + if ((!empty($v_catchall)) && (empty($_POST['v_catchall'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-delete-mail-domain-catchall ".$v_username." ".$v_domain, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $v_catchall = ''; + unset($output); + } + + if ((!empty($v_catchall)) && (!empty($_POST['v_catchall'])) && (empty($_SESSION['error_msg']))) { + if ($v_catchall != $_POST['v_catchall']) { + $v_catchall = escapeshellarg($_POST['v_catchall']); + exec (VESTA_CMD."v-change-mail-domain-catchall ".$v_username." ".$v_domain." ".$v_catchall, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + } + + if ((empty($v_catchall)) && (!empty($_POST['v_catchall'])) && (empty($_SESSION['error_msg']))) { + $v_catchall = escapeshellarg($_POST['v_catchall']); + exec (VESTA_CMD."v-add-mail-domain-catchall ".$v_username." ".$v_domain." ".$v_catchall, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = "OK: changes has been saved."; + } + } + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_mail.html'); + unset($_SESSION['error_msg']); + unset($_SESSION['ok_msg']); + } else { + + $v_username = $user; + $v_domain = escapeshellarg($_GET['domain']); + $v_account = escapeshellarg($_GET['account']); + exec (VESTA_CMD."v-list-mail-account ".$user." ".$v_domain." ".$v_account." 'json'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } else { + $data = json_decode(implode('', $output), true); + unset($output); + $v_username = $user; + $v_domain = $_GET['domain']; + $v_account = $_GET['account']; + $v_password = "••••••••"; + $v_aliases = str_replace(',', "\n", $data[$v_account]['ALIAS']); + $valiases = explode(",", $data[$v_account]['ALIAS']); + $v_fwd = str_replace(',', "\n", $data[$v_account]['FWD']); + $vfwd = explode(",", $data[$v_account]['FWD']); + $v_quota = $data[$v_account]['QUOTA']; + $v_autoreply = $data[$v_account]['AUTOREPLY']; + if ( $v_autoreply == 'yes' ) { + exec (VESTA_CMD."v-list-mail-account-autoreply ".$user." '".$v_domain."' '".$v_account."' json", $output, $return_var); + $autoreply_str = json_decode(implode('', $output), true); + unset($output); + $v_autoreply_message = $autoreply_str[$v_account]['MSG']; + } + $v_suspended = $data[$v_account]['SUSPENDED']; + if ( $v_suspended == 'yes' ) { + $v_status = 'suspended'; + } else { + $v_status = 'active'; + } + $v_date = $data[$v_account]['DATE']; + $v_time = $data[$v_account]['TIME']; + } + + // Action + if (!empty($_POST['save'])) { + $v_domain = escapeshellarg($_POST['v_domain']); + $v_account = escapeshellarg($_POST['v_account']); + + // Password + if (($v_password != $_POST['v_password']) && (empty($_SESSION['error_msg']))) { + $v_password = escapeshellarg($_POST['v_password']); + exec (VESTA_CMD."v-change-mail-account-password ".$v_username." ".$v_domain." ".$v_account." ".$v_password, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $v_password = "••••••••"; + unset($output); + } + + // Quota + if (($v_quota != $_POST['v_quota']) && (empty($_SESSION['error_msg']))) { + if (empty($_POST['v_quota'])) { + $v_quota = 0; + } else { + $v_quota = escapeshellarg($_POST['v_quota']); + } + exec (VESTA_CMD."v-change-mail-account-quota ".$v_username." ".$v_domain." ".$v_account." ".$v_quota, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + + + // Aliases + if (empty($_SESSION['error_msg'])) { + $waliases = preg_replace("/\n/", " ", $_POST['v_aliases']); + $waliases = preg_replace("/,/", " ", $waliases); + $waliases = preg_replace('/\s+/', ' ',$waliases); + $waliases = trim($waliases); + $aliases = explode(" ", $waliases); + $v_aliases = str_replace(' ', "\n", $waliases); + $result = array_diff($valiases, $aliases); + foreach ($result as $alias) { + if ((empty($_SESSION['error_msg'])) && (!empty($alias))) { + exec (VESTA_CMD."v-delete-mail-account-alias ".$v_username." ".$v_domain." ".$v_account." '".$alias."'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + } + $result = array_diff($aliases, $valiases); + foreach ($result as $alias) { + if ((empty($_SESSION['error_msg'])) && (!empty($alias))) { + exec (VESTA_CMD."v-add-mail-account-alias ".$v_username." ".$v_domain." ".$v_account." '".$alias."'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + } + } + + // Forwarders + if (empty($_SESSION['error_msg'])) { + $wfwd = preg_replace("/\n/", " ", $_POST['v_fwd']); + $wfwd = preg_replace("/,/", " ", $wfwd); + $wfwd = preg_replace('/\s+/', ' ',$wfwd); + $wfwd = trim($wfwd); + $fwd = explode(" ", $wfwd); + $v_fwd = str_replace(' ', "\n", $wfwd); + $result = array_diff($vfwd, $fwd); + foreach ($result as $forward) { + if ((empty($_SESSION['error_msg'])) && (!empty($forward))) { + exec (VESTA_CMD."v-delete-mail-account-forward ".$v_username." ".$v_domain." ".$v_account." '".$forward."'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + } + $result = array_diff($fwd, $vfwd); + foreach ($result as $forward) { + if ((empty($_SESSION['error_msg'])) && (!empty($forward))) { + exec (VESTA_CMD."v-add-mail-account-forward ".$v_username." ".$v_domain." ".$v_account." '".$forward."'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + } + } + + // Autoreply + if (($v_autoreply == 'yes') && (empty($_POST['v_autoreply'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-delete-mail-account-autoreply ".$v_username." ".$v_domain." ".$v_account, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_autoreply = 'no'; + $v_autoreply_message = ''; + } + if (($v_autoreply == 'yes') && (!empty($_POST['v_autoreply'])) && (empty($_SESSION['error_msg']))) { + if ( $v_autoreply_message != str_replace("\r\n", "\n", $_POST['v_autoreply_message'])) { + $v_autoreply_message = str_replace("\r\n", "\n", $_POST['v_autoreply_message']); + $v_autoreply_message = escapeshellarg($v_autoreply_message); + exec (VESTA_CMD."v-add-mail-account-autoreply ".$v_username." ".$v_domain." ".$v_account." ".$v_autoreply_message, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_autoreply_message = $_POST['v_autoreply_message']; + } + } + + if (($v_autoreply == 'no') && (!empty($_POST['v_autoreply'])) && (empty($_SESSION['error_msg']))) { + if (empty($_POST['v_autoreply_message'])) $_SESSION['error_msg'] = "Error: field atoreply message can not be blank."; + if (empty($_SESSION['error_msg'])) { + $v_autoreply_message = str_replace("\r\n", "\n", $_POST['v_autoreply_message']); + $v_autoreply_message = escapeshellarg($v_autoreply_message); + exec (VESTA_CMD."v-add-mail-account-autoreply ".$v_username." ".$v_domain." ".$v_account." ".$v_autoreply_message, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_autoreply = 'yes'; + $v_autoreply_message = $_POST['v_autoreply_message']; + } + } + + + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = "OK: changes has been saved."; + } + + } + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_mail_acc.html'); + unset($_SESSION['error_msg']); + unset($_SESSION['ok_msg']); + } +//} + +// Footer +include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/edit/package/index.php b/web/edit/package/index.php index 21e47b7df..a5ea6d025 100644 --- a/web/edit/package/index.php +++ b/web/edit/package/index.php @@ -1,190 +1,190 @@ -', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } else { - $data = json_decode(implode('', $output), true); - unset($output); - - $v_package = $_GET['package']; - $v_template = $data[$v_package]['TEMPLATE']; - $v_web_domains = $data[$v_package]['WEB_DOMAINS']; - $v_web_aliases = $data[$v_package]['WEB_ALIASES']; - $v_dns_domains = $data[$v_package]['DNS_DOMAINS']; - $v_dns_records = $data[$v_package]['DNS_RECORDS']; - $v_mail_domains = $data[$v_package]['MAIL_DOMAINS']; - $v_mail_accounts = $data[$v_package]['MAIL_ACCOUNTS']; - $v_databases = $data[$v_package]['DATABASES']; - $v_cron_jobs = $data[$v_package]['CRON_JOBS']; - $v_disk_quota = $data[$v_package]['DISK_QUOTA']; - $v_bandwidth = $data[$v_package]['BANDWIDTH']; - $v_shell = $data[$v_package]['SHELL']; - $v_ns = $data[$v_package]['NS']; - $nameservers = explode(", ", $v_ns); - $v_ns1 = $nameservers[0]; - $v_ns2 = $nameservers[1]; - $v_ns3 = $nameservers[2]; - $v_ns4 = $nameservers[3]; - $v_backups = $data[$v_package]['BACKUPS']; - $v_date = $data[$v_package]['DATE']; - $v_time = $data[$v_package]['TIME']; - $v_status = 'active'; - - - exec (VESTA_CMD."v-list-web-templates json", $output, $return_var); - check_error($return_var); - $templates = json_decode(implode('', $output), true); - unset($output); - - exec (VESTA_CMD."v-list-sys-shells json", $output, $return_var); - check_error($return_var); - $shells = json_decode(implode('', $output), true); - unset($output); - - // Action - if (!empty($_POST['save'])) { - // Check input - if (empty($_POST['v_package'])) $errors[] = 'package'; - if (empty($_POST['v_template'])) $errors[] = 'template'; - if (empty($_POST['v_shell'])) $errrors[] = 'shell'; - if (!isset($_POST['v_web_domains'])) $errors[] = 'web domains'; - if (!isset($_POST['v_web_aliases'])) $errors[] = 'web aliases'; - if (!isset($_POST['v_dns_domains'])) $errors[] = 'dns domains'; - if (!isset($_POST['v_dns_records'])) $errors[] = 'dns records'; - if (!isset($_POST['v_mail_domains'])) $errors[] = 'mail domains'; - if (!isset($_POST['v_mail_accounts'])) $errors[] = 'mail accounts'; - if (!isset($_POST['v_databases'])) $errors[] = 'databases'; - if (!isset($_POST['v_cron_jobs'])) $errors[] = 'cron jobs'; - if (!isset($_POST['v_backups'])) $errors[] = 'backups'; - if (!isset($_POST['v_disk_quota'])) $errors[] = 'quota'; - if (!isset($_POST['v_bandwidth'])) $errors[] = 'bandwidth'; - if (empty($_POST['v_ns1'])) $errors[] = 'ns1'; - if (empty($_POST['v_ns2'])) $errors[] = 'ns2'; - - // Protect input - $v_package = escapeshellarg($_POST['v_package']); - $v_template = escapeshellarg($_POST['v_template']); - $v_shell = escapeshellarg($_POST['v_shell']); - $v_web_domains = escapeshellarg($_POST['v_web_domains']); - $v_web_aliases = escapeshellarg($_POST['v_web_aliases']); - $v_dns_domains = escapeshellarg($_POST['v_dns_domains']); - $v_dns_records = escapeshellarg($_POST['v_dns_records']); - $v_mail_domains = escapeshellarg($_POST['v_mail_domains']); - $v_mail_accounts = escapeshellarg($_POST['v_mail_accounts']); - $v_databases = escapeshellarg($_POST['v_databases']); - $v_cron_jobs = escapeshellarg($_POST['v_cron_jobs']); - $v_backups = escapeshellarg($_POST['v_backups']); - $v_disk_quota = escapeshellarg($_POST['v_disk_quota']); - $v_bandwidth = escapeshellarg($_POST['v_bandwidth']); - $v_ns1 = trim($_POST['v_ns1'], '.'); - $v_ns2 = trim($_POST['v_ns2'], '.'); - $v_ns3 = trim($_POST['v_ns3'], '.'); - $v_ns4 = trim($_POST['v_ns4'], '.'); - $v_ns = $v_ns1.",".$v_ns2; - if (!empty($v_ns3)) $v_ns .= ",".$v_ns3; - if (!empty($v_ns4)) $v_ns .= ",".$v_ns4; - $v_ns = escapeshellarg($v_ns); - $v_time = escapeshellarg(date('H:i:s')); - $v_date = escapeshellarg(date('Y-m-d')); - - // Check for errors - if (!empty($errors[0])) { - foreach ($errors as $i => $error) { - if ( $i == 0 ) { - $error_msg = $error; - } else { - $error_msg = $error_msg.", ".$error; - } - } - $_SESSION['error_msg'] = "Error: field ".$error_msg." can not be blank."; - } else { - exec ('mktemp -d', $output, $return_var); - $tmpdir = $output[0]; - unset($output); - - // Create package - $pkg = "TEMPLATE=".$v_template."\n"; - $pkg .= "WEB_DOMAINS=".$v_web_domains."\n"; - $pkg .= "WEB_ALIASES=".$v_web_aliases."\n"; - $pkg .= "DNS_DOMAINS=".$v_dns_domains."\n"; - $pkg .= "DNS_RECORDS=".$v_dns_records."\n"; - $pkg .= "MAIL_DOMAINS=".$v_mail_domains."\n"; - $pkg .= "MAIL_ACCOUNTS=".$v_mail_accounts."\n"; - $pkg .= "DATABASES=".$v_databases."\n"; - $pkg .= "CRON_JOBS=".$v_cron_jobs."\n"; - $pkg .= "DISK_QUOTA=".$v_disk_quota."\n"; - $pkg .= "BANDWIDTH=".$v_bandwidth."\n"; - $pkg .= "NS=".$v_ns."\n"; - $pkg .= "SHELL=".$v_shell."\n"; - $pkg .= "BACKUPS=".$v_backups."\n"; - $pkg .= "TIME=".$v_time."\n"; - $pkg .= "DATE=".$v_date."\n"; - - // Write package - $fp = fopen($tmpdir."/".$_POST['v_package'].".pkg", 'w'); - fwrite($fp, $pkg); - fclose($fp); - - // Rewrite package - if (empty($_SESSION['error_msg'])) { - exec (VESTA_CMD."v-add-user-package ".$tmpdir." ".$v_package." 'yes'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - } - - // Remove tmpdir - exec ('rm -rf '.$tmpdir, $output, $return_var); - unset($output); - - // Propogate new package - exec (VESTA_CMD."v-update-user-package ".$v_package." 'json'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = "OK: changes has been saved."; - } - } - } - } - - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_package.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); -} - -// Footer -include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } else { + $data = json_decode(implode('', $output), true); + unset($output); + + $v_package = $_GET['package']; + $v_template = $data[$v_package]['TEMPLATE']; + $v_web_domains = $data[$v_package]['WEB_DOMAINS']; + $v_web_aliases = $data[$v_package]['WEB_ALIASES']; + $v_dns_domains = $data[$v_package]['DNS_DOMAINS']; + $v_dns_records = $data[$v_package]['DNS_RECORDS']; + $v_mail_domains = $data[$v_package]['MAIL_DOMAINS']; + $v_mail_accounts = $data[$v_package]['MAIL_ACCOUNTS']; + $v_databases = $data[$v_package]['DATABASES']; + $v_cron_jobs = $data[$v_package]['CRON_JOBS']; + $v_disk_quota = $data[$v_package]['DISK_QUOTA']; + $v_bandwidth = $data[$v_package]['BANDWIDTH']; + $v_shell = $data[$v_package]['SHELL']; + $v_ns = $data[$v_package]['NS']; + $nameservers = explode(", ", $v_ns); + $v_ns1 = $nameservers[0]; + $v_ns2 = $nameservers[1]; + $v_ns3 = $nameservers[2]; + $v_ns4 = $nameservers[3]; + $v_backups = $data[$v_package]['BACKUPS']; + $v_date = $data[$v_package]['DATE']; + $v_time = $data[$v_package]['TIME']; + $v_status = 'active'; + + + exec (VESTA_CMD."v-list-web-templates json", $output, $return_var); + check_error($return_var); + $templates = json_decode(implode('', $output), true); + unset($output); + + exec (VESTA_CMD."v-list-sys-shells json", $output, $return_var); + check_error($return_var); + $shells = json_decode(implode('', $output), true); + unset($output); + + // Action + if (!empty($_POST['save'])) { + // Check input + if (empty($_POST['v_package'])) $errors[] = 'package'; + if (empty($_POST['v_template'])) $errors[] = 'template'; + if (empty($_POST['v_shell'])) $errrors[] = 'shell'; + if (!isset($_POST['v_web_domains'])) $errors[] = 'web domains'; + if (!isset($_POST['v_web_aliases'])) $errors[] = 'web aliases'; + if (!isset($_POST['v_dns_domains'])) $errors[] = 'dns domains'; + if (!isset($_POST['v_dns_records'])) $errors[] = 'dns records'; + if (!isset($_POST['v_mail_domains'])) $errors[] = 'mail domains'; + if (!isset($_POST['v_mail_accounts'])) $errors[] = 'mail accounts'; + if (!isset($_POST['v_databases'])) $errors[] = 'databases'; + if (!isset($_POST['v_cron_jobs'])) $errors[] = 'cron jobs'; + if (!isset($_POST['v_backups'])) $errors[] = 'backups'; + if (!isset($_POST['v_disk_quota'])) $errors[] = 'quota'; + if (!isset($_POST['v_bandwidth'])) $errors[] = 'bandwidth'; + if (empty($_POST['v_ns1'])) $errors[] = 'ns1'; + if (empty($_POST['v_ns2'])) $errors[] = 'ns2'; + + // Protect input + $v_package = escapeshellarg($_POST['v_package']); + $v_template = escapeshellarg($_POST['v_template']); + $v_shell = escapeshellarg($_POST['v_shell']); + $v_web_domains = escapeshellarg($_POST['v_web_domains']); + $v_web_aliases = escapeshellarg($_POST['v_web_aliases']); + $v_dns_domains = escapeshellarg($_POST['v_dns_domains']); + $v_dns_records = escapeshellarg($_POST['v_dns_records']); + $v_mail_domains = escapeshellarg($_POST['v_mail_domains']); + $v_mail_accounts = escapeshellarg($_POST['v_mail_accounts']); + $v_databases = escapeshellarg($_POST['v_databases']); + $v_cron_jobs = escapeshellarg($_POST['v_cron_jobs']); + $v_backups = escapeshellarg($_POST['v_backups']); + $v_disk_quota = escapeshellarg($_POST['v_disk_quota']); + $v_bandwidth = escapeshellarg($_POST['v_bandwidth']); + $v_ns1 = trim($_POST['v_ns1'], '.'); + $v_ns2 = trim($_POST['v_ns2'], '.'); + $v_ns3 = trim($_POST['v_ns3'], '.'); + $v_ns4 = trim($_POST['v_ns4'], '.'); + $v_ns = $v_ns1.",".$v_ns2; + if (!empty($v_ns3)) $v_ns .= ",".$v_ns3; + if (!empty($v_ns4)) $v_ns .= ",".$v_ns4; + $v_ns = escapeshellarg($v_ns); + $v_time = escapeshellarg(date('H:i:s')); + $v_date = escapeshellarg(date('Y-m-d')); + + // Check for errors + if (!empty($errors[0])) { + foreach ($errors as $i => $error) { + if ( $i == 0 ) { + $error_msg = $error; + } else { + $error_msg = $error_msg.", ".$error; + } + } + $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); + } else { + exec ('mktemp -d', $output, $return_var); + $tmpdir = $output[0]; + unset($output); + + // Create package + $pkg = "TEMPLATE=".$v_template."\n"; + $pkg .= "WEB_DOMAINS=".$v_web_domains."\n"; + $pkg .= "WEB_ALIASES=".$v_web_aliases."\n"; + $pkg .= "DNS_DOMAINS=".$v_dns_domains."\n"; + $pkg .= "DNS_RECORDS=".$v_dns_records."\n"; + $pkg .= "MAIL_DOMAINS=".$v_mail_domains."\n"; + $pkg .= "MAIL_ACCOUNTS=".$v_mail_accounts."\n"; + $pkg .= "DATABASES=".$v_databases."\n"; + $pkg .= "CRON_JOBS=".$v_cron_jobs."\n"; + $pkg .= "DISK_QUOTA=".$v_disk_quota."\n"; + $pkg .= "BANDWIDTH=".$v_bandwidth."\n"; + $pkg .= "NS=".$v_ns."\n"; + $pkg .= "SHELL=".$v_shell."\n"; + $pkg .= "BACKUPS=".$v_backups."\n"; + $pkg .= "TIME=".$v_time."\n"; + $pkg .= "DATE=".$v_date."\n"; + + // Write package + $fp = fopen($tmpdir."/".$_POST['v_package'].".pkg", 'w'); + fwrite($fp, $pkg); + fclose($fp); + + // Rewrite package + if (empty($_SESSION['error_msg'])) { + exec (VESTA_CMD."v-add-user-package ".$tmpdir." ".$v_package." 'yes'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + + // Remove tmpdir + exec ('rm -rf '.$tmpdir, $output, $return_var); + unset($output); + + // Propogate new package + exec (VESTA_CMD."v-update-user-package ".$v_package." 'json'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = "OK: changes has been saved."; + } + } + } + } + + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_package.html'); + unset($_SESSION['error_msg']); + unset($_SESSION['ok_msg']); +} + +// Footer +include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/edit/user/index.php b/web/edit/user/index.php index 947e51970..8411a5518 100644 --- a/web/edit/user/index.php +++ b/web/edit/user/index.php @@ -1,275 +1,275 @@ -', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } else { - $data = json_decode(implode('', $output), true); - unset($output); - $v_username = $_GET['user']; - $v_password = "••••••••"; - $v_email = $data[$v_username]['CONTACT']; - $v_template = $data[$v_username]['TEMPLATE']; - $v_package = $data[$v_username]['PACKAGE']; - $v_fname = $data[$v_username]['FNAME']; - $v_lname = $data[$v_username]['LNAME']; - $v_shell = $data[$v_username]['SHELL']; - $v_ns = $data[$v_username]['NS']; - $nameservers = explode(", ", $v_ns); - $v_ns1 = $nameservers[0]; - $v_ns2 = $nameservers[1]; - $v_ns3 = $nameservers[2]; - $v_ns4 = $nameservers[3]; - $v_suspended = $data[$v_username]['SUSPENDED']; - if ( $v_suspended == 'yes' ) { - $v_status = 'suspended'; - } else { - $v_status = 'active'; - } - $v_time = $data[$v_username]['TIME']; - $v_date = $data[$v_username]['DATE']; - - exec (VESTA_CMD."v-list-user-packages json", $output, $return_var); - $packages = json_decode(implode('', $output), true); - unset($output); - - exec (VESTA_CMD."v-list-web-templates json", $output, $return_var); - $templates = json_decode(implode('', $output), true); - unset($output); - - exec (VESTA_CMD."v-list-sys-shells json", $output, $return_var); - $shells = json_decode(implode('', $output), true); - unset($output); - } - - // Action - if (!empty($_POST['save'])) { - $v_username = escapeshellarg($_POST['v_username']); - - // Change password - if (($v_password != $_POST['v_password']) && (empty($_SESSION['error_msg']))) { - $v_password = escapeshellarg($_POST['v_password']); - exec (VESTA_CMD."v-change-user-password ".$v_username." ".$v_password, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - $v_password = "••••••••"; - unset($output); - } - - // Change package - if (($v_package != $_POST['v_package']) && (empty($_SESSION['error_msg']))) { - $v_package = escapeshellarg($_POST['v_package']); - exec (VESTA_CMD."v-change-user-package ".$v_username." ".$v_package, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - } - - // Change template - if (($v_template != $_POST['v_template']) && (empty($_SESSION['error_msg']))) { - $v_template = escapeshellarg($_POST['v_template']); - exec (VESTA_CMD."v-change-user-template ".$v_username." ".$v_template, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - } - - // Change shell - if (($v_shell != $_POST['v_shell']) && (empty($_SESSION['error_msg']))) { - $v_shell = escapeshellarg($_POST['v_shell']); - exec (VESTA_CMD."v-change-user-shell ".$v_username." ".$v_shell, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - } - - // Change contact email - if (($v_email != $_POST['v_email']) && (empty($_SESSION['error_msg']))) { - // Validate email - if (!filter_var($_POST['v_email'], FILTER_VALIDATE_EMAIL)) { - $_SESSION['error_msg'] = 'Please enter valid email address.'; - } else { - $v_email = escapeshellarg($_POST['v_email']); - exec (VESTA_CMD."v-change-user-contact ".$v_username." ".$v_email, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - } - unset($output); - } - - // Change Name - if (($v_fname != $_POST['v_fname']) || ($v_lname != $_POST['v_lname']) && (empty($_SESSION['error_msg']))) { - $v_fname = escapeshellarg($_POST['v_fname']); - $v_lname = escapeshellarg($_POST['v_lname']); - exec (VESTA_CMD."v-change-user-name ".$v_username." ".$v_fname." ".$v_lname, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - } - - // Change NameServers - if (($v_ns1 != $_POST['v_ns1']) || ($v_ns2 != $_POST['v_ns2']) || ($v_ns3 != $_POST['v_ns3']) || ($v_ns4 != $_POST['v_ns4']) && (empty($_SESSION['error_msg']))) { - $v_ns1 = escapeshellarg($_POST['v_ns1']); - $v_ns2 = escapeshellarg($_POST['v_ns2']); - $v_ns3 = escapeshellarg($_POST['v_ns3']); - $v_ns4 = escapeshellarg($_POST['v_ns4']); - $ns_cmd = VESTA_CMD."v-change-user-ns ".$v_username." ".$v_ns1." ".$v_ns2; - if (!empty($_POST['v_ns3'])) $ns_cmd = $ns_cmd." ".$v_ns3; - if (!empty($_POST['v_ns4'])) $ns_cmd = $ns_cmd." ".$v_ns4; - exec ($ns_cmd, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - } - - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = "OK: changes has been saved."; - } - } - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_user.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); -} else { - // Check user argument? - if (empty($_GET['user'])) { - header("Location: /list/user/"); - exit; - } - - // Check user - $v_username = escapeshellarg($_GET['user']); - exec (VESTA_CMD."v-list-user ".$v_username." json", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } else { - $data = json_decode(implode('', $output), true); - unset($output); - $v_username = $_GET['user']; - $v_password = "••••••••"; - $v_email = $data[$v_username]['CONTACT']; - $v_fname = $data[$v_username]['FNAME']; - $v_lname = $data[$v_username]['LNAME']; - $v_ns = $data[$v_username]['NS']; - $nameservers = explode(", ", $v_ns); - $v_ns1 = $nameservers[0]; - $v_ns2 = $nameservers[1]; - $v_ns3 = $nameservers[2]; - $v_ns4 = $nameservers[3]; - $v_suspended = $data[$v_username]['SUSPENDED']; - if ( $v_suspended == 'yes' ) { - $v_status = 'suspended'; - } else { - $v_status = 'active'; - } - $v_time = $data[$v_username]['TIME']; - $v_date = $data[$v_username]['DATE']; - - } - - // Action - if (!empty($_POST['save'])) { - $v_username = escapeshellarg($_POST['v_username']); - - // Change password - if (($v_password != $_POST['v_password']) && (empty($_SESSION['error_msg']))) { - $v_password = escapeshellarg($_POST['v_password']); - exec (VESTA_CMD."v-change-user-password ".$v_username." ".$v_password, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - $v_password = "••••••••"; - unset($output); - } - - // Change contact email - if (($v_email != $_POST['v_email']) && (empty($_SESSION['error_msg']))) { - $v_email = escapeshellarg($_POST['v_email']); - exec (VESTA_CMD."v-change-user-contact ".$v_username." ".$v_email, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - } - - // Change NameServers - if (($v_ns1 != $_POST['v_ns1']) || ($v_ns2 != $_POST['v_ns2']) || ($v_ns3 != $_POST['v_ns3']) || ($v_ns4 != $_POST['v_ns4']) && (empty($_SESSION['error_msg']))) { - $v_ns1 = escapeshellarg($_POST['v_ns1']); - $v_ns2 = escapeshellarg($_POST['v_ns2']); - $v_ns3 = escapeshellarg($_POST['v_ns3']); - $v_ns4 = escapeshellarg($_POST['v_ns4']); - $ns_cmd = VESTA_CMD."v-change-user-ns ".$v_username." ".$v_ns1." ".$v_ns2; - if (!empty($_POST['v_ns3'])) $ns_cmd = $ns_cmd." ".$v_ns3; - if (!empty($_POST['v_ns4'])) $ns_cmd = $ns_cmd." ".$v_ns4; - exec ($ns_cmd, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - } - - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = "OK: changes has been saved."; - } - } - include($_SERVER['DOCUMENT_ROOT'].'/templates/user/edit_user.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); -} - -// Footer -include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } else { + $data = json_decode(implode('', $output), true); + unset($output); + $v_username = $_GET['user']; + $v_password = "••••••••"; + $v_email = $data[$v_username]['CONTACT']; + $v_template = $data[$v_username]['TEMPLATE']; + $v_package = $data[$v_username]['PACKAGE']; + $v_fname = $data[$v_username]['FNAME']; + $v_lname = $data[$v_username]['LNAME']; + $v_shell = $data[$v_username]['SHELL']; + $v_ns = $data[$v_username]['NS']; + $nameservers = explode(", ", $v_ns); + $v_ns1 = $nameservers[0]; + $v_ns2 = $nameservers[1]; + $v_ns3 = $nameservers[2]; + $v_ns4 = $nameservers[3]; + $v_suspended = $data[$v_username]['SUSPENDED']; + if ( $v_suspended == 'yes' ) { + $v_status = 'suspended'; + } else { + $v_status = 'active'; + } + $v_time = $data[$v_username]['TIME']; + $v_date = $data[$v_username]['DATE']; + + exec (VESTA_CMD."v-list-user-packages json", $output, $return_var); + $packages = json_decode(implode('', $output), true); + unset($output); + + exec (VESTA_CMD."v-list-web-templates json", $output, $return_var); + $templates = json_decode(implode('', $output), true); + unset($output); + + exec (VESTA_CMD."v-list-sys-shells json", $output, $return_var); + $shells = json_decode(implode('', $output), true); + unset($output); + } + + // Action + if (!empty($_POST['save'])) { + $v_username = escapeshellarg($_POST['v_username']); + + // Change password + if (($v_password != $_POST['v_password']) && (empty($_SESSION['error_msg']))) { + $v_password = escapeshellarg($_POST['v_password']); + exec (VESTA_CMD."v-change-user-password ".$v_username." ".$v_password, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $v_password = "••••••••"; + unset($output); + } + + // Change package + if (($v_package != $_POST['v_package']) && (empty($_SESSION['error_msg']))) { + $v_package = escapeshellarg($_POST['v_package']); + exec (VESTA_CMD."v-change-user-package ".$v_username." ".$v_package, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + + // Change template + if (($v_template != $_POST['v_template']) && (empty($_SESSION['error_msg']))) { + $v_template = escapeshellarg($_POST['v_template']); + exec (VESTA_CMD."v-change-user-template ".$v_username." ".$v_template, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + + // Change shell + if (($v_shell != $_POST['v_shell']) && (empty($_SESSION['error_msg']))) { + $v_shell = escapeshellarg($_POST['v_shell']); + exec (VESTA_CMD."v-change-user-shell ".$v_username." ".$v_shell, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + + // Change contact email + if (($v_email != $_POST['v_email']) && (empty($_SESSION['error_msg']))) { + // Validate email + if (!filter_var($_POST['v_email'], FILTER_VALIDATE_EMAIL)) { + $_SESSION['error_msg'] = _('Please enter valid email address.'); + } else { + $v_email = escapeshellarg($_POST['v_email']); + exec (VESTA_CMD."v-change-user-contact ".$v_username." ".$v_email, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + } + unset($output); + } + + // Change Name + if (($v_fname != $_POST['v_fname']) || ($v_lname != $_POST['v_lname']) && (empty($_SESSION['error_msg']))) { + $v_fname = escapeshellarg($_POST['v_fname']); + $v_lname = escapeshellarg($_POST['v_lname']); + exec (VESTA_CMD."v-change-user-name ".$v_username." ".$v_fname." ".$v_lname, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + + // Change NameServers + if (($v_ns1 != $_POST['v_ns1']) || ($v_ns2 != $_POST['v_ns2']) || ($v_ns3 != $_POST['v_ns3']) || ($v_ns4 != $_POST['v_ns4']) && (empty($_SESSION['error_msg']))) { + $v_ns1 = escapeshellarg($_POST['v_ns1']); + $v_ns2 = escapeshellarg($_POST['v_ns2']); + $v_ns3 = escapeshellarg($_POST['v_ns3']); + $v_ns4 = escapeshellarg($_POST['v_ns4']); + $ns_cmd = VESTA_CMD."v-change-user-ns ".$v_username." ".$v_ns1." ".$v_ns2; + if (!empty($_POST['v_ns3'])) $ns_cmd = $ns_cmd." ".$v_ns3; + if (!empty($_POST['v_ns4'])) $ns_cmd = $ns_cmd." ".$v_ns4; + exec ($ns_cmd, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = "OK: changes has been saved."; + } + } + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_user.html'); + unset($_SESSION['error_msg']); + unset($_SESSION['ok_msg']); +} else { + // Check user argument? + if (empty($_GET['user'])) { + header("Location: /list/user/"); + exit; + } + + // Check user + $v_username = escapeshellarg($_GET['user']); + exec (VESTA_CMD."v-list-user ".$v_username." json", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } else { + $data = json_decode(implode('', $output), true); + unset($output); + $v_username = $_GET['user']; + $v_password = "••••••••"; + $v_email = $data[$v_username]['CONTACT']; + $v_fname = $data[$v_username]['FNAME']; + $v_lname = $data[$v_username]['LNAME']; + $v_ns = $data[$v_username]['NS']; + $nameservers = explode(", ", $v_ns); + $v_ns1 = $nameservers[0]; + $v_ns2 = $nameservers[1]; + $v_ns3 = $nameservers[2]; + $v_ns4 = $nameservers[3]; + $v_suspended = $data[$v_username]['SUSPENDED']; + if ( $v_suspended == 'yes' ) { + $v_status = 'suspended'; + } else { + $v_status = 'active'; + } + $v_time = $data[$v_username]['TIME']; + $v_date = $data[$v_username]['DATE']; + + } + + // Action + if (!empty($_POST['save'])) { + $v_username = escapeshellarg($_POST['v_username']); + + // Change password + if (($v_password != $_POST['v_password']) && (empty($_SESSION['error_msg']))) { + $v_password = escapeshellarg($_POST['v_password']); + exec (VESTA_CMD."v-change-user-password ".$v_username." ".$v_password, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $v_password = "••••••••"; + unset($output); + } + + // Change contact email + if (($v_email != $_POST['v_email']) && (empty($_SESSION['error_msg']))) { + $v_email = escapeshellarg($_POST['v_email']); + exec (VESTA_CMD."v-change-user-contact ".$v_username." ".$v_email, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + + // Change NameServers + if (($v_ns1 != $_POST['v_ns1']) || ($v_ns2 != $_POST['v_ns2']) || ($v_ns3 != $_POST['v_ns3']) || ($v_ns4 != $_POST['v_ns4']) && (empty($_SESSION['error_msg']))) { + $v_ns1 = escapeshellarg($_POST['v_ns1']); + $v_ns2 = escapeshellarg($_POST['v_ns2']); + $v_ns3 = escapeshellarg($_POST['v_ns3']); + $v_ns4 = escapeshellarg($_POST['v_ns4']); + $ns_cmd = VESTA_CMD."v-change-user-ns ".$v_username." ".$v_ns1." ".$v_ns2; + if (!empty($_POST['v_ns3'])) $ns_cmd = $ns_cmd." ".$v_ns3; + if (!empty($_POST['v_ns4'])) $ns_cmd = $ns_cmd." ".$v_ns4; + exec ($ns_cmd, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = "OK: changes has been saved."; + } + } + include($_SERVER['DOCUMENT_ROOT'].'/templates/user/edit_user.html'); + unset($_SESSION['error_msg']); + unset($_SESSION['ok_msg']); +} + +// Footer +include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/edit/web/index.php b/web/edit/web/index.php index f453fb5ba..ace532dc6 100644 --- a/web/edit/web/index.php +++ b/web/edit/web/index.php @@ -1,591 +1,591 @@ -', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } else { - $data = json_decode(implode('', $output), true); - unset($output); - $v_username = $user; - $v_domain = $_GET['domain']; - $v_ip = $data[$v_domain]['IP']; - $v_template = $data[$v_domain]['TPL']; - $v_aliases = str_replace(',', "\n", $data[$v_domain]['ALIAS']); - $valiases = explode(",", $data[$v_domain]['ALIAS']); - $v_tpl = $data[$v_domain]['IP']; - $v_cgi = $data[$v_domain]['CGI']; - $v_elog = $data[$v_domain]['ELOG']; - $v_ssl = $data[$v_domain]['SSL']; - if ( $v_ssl == 'yes' ) { - exec (VESTA_CMD."v-list-web-domain-ssl ".$user." '".$v_domain."' json", $output, $return_var); - $ssl_str = json_decode(implode('', $output), true); - unset($output); - $v_ssl_crt = $ssl_str[$v_domain]['CRT']; - $v_ssl_key = $ssl_str[$v_domain]['KEY']; - $v_ssl_ca = $ssl_str[$v_domain]['CA']; - } - $v_ssl_home = $data[$v_domain]['SSL_HOME']; - $v_nginx = $data[$v_domain]['NGINX']; - $v_nginx_ext = str_replace(',', ', ', $data[$v_domain]['NGINX_EXT']); - $v_stats = $data[$v_domain]['STATS']; - $v_stats_user = $data[$v_domain]['STATS_USER']; - if (!empty($v_stats_user)) $v_stats_password = "••••••••"; - $v_ftp_user = $data[$v_domain]['FTP_USER']; - if (!empty($v_ftp_user)) $v_ftp_password = "••••••••"; - $v_suspended = $data[$v_domain]['SUSPENDED']; - if ( $v_suspended == 'yes' ) { - $v_status = 'suspended'; - } else { - $v_status = 'active'; - } - $v_time = $data[$v_domain]['TIME']; - $v_date = $data[$v_domain]['DATE']; - - exec (VESTA_CMD."v-list-user-ips ".$user." json", $output, $return_var); - $ips = json_decode(implode('', $output), true); - unset($output); - - exec (VESTA_CMD."v-list-web-templates json", $output, $return_var); - $templates = json_decode(implode('', $output), true); - unset($output); - - exec (VESTA_CMD."v-list-web-stats json", $output, $return_var); - $stats = json_decode(implode('', $output), true); - unset($output); - } - - // Action - if (!empty($_POST['save'])) { - $v_domain = escapeshellarg($_POST['v_domain']); - - // IP - if (($v_ip != $_POST['v_ip']) && (empty($_SESSION['error_msg']))) { - $v_ip = escapeshellarg($_POST['v_ip']); - exec (VESTA_CMD."v-change-web-domain-ip ".$v_username." ".$v_domain." ".$v_ip." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - $restart_web = 'yes'; - unset($output); - exec (VESTA_CMD."v-list-dns-domain ".$v_username." ".$v_domain." json", $output, $return_var); - if ((empty($_SESSION['error_msg'])) && ($return_var == 0 )) { - exec (VESTA_CMD."v-change-dns-domain-ip ".$v_username." ".$v_domain." ".$v_ip." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - $restart_dns = 'yes'; - } - unset($output); - foreach($valiases as $v_alias ){ - exec (VESTA_CMD."v-list-dns-domain ".$v_username." '".$v_alias."' json", $output, $return_var); - if ((empty($_SESSION['error_msg'])) && ($return_var == 0 )) { - exec (VESTA_CMD."v-change-dns-domain-ip ".$v_username." '".$v_alias."' ".$v_ip, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - $restart_dns = 'yes'; - } - unset($output); - } - } - - // Template - if (( $_SESSION['user'] == 'admin') && ($v_template != $_POST['v_template']) && (empty($_SESSION['error_msg']))) { - $v_template = escapeshellarg($_POST['v_template']); - exec (VESTA_CMD."v-change-web-domain-tpl ".$v_username." ".$v_domain." ".$v_template." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $restart_web = 'yes'; - } - - // Aliases - if (empty($_SESSION['error_msg'])) { - $waliases = preg_replace("/\n/", " ", $_POST['v_aliases']); - $waliases = preg_replace("/,/", " ", $waliases); - $waliases = preg_replace('/\s+/', ' ',$waliases); - $waliases = trim($waliases); - $aliases = explode(" ", $waliases); - $v_aliases = str_replace(' ', "\n", $waliases); - $result = array_diff($valiases, $aliases); - foreach ($result as $alias) { - if ((empty($_SESSION['error_msg'])) && (!empty($alias))) { - $restart_web = 'yes'; - $v_template = escapeshellarg($_POST['v_template']); - exec (VESTA_CMD."v-delete-web-domain-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - - if (empty($_SESSION['error_msg'])) { - exec (VESTA_CMD."v-delete-dns-on-web-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - $restart_dns = 'yes'; - } - unset($output); - } - } - - $result = array_diff($aliases, $valiases); - foreach ($result as $alias) { - if ((empty($_SESSION['error_msg'])) && (!empty($alias))) { - $restart_web = 'yes'; - $v_template = escapeshellarg($_POST['v_template']); - exec (VESTA_CMD."v-add-web-domain-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - if (empty($_SESSION['error_msg'])) { - exec (VESTA_CMD."v-add-dns-on-web-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - $restart_dns = 'yes'; - } - unset($output); - } - } - } - - // Nginx - if ((!empty($v_nginx)) && (empty($_POST['v_nginx'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-delete-web-domain-nginx ".$v_username." ".$v_domain." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - unset($v_nginx); - $restart_web = 'yes'; - } - if ((!empty($v_nginx)) && (!empty($_POST['v_nginx'])) && (empty($_SESSION['error_msg']))) { - $ext = preg_replace("/\n/", " ", $_POST['v_nginx_ext']); - $ext = preg_replace("/,/", " ", $ext); - $ext = preg_replace('/\s+/', ' ',$ext); - $ext = trim($ext); - $ext = str_replace(' ', ", ", $ext); - if ( $v_nginx_ext != $ext ) { - $ext = str_replace(', ', ",", $ext); - exec (VESTA_CMD."v-change-web-domain-nginx-tpl ".$v_username." ".$v_domain." 'default' ".escapeshellarg($ext)." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - $v_nginx_ext = str_replace(',', ', ', $ext); - unset($output); - $restart_web = 'yes'; - } - } - if ((empty($v_nginx)) && (!empty($_POST['v_nginx'])) && (empty($_SESSION['error_msg']))) { - $nginx_ext = "'jpg,jpeg,gif,png,ico,css,zip,tgz,gz,rar,bz2,doc,xls,exe,pdf,ppt,txt,tar,wav,bmp,rtf,js,mp3,avi,mpeg,html,htm'"; - if (!empty($_POST['v_nginx_ext'])) { - $ext = preg_replace("/\n/", " ", $_POST['v_nginx_ext']); - $ext = preg_replace("/,/", " ", $ext); - $ext = preg_replace('/\s+/', ' ',$ext); - $ext = trim($ext); - $ext = str_replace(' ', ",", $ext); - $v_nginx_ext = str_replace(',', ', ', $ext); - } - exec (VESTA_CMD."v-add-web-domain-nginx ".$v_username." ".$v_domain." 'default' ".escapeshellarg($ext)." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_nginx = 'default'; - $restart_web = 'yes'; - } - - // SSL - if (( $v_ssl == 'yes' ) && (empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-delete-web-domain-ssl ".$v_username." ".$v_domain." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_ssl = 'no'; - $restart_web = 'yes'; - } - if (($v_ssl == 'yes') && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) { - if (( $v_ssl_crt != str_replace("\r\n", "\n", $_POST['v_ssl_crt'])) || ( $v_ssl_key != str_replace("\r\n", "\n", $_POST['v_ssl_key'])) || ( $v_ssl_ca != str_replace("\r\n", "\n", $_POST['v_ssl_ca']))) { - exec ('mktemp -d', $mktemp_output, $return_var); - $tmpdir = $mktemp_output[0]; - - // Certificate - if (!empty($_POST['v_ssl_crt'])) { - $fp = fopen($tmpdir."/".$_POST['v_domain'].".crt", 'w'); - fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_crt'])); - fwrite($fp, "\n"); - fclose($fp); - } - - // Key - if (!empty($_POST['v_ssl_key'])) { - $fp = fopen($tmpdir."/".$_POST['v_domain'].".key", 'w'); - fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_key'])); - fwrite($fp, "\n"); - fclose($fp); - } - - // CA - if (!empty($_POST['v_ssl_ca'])) { - $fp = fopen($tmpdir."/".$_POST['v_domain'].".ca", 'w'); - fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_ca'])); - fwrite($fp, "\n"); - fclose($fp); - } - - exec (VESTA_CMD."v-change-web-domain-sslcert ".$user." ".$v_domain." ".$tmpdir." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $restart_web = 'yes'; - $v_ssl_crt = $_POST['v_ssl_crt']; - $v_ssl_key = $_POST['v_ssl_key']; - $v_ssl_ca = $_POST['v_ssl_ca']; - } - } - if (( $v_ssl == 'yes') && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) { - if ( $v_ssl_home != $_POST['v_ssl_home'] ) { - $v_ssl_home = escapeshellarg($_POST['v_ssl_home']); - exec (VESTA_CMD."v-change-web-domain-sslhome ".$user." ".$v_domain." ".$v_ssl_home." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - $v_ssl_home = $_POST['v_ssl_home']; - unset($output); - } - } - if (( $v_ssl == 'no') && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) { - if ((!empty($_POST['v_ssl'])) && (empty($_POST['v_ssl_crt']))) $errors[] = 'ssl certificate'; - if ((!empty($_POST['v_ssl'])) && (empty($_POST['v_ssl_key']))) $errors[] = 'ssl key'; - if ((!empty($_POST['v_ssl'])) && (empty($_POST['v_ssl_home']))) $errors[] = 'ssl home'; - $v_ssl_home = escapeshellarg($_POST['v_ssl_home']); - if (!empty($errors[0])) { - foreach ($errors as $i => $error) { - if ( $i == 0 ) { - $error_msg = $error; - } else { - $error_msg = $error_msg.", ".$error; - } - } - $_SESSION['error_msg'] = "Error: field ".$error_msg." can not be blank."; - } else { - exec ('mktemp -d', $mktemp_output, $return_var); - $tmpdir = $mktemp_output[0]; - - // Certificate - if (!empty($_POST['v_ssl_crt'])) { - $fp = fopen($tmpdir."/".$_POST['v_domain'].".crt", 'w'); - fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_crt'])); - fclose($fp); - } - - // Key - if (!empty($_POST['v_ssl_key'])) { - $fp = fopen($tmpdir."/".$_POST['v_domain'].".key", 'w'); - fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_key'])); - fclose($fp); - } - - // CA - if (!empty($_POST['v_ssl_ca'])) { - $fp = fopen($tmpdir."/".$_POST['v_domain'].".ca", 'w'); - fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_ca'])); - fclose($fp); - } - exec (VESTA_CMD."v-add-web-domain-ssl ".$user." ".$v_domain." ".$tmpdir." ".$v_ssl_home." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_ssl = 'yes'; - $restart_web = 'yes'; - $v_ssl_crt = $_POST['v_ssl_crt']; - $v_ssl_key = $_POST['v_ssl_key']; - $v_ssl_ca = $_POST['v_ssl_ca']; - $v_ssl_home = $_POST['v_ssl_home']; - } - } - - // Web Stats - if ((!empty($v_stats)) && ($_POST['v_stats'] == 'none') && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-delete-web-domain-stats ".$v_username." ".$v_domain, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_stats = ''; - } - if ((!empty($v_stats)) && ($_POST['v_stats'] != $v_stats) && (empty($_SESSION['error_msg']))) { - $v_stats = escapeshellarg($_POST['v_stats']); - exec (VESTA_CMD."v-change-web-domain-stats ".$v_username." ".$v_domain." ".$v_stats, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - } - if ((empty($v_stats)) && ($_POST['v_stats'] != 'none') && (empty($_SESSION['error_msg']))) { - $v_stats = escapeshellarg($_POST['v_stats']); - exec (VESTA_CMD."v-add-web-domain-stats ".$v_username." ".$v_domain." ".$v_stats, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - } - - // Web Stats Auth - if ((!empty($v_stats_user)) && (empty($_POST['v_stats_auth'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-delete-web-domain-stats-user ".$v_username." ".$v_domain, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_stats_user = ''; - $v_stats_password = ''; - } - if ((empty($v_stats_user)) && (!empty($_POST['v_stats_auth'])) && (empty($_SESSION['error_msg']))) { - if (empty($_POST['v_stats_user'])) $errors[] = 'stats username'; - if (empty($_POST['v_stats_password'])) $errors[] = 'stats password'; - if (!empty($errors[0])) { - foreach ($errors as $i => $error) { - if ( $i == 0 ) { - $error_msg = $error; - } else { - $error_msg = $error_msg.", ".$error; - } - } - $_SESSION['error_msg'] = "Error: field ".$error_msg." can not be blank."; - } else { - $v_stats_user = escapeshellarg($_POST['v_stats_user']); - $v_stats_password = escapeshellarg($_POST['v_stats_password']); - exec (VESTA_CMD."v-add-web-domain-stats-user ".$v_username." ".$v_domain." ".$v_stats_user." ".$v_stats_password, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_stats_password = "••••••••"; - } - } - if ((!empty($v_stats_user)) && (!empty($_POST['v_stats_auth'])) && (empty($_SESSION['error_msg']))) { - if (empty($_POST['v_stats_user'])) $errors[] = 'stats user'; - if (empty($_POST['v_stats_password'])) $errors[] = 'stats password'; - if (!empty($errors[0])) { - foreach ($errors as $i => $error) { - if ( $i == 0 ) { - $error_msg = $error; - } else { - $error_msg = $error_msg.", ".$error; - } - } - $_SESSION['error_msg'] = "Error: field ".$error_msg." can not be blank."; - } - if (($v_stats_user != $_POST['v_stats_user']) || ($_POST['v_stats_password'] != "••••••••" ) && (empty($_SESSION['error_msg']))) { - $v_stats_user = escapeshellarg($_POST['v_stats_user']); - $v_stats_password = escapeshellarg($_POST['v_stats_password']); - exec (VESTA_CMD."v-add-web-domain-stats-user ".$v_username." ".$v_domain." ".$v_stats_user." ".$v_stats_password, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_stats_password = "••••••••"; - } - } - - // FTP Account - if ((!empty($v_ftp_user)) && (empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-delete-web-domain-ftp ".$v_username." ".$v_domain, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_ftp= ''; - $v_ftp_user = ''; - $v_ftp_password = ''; - } - if ((!empty($v_ftp_user)) && (!empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) { - if (empty($_POST['v_ftp_user'])) $errors[] = 'ftp user'; - if (empty($_POST['v_ftp_password'])) $errors[] = 'ftp password'; - if (!empty($errors[0])) { - foreach ($errors as $i => $error) { - if ( $i == 0 ) { - $error_msg = $error; - } else { - $error_msg = $error_msg.", ".$error; - } - } - $_SESSION['error_msg'] = "Error: field ".$error_msg." can not be blank."; - } - if (($v_ftp_user != $_POST['v_ftp_user']) || ($_POST['v_ftp_password'] != "••••••••" ) && (empty($_SESSION['error_msg']))) { - $v_ftp_user = preg_replace("/^".$user."_/", "", $_POST['v_ftp_user']); - $v_ftp_user = escapeshellarg($v_ftp_user); - $v_ftp_password = escapeshellarg($_POST['v_ftp_password']); - exec (VESTA_CMD."v-add-web-domain-ftp ".$v_username." ".$v_domain." ".$v_ftp_user." ".$v_ftp_password, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_ftp_user = $user."_".$_POST['v_ftp_user']; - $v_ftp_password = "••••••••"; - } - } - - if ((empty($v_ftp_user)) && (!empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) { - if ((!empty($_POST['v_ftp_email'])) && (!filter_var($_POST['v_ftp_email'], FILTER_VALIDATE_EMAIL))) $_SESSION['error_msg'] = 'Please enter valid email address.'; - if (empty($_POST['v_ftp_user'])) $errors[] = 'ftp username'; - if (empty($_POST['v_ftp_password'])) $errors[] = 'ftp password'; - if (!empty($errors[0])) { - foreach ($errors as $i => $error) { - if ( $i == 0 ) { - $error_msg = $error; - } else { - $error_msg = $error_msg.", ".$error; - } - } - $_SESSION['error_msg'] = "Error: field ".$error_msg." can not be blank."; - } - if (empty($_SESSION['error_msg'])) { - $v_ftp_user = escapeshellarg($_POST['v_ftp_user']); - $v_ftp_password = escapeshellarg($_POST['v_ftp_password']); - exec (VESTA_CMD."v-add-web-domain-ftp ".$v_username." ".$v_domain." ".$v_ftp_user." ".$v_ftp_password, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } else { - if (!empty($_POST['v_ftp_email'])) { - $to = $_POST['v_ftp_email']; - $subject = "FTP login credentials"; - $hostname = exec('hostname'); - $from = "Vesta Control Panel "; - $mailtext .= "Your ftp account has been created successfully and is ready to use.\n\n"; - $mailtext .= "hostname: ".$_GET['domain']."\n"; - $mailtext .= "username: ".$user."_".$_POST['v_ftp_user']."\n"; - $mailtext .= "password: ".$_POST['v_ftp_password']."\n\n"; - $mailtext .= "--\nVesta Control Panel\n"; - send_email($to, $subject, $mailtext, $from); - unset($v_ftp_email); - } - } - unset($output); - $v_ftp_user = $user."_".$_POST['v_ftp_user']; - $v_ftp_password = "••••••••"; - } - } - - // Restart web - if (!empty($restart_web) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-restart-web", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - } - - // Restart dns - if (!empty($restart_dns) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-restart-dns", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - } - - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = "OK: changes has been saved."; - } - - } -if ($_SESSION['user'] == 'admin') { - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_web.html'); -} else { - include($_SERVER['DOCUMENT_ROOT'].'/templates/user/edit_web.html'); -} - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); -//} - -// Footer -include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } else { + $data = json_decode(implode('', $output), true); + unset($output); + $v_username = $user; + $v_domain = $_GET['domain']; + $v_ip = $data[$v_domain]['IP']; + $v_template = $data[$v_domain]['TPL']; + $v_aliases = str_replace(',', "\n", $data[$v_domain]['ALIAS']); + $valiases = explode(",", $data[$v_domain]['ALIAS']); + $v_tpl = $data[$v_domain]['IP']; + $v_cgi = $data[$v_domain]['CGI']; + $v_elog = $data[$v_domain]['ELOG']; + $v_ssl = $data[$v_domain]['SSL']; + if ( $v_ssl == 'yes' ) { + exec (VESTA_CMD."v-list-web-domain-ssl ".$user." '".$v_domain."' json", $output, $return_var); + $ssl_str = json_decode(implode('', $output), true); + unset($output); + $v_ssl_crt = $ssl_str[$v_domain]['CRT']; + $v_ssl_key = $ssl_str[$v_domain]['KEY']; + $v_ssl_ca = $ssl_str[$v_domain]['CA']; + } + $v_ssl_home = $data[$v_domain]['SSL_HOME']; + $v_nginx = $data[$v_domain]['NGINX']; + $v_nginx_ext = str_replace(',', ', ', $data[$v_domain]['NGINX_EXT']); + $v_stats = $data[$v_domain]['STATS']; + $v_stats_user = $data[$v_domain]['STATS_USER']; + if (!empty($v_stats_user)) $v_stats_password = "••••••••"; + $v_ftp_user = $data[$v_domain]['FTP_USER']; + if (!empty($v_ftp_user)) $v_ftp_password = "••••••••"; + $v_suspended = $data[$v_domain]['SUSPENDED']; + if ( $v_suspended == 'yes' ) { + $v_status = 'suspended'; + } else { + $v_status = 'active'; + } + $v_time = $data[$v_domain]['TIME']; + $v_date = $data[$v_domain]['DATE']; + + exec (VESTA_CMD."v-list-user-ips ".$user." json", $output, $return_var); + $ips = json_decode(implode('', $output), true); + unset($output); + + exec (VESTA_CMD."v-list-web-templates json", $output, $return_var); + $templates = json_decode(implode('', $output), true); + unset($output); + + exec (VESTA_CMD."v-list-web-stats json", $output, $return_var); + $stats = json_decode(implode('', $output), true); + unset($output); + } + + // Action + if (!empty($_POST['save'])) { + $v_domain = escapeshellarg($_POST['v_domain']); + + // IP + if (($v_ip != $_POST['v_ip']) && (empty($_SESSION['error_msg']))) { + $v_ip = escapeshellarg($_POST['v_ip']); + exec (VESTA_CMD."v-change-web-domain-ip ".$v_username." ".$v_domain." ".$v_ip." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $restart_web = 'yes'; + unset($output); + exec (VESTA_CMD."v-list-dns-domain ".$v_username." ".$v_domain." json", $output, $return_var); + if ((empty($_SESSION['error_msg'])) && ($return_var == 0 )) { + exec (VESTA_CMD."v-change-dns-domain-ip ".$v_username." ".$v_domain." ".$v_ip." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $restart_dns = 'yes'; + } + unset($output); + foreach($valiases as $v_alias ){ + exec (VESTA_CMD."v-list-dns-domain ".$v_username." '".$v_alias."' json", $output, $return_var); + if ((empty($_SESSION['error_msg'])) && ($return_var == 0 )) { + exec (VESTA_CMD."v-change-dns-domain-ip ".$v_username." '".$v_alias."' ".$v_ip, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $restart_dns = 'yes'; + } + unset($output); + } + } + + // Template + if (( $_SESSION['user'] == 'admin') && ($v_template != $_POST['v_template']) && (empty($_SESSION['error_msg']))) { + $v_template = escapeshellarg($_POST['v_template']); + exec (VESTA_CMD."v-change-web-domain-tpl ".$v_username." ".$v_domain." ".$v_template." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $restart_web = 'yes'; + } + + // Aliases + if (empty($_SESSION['error_msg'])) { + $waliases = preg_replace("/\n/", " ", $_POST['v_aliases']); + $waliases = preg_replace("/,/", " ", $waliases); + $waliases = preg_replace('/\s+/', ' ',$waliases); + $waliases = trim($waliases); + $aliases = explode(" ", $waliases); + $v_aliases = str_replace(' ', "\n", $waliases); + $result = array_diff($valiases, $aliases); + foreach ($result as $alias) { + if ((empty($_SESSION['error_msg'])) && (!empty($alias))) { + $restart_web = 'yes'; + $v_template = escapeshellarg($_POST['v_template']); + exec (VESTA_CMD."v-delete-web-domain-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + + if (empty($_SESSION['error_msg'])) { + exec (VESTA_CMD."v-delete-dns-on-web-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $restart_dns = 'yes'; + } + unset($output); + } + } + + $result = array_diff($aliases, $valiases); + foreach ($result as $alias) { + if ((empty($_SESSION['error_msg'])) && (!empty($alias))) { + $restart_web = 'yes'; + $v_template = escapeshellarg($_POST['v_template']); + exec (VESTA_CMD."v-add-web-domain-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + if (empty($_SESSION['error_msg'])) { + exec (VESTA_CMD."v-add-dns-on-web-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $restart_dns = 'yes'; + } + unset($output); + } + } + } + + // Nginx + if ((!empty($v_nginx)) && (empty($_POST['v_nginx'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-delete-web-domain-nginx ".$v_username." ".$v_domain." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + unset($v_nginx); + $restart_web = 'yes'; + } + if ((!empty($v_nginx)) && (!empty($_POST['v_nginx'])) && (empty($_SESSION['error_msg']))) { + $ext = preg_replace("/\n/", " ", $_POST['v_nginx_ext']); + $ext = preg_replace("/,/", " ", $ext); + $ext = preg_replace('/\s+/', ' ',$ext); + $ext = trim($ext); + $ext = str_replace(' ', ", ", $ext); + if ( $v_nginx_ext != $ext ) { + $ext = str_replace(', ', ",", $ext); + exec (VESTA_CMD."v-change-web-domain-nginx-tpl ".$v_username." ".$v_domain." 'default' ".escapeshellarg($ext)." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $v_nginx_ext = str_replace(',', ', ', $ext); + unset($output); + $restart_web = 'yes'; + } + } + if ((empty($v_nginx)) && (!empty($_POST['v_nginx'])) && (empty($_SESSION['error_msg']))) { + $nginx_ext = "'jpg,jpeg,gif,png,ico,css,zip,tgz,gz,rar,bz2,doc,xls,exe,pdf,ppt,txt,tar,wav,bmp,rtf,js,mp3,avi,mpeg,html,htm'"; + if (!empty($_POST['v_nginx_ext'])) { + $ext = preg_replace("/\n/", " ", $_POST['v_nginx_ext']); + $ext = preg_replace("/,/", " ", $ext); + $ext = preg_replace('/\s+/', ' ',$ext); + $ext = trim($ext); + $ext = str_replace(' ', ",", $ext); + $v_nginx_ext = str_replace(',', ', ', $ext); + } + exec (VESTA_CMD."v-add-web-domain-nginx ".$v_username." ".$v_domain." 'default' ".escapeshellarg($ext)." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_nginx = 'default'; + $restart_web = 'yes'; + } + + // SSL + if (( $v_ssl == 'yes' ) && (empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-delete-web-domain-ssl ".$v_username." ".$v_domain." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_ssl = 'no'; + $restart_web = 'yes'; + } + if (($v_ssl == 'yes') && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) { + if (( $v_ssl_crt != str_replace("\r\n", "\n", $_POST['v_ssl_crt'])) || ( $v_ssl_key != str_replace("\r\n", "\n", $_POST['v_ssl_key'])) || ( $v_ssl_ca != str_replace("\r\n", "\n", $_POST['v_ssl_ca']))) { + exec ('mktemp -d', $mktemp_output, $return_var); + $tmpdir = $mktemp_output[0]; + + // Certificate + if (!empty($_POST['v_ssl_crt'])) { + $fp = fopen($tmpdir."/".$_POST['v_domain'].".crt", 'w'); + fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_crt'])); + fwrite($fp, "\n"); + fclose($fp); + } + + // Key + if (!empty($_POST['v_ssl_key'])) { + $fp = fopen($tmpdir."/".$_POST['v_domain'].".key", 'w'); + fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_key'])); + fwrite($fp, "\n"); + fclose($fp); + } + + // CA + if (!empty($_POST['v_ssl_ca'])) { + $fp = fopen($tmpdir."/".$_POST['v_domain'].".ca", 'w'); + fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_ca'])); + fwrite($fp, "\n"); + fclose($fp); + } + + exec (VESTA_CMD."v-change-web-domain-sslcert ".$user." ".$v_domain." ".$tmpdir." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $restart_web = 'yes'; + $v_ssl_crt = $_POST['v_ssl_crt']; + $v_ssl_key = $_POST['v_ssl_key']; + $v_ssl_ca = $_POST['v_ssl_ca']; + } + } + if (( $v_ssl == 'yes') && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) { + if ( $v_ssl_home != $_POST['v_ssl_home'] ) { + $v_ssl_home = escapeshellarg($_POST['v_ssl_home']); + exec (VESTA_CMD."v-change-web-domain-sslhome ".$user." ".$v_domain." ".$v_ssl_home." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $v_ssl_home = $_POST['v_ssl_home']; + unset($output); + } + } + if (( $v_ssl == 'no') && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) { + if ((!empty($_POST['v_ssl'])) && (empty($_POST['v_ssl_crt']))) $errors[] = 'ssl certificate'; + if ((!empty($_POST['v_ssl'])) && (empty($_POST['v_ssl_key']))) $errors[] = 'ssl key'; + if ((!empty($_POST['v_ssl'])) && (empty($_POST['v_ssl_home']))) $errors[] = 'ssl home'; + $v_ssl_home = escapeshellarg($_POST['v_ssl_home']); + if (!empty($errors[0])) { + foreach ($errors as $i => $error) { + if ( $i == 0 ) { + $error_msg = $error; + } else { + $error_msg = $error_msg.", ".$error; + } + } + $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); + } else { + exec ('mktemp -d', $mktemp_output, $return_var); + $tmpdir = $mktemp_output[0]; + + // Certificate + if (!empty($_POST['v_ssl_crt'])) { + $fp = fopen($tmpdir."/".$_POST['v_domain'].".crt", 'w'); + fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_crt'])); + fclose($fp); + } + + // Key + if (!empty($_POST['v_ssl_key'])) { + $fp = fopen($tmpdir."/".$_POST['v_domain'].".key", 'w'); + fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_key'])); + fclose($fp); + } + + // CA + if (!empty($_POST['v_ssl_ca'])) { + $fp = fopen($tmpdir."/".$_POST['v_domain'].".ca", 'w'); + fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_ca'])); + fclose($fp); + } + exec (VESTA_CMD."v-add-web-domain-ssl ".$user." ".$v_domain." ".$tmpdir." ".$v_ssl_home." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_ssl = 'yes'; + $restart_web = 'yes'; + $v_ssl_crt = $_POST['v_ssl_crt']; + $v_ssl_key = $_POST['v_ssl_key']; + $v_ssl_ca = $_POST['v_ssl_ca']; + $v_ssl_home = $_POST['v_ssl_home']; + } + } + + // Web Stats + if ((!empty($v_stats)) && ($_POST['v_stats'] == 'none') && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-delete-web-domain-stats ".$v_username." ".$v_domain, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_stats = ''; + } + if ((!empty($v_stats)) && ($_POST['v_stats'] != $v_stats) && (empty($_SESSION['error_msg']))) { + $v_stats = escapeshellarg($_POST['v_stats']); + exec (VESTA_CMD."v-change-web-domain-stats ".$v_username." ".$v_domain." ".$v_stats, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + if ((empty($v_stats)) && ($_POST['v_stats'] != 'none') && (empty($_SESSION['error_msg']))) { + $v_stats = escapeshellarg($_POST['v_stats']); + exec (VESTA_CMD."v-add-web-domain-stats ".$v_username." ".$v_domain." ".$v_stats, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + + // Web Stats Auth + if ((!empty($v_stats_user)) && (empty($_POST['v_stats_auth'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-delete-web-domain-stats-user ".$v_username." ".$v_domain, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_stats_user = ''; + $v_stats_password = ''; + } + if ((empty($v_stats_user)) && (!empty($_POST['v_stats_auth'])) && (empty($_SESSION['error_msg']))) { + if (empty($_POST['v_stats_user'])) $errors[] = 'stats username'; + if (empty($_POST['v_stats_password'])) $errors[] = 'stats password'; + if (!empty($errors[0])) { + foreach ($errors as $i => $error) { + if ( $i == 0 ) { + $error_msg = $error; + } else { + $error_msg = $error_msg.", ".$error; + } + } + $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); + } else { + $v_stats_user = escapeshellarg($_POST['v_stats_user']); + $v_stats_password = escapeshellarg($_POST['v_stats_password']); + exec (VESTA_CMD."v-add-web-domain-stats-user ".$v_username." ".$v_domain." ".$v_stats_user." ".$v_stats_password, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_stats_password = "••••••••"; + } + } + if ((!empty($v_stats_user)) && (!empty($_POST['v_stats_auth'])) && (empty($_SESSION['error_msg']))) { + if (empty($_POST['v_stats_user'])) $errors[] = 'stats user'; + if (empty($_POST['v_stats_password'])) $errors[] = 'stats password'; + if (!empty($errors[0])) { + foreach ($errors as $i => $error) { + if ( $i == 0 ) { + $error_msg = $error; + } else { + $error_msg = $error_msg.", ".$error; + } + } + $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); + } + if (($v_stats_user != $_POST['v_stats_user']) || ($_POST['v_stats_password'] != "••••••••" ) && (empty($_SESSION['error_msg']))) { + $v_stats_user = escapeshellarg($_POST['v_stats_user']); + $v_stats_password = escapeshellarg($_POST['v_stats_password']); + exec (VESTA_CMD."v-add-web-domain-stats-user ".$v_username." ".$v_domain." ".$v_stats_user." ".$v_stats_password, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_stats_password = "••••••••"; + } + } + + // FTP Account + if ((!empty($v_ftp_user)) && (empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-delete-web-domain-ftp ".$v_username." ".$v_domain, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_ftp= ''; + $v_ftp_user = ''; + $v_ftp_password = ''; + } + if ((!empty($v_ftp_user)) && (!empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) { + if (empty($_POST['v_ftp_user'])) $errors[] = 'ftp user'; + if (empty($_POST['v_ftp_password'])) $errors[] = 'ftp password'; + if (!empty($errors[0])) { + foreach ($errors as $i => $error) { + if ( $i == 0 ) { + $error_msg = $error; + } else { + $error_msg = $error_msg.", ".$error; + } + } + $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); + } + if (($v_ftp_user != $_POST['v_ftp_user']) || ($_POST['v_ftp_password'] != "••••••••" ) && (empty($_SESSION['error_msg']))) { + $v_ftp_user = preg_replace("/^".$user."_/", "", $_POST['v_ftp_user']); + $v_ftp_user = escapeshellarg($v_ftp_user); + $v_ftp_password = escapeshellarg($_POST['v_ftp_password']); + exec (VESTA_CMD."v-add-web-domain-ftp ".$v_username." ".$v_domain." ".$v_ftp_user." ".$v_ftp_password, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_ftp_user = $user."_".$_POST['v_ftp_user']; + $v_ftp_password = "••••••••"; + } + } + + if ((empty($v_ftp_user)) && (!empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) { + if ((!empty($_POST['v_ftp_email'])) && (!filter_var($_POST['v_ftp_email'], FILTER_VALIDATE_EMAIL))) $_SESSION['error_msg'] = _('Please enter valid email address.'); + if (empty($_POST['v_ftp_user'])) $errors[] = 'ftp username'; + if (empty($_POST['v_ftp_password'])) $errors[] = 'ftp password'; + if (!empty($errors[0])) { + foreach ($errors as $i => $error) { + if ( $i == 0 ) { + $error_msg = $error; + } else { + $error_msg = $error_msg.", ".$error; + } + } + $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); + } + if (empty($_SESSION['error_msg'])) { + $v_ftp_user = escapeshellarg($_POST['v_ftp_user']); + $v_ftp_password = escapeshellarg($_POST['v_ftp_password']); + exec (VESTA_CMD."v-add-web-domain-ftp ".$v_username." ".$v_domain." ".$v_ftp_user." ".$v_ftp_password, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } else { + if (!empty($_POST['v_ftp_email'])) { + $to = $_POST['v_ftp_email']; + $subject = "FTP login credentials"; + $hostname = exec('hostname'); + $from = "Vesta Control Panel "; + $mailtext .= "Your ftp account has been created successfully and is ready to use.\n\n"; + $mailtext .= "hostname: ".$_GET['domain']."\n"; + $mailtext .= "username: ".$user."_".$_POST['v_ftp_user']."\n"; + $mailtext .= "password: ".$_POST['v_ftp_password']."\n\n"; + $mailtext .= "--\nVesta Control Panel\n"; + send_email($to, $subject, $mailtext, $from); + unset($v_ftp_email); + } + } + unset($output); + $v_ftp_user = $user."_".$_POST['v_ftp_user']; + $v_ftp_password = "••••••••"; + } + } + + // Restart web + if (!empty($restart_web) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-restart-web", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + } + + // Restart dns + if (!empty($restart_dns) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-restart-dns", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + } + + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = "OK: changes has been saved."; + } + + } +if ($_SESSION['user'] == 'admin') { + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_web.html'); +} else { + include($_SERVER['DOCUMENT_ROOT'].'/templates/user/edit_web.html'); +} + unset($_SESSION['error_msg']); + unset($_SESSION['ok_msg']); +//} + +// Footer +include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/inc/i18n/en.php b/web/inc/i18n/en.php new file mode 100644 index 000000000..31d4872c2 --- /dev/null +++ b/web/inc/i18n/en.php @@ -0,0 +1,15 @@ +'Hour', + 'Min'=>'Min', + 'pb'=>'pb', + +); \ No newline at end of file diff --git a/web/inc/i18n/ru.php b/web/inc/i18n/ru.php new file mode 100644 index 000000000..a2f6a1343 --- /dev/null +++ b/web/inc/i18n/ru.php @@ -0,0 +1,82 @@ +'Час', + 'Min'=>'Мин', + 'pb'=>'пб', + 'tb'=>'тб', + 'gb'=>'гб', + 'mb'=>'мб', + 'Error'=>'Ошибка', + 'minute'=>'минута', + 'hour'=>'час', + 'day'=>'день', + 'month'=>'месяц', + 'day of week'=>'день недели', + 'cmd'=>'командная строка', + 'Error: field "%s" can not be blank.'=>'Ошибка: Поле "%s" не может быть пустым.', + _('Error: vesta did not return any output.')=>'Ошибка: Vesta не отвечает', + 'OK: cron job has been created successfully.'=>'Успех: Задание Cron успешно создано', + 'database'=>'база данных', + 'username'=>'имя пользователя', + 'password'=>'пароль', + 'type'=>'тип', + 'charset'=>'кодировка', + 'DATABASE_CREATED_OK'=>'Успех: База данных %s успешно создана.', + 'domain'=>'домен', + 'ip'=>'IP', + 'DOMAIN_CREATED_OK'=>'Успех: Домен %s успешно создан.', + 'RECORD_CREATED_OK'=>'Успех: Запись %s.%s успешно создана.', + 'ip address'=>'IP-адрес', + 'netmask'=>'маска подсети', + 'interface'=>'интерфейс', + 'assigned user'=>'назначенный пользователь', + 'IP_CREATED_OK'=>'"Успех: ip-адрес %s успешно создан.', + 'DOMAIN_MAIL_CREATED_OK'=>'Успех: почта для домена %s подключена успешно', + 'account'=>'аккаунт', + 'password'=>'пароль', + 'MAIL_ACCOUNT_CREATED_OK'=>'Успех: почтовый аккаунт %s@%s успешно создан.', + 'package'=>'пакет', + 'template'=>'шаблон', + 'shell'=>'SSH', + 'web domains'=>'хосты', + 'web aliases'=>'перенаправления хостов', + 'dns records'=>'DNS записи', + 'mail domains'=>'домены с почтой', + 'mail accounts'=>'почтовые аккаунты', + 'databases'=>'базы данных', + 'cron jobs'=>'cron задания', + 'backups'=>'бэкапы', + 'quota'=>'квота диска', + 'bandwidth'=>'ширина канала', + 'ns1'=>'DNS-сервер #1', + 'ns2'=>'DNS-сервер #2', + 'PACKAGE_CREATED_OK'=>'Успех: Пакет %s успешно создан.', + 'user'=>'пользователь', + 'email'=>'Email', + 'first name'=>'Имя', + 'last name'=>'Фамилия', + 'Please enter valid email address.'=>'Пожалуйста, введите реальный email адрес.', + 'Welcome to Vesta Control Panel'=>'Добро пожаловать в панель управления Vesta', + 'MAIL_FROM'=>'Vesta Control Panel ', + 'GREETINGS_GORDON_FREEMAN'=>"Здравствуйте, %s %s,\n", + 'GREETINGS'=>"Здравствуйте,\n", + 'ACCOUNT_READY'=>"Ваш аккаунт успешно создан и готов к использованию.\n\nhttps://%s/login/\nИмя пользователя: %s\nПароль: %s\n\n--\nПанель управления Vesta\n", + 'ACCOUNT_CREATED_OK'=>'Успех: Пользователь %s успешно создан.', + 'ssl certificate'=>'SSL сертификат', + 'ssl key'=>'ключ SSL сертификата', + 'stats user password'=>'пароль для доступа к статистике', + 'ftp user password'=>'пароль для доступа к FTP', + 'FTP login credentials'=>'Данные для доступа к FTP', + 'FTP_ACCOUNT_READY'=>"Ваш FTP аккаунт успешно создан и готов к использованию.\n\nХост: %s\nИмя пользователя: %s_%s\nПароль: %s\n\n--\nПанель управления Vesta\n", + 'HOSTING_DOMAIN_CREATED_OK'=>'Успешно: хостинг для домена %s был успешно создан.', + + + +); \ No newline at end of file diff --git a/web/inc/main.php b/web/inc/main.php index 5df9e1bd3..c9c2f440a 100644 --- a/web/inc/main.php +++ b/web/inc/main.php @@ -1,138 +1,159 @@ - 0 ) { - header("Location: /error/"); - exit; - } -} - -function top_panel($user, $TAB) { - global $panel; - $command = VESTA_CMD."v-list-user '".$user."' 'json'"; - exec ($command, $output, $return_var); - if ( $return_var > 0 ) { - header("Location: /error/"); - exit; - } - $panel = json_decode(implode('', $output), true); - unset($output); - if ( $user == 'admin' ) { - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/panel.html'); - } else { - include($_SERVER['DOCUMENT_ROOT'].'/templates/user/panel.html'); - } -} - -function humanize_time($usage) { - if ( $usage > 60 ) { - $usage = $usage / 60; - $usage = number_format($usage, 2); - $usage = $usage." Hour."; - } else { - $usage = $usage." Min."; - } - return $usage; -} - -function humanize_usage($usage) { - if ( $usage > 1000 ) { - $usage = $usage / 1000; - if ( $usage > 1000 ) { - $usage = $usage / 1000 ; - if ( $usage > 1000 ) { - $usage = $usage / 1000 ; - $usage = number_format($usage, 2); - $usage = $usage." pb"; - } else { - $usage = number_format($usage, 2); - $usage = $usage." tb"; - } - } else { - $usage = number_format($usage, 2); - $usage = $usage." gb"; - } - } else { - $usage = $usage." mb"; - } - return $usage; -} - -function get_percentage($used,$total) { - if (!isset($total)) $total = 0; - if (!isset($used)) $used = 0; - if ( $total == 0 ) { - $percent = 0; - } else { - $percent = $used / $total; - $percent = $percent * 100; - $percent = number_format($percent, 0, '', ''); - if ( $percent > 100 ) { - $percent = 100; - } - if ( $percent < 0 ) { - $percent = 0; - } - - } - return $percent; -} - -function send_email($to,$subject,$mailtext,$from) { - $charset = "utf-8"; - $to = '<'.$to.'>'; - $boundary = '--' . md5( uniqid("myboundary") ); - $priorities = array( '1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)' ); - $priority = $priorities[2]; - $ctencoding = "8bit"; - $sep = chr(13) . chr(10); - $disposition = "inline"; - $subject = "=?$charset?B?".base64_encode($subject)."?="; - $header = "From: $from \nX-Priority: $priority\nCC:\n"; - $header .= "Mime-Version: 1.0\nContent-Type: text/plain; charset=$charset \n"; - $header .= "Content-Transfer-Encoding: $ctencoding\nX-Mailer: Php/libMailv1.3\n"; - $message = $mailtext; - mail($to, $subject, $message, $header); -} - -function display_error_block() { - if (!empty($_SESSION['error_msg'])) { - echo ' - -
-

'; - echo $_SESSION['error_msg']; - echo "

\n
\n"; - unset($_SESSION['error_msg']); - } -} -?> +1) { $args[0] = $text; + return call_user_func_array("sprintf",$args); + } + else return $text; +} + +// Check user session +if (!isset($_SESSION['user'])) { + $_SESSION['request_uri'] = $_SERVER['REQUEST_URI']; + header("Location: /login/"); + exit; +} + +if (isset($_SESSION['look']) && ( $_SESSION['look'] != 'admin' )) { + $user = $_SESSION['look']; +} else { + $user = $_SESSION['user']; +} + +define('VESTA_CMD', '/usr/bin/sudo /usr/local/vesta/bin/'); + +$i = 0; + +// Define functions +function check_error($return_var){ + if ( $return_var > 0 ) { + header("Location: /error/"); + exit; + } +} + +function top_panel($user, $TAB) { + global $panel; + $command = VESTA_CMD."v-list-user '".$user."' 'json'"; + exec ($command, $output, $return_var); + if ( $return_var > 0 ) { + header("Location: /error/"); + exit; + } + $panel = json_decode(implode('', $output), true); + unset($output); + if ( $user == 'admin' ) { + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/panel.html'); + } else { + include($_SERVER['DOCUMENT_ROOT'].'/templates/user/panel.html'); + } +} + +function humanize_time($usage) { + if ( $usage > 60 ) { + $usage = $usage / 60; + $usage = number_format($usage, 2); + $usage = $usage." "._('Hour')."."; + } else { + $usage = $usage." "._('Min')."."; + } + return $usage; +} + +function humanize_usage($usage) { + if ( $usage > 1000 ) { + $usage = $usage / 1000; + if ( $usage > 1000 ) { + $usage = $usage / 1000 ; + if ( $usage > 1000 ) { + $usage = $usage / 1000 ; + $usage = number_format($usage, 2); + $usage = $usage." "._('pb'); + } else { + $usage = number_format($usage, 2); + $usage = $usage." "._('tb'); + } + } else { + $usage = number_format($usage, 2); + $usage = $usage." "._('gb'); + } + } else { + $usage = $usage." "._('mb'); + } + return $usage; +} + +function get_percentage($used,$total) { + if (!isset($total)) $total = 0; + if (!isset($used)) $used = 0; + if ( $total == 0 ) { + $percent = 0; + } else { + $percent = $used / $total; + $percent = $percent * 100; + $percent = number_format($percent, 0, '', ''); + if ( $percent > 100 ) { + $percent = 100; + } + if ( $percent < 0 ) { + $percent = 0; + } + + } + return $percent; +} + +function send_email($to,$subject,$mailtext,$from) { + $charset = "utf-8"; + $to = '<'.$to.'>'; + $boundary = '--' . md5( uniqid("myboundary") ); + $priorities = array( '1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)' ); + $priority = $priorities[2]; + $ctencoding = "8bit"; + $sep = chr(13) . chr(10); + $disposition = "inline"; + $subject = "=?$charset?B?".base64_encode($subject)."?="; + $header = "From: $from \nX-Priority: $priority\nCC:\n"; + $header .= "Mime-Version: 1.0\nContent-Type: text/plain; charset=$charset \n"; + $header .= "Content-Transfer-Encoding: $ctencoding\nX-Mailer: Php/libMailv1.3\n"; + $message = $mailtext; + mail($to, $subject, $message, $header); +} + +function display_error_block() { + if (!empty($_SESSION['error_msg'])) { + echo ' + +
+

'; + echo $_SESSION['error_msg']; + echo "

\n
\n"; + unset($_SESSION['error_msg']); + } +} +?> diff --git a/web/suspend/cron/index.php b/web/suspend/cron/index.php index 13824ea7c..6c9c68a21 100644 --- a/web/suspend/cron/index.php +++ b/web/suspend/cron/index.php @@ -1,32 +1,32 @@ -', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); -} - -$back = $_SESSION['back']; -if (!empty($back)) { - header("Location: ".$back); - exit; -} - -header("Location: /list/cron/"); -exit; +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); +} + +$back = $_SESSION['back']; +if (!empty($back)) { + header("Location: ".$back); + exit; +} + +header("Location: /list/cron/"); +exit; diff --git a/web/suspend/db/index.php b/web/suspend/db/index.php index 9e22dceee..320c89d36 100644 --- a/web/suspend/db/index.php +++ b/web/suspend/db/index.php @@ -1,34 +1,34 @@ -', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - -} - -$back = $_SESSION['back']; -if (!empty($back)) { - header("Location: ".$back); - exit; -} - -header("Location: /list/db/"); -exit; +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + +} + +$back = $_SESSION['back']; +if (!empty($back)) { + header("Location: ".$back); + exit; +} + +header("Location: /list/db/"); +exit; diff --git a/web/suspend/dns/index.php b/web/suspend/dns/index.php index 38586bc88..e907f6097 100644 --- a/web/suspend/dns/index.php +++ b/web/suspend/dns/index.php @@ -1,63 +1,63 @@ -', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $back = $_SESSION['back']; - if (!empty($back)) { - header("Location: ".$back); - exit; - } - header("Location: /list/dns/"); - exit; - } - - // DNS record - if ((!empty($_GET['domain'])) && (!empty($_GET['record_id']))) { - $v_username = escapeshellarg($user); - $v_domain = escapeshellarg($_GET['domain']); - $v_record_id = escapeshellarg($_GET['record_id']); - exec (VESTA_CMD."v-suspend-dns-domain-record ".$v_username." ".$v_domain." ".$v_record_id, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $back = $_SESSION['back']; - if (!empty($back)) { - header("Location: ".$back); - exit; - } - header("Location: /list/dns/?domain=".$_GET['domain']); - exit; - - } - -} -$back = $_SESSION['back']; -if (!empty($back)) { - header("Location: ".$back); - exit; -} - -header("Location: /list/dns/"); -exit; +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $back = $_SESSION['back']; + if (!empty($back)) { + header("Location: ".$back); + exit; + } + header("Location: /list/dns/"); + exit; + } + + // DNS record + if ((!empty($_GET['domain'])) && (!empty($_GET['record_id']))) { + $v_username = escapeshellarg($user); + $v_domain = escapeshellarg($_GET['domain']); + $v_record_id = escapeshellarg($_GET['record_id']); + exec (VESTA_CMD."v-suspend-dns-domain-record ".$v_username." ".$v_domain." ".$v_record_id, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $back = $_SESSION['back']; + if (!empty($back)) { + header("Location: ".$back); + exit; + } + header("Location: /list/dns/?domain=".$_GET['domain']); + exit; + + } + +} +$back = $_SESSION['back']; +if (!empty($back)) { + header("Location: ".$back); + exit; +} + +header("Location: /list/dns/"); +exit; diff --git a/web/suspend/mail/index.php b/web/suspend/mail/index.php index cda23e817..a9a996320 100644 --- a/web/suspend/mail/index.php +++ b/web/suspend/mail/index.php @@ -1,61 +1,61 @@ -', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $back=getenv("HTTP_REFERER"); - if (!empty($back)) { - header("Location: ".$back); - exit; - } - header("Location: /list/mail/"); - exit; - } - - // Mail account - if ((!empty($_GET['domain'])) && (!empty($_GET['account']))) { - $v_username = escapeshellarg($user); - $v_domain = escapeshellarg($_GET['domain']); - $v_account = escapeshellarg($_GET['account']); - exec (VESTA_CMD."v-suspend-mail-account ".$v_username." ".$v_domain." ".$v_account, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $back = $_SESSION['back']; - if (!empty($back)) { - header("Location: ".$back); - exit; - } - header("Location: /list/mail/?domain=".$_GET['domain']); - exit; - } -} - -$back = $_SESSION['back']; -if (!empty($back)) { - header("Location: ".$back); - exit; -} -header("Location: /list/mail/"); -exit; +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $back=getenv("HTTP_REFERER"); + if (!empty($back)) { + header("Location: ".$back); + exit; + } + header("Location: /list/mail/"); + exit; + } + + // Mail account + if ((!empty($_GET['domain'])) && (!empty($_GET['account']))) { + $v_username = escapeshellarg($user); + $v_domain = escapeshellarg($_GET['domain']); + $v_account = escapeshellarg($_GET['account']); + exec (VESTA_CMD."v-suspend-mail-account ".$v_username." ".$v_domain." ".$v_account, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $back = $_SESSION['back']; + if (!empty($back)) { + header("Location: ".$back); + exit; + } + header("Location: /list/mail/?domain=".$_GET['domain']); + exit; + } +} + +$back = $_SESSION['back']; +if (!empty($back)) { + header("Location: ".$back); + exit; +} +header("Location: /list/mail/"); +exit; diff --git a/web/suspend/user/index.php b/web/suspend/user/index.php index 20d1debb3..9f4bd86a6 100644 --- a/web/suspend/user/index.php +++ b/web/suspend/user/index.php @@ -1,30 +1,30 @@ -', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - -} - -$back = $_SESSION['back']; -if (!empty($back)) { - header("Location: ".$back); - exit; -} - -header("Location: /list/user/"); -exit; +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + +} + +$back = $_SESSION['back']; +if (!empty($back)) { + header("Location: ".$back); + exit; +} + +header("Location: /list/user/"); +exit; diff --git a/web/suspend/web/index.php b/web/suspend/web/index.php index fef9158e6..36ab7d0b2 100644 --- a/web/suspend/web/index.php +++ b/web/suspend/web/index.php @@ -1,33 +1,33 @@ -', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); -} - -$back = $_SESSION['back']; -if (!empty($back)) { - header("Location: ".$back); - exit; -} - -header("Location: /list/web/"); -exit; +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); +} + +$back = $_SESSION['back']; +if (!empty($back)) { + header("Location: ".$back); + exit; +} + +header("Location: /list/web/"); +exit; diff --git a/web/unsuspend/cron/index.php b/web/unsuspend/cron/index.php index 500517b64..0b5e47606 100644 --- a/web/unsuspend/cron/index.php +++ b/web/unsuspend/cron/index.php @@ -1,32 +1,32 @@ -', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - -} - -$back=getenv("HTTP_REFERER"); -if (!empty($back)) { - header("Location: ".$back); - exit; -} -header("Location: /list/cron/"); -exit; +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + +} + +$back=getenv("HTTP_REFERER"); +if (!empty($back)) { + header("Location: ".$back); + exit; +} +header("Location: /list/cron/"); +exit; diff --git a/web/unsuspend/dns/index.php b/web/unsuspend/dns/index.php index 2b87b6bd3..d21709488 100644 --- a/web/unsuspend/dns/index.php +++ b/web/unsuspend/dns/index.php @@ -1,62 +1,62 @@ -', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $back=getenv("HTTP_REFERER"); - if (!empty($back)) { - header("Location: ".$back); - exit; - } - header("Location: /list/dns/"); - exit; - - } - - // DNS record - if ((!empty($_GET['domain'])) && (!empty($_GET['record_id']))) { - $v_username = escapeshellarg($user); - $v_domain = escapeshellarg($_GET['domain']); - $v_record_id = escapeshellarg($_GET['record_id']); - exec (VESTA_CMD."v-unsuspend-dns-domain-record ".$v_username." ".$v_domain." ".$v_record_id, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $back=getenv("HTTP_REFERER"); - if (!empty($back)) { - header("Location: ".$back); - exit; - } - header("Location: /list/dns/?domain=".$_GET['domain']); - exit; - } - -} - -$back=getenv("HTTP_REFERER"); -if (!empty($back)) { - header("Location: ".$back); - exit; -} -header("Location: /list/dns/"); -exit; +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $back=getenv("HTTP_REFERER"); + if (!empty($back)) { + header("Location: ".$back); + exit; + } + header("Location: /list/dns/"); + exit; + + } + + // DNS record + if ((!empty($_GET['domain'])) && (!empty($_GET['record_id']))) { + $v_username = escapeshellarg($user); + $v_domain = escapeshellarg($_GET['domain']); + $v_record_id = escapeshellarg($_GET['record_id']); + exec (VESTA_CMD."v-unsuspend-dns-domain-record ".$v_username." ".$v_domain." ".$v_record_id, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $back=getenv("HTTP_REFERER"); + if (!empty($back)) { + header("Location: ".$back); + exit; + } + header("Location: /list/dns/?domain=".$_GET['domain']); + exit; + } + +} + +$back=getenv("HTTP_REFERER"); +if (!empty($back)) { + header("Location: ".$back); + exit; +} +header("Location: /list/dns/"); +exit; diff --git a/web/unsuspend/mail/index.php b/web/unsuspend/mail/index.php index 5c95351eb..7f2dd127d 100644 --- a/web/unsuspend/mail/index.php +++ b/web/unsuspend/mail/index.php @@ -1,60 +1,60 @@ -', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $back=getenv("HTTP_REFERER"); - if (!empty($back)) { - header("Location: ".$back); - exit; - } - header("Location: /list/mail/"); - exit; - } - - // Mail account - if ((!empty($_GET['domain'])) && (!empty($_GET['account']))) { - $v_username = escapeshellarg($user); - $v_domain = escapeshellarg($_GET['domain']); - $v_account = escapeshellarg($_GET['account']); - exec (VESTA_CMD."v-unsuspend-mail-account ".$v_username." ".$v_domain." ".$v_account, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); - $back=getenv("HTTP_REFERER"); - if (!empty($back)) { - header("Location: ".$back); - exit; - } - header("Location: /list/mail/?domain=".$_GET['domain']); - exit; - } -} - -$back=getenv("HTTP_REFERER"); -if (!empty($back)) { - header("Location: ".$back); - exit; -} -header("Location: /list/mail/"); -exit; +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $back=getenv("HTTP_REFERER"); + if (!empty($back)) { + header("Location: ".$back); + exit; + } + header("Location: /list/mail/"); + exit; + } + + // Mail account + if ((!empty($_GET['domain'])) && (!empty($_GET['account']))) { + $v_username = escapeshellarg($user); + $v_domain = escapeshellarg($_GET['domain']); + $v_account = escapeshellarg($_GET['account']); + exec (VESTA_CMD."v-unsuspend-mail-account ".$v_username." ".$v_domain." ".$v_account, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $back=getenv("HTTP_REFERER"); + if (!empty($back)) { + header("Location: ".$back); + exit; + } + header("Location: /list/mail/?domain=".$_GET['domain']); + exit; + } +} + +$back=getenv("HTTP_REFERER"); +if (!empty($back)) { + header("Location: ".$back); + exit; +} +header("Location: /list/mail/"); +exit; diff --git a/web/unsuspend/user/index.php b/web/unsuspend/user/index.php index 8a07505a5..0441eecf0 100644 --- a/web/unsuspend/user/index.php +++ b/web/unsuspend/user/index.php @@ -1,28 +1,28 @@ -', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); -} - -$back=getenv("HTTP_REFERER"); -if (!empty($back)) { - header("Location: ".$back); - exit; -} -header("Location: /list/user/"); -exit; +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); +} + +$back=getenv("HTTP_REFERER"); +if (!empty($back)) { + header("Location: ".$back); + exit; +} +header("Location: /list/user/"); +exit; diff --git a/web/unsuspend/web/index.php b/web/unsuspend/web/index.php index 04ff36cac..786357a91 100644 --- a/web/unsuspend/web/index.php +++ b/web/unsuspend/web/index.php @@ -1,31 +1,31 @@ -', $output); - if (empty($error)) $error = 'Error: vesta did not return any output.'; - $_SESSION['error_msg'] = $error; - } - unset($output); -} - -$back=getenv("HTTP_REFERER"); -if (!empty($back)) { - header("Location: ".$back); - exit; -} -header("Location: /list/web/"); -exit; +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); +} + +$back=getenv("HTTP_REFERER"); +if (!empty($back)) { + header("Location: ".$back); + exit; +} +header("Location: /list/web/"); +exit; From dcf849263da2a2f7d0423669797f8fd00497d01d Mon Sep 17 00:00:00 2001 From: ZonD Eighty Date: Thu, 27 Dec 2012 17:28:16 +0400 Subject: [PATCH 02/11] Backend changes & some templates' translation --- web/edit/cron/index.php | 2 +- web/edit/db/index.php | 2 +- web/edit/dns/index.php | 4 +- web/edit/ip/index.php | 2 +- web/edit/mail/index.php | 6 +- web/edit/package/index.php | 34 +-- web/edit/user/index.php | 4 +- web/edit/web/index.php | 28 +-- web/error/index.html | 52 ++--- web/inc/i18n/ru.php | 71 +++++- web/inc/main.php | 2 +- web/login/index.php | 97 ++++---- web/logout/index.php | 25 ++- web/reset/index.php | 183 +++++++--------- web/templates/admin/add_cron.html | 230 +++++++++---------- web/templates/admin/add_db.html | 352 +++++++++++++++--------------- web/templates/admin/add_dns.html | 330 ++++++++++++++-------------- web/templates/admin/panel.html | 152 ++++++------- web/templates/footer.html | 44 ++-- web/templates/login.html | 118 +++++----- web/templates/reset_1.html | 104 ++++----- web/templates/reset_2.html | 103 +++++---- web/templates/reset_3.html | 126 +++++------ web/templates/user/panel.html | 150 ++++++------- 24 files changed, 1136 insertions(+), 1085 deletions(-) diff --git a/web/edit/cron/index.php b/web/edit/cron/index.php index 646f7af60..d35f27257 100644 --- a/web/edit/cron/index.php +++ b/web/edit/cron/index.php @@ -71,7 +71,7 @@ top_panel($user,$TAB); $v_cmd = $_POST['v_cmd']; } if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = "OK: changes has been saved."; + $_SESSION['ok_msg'] = _("OK: changes has been saved."); } } } diff --git a/web/edit/db/index.php b/web/edit/db/index.php index a62cd5404..4ecbe1876 100644 --- a/web/edit/db/index.php +++ b/web/edit/db/index.php @@ -65,7 +65,7 @@ top_panel($user,$TAB); unset($output); } if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = "OK: changes has been saved."; + $_SESSION['ok_msg'] = _('OK: changes has been saved.'); } } } diff --git a/web/edit/dns/index.php b/web/edit/dns/index.php index b0a619085..5d519135b 100644 --- a/web/edit/dns/index.php +++ b/web/edit/dns/index.php @@ -137,7 +137,7 @@ top_panel($user,$TAB); } if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = "OK: changes has been saved."; + $_SESSION['ok_msg'] = _('OK: changes has been saved.'); } } @@ -196,7 +196,7 @@ top_panel($user,$TAB); } if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = "OK: changes has been saved."; + $_SESSION['ok_msg'] = _('OK: changes has been saved.'); } } diff --git a/web/edit/ip/index.php b/web/edit/ip/index.php index bdc0b370d..eb06a1a63 100644 --- a/web/edit/ip/index.php +++ b/web/edit/ip/index.php @@ -105,7 +105,7 @@ if ($_SESSION['user'] == 'admin') { } if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = "OK: changes has been saved."; + $_SESSION['ok_msg'] = _('OK: changes has been saved.'); } } } diff --git a/web/edit/mail/index.php b/web/edit/mail/index.php index cab7a11ee..bf38564f6 100644 --- a/web/edit/mail/index.php +++ b/web/edit/mail/index.php @@ -100,7 +100,7 @@ top_panel($user,$TAB); } if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = "OK: changes has been saved."; + $_SESSION['ok_msg'] = _('OK: changes has been saved.'); } // DKIM @@ -162,7 +162,7 @@ top_panel($user,$TAB); } if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = "OK: changes has been saved."; + $_SESSION['ok_msg'] = _('OK: changes has been saved.'); } } include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_mail.html'); @@ -356,7 +356,7 @@ top_panel($user,$TAB); if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = "OK: changes has been saved."; + $_SESSION['ok_msg'] = _('OK: changes has been saved.'); } } diff --git a/web/edit/package/index.php b/web/edit/package/index.php index a5ea6d025..ed29f15b9 100644 --- a/web/edit/package/index.php +++ b/web/edit/package/index.php @@ -70,22 +70,22 @@ if ($_SESSION['user'] == 'admin') { // Action if (!empty($_POST['save'])) { // Check input - if (empty($_POST['v_package'])) $errors[] = 'package'; - if (empty($_POST['v_template'])) $errors[] = 'template'; - if (empty($_POST['v_shell'])) $errrors[] = 'shell'; - if (!isset($_POST['v_web_domains'])) $errors[] = 'web domains'; - if (!isset($_POST['v_web_aliases'])) $errors[] = 'web aliases'; - if (!isset($_POST['v_dns_domains'])) $errors[] = 'dns domains'; - if (!isset($_POST['v_dns_records'])) $errors[] = 'dns records'; - if (!isset($_POST['v_mail_domains'])) $errors[] = 'mail domains'; - if (!isset($_POST['v_mail_accounts'])) $errors[] = 'mail accounts'; - if (!isset($_POST['v_databases'])) $errors[] = 'databases'; - if (!isset($_POST['v_cron_jobs'])) $errors[] = 'cron jobs'; - if (!isset($_POST['v_backups'])) $errors[] = 'backups'; - if (!isset($_POST['v_disk_quota'])) $errors[] = 'quota'; - if (!isset($_POST['v_bandwidth'])) $errors[] = 'bandwidth'; - if (empty($_POST['v_ns1'])) $errors[] = 'ns1'; - if (empty($_POST['v_ns2'])) $errors[] = 'ns2'; + if (empty($_POST['v_package'])) $errors[] = _('package'); + if (empty($_POST['v_template'])) $errors[] = _('template'); + if (empty($_POST['v_shell'])) $errrors[] = _('shell'); + if (!isset($_POST['v_web_domains'])) $errors[] = _('web domains'); + if (!isset($_POST['v_web_aliases'])) $errors[] = _('web aliases'); + if (!isset($_POST['v_dns_domains'])) $errors[] = _('dns domains'); + if (!isset($_POST['v_dns_records'])) $errors[] = _('dns records'); + if (!isset($_POST['v_mail_domains'])) $errors[] = _('mail domains'); + if (!isset($_POST['v_mail_accounts'])) $errors[] = _('mail accounts'); + if (!isset($_POST['v_databases'])) $errors[] = _('databases'); + if (!isset($_POST['v_cron_jobs'])) $errors[] = _('cron jobs'); + if (!isset($_POST['v_backups'])) $errors[] = _('backups'); + if (!isset($_POST['v_disk_quota'])) $errors[] = _('quota'); + if (!isset($_POST['v_bandwidth'])) $errors[] = _('bandwidth'); + if (empty($_POST['v_ns1'])) $errors[] = _('ns1'); + if (empty($_POST['v_ns2'])) $errors[] = _('ns2'); // Protect input $v_package = escapeshellarg($_POST['v_package']); @@ -175,7 +175,7 @@ if ($_SESSION['user'] == 'admin') { } if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = "OK: changes has been saved."; + $_SESSION['ok_msg'] = _('OK: changes has been saved.'); } } } diff --git a/web/edit/user/index.php b/web/edit/user/index.php index 8411a5518..92edcf42a 100644 --- a/web/edit/user/index.php +++ b/web/edit/user/index.php @@ -170,7 +170,7 @@ if ($_SESSION['user'] == 'admin') { } if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = "OK: changes has been saved."; + $_SESSION['ok_msg'] = _('OK: changes has been saved.'); } } include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_user.html'); @@ -263,7 +263,7 @@ if ($_SESSION['user'] == 'admin') { } if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = "OK: changes has been saved."; + $_SESSION['ok_msg'] = _('OK: changes has been saved.'); } } include($_SERVER['DOCUMENT_ROOT'].'/templates/user/edit_user.html'); diff --git a/web/edit/web/index.php b/web/edit/web/index.php index ace532dc6..3116d8763 100644 --- a/web/edit/web/index.php +++ b/web/edit/web/index.php @@ -417,8 +417,8 @@ top_panel($user,$TAB); $v_stats_password = ''; } if ((empty($v_stats_user)) && (!empty($_POST['v_stats_auth'])) && (empty($_SESSION['error_msg']))) { - if (empty($_POST['v_stats_user'])) $errors[] = 'stats username'; - if (empty($_POST['v_stats_password'])) $errors[] = 'stats password'; + if (empty($_POST['v_stats_user'])) $errors[] = _('stats username'); + if (empty($_POST['v_stats_password'])) $errors[] = _('stats password'); if (!empty($errors[0])) { foreach ($errors as $i => $error) { if ( $i == 0 ) { @@ -442,8 +442,8 @@ top_panel($user,$TAB); } } if ((!empty($v_stats_user)) && (!empty($_POST['v_stats_auth'])) && (empty($_SESSION['error_msg']))) { - if (empty($_POST['v_stats_user'])) $errors[] = 'stats user'; - if (empty($_POST['v_stats_password'])) $errors[] = 'stats password'; + if (empty($_POST['v_stats_user'])) $errors[] = _('stats user'); + if (empty($_POST['v_stats_password'])) $errors[] = _('stats password'); if (!empty($errors[0])) { foreach ($errors as $i => $error) { if ( $i == 0 ) { @@ -482,8 +482,8 @@ top_panel($user,$TAB); $v_ftp_password = ''; } if ((!empty($v_ftp_user)) && (!empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) { - if (empty($_POST['v_ftp_user'])) $errors[] = 'ftp user'; - if (empty($_POST['v_ftp_password'])) $errors[] = 'ftp password'; + if (empty($_POST['v_ftp_user'])) $errors[] = _('ftp user'); + if (empty($_POST['v_ftp_password'])) $errors[] = _('ftp user password'); if (!empty($errors[0])) { foreach ($errors as $i => $error) { if ( $i == 0 ) { @@ -512,8 +512,8 @@ top_panel($user,$TAB); if ((empty($v_ftp_user)) && (!empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) { if ((!empty($_POST['v_ftp_email'])) && (!filter_var($_POST['v_ftp_email'], FILTER_VALIDATE_EMAIL))) $_SESSION['error_msg'] = _('Please enter valid email address.'); - if (empty($_POST['v_ftp_user'])) $errors[] = 'ftp username'; - if (empty($_POST['v_ftp_password'])) $errors[] = 'ftp password'; + if (empty($_POST['v_ftp_user'])) $errors[] = 'ftp user'; + if (empty($_POST['v_ftp_password'])) $errors[] = 'ftp user password'; if (!empty($errors[0])) { foreach ($errors as $i => $error) { if ( $i == 0 ) { @@ -535,14 +535,10 @@ top_panel($user,$TAB); } else { if (!empty($_POST['v_ftp_email'])) { $to = $_POST['v_ftp_email']; - $subject = "FTP login credentials"; + $subject = _("FTP login credentials"); $hostname = exec('hostname'); - $from = "Vesta Control Panel "; - $mailtext .= "Your ftp account has been created successfully and is ready to use.\n\n"; - $mailtext .= "hostname: ".$_GET['domain']."\n"; - $mailtext .= "username: ".$user."_".$_POST['v_ftp_user']."\n"; - $mailtext .= "password: ".$_POST['v_ftp_password']."\n\n"; - $mailtext .= "--\nVesta Control Panel\n"; + $from = _('MAIL_FROM',$hostname); + $mailtext .= _('FTP_ACCOUNT_READY',$_GET['domain'],$user,$_POST['v_ftp_user'],$_POST['v_ftp_password']); send_email($to, $subject, $mailtext, $from); unset($v_ftp_email); } @@ -574,7 +570,7 @@ top_panel($user,$TAB); } if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = "OK: changes has been saved."; + $_SESSION['ok_msg'] = _('OK: changes has been saved.'); } } diff --git a/web/error/index.html b/web/error/index.html index 657e79e38..b7a291243 100644 --- a/web/error/index.html +++ b/web/error/index.html @@ -1,26 +1,26 @@ - - - 505 — internal error - - - - - - -

An internal error occurred

- -
- Try start again from home page or go back to previous page. -
- - + + + <?php print _('505');?> + + + + + + +

+ +
+ +
+ + diff --git a/web/inc/i18n/ru.php b/web/inc/i18n/ru.php index a2f6a1343..5f1fb08e7 100644 --- a/web/inc/i18n/ru.php +++ b/web/inc/i18n/ru.php @@ -72,11 +72,78 @@ $LANG = array( 'ssl certificate'=>'SSL сертификат', 'ssl key'=>'ключ SSL сертификата', 'stats user password'=>'пароль для доступа к статистике', + 'stats username'=>'имя пользователя статистики', + 'stats password'=>'пароль пользователя статистики', 'ftp user password'=>'пароль для доступа к FTP', + 'ftp user'=>'пользователь FTP', 'FTP login credentials'=>'Данные для доступа к FTP', 'FTP_ACCOUNT_READY'=>"Ваш FTP аккаунт успешно создан и готов к использованию.\n\nХост: %s\nИмя пользователя: %s_%s\nПароль: %s\n\n--\nПанель управления Vesta\n", 'HOSTING_DOMAIN_CREATED_OK'=>'Успешно: хостинг для домена %s был успешно создан.', - - + 'OK: changes has been saved.'=>'Успешно: изменения были сохранены.', + 'FTP login credentials'=>'Данные для доступа к FTP', + '505'=>'505 — внутренняя ошибка', + 'An internal error occurred'=>'Произошла внутренняя ошибка', + 'GO_BACK_LINK'=>'Попробуйте вернуться на главную страницу или вернитесь на предыдущую страницу', + 'ERROR: Invalid username or password'=>'Ошибка: Неверный логин или пароль', + 'ERROR: Invalid username or code'=>'Ошибка: Неверный логин или код сброса пароля', + 'MAIL_RESET_SUBJECT'=>'Password Reset at %s', + 'PASSWORD_RESET_REQUEST'=>"Вы недавно запросили смену пароля.\nЧтобы произвести смену пароля, пройдите по этой ссылки:\nhttps://%s/reset/?action=confirm&user=%s&code=%s\n\nВы также можете пойти по ссылке https://%s/reset/?action=code&user=%s и ввести следующий код для сброса пароля:\n%s\n\nЕсли вы не создавали запрос на сброс пароля, пожалуйста проигнорируйте это письмо и примите наши извиниения.\n\n--\nПанель управления Vesta\n", + 'ERROR: Passwords not match'=>'Ошибка: Пароли не совпадают', + 'Adding Cron Job'=>'Добавление cron задания', + 'Minute'=>'Минута', + 'Day'=>'День', + 'Month'=>'Месяц', + 'Day of week'=>'День недели', + 'Command'=>'Команда', + 'Add'=>'Добавить', + 'Back'=>'Назад', + 'Adding database'=>'Добавление базы данных', + 'DB_PREFIX_WILL_BE_ADDED'=>'Префикс %s будет автоматически добавлен к БД и пользователю БД', + 'Database'=>'База данных', + 'Username'=>'Имя пользователя', + 'Password'=>'Пароль', + 'generate'=>'сгенерировать', + 'Type'=>'Тип', + 'Charset'=>'Кодировка', + 'Adding DNS Domain'=>'Добавление доменного имени', + 'Domain'=>'Домен', + 'IP-Address'=>'IP-адрес', + 'Advanced options'=>'Расширенные опции', + 'Template'=>'Шаблон', + 'Expiration date'=>'Дата окончания делегирования', + 'Name servers'=>'Сервера имен', + 'Powered by Vesta Control Panel'=>'Работает на Панели Управления Vesta', + 'Vesta Control Panel'=>'Панель Управления Vesta', + 'Translation by ZonD80'=>'Перевод ZonD80', + 'Forgot Password?'=>'Забыли пароль?', + 'Log in'=>'Войти', + 'Log out'=>'Выйти', + "RESET_NOTICE"=>"Для сброса пароля введите ваше имя пользователя, и мы расскажем, что нужно делать дальше.", + 'Submit'=>'Отправить', + 'RESET_CODE_SENT'=>'Код сброса пароля выслан на ваш email
Пожалуйста, введите код в располженное ниже поле для продолжения', + 'Confirm'=>'Подтвердить', + 'New Password'=>'Новый Пароль', + 'Confirm Password'=>'Подтверждение Пароля', + 'Reset'=>'Сбросить', + 'Statistics'=>'Статистика', + 'History Log'=>'История изменений', + 'Vesta logo'=>'Логотип Vesta', + 'USER'=>'ПОЛЬЗОВАТЕЛИ', + 'users'=>'пользователи', + 'suspended'=>'заблокировано', + 'WEB'=>'ХОСТИНГ', + 'domains'=>'домены', + 'aliases'=>'редиректы', + 'DNS'=>'DNS', + 'records'=>'записи', + 'MAIL'=>'ПОЧТА', + 'DB'=>'БД', + 'CRON'=>'CRON', + 'BACKUP'=>'БЭКАПЫ', + 'Packages'=>'Пакеты', + 'IP Addresses'=>'IP адреса', + 'RRD Graphics'=>'Графики', + 'jobs'=>'Задания', + 'Reset Code'=>'Код сброса' ); \ No newline at end of file diff --git a/web/inc/main.php b/web/inc/main.php index c9c2f440a..d9fe83903 100644 --- a/web/inc/main.php +++ b/web/inc/main.php @@ -21,7 +21,7 @@ function _() { } // Check user session -if (!isset($_SESSION['user'])) { +if (!isset($_SESSION['user'])&&!defined('NO_AUTH_REQUIRED')) { $_SESSION['request_uri'] = $_SERVER['REQUEST_URI']; header("Location: /login/"); exit; diff --git a/web/login/index.php b/web/login/index.php index d456da8ab..941e757aa 100644 --- a/web/login/index.php +++ b/web/login/index.php @@ -1,46 +1,51 @@ - 0 ) { - $ERROR = "ERROR: Invalid username or password"; - } else { - $_SESSION['user'] = $_POST['user']; - if ($_POST['user'] == 'root') $_SESSION['user'] = 'admin'; - if (!empty($_SESSION['request_uri'])) { - header("Location: ".$_SESSION['request_uri']); - unset($_SESSION['request_uri']); - exit; - } else { - header("Location: /"); - exit; - } - } - } - require_once '../templates/header.html'; - require_once '../templates/login.html'; -} -?> + 0 ) { + $ERROR = ""._('ERROR: Invalid username or password').""; + } else { + $_SESSION['user'] = $_POST['user']; + if ($_POST['user'] == 'root') $_SESSION['user'] = 'admin'; + if (!empty($_SESSION['request_uri'])) { + header("Location: ".$_SESSION['request_uri']); + unset($_SESSION['request_uri']); + exit; + } else { + header("Location: /"); + exit; + } + } + } + require_once '../templates/header.html'; + require_once '../templates/login.html'; +} +?> diff --git a/web/logout/index.php b/web/logout/index.php index 5cbfd2099..139206524 100644 --- a/web/logout/index.php +++ b/web/logout/index.php @@ -1,12 +1,13 @@ - + diff --git a/web/reset/index.php b/web/reset/index.php index 02430f52e..158b939c4 100644 --- a/web/reset/index.php +++ b/web/reset/index.php @@ -1,100 +1,83 @@ -'; - $boundary='--' . md5( uniqid("myboundary") ); - $priorities = array( '1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)' ); - $priority = $priorities[2]; - $ctencoding = "8bit"; - $sep = chr(13) . chr(10); - $disposition = "inline"; - $subject = "=?$charset?B?".base64_encode($subject)."?="; - $header.="From: $from \nX-Priority: $priority\nCC: $cc\n"; - $header.="Mime-Version: 1.0\nContent-Type: text/plain; charset=$charset \n"; - $header.="Content-Transfer-Encoding: $ctencoding\nX-Mailer: Php/libMailv1.3\n"; - $message .= $mailtext; - mail($to, $subject, $message, $header); -} - -if ((!empty($_POST['user'])) && (empty($_POST['code']))) { - $v_user = escapeshellarg($_POST['user']); - $user = $_POST['user']; - $cmd="/usr/bin/sudo /usr/local/vesta/bin/v-list-user"; - exec ($cmd." ".$v_user." json", $output, $return_var); - if ( $return_var == 0 ) { - $data = json_decode(implode('', $output), true); - $rkey = $data[$user]['RKEY']; - $fname = $data[$user]['FNAME']; - $lname = $data[$user]['LNAME']; - $contact = $data[$user]['CONTACT']; - $to = $data[$user]['CONTACT']; - $subject = 'Password Reset '.date("Y-m-d H:i:s"); - $hostname = exec('hostname'); - $from = "Vesta Control Panel "; - if (!empty($fname)) { - $mailtext = "Hello ".$fname." ".$lname.",\n"; - } else { - $mailtext = "Hello,\n"; - } - $mailtext .= "You recently asked to reset your control panel password. "; - $mailtext .= "To complete your request, please follow this link:\n"; - $mailtext .= "https://".$_SERVER['HTTP_HOST']."/reset/?action=confirm&user=".$user."&code=".$rkey."\n\n"; - $mailtext .= "Alternately, you may go to https://".$_SERVER['HTTP_HOST']."/reset/?action=code&user=".$user." and enter the following password reset code:\n"; - $mailtext .= $rkey."\n\n"; - $mailtext .= "If you did not request a new password please ignore this letter and accept our apologies — we didn't intend to disturb you.\n\n"; - $mailtext .= "--\nVesta Control Panel\n"; - if (!empty($rkey)) send_email($to, $subject, $mailtext, $from); - unset($output); - } - - header("Location: /reset/?action=code&user=".$_POST['user']); - exit; -} - -if ((!empty($_POST['user'])) && (!empty($_POST['code'])) && (!empty($_POST['password'])) ) { - if ( $_POST['password'] == $_POST['password_confirm'] ) { - $v_user = escapeshellarg($_POST['user']); - $user = $_POST['user']; - $v_password = escapeshellarg($_POST['password']); - $cmd="/usr/bin/sudo /usr/local/vesta/bin/v-list-user"; - exec ($cmd." ".$v_user." json", $output, $return_var); - if ( $return_var == 0 ) { - $data = json_decode(implode('', $output), true); - $rkey = $data[$user]['RKEY']; - if ($rkey == $_POST['code']) { - $cmd="/usr/bin/sudo /usr/local/vesta/bin/v-change-user-password"; - exec ($cmd." ".$v_user." ".$v_password, $output, $return_var); - if ( $return_var > 0 ) { - $ERROR = "ERROR: Internal error"; - } else { - $_SESSION['user'] = $_POST['user']; - header("Location: /"); - exit; - } - } else { - $ERROR = "ERROR: Invalid username or code"; - } - } else { - $ERROR = "ERROR: Invalid username or code"; - } - } else { - $ERROR = "ERROR: Passwords not match"; - } -} - -require_once '../templates/header.html'; -if (empty($_GET['action'])) { - require_once '../templates/reset_1.html'; -} else { - if ($_GET['action'] == 'code' ) { - require_once '../templates/reset_2.html'; - } - if (($_GET['action'] == 'confirm' ) && (!empty($_GET['code']))) { - require_once '../templates/reset_3.html'; - } -} - -?> + 0 ) { + $ERROR = ""._('An internal error occurred').""; + } else { + $_SESSION['user'] = $_POST['user']; + header("Location: /"); + exit; + } + } else { + $ERROR = ""._('ERROR: Invalid username or code').""; + } + } else { + $ERROR = ""._('ERROR: Invalid username or code').""; + } + } else { + $ERROR = ""._('ERROR: Passwords not match').""; + } +} + +require_once '../templates/header.html'; +if (empty($_GET['action'])) { + require_once '../templates/reset_1.html'; +} else { + if ($_GET['action'] == 'code' ) { + require_once '../templates/reset_2.html'; + } + if (($_GET['action'] == 'confirm' ) && (!empty($_GET['code']))) { + require_once '../templates/reset_3.html'; + } +} + +?> diff --git a/web/templates/admin/add_cron.html b/web/templates/admin/add_cron.html index e7c237138..05287e27e 100644 --- a/web/templates/admin/add_cron.html +++ b/web/templates/admin/add_cron.html @@ -1,115 +1,115 @@ - - - - - - - - - - - - -
- - - - - -
- - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- Minute -
- - Hour -
- - Day -
- - Month -
- - Day of Week -
- - Command -
- > -
- - -
-
-
+ + + + + + + + + + + + +
+ + + + + +
+ + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ + +
+ + +
+ + +
+ + +
+ > +
+ + +
+
+
diff --git a/web/templates/admin/add_db.html b/web/templates/admin/add_db.html index e978bd549..fdeb1d8b5 100644 --- a/web/templates/admin/add_db.html +++ b/web/templates/admin/add_db.html @@ -1,176 +1,176 @@ - - - - - - - - - - - - -
- - - - - - - -
- - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Prefix "" will be automaticaly added to database name and database user -
- Database -
- - Username -
- - Password generate -
- -
- Type -
- -
- Charset -
- -
- - -
-
-
+ + + + + + + + + + + + +
+ + + + + + + +
+ + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ + +
+ + +
+ +
+ +
+ +
+ +
+ +
+ + +
+
+
diff --git a/web/templates/admin/add_dns.html b/web/templates/admin/add_dns.html index 0d02a9e9b..8f8df86de 100644 --- a/web/templates/admin/add_dns.html +++ b/web/templates/admin/add_dns.html @@ -1,165 +1,165 @@ - - - - - - - - - - - - -
- - - - - - + +
- - -
-
- - - - -
- - - - - - - - - - - - - -
- Domain -
- - IP address -
- - Advanced Options -
- - - - - - - - - - - - - - - - - - - -
- Template -
- -
- Domain Expiriation (YYYY-MM-DD) -
- - TTL -
- - Name Servers -
- - - -
-
- + + + + + + + + +
+ +
+ + + + + + - -
+ + +
+
+ + + + +
+ + + + + + + + + + + + + +
+ +
+ + +
+ + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ (YYYY-MM-DD) +
+ + TTL +
+ + +
+ + + +
+
+ diff --git a/web/templates/admin/panel.html b/web/templates/admin/panel.html index 4998543a3..4049b1001 100644 --- a/web/templates/admin/panel.html +++ b/web/templates/admin/panel.html @@ -1,76 +1,76 @@ -
- - - + +
- - - - -
- - - - - - - - - - -
PackagesIP AdressesRRD GraphicsStatisticsHistory LogLog out
- - - - - - - - - - - - +
+ + + + +
+ + + - -
+ + + + + + + + + + +
+ + + + + + + + + + + + diff --git a/web/templates/footer.html b/web/templates/footer.html index f1935d377..8670dd3cb 100644 --- a/web/templates/footer.html +++ b/web/templates/footer.html @@ -1,22 +1,22 @@ - - - - - - - - -
Powered by Vesta Control Panel
vestacp.com
-
- - - - - - + + + + + + + + +
vestacp.com |
+
+ + + +
+ + diff --git a/web/templates/login.html b/web/templates/login.html index 00689c2d8..895539f89 100644 --- a/web/templates/login.html +++ b/web/templates/login.html @@ -1,59 +1,59 @@ -
- - - - -
- - +
+ + + + +
+ + diff --git a/web/templates/reset_1.html b/web/templates/reset_1.html index 1d47d613b..d721e0415 100644 --- a/web/templates/reset_1.html +++ b/web/templates/reset_1.html @@ -1,52 +1,52 @@ -
- - - - - -
- - - +
+ + + + + +
+ + + diff --git a/web/templates/reset_2.html b/web/templates/reset_2.html index b6d982975..579417f5d 100644 --- a/web/templates/reset_2.html +++ b/web/templates/reset_2.html @@ -1,52 +1,51 @@ -
- - - - - -
- - +
+ + + + + +
+ + diff --git a/web/templates/reset_3.html b/web/templates/reset_3.html index a2055ec07..21ede8a6b 100644 --- a/web/templates/reset_3.html +++ b/web/templates/reset_3.html @@ -1,63 +1,63 @@ -
- - - - - -
- - +
+ + + + + +
+ + diff --git a/web/templates/user/panel.html b/web/templates/user/panel.html index f381630ce..689d6097e 100644 --- a/web/templates/user/panel.html +++ b/web/templates/user/panel.html @@ -1,75 +1,75 @@ -
- - - + +
- - - - -
- - - - - - - - - - -
StatisticsHistory LogLog out
- - - - - - - - - - - +
+ + + + +
+ + + - -
+ + + + + + + + + + +
+ + + + + + + + + + + From 2b16d9bd832cc3764abc30f83fb1b774046268a7 Mon Sep 17 00:00:00 2001 From: ZonD Eighty Date: Fri, 28 Dec 2012 23:31:02 +0400 Subject: [PATCH 03/11] Merge changes from upstream I'm a little angry --- bin/v-add-cron-job | 162 +-- bin/v-add-cron-report | 108 +- bin/v-add-database | 172 +-- bin/v-add-database-server | 158 +-- bin/v-add-dns-domain | 286 ++--- bin/v-add-dns-domain-record | 184 +-- bin/v-add-dns-on-web-alias | 160 +-- bin/v-add-mail-account | 158 +-- bin/v-add-mail-account-alias | 136 +- bin/v-add-mail-account-autoreply | 128 +- bin/v-add-mail-account-forward | 146 +-- bin/v-add-mail-domain | 242 ++-- bin/v-add-mail-domain-antispam | 116 +- bin/v-add-mail-domain-antivirus | 118 +- bin/v-add-mail-domain-catchall | 120 +- bin/v-add-mail-domain-dkim | 162 +-- bin/v-add-sys-ip | 200 +-- bin/v-add-user | 436 +++---- bin/v-add-user-backup | 92 +- bin/v-add-user-package | 158 +-- bin/v-add-web-domain | 380 +++--- bin/v-add-web-domain-alias | 218 ++-- bin/v-add-web-domain-cgi | 160 +-- bin/v-add-web-domain-elog | 198 +-- bin/v-add-web-domain-ftp | 142 +-- bin/v-add-web-domain-nginx | 222 ++-- bin/v-add-web-domain-ssl | 272 ++-- bin/v-add-web-domain-stats | 182 +-- bin/v-add-web-domain-stats-user | 144 +-- bin/v-backup-user | 1046 ++++++++-------- bin/v-backup-users | 78 +- bin/v-change-cron-job | 146 +-- bin/v-change-database-password | 130 +- bin/v-change-dns-domain-exp | 106 +- bin/v-change-dns-domain-ip | 138 +-- bin/v-change-dns-domain-record | 154 +-- bin/v-change-dns-domain-soa | 126 +- bin/v-change-dns-domain-tpl | 168 +-- bin/v-change-dns-domain-ttl | 124 +- bin/v-change-mail-account-password | 144 +-- bin/v-change-mail-account-quota | 124 +- bin/v-change-mail-domain-catchall | 118 +- bin/v-change-sys-config-value | 102 +- bin/v-change-sys-ip-name | 94 +- bin/v-change-sys-ip-owner | 162 +-- bin/v-change-sys-ip-status | 120 +- bin/v-change-user-contact | 102 +- bin/v-change-user-name | 106 +- bin/v-change-user-ns | 132 +- bin/v-change-user-package | 288 ++--- bin/v-change-user-password | 114 +- bin/v-change-user-shell | 108 +- bin/v-change-user-template | 98 +- bin/v-change-web-domain-ftp | 124 +- bin/v-change-web-domain-ip | 192 +-- bin/v-change-web-domain-nginx-tpl | 202 +-- bin/v-change-web-domain-sslcert | 158 +-- bin/v-change-web-domain-sslhome | 158 +-- bin/v-change-web-domain-stats | 190 +-- bin/v-change-web-domain-tpl | 220 ++-- bin/v-delete-cron-job | 124 +- bin/v-delete-cron-reports | 108 +- bin/v-delete-database | 130 +- bin/v-delete-database-server | 100 +- bin/v-delete-databases | 96 +- bin/v-delete-dns-domain | 140 +-- bin/v-delete-dns-domain-record | 128 +- bin/v-delete-dns-domains | 100 +- bin/v-delete-dns-on-web-alias | 158 +-- bin/v-delete-mail-account | 140 +-- bin/v-delete-mail-account-alias | 140 +-- bin/v-delete-mail-account-autoreply | 122 +- bin/v-delete-mail-account-forward | 144 +-- bin/v-delete-mail-domain | 144 +-- bin/v-delete-mail-domain-antispam | 114 +- bin/v-delete-mail-domain-antivirus | 114 +- bin/v-delete-mail-domain-catchall | 114 +- bin/v-delete-mail-domain-dkim | 138 +-- bin/v-delete-mail-domains | 94 +- bin/v-delete-sys-ip | 188 +-- bin/v-delete-user | 226 ++-- bin/v-delete-user-backup | 106 +- bin/v-delete-user-ips | 126 +- bin/v-delete-user-package | 110 +- bin/v-delete-web-domain | 330 ++--- bin/v-delete-web-domain-alias | 216 ++-- bin/v-delete-web-domain-cgi | 158 +-- bin/v-delete-web-domain-elog | 194 +-- bin/v-delete-web-domain-ftp | 116 +- bin/v-delete-web-domain-nginx | 174 +-- bin/v-delete-web-domain-ssl | 202 +-- bin/v-delete-web-domain-stats | 138 +-- bin/v-delete-web-domain-stats-user | 122 +- bin/v-delete-web-domains | 106 +- bin/v-get-dns-domain-value | 94 +- bin/v-get-mail-account-value | 49 + bin/v-get-mail-domain-value | 47 + bin/v-get-user-value | 90 +- bin/v-get-web-domain-value | 98 +- bin/v-list-cron-job | 182 +-- bin/v-list-cron-jobs | 212 ++-- bin/v-list-database | 178 +-- bin/v-list-database-server | 176 +-- bin/v-list-database-servers | 102 +- bin/v-list-database-types | 132 +- bin/v-list-databases | 102 +- bin/v-list-dns-domain | 210 ++-- bin/v-list-dns-domain-records | 210 ++-- bin/v-list-dns-domains | 102 +- bin/v-list-dns-template | 204 +-- bin/v-list-dns-templates | 130 +- bin/v-list-mail-account | 188 +-- bin/v-list-mail-account-autoreply | 144 +-- bin/v-list-mail-accounts | 108 +- bin/v-list-mail-domain | 180 +-- bin/v-list-mail-domain-dkim | 146 +-- bin/v-list-mail-domains | 104 +- bin/v-list-sys-config | 122 +- bin/v-list-sys-interfaces | 130 +- bin/v-list-sys-ip | 184 +-- bin/v-list-sys-ips | 188 +-- bin/v-list-sys-rrd | 228 ++-- bin/v-list-sys-shells | 134 +- bin/v-list-sys-users | 130 +- bin/v-list-user | 194 +-- bin/v-list-user-backups | 112 +- bin/v-list-user-ips | 242 ++-- bin/v-list-user-log | 176 +-- bin/v-list-user-ns | 150 +-- bin/v-list-user-package | 184 +-- bin/v-list-user-packages | 182 +-- bin/v-list-user-stats | 116 +- bin/v-list-users | 204 +-- bin/v-list-users-stats | 110 +- bin/v-list-web-domain | 188 +-- bin/v-list-web-domain-ssl | 162 +-- bin/v-list-web-domains | 110 +- bin/v-list-web-domains-alias | 108 +- bin/v-list-web-domains-elog | 108 +- bin/v-list-web-domains-nginx | 108 +- bin/v-list-web-domains-ssl | 108 +- bin/v-list-web-domains-stats | 110 +- bin/v-list-web-stats | 132 +- bin/v-list-web-templates | 136 +- bin/v-list-web-templates-nginx | 134 +- bin/v-rebuild-cron-jobs | 102 +- bin/v-rebuild-databases | 106 +- bin/v-rebuild-dns-domains | 256 ++-- bin/v-rebuild-mail-domains | 368 +++--- bin/v-rebuild-user | 314 ++--- bin/v-rebuild-web-domains | 624 +++++----- bin/v-restart-cron | 78 +- bin/v-restart-dns | 74 +- bin/v-restart-mail | 74 +- bin/v-restart-web | 122 +- bin/v-restore-user | 80 +- bin/v-search-domain-owner | 55 + bin/v-search-object | 516 ++++---- bin/v-search-user-object | 516 ++++---- bin/v-suspend-cron-job | 114 +- bin/v-suspend-cron-jobs | 104 +- bin/v-suspend-database | 120 +- bin/v-suspend-database-server | 94 +- bin/v-suspend-databases | 94 +- bin/v-suspend-dns-domain | 120 +- bin/v-suspend-dns-domain-record | 142 +-- bin/v-suspend-dns-domains | 106 +- bin/v-suspend-mail-account | 120 +- bin/v-suspend-mail-accounts | 106 +- bin/v-suspend-mail-domain | 116 +- bin/v-suspend-mail-domains | 96 +- bin/v-suspend-user | 170 +-- bin/v-suspend-web-domain | 192 +-- bin/v-suspend-web-domains | 106 +- bin/v-unsuspend-cron-job | 114 +- bin/v-unsuspend-cron-jobs | 104 +- bin/v-unsuspend-database | 118 +- bin/v-unsuspend-database-server | 94 +- bin/v-unsuspend-databases | 96 +- bin/v-unsuspend-dns-domain | 124 +- bin/v-unsuspend-dns-domain-record | 140 +-- bin/v-unsuspend-dns-domains | 106 +- bin/v-unsuspend-mail-account | 122 +- bin/v-unsuspend-mail-accounts | 106 +- bin/v-unsuspend-mail-domain | 114 +- bin/v-unsuspend-mail-domains | 96 +- bin/v-unsuspend-user | 166 +-- bin/v-unsuspend-web-domain | 186 +-- bin/v-unsuspend-web-domains | 108 +- bin/v-update-database-disk | 120 +- bin/v-update-databases-disk | 94 +- bin/v-update-mail-domain-disk | 128 +- bin/v-update-mail-domains-disk | 126 +- bin/v-update-sys-ip | 186 +-- bin/v-update-sys-queue | 122 +- bin/v-update-sys-rrd | 274 ++--- bin/v-update-sys-rrd-ftp | 194 +-- bin/v-update-sys-rrd-httpd | 206 ++-- bin/v-update-sys-rrd-la | 206 ++-- bin/v-update-sys-rrd-mem | 206 ++-- bin/v-update-sys-rrd-mysql | 282 ++--- bin/v-update-sys-rrd-net | 232 ++-- bin/v-update-sys-rrd-nginx | 190 +-- bin/v-update-sys-rrd-pgsql | 292 ++--- bin/v-update-sys-rrd-ssh | 192 +-- bin/v-update-sys-vesta | 226 ++-- bin/v-update-user-backups | 556 ++++----- bin/v-update-user-counters | 428 +++---- bin/v-update-user-disk | 130 +- bin/v-update-user-package | 94 +- bin/v-update-user-stats | 338 ++--- bin/v-update-web-domain-disk | 120 +- bin/v-update-web-domain-stat | 288 ++--- bin/v-update-web-domain-traff | 152 +-- bin/v-update-web-domains-disk | 110 +- bin/v-update-web-domains-stat | 104 +- bin/v-update-web-domains-traff | 144 +-- install/0.9.7/rhel/roundcube-driver.php | 54 + install/0.9.7/rhel/roundcube-main.conf | 589 ++++----- install/0.9.7/rhel/roundcube-pw.conf | 33 + install/vst-install.sh | 1276 +++++++++---------- web/inc/i18n/ru.php | 4 +- web/inc/main.php | 18 +- web/reset/mail/index.php | 145 +++ web/templates/admin/add_package.html | 492 ++++---- web/templates/admin/edit_mail_acc.html | 318 +++-- web/templates/admin/list_backup.html | 386 +++--- web/templates/admin/list_cron.html | 362 +++--- web/templates/admin/list_db.html | 322 ++--- web/templates/admin/list_dns.html | 294 ++--- web/templates/admin/list_dns_rec.html | 214 ++-- web/templates/admin/list_ip.html | 274 ++--- web/templates/admin/list_log.html | 142 +-- web/templates/admin/list_mail.html | 346 +++--- web/templates/admin/list_mail_acc.html | 310 ++--- web/templates/admin/list_packages.html | 434 +++---- web/templates/admin/list_rrd.html | 144 +-- web/templates/admin/list_search.html | 436 +++---- web/templates/admin/list_stats.html | 442 +++---- web/templates/admin/list_user.html | 500 ++++---- web/templates/admin/list_web.html | 414 +++---- web/templates/admin/panel.html | 188 +-- web/templates/header.html | 1505 +++++++++++------------ web/templates/user/list_cron.html | 342 ++--- web/templates/user/list_db.html | 302 ++--- web/templates/user/list_dns.html | 274 ++--- web/templates/user/list_dns_rec.html | 196 +-- web/templates/user/list_mail.html | 328 ++--- web/templates/user/list_mail_acc.html | 290 ++--- web/templates/user/list_search.html | 342 ++--- web/templates/user/list_stats.html | 406 +++--- web/templates/user/list_user.html | 392 +++--- web/templates/user/list_web.html | 388 +++--- web/templates/user/panel.html | 188 +-- 254 files changed, 24485 insertions(+), 24094 deletions(-) create mode 100755 bin/v-get-mail-account-value create mode 100755 bin/v-get-mail-domain-value create mode 100755 bin/v-search-domain-owner create mode 100644 install/0.9.7/rhel/roundcube-driver.php create mode 100644 install/0.9.7/rhel/roundcube-pw.conf create mode 100644 web/reset/mail/index.php diff --git a/bin/v-add-cron-job b/bin/v-add-cron-job index fd94c5b8e..8b2ad562f 100755 --- a/bin/v-add-cron-job +++ b/bin/v-add-cron-job @@ -1,81 +1,81 @@ -#!/bin/bash -# info: add cron job -# options: user min hour day month wday command [job] -# -# The function adds a job to cron daemon. When executing commands, any output -# is mailed to user's email if parameter REPORTS is set to 'yes'. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -min=$2 -hour=$3 -day=$4 -month=$5 -wday=$6 -command=$(echo $7 | sed -e "s/'/%quote%/g") -job=$8 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - -# Assing new value -A7="$command" - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '7' "$#" 'user min hour day month wday command [job]' -validate_format 'user' 'min' 'hour' 'day' 'month' 'wday' 'command' -is_system_enabled $CRON_SYSTEM -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_package_full 'CRON_JOBS' -get_next_cronjob -validate_format 'job' -is_object_free 'cron' 'JOB' "$job" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Concatenating cron string -str="JOB='$job' MIN='$min' HOUR='$hour' DAY='$day' MONTH='$month' WDAY='$wday'" -str="$str CMD='$command' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" - -# Adding to crontab -echo "$str" >> $VESTA/data/users/$user/cron.conf - -# Chaning permissions -chmod 660 $VESTA/data/users/$user/cron.conf - -# Sort jobs by id number -sort_cron_jobs - -# Sync cronjobs with system crond -sync_cron_jobs - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Increasing cron value -increase_user_value $user '$U_CRON_JOBS' - -# Restart crond -$BIN/v-restart-cron "$EVENT" - -# Logging -log_history "added cron job $job" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add cron job +# options: USER MIN HOUR DAY MONTH WDAY COMMAND [JOB] +# +# The function adds a job to cron daemon. When executing commands, any output +# is mailed to user's email if parameter REPORTS is set to 'yes'. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +min=$2 +hour=$3 +day=$4 +month=$5 +wday=$6 +command=$(echo $7 | sed -e "s/'/%quote%/g") +job=$8 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + +# Assing new value +A7="$command" + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '7' "$#" 'USER MIN HOUR DAY MONTH WDAY COMMAND [JOB]' +validate_format 'user' 'min' 'hour' 'day' 'month' 'wday' 'command' +is_system_enabled $CRON_SYSTEM +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_package_full 'CRON_JOBS' +get_next_cronjob +validate_format 'job' +is_object_free 'cron' 'JOB' "$job" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Concatenating cron string +str="JOB='$job' MIN='$min' HOUR='$hour' DAY='$day' MONTH='$month' WDAY='$wday'" +str="$str CMD='$command' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" + +# Adding to crontab +echo "$str" >> $VESTA/data/users/$user/cron.conf + +# Chaning permissions +chmod 660 $VESTA/data/users/$user/cron.conf + +# Sort jobs by id number +sort_cron_jobs + +# Sync cronjobs with system crond +sync_cron_jobs + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Increasing cron value +increase_user_value $user '$U_CRON_JOBS' + +# Restart crond +$BIN/v-restart-cron "$EVENT" + +# Logging +log_history "added cron job $job" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-cron-report b/bin/v-add-cron-report index fa1c0edc0..b40727cd3 100755 --- a/bin/v-add-cron-report +++ b/bin/v-add-cron-report @@ -1,54 +1,54 @@ -#!/bin/bash -# info: add cron reports -# opions: user -# -# The script for enabling reports on cron tasks and administrative -# notifications. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user' -validate_format 'user' -is_system_enabled "$CRON_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing user report value -update_user_value "$user" '$CRON_REPORTS' 'yes' - -# Sync system cron with user -sync_cron_jobs - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart crond -$BIN/v-restart-cron "$EVENT" - -# Logging -log_history "enabled cron reporting" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add cron reports +# opions: user +# +# The script for enabling reports on cron tasks and administrative +# notifications. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_system_enabled "$CRON_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Changing user report value +update_user_value "$user" '$CRON_REPORTS' 'yes' + +# Sync system cron with user +sync_cron_jobs + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart crond +$BIN/v-restart-cron "$EVENT" + +# Logging +log_history "enabled cron reporting" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-database b/bin/v-add-database index df474d4a0..aa0e9658d 100755 --- a/bin/v-add-database +++ b/bin/v-add-database @@ -1,86 +1,86 @@ -#!/bin/bash -# info: add database -# options: user database dbuser dbpass type [host] [charset] -# -# The function creates the database concatenating username and user_db. -# Supported yypes of databases you can get using v-list-sys-config script. -# If the host isn't stated and there are few hosts configured on the server, -# then the host will be defined by one of three algorithms. "First" will choose -# the first host in the list. "Random" will chose the host by a chance. -# "Weight" will distribute new database through hosts evenly. Algorithm and -# types of supported databases is designated in the main configuration file. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -database="$user"_"$2" -dbuser="$user"_"$3" -dbpass=$4 -type=$5 -host=$6 -charset=${7-UTF8} -charset=$(echo "$charset" |tr '[:lower:]' '[:upper:]') - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/db.sh - -# Hiding password -A4='******' -EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'" -EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'" - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '5' "$#" 'user database dbuser dbpass type [host] [charset]' -validate_format 'user' 'database' 'dbuser' 'dbpass' 'charset' -is_system_enabled "$DB_SYSTEM" -is_type_valid "$DB_SYSTEM" "$type" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_free 'db' 'DB' "$database" -get_next_dbhost -is_object_valid "../../../conf/$type" 'HOST' "$host" -is_object_unsuspended "../../../conf/$type" 'HOST' "$host" -#is_charset_valid -is_package_full 'DATABASES' - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on db type -case $type in - mysql) add_mysql_database ;; - pgsql) add_pgsql_database ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Increasing counters -increase_dbhost_values -increase_user_value "$user" '$U_DATABASES' - -# Adding db to db conf -str="DB='$database' DBUSER='$dbuser' MD5='$md5' HOST='$host' TYPE='$type'" -str="$str CHARSET='$charset' U_DISK='0' SUSPENDED='no' TIME='$TIME'" -str="$str DATE='$DATE'" -echo "$str" >> $USER_DATA/db.conf -chmod 660 $USER_DATA/db.conf - -# Logging -log_history "added $type database $database" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add database +# options: USER DATABASE DBUSER DBPASS TYPE [HOST] [CHARSET] +# +# The function creates the database concatenating username and user_db. +# Supported yypes of databases you can get using v-list-sys-config script. +# If the host isn't stated and there are few hosts configured on the server, +# then the host will be defined by one of three algorithms. "First" will choose +# the first host in the list. "Random" will chose the host by a chance. +# "Weight" will distribute new database through hosts evenly. Algorithm and +# types of supported databases is designated in the main configuration file. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +database="$user"_"$2" +dbuser="$user"_"$3" +dbpass=$4 +type=$5 +host=$6 +charset=${7-UTF8} +charset=$(echo "$charset" |tr '[:lower:]' '[:upper:]') + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/db.sh + +# Hiding password +A4='******' +EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'" +EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'" + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '5' "$#" 'USER DATABASE DBUSER DBPASS TYPE [HOST] [CHARSET]' +validate_format 'user' 'database' 'dbuser' 'dbpass' 'charset' +is_system_enabled "$DB_SYSTEM" +is_type_valid "$DB_SYSTEM" "$type" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_free 'db' 'DB' "$database" +get_next_dbhost +is_object_valid "../../../conf/$type" 'HOST' "$host" +is_object_unsuspended "../../../conf/$type" 'HOST' "$host" +#is_charset_valid +is_package_full 'DATABASES' + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Switching on db type +case $type in + mysql) add_mysql_database ;; + pgsql) add_pgsql_database ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Increasing counters +increase_dbhost_values +increase_user_value "$user" '$U_DATABASES' + +# Adding db to db conf +str="DB='$database' DBUSER='$dbuser' MD5='$md5' HOST='$host' TYPE='$type'" +str="$str CHARSET='$charset' U_DISK='0' SUSPENDED='no' TIME='$TIME'" +str="$str DATE='$DATE'" +echo "$str" >> $USER_DATA/db.conf +chmod 660 $USER_DATA/db.conf + +# Logging +log_history "added $type database $database" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-database-server b/bin/v-add-database-server index 91d263ba5..2f9e68397 100755 --- a/bin/v-add-database-server +++ b/bin/v-add-database-server @@ -1,79 +1,79 @@ -#!/bin/bash -# info: add new database server -# options: type host port dbuser dbpass [max_db] [charsets] [template] -# -# The function add new database server to the server pool. It supports local -# and remote database servers, which is useful for clusters. By adding a host -# you can set limit for number of databases on a host. Template parameter is -# used only for PostgreSQL and has an default value "template1". You can read -# more about templates in official PostgreSQL documentation. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -type=$1 -host=$2 -port=$3 -dbuser=$4 -dbpass=$5 -A5='******' -charsets=${7-UTF8,LATIN1,WIN1250,WIN1251,WIN1252,WIN1256,WIN1258,KOI8} -template=${8-template1} - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/db.sh - -# Hiding password -max_db=${6-500} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -args_usage='type host port dbuser dbpass [max_db] [charsets] [tpl]' -check_args '5' "$#" "$args_usage" -validate_format 'host' 'port' 'dbuser' 'dbpass' 'max_db' 'charsets' 'template' -is_system_enabled "$DB_SYSTEM" -is_type_valid "$DB_SYSTEM" "$type" -is_dbhost_new -case $type in - mysql) is_mysql_host_alive ;; - pgsql) is_pgsql_host_alive ;; -esac - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Concatentating db host string -case $type in - mysql) str="HOST='$host' USER='$dbuser' PASSWORD='$dbpass' PORT='$port'"; - str="$str CHARSETS='$charsets' MAX_DB='$max_db' U_SYS_USERS=''"; - str="$str U_DB_BASES='0' SUSPENDED='no' TIME='$TIME' DATE='$DATE'";; - pgsql) str="HOST='$host' USER='$dbuser' PASSWORD='$dbpass' PORT='$port'"; - str="$str CHARSETS='$charsets' TPL='$template' MAX_DB='$max_db'"; - str="$str U_SYS_USERS='' U_DB_BASES='0' SUSPENDED='no'"; - str="$str TIME='$TIME' DATE='$DATE'";; -esac - -# Adding host to conf -echo "$str" >> $VESTA/conf/$type.conf -chmod 660 $VESTA/conf/$type.conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "added $type database server $host" '' 'admin' -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add new database server +# options: TYPE HOST PORT DBUSER DBPASS [MAX_DB] [CHARSETS] [TEMPLATE] +# +# The function add new database server to the server pool. It supports local +# and remote database servers, which is useful for clusters. By adding a host +# you can set limit for number of databases on a host. Template parameter is +# used only for PostgreSQL and has an default value "template1". You can read +# more about templates in official PostgreSQL documentation. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +type=$1 +host=$2 +port=$3 +dbuser=$4 +dbpass=$5 +A5='******' +charsets=${7-UTF8,LATIN1,WIN1250,WIN1251,WIN1252,WIN1256,WIN1258,KOI8} +template=${8-template1} + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/db.sh + +# Hiding password +max_db=${6-500} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +args_usage='TYPE HOST PORT DBUSER DBPASS [MAX_DB] [CHARSETS] [TPL]' +check_args '5' "$#" "$args_usage" +validate_format 'host' 'port' 'dbuser' 'dbpass' 'max_db' 'charsets' 'template' +is_system_enabled "$DB_SYSTEM" +is_type_valid "$DB_SYSTEM" "$type" +is_dbhost_new +case $type in + mysql) is_mysql_host_alive ;; + pgsql) is_pgsql_host_alive ;; +esac + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Concatentating db host string +case $type in + mysql) str="HOST='$host' USER='$dbuser' PASSWORD='$dbpass' PORT='$port'"; + str="$str CHARSETS='$charsets' MAX_DB='$max_db' U_SYS_USERS=''"; + str="$str U_DB_BASES='0' SUSPENDED='no' TIME='$TIME' DATE='$DATE'";; + pgsql) str="HOST='$host' USER='$dbuser' PASSWORD='$dbpass' PORT='$port'"; + str="$str CHARSETS='$charsets' TPL='$template' MAX_DB='$max_db'"; + str="$str U_SYS_USERS='' U_DB_BASES='0' SUSPENDED='no'"; + str="$str TIME='$TIME' DATE='$DATE'";; +esac + +# Adding host to conf +echo "$str" >> $VESTA/conf/$type.conf +chmod 660 $VESTA/conf/$type.conf + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_history "added $type database server $host" '' 'admin' +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-dns-domain b/bin/v-add-dns-domain index 92b651535..03fc7f454 100755 --- a/bin/v-add-dns-domain +++ b/bin/v-add-dns-domain @@ -1,143 +1,143 @@ -#!/bin/bash -# info: add dns domain -# options: user domain ip [template] [ns1] [ns2] [ns3] [ns4] [restart] -# -# The function adds DNS zone with records defined in the template. If the exp -# argument isn't stated, the expiration date value will be set to next year. -# The soa argument is responsible for the relevant record. By default the first -# user's NS server is used. TTL is set as common for the zone and for all of -# its records with a default value of 14400 seconds. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g') -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -ip=$3 -template=$4 -ns1=$5 -ns2=$6 -ns3=$7 -ns4=$8 -restart=$9 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user domain ip [template] [ns1] [ns2] [ns3] [ns4]' -validate_format 'user' 'domain' 'ip' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_domain_new 'dns' -is_package_full 'DNS_DOMAINS' -if [ ! -z "$template" ]; then - validate_format 'template' - is_dns_template_valid -else - template=$(get_user_value '$TEMPLATE') - is_dns_template_valid -fi - -if [ ! -z "$ns1" ]; then - ns1=$(echo $5 | sed -e 's/\.*$//g' -e 's/^\.*//g') - validate_format 'ns1' -fi -if [ ! -z "$ns2" ]; then - ns2=$(echo $6 | sed -e 's/\.*$//g' -e 's/^\.*//g') - validate_format 'ns2' -fi - -if [ ! -z "$ns3" ]; then - ns3=$(echo $7 | sed -e 's/\.*$//g' -e 's/^\.*//g') - validate_format 'ns3' -fi -if [ ! -z "$ns4" ]; then - ns4=$(echo $8 | sed -e 's/\.*$//g' -e 's/^\.*//g') - validate_format 'ns4' -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining variables -if [ -z $ns2 ]; then - i=1 - ns=$(get_user_value '$NS') - for nameserver in ${ns//,/ };do - eval ns$i=$nameserver - (( ++i)) - done -fi -soa="$ns1" -exp=$(date +%F -d "+ 1 year") -ttl=14400 - - -# Adding zone to dns dir -cat $DNSTPL/$template.tpl |\ - sed -e "s/%ip%/$ip/g" \ - -e "s/%domain_idn%/$domain_idn/g" \ - -e "s/%domain%/$domain/g" \ - -e "s/%ns1%/$ns1/g" \ - -e "s/%ns2%/$ns2/g" \ - -e "s/%ns3%/$ns3/g" \ - -e "s/%ns4%/$ns4/g" \ - -e "s/%time%/$TIME/g" \ - -e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain.conf -chmod 660 $USER_DATA/dns/$domain.conf -records="$(wc -l $USER_DATA/dns/$domain.conf |cut -f 1 -d ' ')" - -# Adding dns.conf record -dns_rec="DOMAIN='$domain' IP='$ip' TPL='$template' TTL='$ttl' EXP='$exp'" -dns_rec="$dns_rec SOA='$soa' RECORDS='$records' SUSPENDED='no' TIME='$TIME'" -dns_rec="$dns_rec DATE='$DATE'" - -echo "$dns_rec" >> $USER_DATA/dns.conf -chmod 660 $USER_DATA/dns.conf - -# Adding zone in named.conf -named="zone \"$domain_idn\" {type master; file" -named="$named \"$HOMEDIR/$user/conf/dns/$domain.db\";};" -echo "$named" >> /etc/named.conf - -# Updating domain dns zone -update_domain_zone - -chmod 640 $conf -chown root:named $conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Increasing domain value -increase_user_value "$user" '$U_DNS_DOMAINS' -increase_user_value "$user" '$U_DNS_RECORDS' "$records" - -# Restart named -if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" -fi - -# Logging -log_history "added dns domain $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add dns domain +# options: USER DOMAIN IP [TEMPLATE] [NS1] [NS2] [NS3] [NS4] [RESTART] +# +# The function adds DNS zone with records defined in the template. If the exp +# argument isn't stated, the expiration date value will be set to next year. +# The soa argument is responsible for the relevant record. By default the first +# user's NS server is used. TTL is set as common for the zone and for all of +# its records with a default value of 14400 seconds. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g') +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +ip=$3 +template=$4 +ns1=$5 +ns2=$6 +ns3=$7 +ns4=$8 +restart=$9 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN IP [TEMPLATE] [NS1] [NS2] [NS3] [NS4]' +validate_format 'user' 'domain' 'ip' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_domain_new 'dns' +is_package_full 'DNS_DOMAINS' +if [ ! -z "$template" ]; then + validate_format 'template' + is_dns_template_valid +else + template=$(get_user_value '$TEMPLATE') + is_dns_template_valid +fi + +if [ ! -z "$ns1" ]; then + ns1=$(echo $5 | sed -e 's/\.*$//g' -e 's/^\.*//g') + validate_format 'ns1' +fi +if [ ! -z "$ns2" ]; then + ns2=$(echo $6 | sed -e 's/\.*$//g' -e 's/^\.*//g') + validate_format 'ns2' +fi + +if [ ! -z "$ns3" ]; then + ns3=$(echo $7 | sed -e 's/\.*$//g' -e 's/^\.*//g') + validate_format 'ns3' +fi +if [ ! -z "$ns4" ]; then + ns4=$(echo $8 | sed -e 's/\.*$//g' -e 's/^\.*//g') + validate_format 'ns4' +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining variables +if [ -z $ns2 ]; then + i=1 + ns=$(get_user_value '$NS') + for nameserver in ${ns//,/ };do + eval ns$i=$nameserver + (( ++i)) + done +fi +soa="$ns1" +exp=$(date +%F -d "+ 1 year") +ttl=14400 + + +# Adding zone to dns dir +cat $DNSTPL/$template.tpl |\ + sed -e "s/%ip%/$ip/g" \ + -e "s/%domain_idn%/$domain_idn/g" \ + -e "s/%domain%/$domain/g" \ + -e "s/%ns1%/$ns1/g" \ + -e "s/%ns2%/$ns2/g" \ + -e "s/%ns3%/$ns3/g" \ + -e "s/%ns4%/$ns4/g" \ + -e "s/%time%/$TIME/g" \ + -e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain.conf +chmod 660 $USER_DATA/dns/$domain.conf +records="$(wc -l $USER_DATA/dns/$domain.conf |cut -f 1 -d ' ')" + +# Adding dns.conf record +dns_rec="DOMAIN='$domain' IP='$ip' TPL='$template' TTL='$ttl' EXP='$exp'" +dns_rec="$dns_rec SOA='$soa' RECORDS='$records' SUSPENDED='no' TIME='$TIME'" +dns_rec="$dns_rec DATE='$DATE'" + +echo "$dns_rec" >> $USER_DATA/dns.conf +chmod 660 $USER_DATA/dns.conf + +# Adding zone in named.conf +named="zone \"$domain_idn\" {type master; file" +named="$named \"$HOMEDIR/$user/conf/dns/$domain.db\";};" +echo "$named" >> /etc/named.conf + +# Updating domain dns zone +update_domain_zone + +chmod 640 $conf +chown root:named $conf + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Increasing domain value +increase_user_value "$user" '$U_DNS_DOMAINS' +increase_user_value "$user" '$U_DNS_RECORDS' "$records" + +# Restart named +if [ "$restart" != 'no' ]; then + $BIN/v-restart-dns "$EVENT" +fi + +# Logging +log_history "added dns domain $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-dns-domain-record b/bin/v-add-dns-domain-record index ca9c6247f..e59fbec41 100755 --- a/bin/v-add-dns-domain-record +++ b/bin/v-add-dns-domain-record @@ -1,92 +1,92 @@ -#!/bin/bash -# info: add dns domain record -# options: user domain record type value [priority] [id] [restart] -# -# The call is used for adding new DNS record. Complex records of TXT, MX and -# SRV types can be used by a filling in the 'value' argument. The function also -# gets an id parameter for definition of certain record identifier or for the -# regulation of records. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -record=$(idn -t --quiet -u "$3" ) -record=$(echo "$record" | tr '[:upper:]' '[:lower:]') -rtype=$(echo "$4"| tr '[:lower:]' '[:upper:]') -dvalue=$(idn -t --quiet -u "$5" ) -dvalue=$(echo "$dvalue" | tr '[:upper:]' '[:lower:]') -priority=$6 -id=$7 -restart=$8 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '5' "$#" 'user domain record type value [priority] [id] [restart]' -validate_format 'user' 'domain' 'record' 'rtype' 'dvalue' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" -is_package_full 'DNS_RECORDS' -get_next_dnsrecord -validate_format 'id' -is_object_free "dns/$domain" 'ID' "$id" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -if [ "$rtype" != 'MX' ] && [ "$rtype" != 'SRV' ]; then - priority='' -fi - -# Adding record -zone="$USER_DATA/dns/$domain.conf" -dns_rec="ID='$id' RECORD='$record' TYPE='$rtype' PRIORITY='$priority'" -dns_rec="$dns_rec VALUE='$dvalue' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" -echo "$dns_rec" >> $zone -chmod 660 $zone - -# Sorting records -sort_dns_records - -# Updating zone -update_domain_zone - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Upddate counters -records="$(wc -l $USER_DATA/dns/$domain.conf | cut -f1 -d ' ')" -update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records" -increase_user_value "$user" '$U_DNS_RECORDS' - -# Restart named -if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" -fi - -# Logging -log_history "added $rtype dns record $record for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add dns domain record +# options: USER DOMAIN RECORD TYPE VALUE [PRIORITY] [ID] [RESTART] +# +# The call is used for adding new DNS record. Complex records of TXT, MX and +# SRV types can be used by a filling in the 'value' argument. The function also +# gets an id parameter for definition of certain record identifier or for the +# regulation of records. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +record=$(idn -t --quiet -u "$3" ) +record=$(echo "$record" | tr '[:upper:]' '[:lower:]') +rtype=$(echo "$4"| tr '[:lower:]' '[:upper:]') +dvalue=$(idn -t --quiet -u "$5" ) +dvalue=$(echo "$dvalue" | tr '[:upper:]' '[:lower:]') +priority=$6 +id=$7 +restart=$8 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '5' "$#" 'USER DOMAIN RECORD TYPE VALUE [PRIORITY] [ID] [RESTART]' +validate_format 'user' 'domain' 'record' 'rtype' 'dvalue' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" +is_object_unsuspended 'dns' 'DOMAIN' "$domain" +is_package_full 'DNS_RECORDS' +get_next_dnsrecord +validate_format 'id' +is_object_free "dns/$domain" 'ID' "$id" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +if [ "$rtype" != 'MX' ] && [ "$rtype" != 'SRV' ]; then + priority='' +fi + +# Adding record +zone="$USER_DATA/dns/$domain.conf" +dns_rec="ID='$id' RECORD='$record' TYPE='$rtype' PRIORITY='$priority'" +dns_rec="$dns_rec VALUE='$dvalue' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" +echo "$dns_rec" >> $zone +chmod 660 $zone + +# Sorting records +sort_dns_records + +# Updating zone +update_domain_zone + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Upddate counters +records="$(wc -l $USER_DATA/dns/$domain.conf | cut -f1 -d ' ')" +update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records" +increase_user_value "$user" '$U_DNS_RECORDS' + +# Restart named +if [ "$restart" != 'no' ]; then + $BIN/v-restart-dns "$EVENT" +fi + +# Logging +log_history "added $rtype dns record $record for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-dns-on-web-alias b/bin/v-add-dns-on-web-alias index dc00e3a82..a3383ee32 100755 --- a/bin/v-add-dns-on-web-alias +++ b/bin/v-add-dns-on-web-alias @@ -1,80 +1,80 @@ -#!/bin/bash -# info: add dns domain or dns record based on web domain alias restart -# options: user domain -# -# The function adds dns domain or dns record based on web domain alias. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g') -domain_idn=$(idn -t --quiet -a "$domain") -dom_alias=$(idn -t --quiet -u "$3" ) -dom_alias=$(echo $dom_alias | sed -e 's/\.*$//g' -e 's/^\.*//g') -dom_alias=$(echo $dom_alias | tr '[:upper:]' '[:lower:]') -dom_alias_idn=$(idn -t --quiet -a "$dom_alias" ) -restart="$4" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user domain alias' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain values -get_domain_values 'web' - -# Check if it a simple domain -if [ $(echo -e "${dom_alias//\./\n}" | wc -l) -le 2 ]; then - if [ ! -e "$USER_DATA/dns/$dom_alias.conf" ]; then - $BIN/v-add-dns-domain $user $dom_alias $IP '' '' '' '' '' $restart - fi -else - # Check subdomain - sub=$(echo "$dom_alias" | cut -f1 -d . -s) - dom=$(echo "$dom_alias" | sed -e "s/^$sub.//" ) - if [ ! -e "$USER_DATA/dns/$dom.conf" ]; then - $BIN/v-add-dns-domain $user $dom $IP '' '' '' '' '' $restart - $BIN/v-add-dns-domain-record $user $dom "$sub" A $IP '' '' $restart - else - if [ "$sub" == '*' ]; then - rec=$(grep -w "RECORD='\*'" $USER_DATA/dns/$dom.conf) - else - rec=$(grep -w "RECORD='$sub'" $USER_DATA/dns/$dom.conf) - fi - if [ -z "$rec" ]; then - $BIN/v-add-dns-domain-record $user $dom "$sub" A $IP '' '' $restart - fi - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# No Logging - -exit +#!/bin/bash +# info: add dns domain or dns record based on web domain alias restart +# options: USER DOMAIN +# +# The function adds dns domain or dns record based on web domain alias. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g') +domain_idn=$(idn -t --quiet -a "$domain") +dom_alias=$(idn -t --quiet -u "$3" ) +dom_alias=$(echo $dom_alias | sed -e 's/\.*$//g' -e 's/^\.*//g') +dom_alias=$(echo $dom_alias | tr '[:upper:]' '[:lower:]') +dom_alias_idn=$(idn -t --quiet -a "$dom_alias" ) +restart="$4" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN ALIAS' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Parsing domain values +get_domain_values 'web' + +# Check if it a simple domain +if [ $(echo -e "${dom_alias//\./\n}" | wc -l) -le 2 ]; then + if [ ! -e "$USER_DATA/dns/$dom_alias.conf" ]; then + $BIN/v-add-dns-domain $user $dom_alias $IP '' '' '' '' '' $restart + fi +else + # Check subdomain + sub=$(echo "$dom_alias" | cut -f1 -d . -s) + dom=$(echo "$dom_alias" | sed -e "s/^$sub.//" ) + if [ ! -e "$USER_DATA/dns/$dom.conf" ]; then + $BIN/v-add-dns-domain $user $dom $IP '' '' '' '' '' $restart + $BIN/v-add-dns-domain-record $user $dom "$sub" A $IP '' '' $restart + else + if [ "$sub" == '*' ]; then + rec=$(grep -w "RECORD='\*'" $USER_DATA/dns/$dom.conf) + else + rec=$(grep -w "RECORD='$sub'" $USER_DATA/dns/$dom.conf) + fi + if [ -z "$rec" ]; then + $BIN/v-add-dns-domain-record $user $dom "$sub" A $IP '' '' $restart + fi + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# No Logging + +exit diff --git a/bin/v-add-mail-account b/bin/v-add-mail-account index 8a16cbfe8..f3e6f921a 100755 --- a/bin/v-add-mail-account +++ b/bin/v-add-mail-account @@ -1,79 +1,79 @@ -#!/bin/bash -# info: add mail domain account -# options: user domain account password [quota] -# -# The function add new email account. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -account=$3 -password=$4 -quota=${5-0} - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - -# Hiding password -A4='******' -EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'" -EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'" - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'user domain account password [quota]' -validate_format 'user' 'domain' 'account' 'password' 'quota' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_package_full 'MAIL_ACCOUNTS' -is_mail_new "$account" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -if [ -x '/usr/bin/doveadm' ]; then - md5=$(/usr/bin/doveadm pw -s md5 -p "$password") -else - md5=$(/usr/sbin/dovecotpw -s md5 -p "$password") -fi - -str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota" -echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -str="ACCOUNT='$account' ALIAS='' QUOTA='$quota' AUTOREPLY='no' FWD=''" -str="$str MD5='$md5' U_DISK='0' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" -echo "$str" >> $USER_DATA/mail/$domain.conf -chmod 660 $USER_DATA/mail/$domain.conf - -# Increase mail accounts counter -accounts=$(wc -l $USER_DATA/mail/$domain.conf | cut -f 1 -d ' ') -increase_user_value "$user" '$U_MAIL_ACCOUNTS' -update_object_value 'mail' 'DOMAIN' "$domain" '$ACCOUNTS' "$accounts" - -# Logging -log_history "added mail account $account@$domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add mail domain account +# options: USER DOMAIN ACCOUNT PASSWORD [QUOTA] +# +# The function add new email account. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +account=$3 +password=$4 +quota=${5-0} + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + +# Hiding password +A4='******' +EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'" +EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'" + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '4' "$#" 'USER DOMAIN ACCOUNT PASSWORD [QUOTA]' +validate_format 'user' 'domain' 'account' 'password' 'quota' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_package_full 'MAIL_ACCOUNTS' +is_mail_new "$account" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +if [ -x '/usr/bin/doveadm' ]; then + md5=$(/usr/bin/doveadm pw -s md5 -p "$password") +else + md5=$(/usr/sbin/dovecotpw -s md5 -p "$password") +fi + +str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota" +echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +str="ACCOUNT='$account' ALIAS='' QUOTA='$quota' AUTOREPLY='no' FWD=''" +str="$str MD5='$md5' U_DISK='0' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" +echo "$str" >> $USER_DATA/mail/$domain.conf +chmod 660 $USER_DATA/mail/$domain.conf + +# Increase mail accounts counter +accounts=$(wc -l $USER_DATA/mail/$domain.conf | cut -f 1 -d ' ') +increase_user_value "$user" '$U_MAIL_ACCOUNTS' +update_object_value 'mail' 'DOMAIN' "$domain" '$ACCOUNTS' "$accounts" + +# Logging +log_history "added mail account $account@$domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-mail-account-alias b/bin/v-add-mail-account-alias index 86552441c..2e523f087 100755 --- a/bin/v-add-mail-account-alias +++ b/bin/v-add-mail-account-alias @@ -1,68 +1,68 @@ -#!/bin/bash -# info: add mail account alias aka nickname -# options: user domain account alias -# -# The function add new email alias. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -account=$3 -malias=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'user domain account alias' -validate_format 'user' 'domain' 'account' 'malias' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" -is_mail_new "$malias" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding exim alias -str="$malias@$domain:$account@$domain" -echo "$str" >> $HOMEDIR/$user/conf/mail/$domain/aliases - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding vesta alias -aliases=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS') -if [ -z "$aliases" ]; then - aliases="$malias" -else - aliases="$aliases,$malias" -fi -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS' "$aliases" - -# Logging -log_history "added alias $malias to $account@$domain " -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add mail account alias aka nickname +# options: USER DOMAIN ACCOUNT ALIAS +# +# The function add new email alias. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +account=$3 +malias=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '4' "$#" 'USER DOMAIN ACCOUNT ALIAS' +validate_format 'user' 'domain' 'account' 'malias' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_valid "mail/$domain" 'ACCOUNT' "$account" +is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" +is_mail_new "$malias" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Adding exim alias +str="$malias@$domain:$account@$domain" +echo "$str" >> $HOMEDIR/$user/conf/mail/$domain/aliases + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Adding vesta alias +aliases=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS') +if [ -z "$aliases" ]; then + aliases="$malias" +else + aliases="$aliases,$malias" +fi +update_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS' "$aliases" + +# Logging +log_history "added alias $malias to $account@$domain " +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-mail-account-autoreply b/bin/v-add-mail-account-autoreply index bd1f86f1c..79deeb276 100755 --- a/bin/v-add-mail-account-autoreply +++ b/bin/v-add-mail-account-autoreply @@ -1,64 +1,64 @@ -#!/bin/bash -# info: add mail account autoreply message -# options: user domain account message -# -# The function add new email account. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -account=$3 -autoreply=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'user domain account message' -validate_format 'user' 'domain' 'account' 'autoreply' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" -# is_object_value_empty "mail/$domain" 'ACCOUNT' "$account" '$AUTOREPLY' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# -# Add exim autoreply -echo -e "$autoreply" > $HOMEDIR/$user/conf/mail/$domain/autoreply.$account.msg -chown -R root:mail $HOMEDIR/$user/conf/mail/$domain/autoreply.$account.msg -chmod 660 $HOMEDIR/$user/conf/mail/$domain/autoreply.$account.msg - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding vesta alias -echo -e "$autoreply" > $USER_DATA/mail/$account@$domain.msg -chmod 660 $USER_DATA/mail/$account@$domain.msg -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$AUTOREPLY' 'yes' - -# Logging -log_history "added autoreply message on $account@$domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add mail account autoreply message +# options: USER DOMAIN ACCOUNT MESSAGE +# +# The function add new email account. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +account=$3 +autoreply=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '4' "$#" 'USER DOMAIN ACCOUNT MESSAGE' +validate_format 'user' 'domain' 'account' 'autoreply' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_valid "mail/$domain" 'ACCOUNT' "$account" +is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" +# is_object_value_empty "mail/$domain" 'ACCOUNT' "$account" '$AUTOREPLY' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# +# Add exim autoreply +echo -e "$autoreply" > $HOMEDIR/$user/conf/mail/$domain/autoreply.$account.msg +chown -R root:mail $HOMEDIR/$user/conf/mail/$domain/autoreply.$account.msg +chmod 660 $HOMEDIR/$user/conf/mail/$domain/autoreply.$account.msg + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Adding vesta alias +echo -e "$autoreply" > $USER_DATA/mail/$account@$domain.msg +chmod 660 $USER_DATA/mail/$account@$domain.msg +update_object_value "mail/$domain" 'ACCOUNT' "$account" '$AUTOREPLY' 'yes' + +# Logging +log_history "added autoreply message on $account@$domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-mail-account-forward b/bin/v-add-mail-account-forward index 6288098c8..979ccd557 100755 --- a/bin/v-add-mail-account-forward +++ b/bin/v-add-mail-account-forward @@ -1,73 +1,73 @@ -#!/bin/bash -# info: add mail account forward address -# options: user domain account forward -# -# The function add new email account. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -account=$3 -forward=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'user domain account forward' -validate_format 'user' 'domain' 'account' 'forward' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" -fwd=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD') -if [ ! -z "$(echo $fwd | grep -w $forward)" ]; then - echo "Error: forward $forward exists" - log_event "$E_EXISTS $EVENT" - exit $E_EXISTS -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding forward to exim -if [ -z "$fwd" ]; then - fwd="$forward" -else - fwd="$fwd,$forward" -fi - -sed -i "/^$account@$domain:/ d" $HOMEDIR/$user/conf/mail/$domain/aliases -echo "$account@$domain:$fwd" >> $HOMEDIR/$user/conf/mail/$domain/aliases - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating config -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD' "$fwd" - -# Logging -log_history "added forwarding from $account@$domain to $forward" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add mail account forward address +# options: USER DOMAIN ACCOUNT FORWARD +# +# The function add new email account. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +account=$3 +forward=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '4' "$#" 'USER DOMAIN ACCOUNT FORWARD' +validate_format 'user' 'domain' 'account' 'forward' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_valid "mail/$domain" 'ACCOUNT' "$account" +is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" +fwd=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD') +if [ ! -z "$(echo $fwd | grep -w $forward)" ]; then + echo "Error: forward $forward exists" + log_event "$E_EXISTS $EVENT" + exit $E_EXISTS +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Adding forward to exim +if [ -z "$fwd" ]; then + fwd="$forward" +else + fwd="$fwd,$forward" +fi + +sed -i "/^$account@$domain:/ d" $HOMEDIR/$user/conf/mail/$domain/aliases +echo "$account@$domain:$fwd" >> $HOMEDIR/$user/conf/mail/$domain/aliases + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Updating config +update_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD' "$fwd" + +# Logging +log_history "added forwarding from $account@$domain to $forward" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-mail-domain b/bin/v-add-mail-domain index b8f5666d6..8f72c2a17 100755 --- a/bin/v-add-mail-domain +++ b/bin/v-add-mail-domain @@ -1,121 +1,121 @@ -#!/bin/bash -# info: add mail domain -# options: user domain [antispam] [antivirus] [dkim] [dkim_size] -# -# The function adds MAIL domain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g') -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -antispam=${3-yes} -antivirus=${4-yes} -dkim=${5-yes} -dkim_size=${6-512} - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain [antispam] [antivirus] [dkim] [dkim_size]' -validate_format 'user' 'domain' 'antispam' 'antivirus' 'dkim' 'dkim_size' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_domain_new 'mail' -is_package_full 'MAIL_DOMAINS' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding domain directory -mkdir $HOMEDIR/$user/conf/mail/$domain -touch $HOMEDIR/$user/conf/mail/$domain/aliases -touch $HOMEDIR/$user/conf/mail/$domain/protection -touch $HOMEDIR/$user/conf/mail/$domain/passwd -chown -R dovecot:mail $HOMEDIR/$user/conf/mail/$domain -chmod 770 $HOMEDIR/$user/conf/mail/$domain -chmod 660 $HOMEDIR/$user/conf/mail/$domain/* -mkdir $HOMEDIR/$user/mail/$domain -chown $user:mail $HOMEDIR/$user/mail/$domain -chmod 770 $HOMEDIR/$user/mail/$domain - -# Adding symlink -ln -s $HOMEDIR/$user/conf/mail/$domain /etc/exim/domains/ - -# Adding antispam protection -if [ "$antispam" = 'yes' ]; then - echo 'antispam' >> $HOMEDIR/$user/conf/mail/$domain/protection -fi - -# Adding antivirus protection -if [ "$antivirus" = 'yes' ]; then - echo 'antivirus' >> $HOMEDIR/$user/conf/mail/$domain/protection -fi - -# Adding dkim -if [ "$dkim" = 'yes' ]; then - openssl genrsa -out $USER_DATA/mail/$domain.pem $dkim_size &>/dev/null - openssl rsa -pubout -in $USER_DATA/mail/$domain.pem \ - -out $USER_DATA/mail/$domain.pub &>/dev/null - chmod 660 $USER_DATA/mail/$domain.* - - cp $USER_DATA/mail/$domain.pem $HOMEDIR/$user/conf/mail/$domain/dkim.pem - chown root:mail $HOMEDIR/$user/conf/mail/$domain/dkim.pem - chmod 660 $HOMEDIR/$user/conf/mail/$domain/dkim.pem - - # Adding dkim dns records - check_dns_domain=$(is_object_valid 'dns' 'DOMAIN' "$domain") - if [ "$?" -eq 0 ]; then - p=$(cat $USER_DATA/mail/$domain.pub|grep -v ' KEY---'|tr -d '\n') - record='_domainkey' - policy="\"t=y; o=~;\"" - $BIN/v-add-dns-domain-record $user $domain $record TXT "$policy" - - record='mail._domainkey' - selector="\"k=rsa\; p=$p\"" - $BIN/v-add-dns-domain-record $user $domain $record TXT "$selector" - fi -fi - -# Adding domain to vesta db -s="DOMAIN='$domain' ANTIVIRUS='$antivirus' ANTISPAM='$antispam' DKIM='$dkim'" -s="$s ACCOUNTS='0' U_DISK='0' CATCHALL='' SUSPENDED='no' TIME='$TIME'" -s="$s DATE='$DATE'" - -echo $s >> $USER_DATA/mail.conf -touch $USER_DATA/mail/$domain.conf -chmod 660 $USER_DATA/mail.conf -chmod 660 $USER_DATA/mail/$domain.conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Increasing domain value -increase_user_value "$user" '$U_MAIL_DOMAINS' -if [ "$dkim" = 'yes' ]; then - increase_user_value "$user" '$U_MAIL_DKMI' -fi - -# Logging -log_history "added mail domain $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add mail domain +# options: USER DOMAIN [ANTISPAM] [ANTIVIRUS] [DKIM] [DKIM_SIZE] +# +# The function adds MAIL domain. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g') +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +antispam=${3-yes} +antivirus=${4-yes} +dkim=${5-yes} +dkim_size=${6-512} + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [ANTISPAM] [ANTIVIRUS] [DKIM] [DKIM_SIZE]' +validate_format 'user' 'domain' 'antispam' 'antivirus' 'dkim' 'dkim_size' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_domain_new 'mail' +is_package_full 'MAIL_DOMAINS' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Adding domain directory +mkdir $HOMEDIR/$user/conf/mail/$domain +touch $HOMEDIR/$user/conf/mail/$domain/aliases +touch $HOMEDIR/$user/conf/mail/$domain/protection +touch $HOMEDIR/$user/conf/mail/$domain/passwd +chown -R dovecot:mail $HOMEDIR/$user/conf/mail/$domain +chmod 770 $HOMEDIR/$user/conf/mail/$domain +chmod 660 $HOMEDIR/$user/conf/mail/$domain/* +mkdir $HOMEDIR/$user/mail/$domain +chown $user:mail $HOMEDIR/$user/mail/$domain +chmod 770 $HOMEDIR/$user/mail/$domain + +# Adding symlink +ln -s $HOMEDIR/$user/conf/mail/$domain /etc/exim/domains/ + +# Adding antispam protection +if [ "$antispam" = 'yes' ]; then + echo 'antispam' >> $HOMEDIR/$user/conf/mail/$domain/protection +fi + +# Adding antivirus protection +if [ "$antivirus" = 'yes' ]; then + echo 'antivirus' >> $HOMEDIR/$user/conf/mail/$domain/protection +fi + +# Adding dkim +if [ "$dkim" = 'yes' ]; then + openssl genrsa -out $USER_DATA/mail/$domain.pem $dkim_size &>/dev/null + openssl rsa -pubout -in $USER_DATA/mail/$domain.pem \ + -out $USER_DATA/mail/$domain.pub &>/dev/null + chmod 660 $USER_DATA/mail/$domain.* + + cp $USER_DATA/mail/$domain.pem $HOMEDIR/$user/conf/mail/$domain/dkim.pem + chown root:mail $HOMEDIR/$user/conf/mail/$domain/dkim.pem + chmod 660 $HOMEDIR/$user/conf/mail/$domain/dkim.pem + + # Adding dkim dns records + check_dns_domain=$(is_object_valid 'dns' 'DOMAIN' "$domain") + if [ "$?" -eq 0 ]; then + p=$(cat $USER_DATA/mail/$domain.pub|grep -v ' KEY---'|tr -d '\n') + record='_domainkey' + policy="\"t=y; o=~;\"" + $BIN/v-add-dns-domain-record $user $domain $record TXT "$policy" + + record='mail._domainkey' + selector="\"k=rsa\; p=$p\"" + $BIN/v-add-dns-domain-record $user $domain $record TXT "$selector" + fi +fi + +# Adding domain to vesta db +s="DOMAIN='$domain' ANTIVIRUS='$antivirus' ANTISPAM='$antispam' DKIM='$dkim'" +s="$s ACCOUNTS='0' U_DISK='0' CATCHALL='' SUSPENDED='no' TIME='$TIME'" +s="$s DATE='$DATE'" + +echo $s >> $USER_DATA/mail.conf +touch $USER_DATA/mail/$domain.conf +chmod 660 $USER_DATA/mail.conf +chmod 660 $USER_DATA/mail/$domain.conf + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Increasing domain value +increase_user_value "$user" '$U_MAIL_DOMAINS' +if [ "$dkim" = 'yes' ]; then + increase_user_value "$user" '$U_MAIL_DKMI' +fi + +# Logging +log_history "added mail domain $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-mail-domain-antispam b/bin/v-add-mail-domain-antispam index 58585fc66..6ee6c82bc 100755 --- a/bin/v-add-mail-domain-antispam +++ b/bin/v-add-mail-domain-antispam @@ -1,58 +1,58 @@ -#!/bin/bash -# info: add mail domain antispam support -# options: user domain -# -# The function enables spamassasin for incomming emails. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain' -validate_format 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_value_empty 'mail' 'DOMAIN' "$domain" '$ANTISPAM' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding antispam key to config -if [ -z "$(grep spam $HOMEDIR/$user/conf/mail/$domain/protection)" ]; then - echo 'antispam' >> $HOMEDIR/$user/conf/mail/$domain/protection -fi - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding antispam in config -update_object_value 'mail' 'DOMAIN' "$domain" '$ANTISPAM' 'yes' - -# Logging -log_history "enabled antispam on $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add mail domain antispam support +# options: USER DOMAIN +# +# The function enables spamassasin for incomming emails. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_value_empty 'mail' 'DOMAIN' "$domain" '$ANTISPAM' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Adding antispam key to config +if [ -z "$(grep spam $HOMEDIR/$user/conf/mail/$domain/protection)" ]; then + echo 'antispam' >> $HOMEDIR/$user/conf/mail/$domain/protection +fi + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Adding antispam in config +update_object_value 'mail' 'DOMAIN' "$domain" '$ANTISPAM' 'yes' + +# Logging +log_history "enabled antispam on $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-mail-domain-antivirus b/bin/v-add-mail-domain-antivirus index d2f689b9a..6e609010d 100755 --- a/bin/v-add-mail-domain-antivirus +++ b/bin/v-add-mail-domain-antivirus @@ -1,59 +1,59 @@ -#!/bin/bash -# info: add mail domain antivirus support -# options: user domain -# -# The function enables clamav scan for incomming emails. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain' -validate_format 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_value_empty 'mail' 'DOMAIN' "$domain" '$ANTIVIRUS' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding antivirus key to config -if [ -z "$(grep 'virus' $HOMEDIR/$user/conf/mail/$domain/protection)" ]; then - echo 'antivirus' >> $HOMEDIR/$user/conf/mail/$domain/protection -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding antivirus in config -update_object_value 'mail' 'DOMAIN' "$domain" '$ANTIVIRUS' 'yes' - -# Logging -log_history "enabled antivirus on $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add mail domain antivirus support +# options: USER DOMAIN +# +# The function enables clamav scan for incomming emails. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_value_empty 'mail' 'DOMAIN' "$domain" '$ANTIVIRUS' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Adding antivirus key to config +if [ -z "$(grep 'virus' $HOMEDIR/$user/conf/mail/$domain/protection)" ]; then + echo 'antivirus' >> $HOMEDIR/$user/conf/mail/$domain/protection +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Adding antivirus in config +update_object_value 'mail' 'DOMAIN' "$domain" '$ANTIVIRUS' 'yes' + +# Logging +log_history "enabled antivirus on $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-mail-domain-catchall b/bin/v-add-mail-domain-catchall index ddea0d88c..e698f01bf 100755 --- a/bin/v-add-mail-domain-catchall +++ b/bin/v-add-mail-domain-catchall @@ -1,60 +1,60 @@ -#!/bin/bash -# info: add mail domain catchall account -# options: user domain email -# -# The function enables catchall account for incomming emails. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -email="$3" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user domain email' -validate_format 'user' 'domain' 'email' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_value_empty 'mail' 'DOMAIN' "$domain" '$CATCHALL' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding catchall alias -sed -i "/*@$domain:/d" $HOMEDIR/$user/conf/mail/$domain/aliases -echo "*@$domain:$email" >> $HOMEDIR/$user/conf/mail/$domain/aliases - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding antispam in config -update_object_value 'mail' 'DOMAIN' "$domain" '$CATCHALL' "$email" - - -# Logging -log_history "added $email as catchall email for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add mail domain catchall account +# options: USER DOMAIN EMAIL +# +# The function enables catchall account for incomming emails. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +email="$3" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN EMAIL' +validate_format 'user' 'domain' 'email' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_value_empty 'mail' 'DOMAIN' "$domain" '$CATCHALL' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Adding catchall alias +sed -i "/*@$domain:/d" $HOMEDIR/$user/conf/mail/$domain/aliases +echo "*@$domain:$email" >> $HOMEDIR/$user/conf/mail/$domain/aliases + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Adding antispam in config +update_object_value 'mail' 'DOMAIN' "$domain" '$CATCHALL' "$email" + + +# Logging +log_history "added $email as catchall email for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-mail-domain-dkim b/bin/v-add-mail-domain-dkim index e5be80f01..74a0d4b19 100755 --- a/bin/v-add-mail-domain-dkim +++ b/bin/v-add-mail-domain-dkim @@ -1,81 +1,81 @@ -#!/bin/bash -# info: add mail domain dkim support -# options: user domain [dkim_size] -# -# The function adds DKIM signature to outgoing domain emails. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -dkim_size=${3-512} - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain [dkim_size]' -validate_format 'user' 'domain' 'dkim_size' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_value_empty 'mail' 'DOMAIN' "$domain" '$DKIM' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Generating dkim -openssl genrsa -out $USER_DATA/mail/$domain.pem $dkim_size &>/dev/null -openssl rsa -pubout -in $USER_DATA/mail/$domain.pem \ - -out $USER_DATA/mail/$domain.pub &>/dev/null -chmod 660 $USER_DATA/mail/$domain.* - -# Adding dkim to config -cp $USER_DATA/mail/$domain.pem $HOMEDIR/$user/conf/mail/$domain/dkim.pem -chown root:mail $HOMEDIR/$user/conf/mail/$domain/dkim.pem -chmod 660 $HOMEDIR/$user/conf/mail/$domain/dkim.pem - -# Checking dns domain -check_dns_domain=$(is_object_valid 'dns' 'DOMAIN' "$domain") -if [ "$?" -eq 0 ]; then - # Adding dkim dns records - p=$(cat $USER_DATA/mail/$domain.pub|grep -v ' KEY---'|tr -d '\n') - record='_domainkey' - policy="\"t=y; o=~;\"" - $BIN/v-add-dns-domain-record $user $domain $record TXT "$policy" - - record='mail._domainkey' - selector="\"k=rsa\; p=$p\"" - $BIN/v-add-dns-domain-record $user $domain $record TXT "$selector" -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding dkim in config -update_object_value 'mail' 'DOMAIN' "$domain" '$DKIM' 'yes' -increase_user_value "$user" '$U_MAIL_DKMI' - -# Logging -log_history "enabled DKIM support for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add mail domain dkim support +# options: USER DOMAIN [DKIM_SIZE] +# +# The function adds DKIM signature to outgoing domain emails. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +dkim_size=${3-512} + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [DKIM_SIZE]' +validate_format 'user' 'domain' 'dkim_size' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_value_empty 'mail' 'DOMAIN' "$domain" '$DKIM' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Generating dkim +openssl genrsa -out $USER_DATA/mail/$domain.pem $dkim_size &>/dev/null +openssl rsa -pubout -in $USER_DATA/mail/$domain.pem \ + -out $USER_DATA/mail/$domain.pub &>/dev/null +chmod 660 $USER_DATA/mail/$domain.* + +# Adding dkim to config +cp $USER_DATA/mail/$domain.pem $HOMEDIR/$user/conf/mail/$domain/dkim.pem +chown root:mail $HOMEDIR/$user/conf/mail/$domain/dkim.pem +chmod 660 $HOMEDIR/$user/conf/mail/$domain/dkim.pem + +# Checking dns domain +check_dns_domain=$(is_object_valid 'dns' 'DOMAIN' "$domain") +if [ "$?" -eq 0 ]; then + # Adding dkim dns records + p=$(cat $USER_DATA/mail/$domain.pub|grep -v ' KEY---'|tr -d '\n') + record='_domainkey' + policy="\"t=y; o=~;\"" + $BIN/v-add-dns-domain-record $user $domain $record TXT "$policy" + + record='mail._domainkey' + selector="\"k=rsa\; p=$p\"" + $BIN/v-add-dns-domain-record $user $domain $record TXT "$selector" +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Adding dkim in config +update_object_value 'mail' 'DOMAIN' "$domain" '$DKIM' 'yes' +increase_user_value "$user" '$U_MAIL_DKMI' + +# Logging +log_history "enabled DKIM support for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-sys-ip b/bin/v-add-sys-ip index 2e8b3c3c3..808acf86a 100755 --- a/bin/v-add-sys-ip +++ b/bin/v-add-sys-ip @@ -1,100 +1,100 @@ -#!/bin/bash -# info: add system ip address -# options: ip mask [interface] [user] [ip_status] [ip_name] -# -# The function adds ip address into a system. It also creates rc scripts. You -# can specify ip name which will be used as root domain for temporary aliases. -# For example, if you set a1.myhosting.com as name, each new domain created on -# this ip will automaticaly receive alias $domain.a1.myhosting.com. Of course -# you must have wildcard record *.a1.myhosting.com pointed to ip. This feature -# is very handy when customer wants to test domain before dns migration. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -ip=${1// /} -mask=$2 -interface="${3-eth0}" -user="${4-admin}" -ip_status="${5-shared}" # can be dedicated as well -ip_name=$6 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/ip.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'ip mask [interface] [user] [ip_status] [ip_name]' -validate_format 'ip' 'mask' 'interface' 'user' 'ip_status' -is_ip_free -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -if [ ! -z "$ip_name" ] ; then - validate_format 'ip_name' -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get full interface name -get_ip_iface - -# Defining config paths -conf='/etc/httpd/conf.d/vesta.conf' -nconf='/etc/nginx/conf.d/vesta_ip.conf' -iconf='/etc/sysconfig/network-scripts/ifcfg' -rconf='/etc/httpd/conf.d/mod_extract_forwarded.conf' - -# Adding ip -/sbin/ifconfig "$iface" "$ip" netmask "$mask" - -# Adding startup script -create_ip_startup - -# Adding vesta ip -create_vesta_ip - -# Namehosting support -namehost_ip_support - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating user counters -increase_user_value "$user" '$IP_OWNED' -if [ "$user" = 'admin' ]; then - if [ "$ip_status" = 'shared' ]; then - for user in $(ls $VESTA/data/users); do - increase_user_value "$user" '$IP_AVAIL' - done - else - increase_user_value 'admin' '$IP_AVAIL' - fi -else - increase_user_value "$user" '$IP_AVAIL' - increase_user_value 'admin' '$IP_AVAIL' -fi - -# Restart web server -if [ "$web_restart" = 'yes' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_history "added system ip address $ip" '' 'admin' -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add system ip address +# options: IP MASK [INTERFACE] [USER] [IP_STATUS] [IP_NAME] +# +# The function adds ip address into a system. It also creates rc scripts. You +# can specify ip name which will be used as root domain for temporary aliases. +# For example, if you set a1.myhosting.com as name, each new domain created on +# this ip will automaticaly receive alias $domain.a1.myhosting.com. Of course +# you must have wildcard record *.a1.myhosting.com pointed to ip. This feature +# is very handy when customer wants to test domain before dns migration. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +ip=${1// /} +mask=$2 +interface="${3-eth0}" +user="${4-admin}" +ip_status="${5-shared}" # can be dedicated as well +ip_name=$6 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/ip.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'IP MASK [INTERFACE] [USER] [IP_STATUS] [IP_NAME]' +validate_format 'ip' 'mask' 'interface' 'user' 'ip_status' +is_ip_free +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +if [ ! -z "$ip_name" ] ; then + validate_format 'ip_name' +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Get full interface name +get_ip_iface + +# Defining config paths +conf='/etc/httpd/conf.d/vesta.conf' +nconf='/etc/nginx/conf.d/vesta_ip.conf' +iconf='/etc/sysconfig/network-scripts/ifcfg' +rconf='/etc/httpd/conf.d/mod_extract_forwarded.conf' + +# Adding ip +/sbin/ifconfig "$iface" "$ip" netmask "$mask" + +# Adding startup script +create_ip_startup + +# Adding vesta ip +create_vesta_ip + +# Namehosting support +namehost_ip_support + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Updating user counters +increase_user_value "$user" '$IP_OWNED' +if [ "$user" = 'admin' ]; then + if [ "$ip_status" = 'shared' ]; then + for user in $(ls $VESTA/data/users); do + increase_user_value "$user" '$IP_AVAIL' + done + else + increase_user_value 'admin' '$IP_AVAIL' + fi +else + increase_user_value "$user" '$IP_AVAIL' + increase_user_value 'admin' '$IP_AVAIL' +fi + +# Restart web server +if [ "$web_restart" = 'yes' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_history "added system ip address $ip" '' 'admin' +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-user b/bin/v-add-user index 31f792840..d88565c79 100755 --- a/bin/v-add-user +++ b/bin/v-add-user @@ -1,218 +1,218 @@ -#!/bin/bash -# info: add system user -# options: user password email [package] [fname] [lname] -# -# The function creates new user account. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -password=$2 -email=$3 -package=${4-default} -fname=$5 -lname=$6 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - -# Hiding password -A2='******' -EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'" -EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'" - -is_user_free() { - check_sysuser=$(cut -f 1 -d : /etc/passwd | grep -w "$user" ) - if [ ! -z "$check_sysuser" ] || [ -e "$USER_DATA" ]; then - echo "Error: user $user exist" - log_event "$E_EXISTS" "$EVENT" - exit $E_EXISTS - fi -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user password email [package] [fname] [lname]' -validate_format 'user' 'password' 'email' 'package' -if [ ! -z "$fname" ]; then - validate_format 'fname' 'lname' -fi - -is_user_free "$user" -is_package_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing package data -pkg_data=$(cat $VESTA/data/packages/$package.pkg |grep -v TIME |grep -v DATE) - -# Checking shell -shell_conf=$(echo "$pkg_data" | grep 'SHELL' | cut -f 2 -d \') -shell=$(/usr/bin/chsh --list-shells | grep -w "$shell_conf" |head -n1) - -# Adding user -/usr/sbin/adduser "$user" -s "$shell" -c "$email" -m -d "$HOMEDIR/$user" - -# Adding password -echo "$password" | /usr/bin/passwd "$user" --stdin &>/dev/null - -# Building directory tree -mkdir $HOMEDIR/$user/conf - -if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then - mkdir $HOMEDIR/$user/conf/web - mkdir $HOMEDIR/$user/web - mkdir $HOMEDIR/$user/tmp - chmod 751 $HOMEDIR/$user/conf/web - chmod 751 $HOMEDIR/$user/web - chmod 771 $HOMEDIR/$user/tmp - chown $user:$user $HOMEDIR/$user/web - chown $user:$user $HOMEDIR/$user/tmp -fi - -if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then - mkdir $HOMEDIR/$user/conf/mail - mkdir $HOMEDIR/$user/mail - chmod 751 $HOMEDIR/$user/mail - chmod 751 $HOMEDIR/$user/conf/mail -fi - -if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then - mkdir $HOMEDIR/$user/conf/dns - chmod 751 $HOMEDIR/$user/conf/dns -fi - - -# Set permissions -chmod a+x $HOMEDIR/$user - -# Checking quota -if [ ! -z "$DISK_QUOTA" ] && [ "$DISK_QUOTA" != 'no' ]; then - DISK_QUOTA=$(echo "$pkg_data" | grep 'DISK_QUOTA' | cut -f 2 -d \') - #$BIN/v-add-user_quota "$user" "$DISK_QUOTA" -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding user dir -mkdir $USER_DATA -chmod 770 $USER_DATA - -# Creating configuration files and pipes -touch $USER_DATA/backup.conf -chmod 660 $USER_DATA/backup.conf -touch $USER_DATA/history.log -chmod 660 $USER_DATA/history.log -touch $USER_DATA/stats.log -chmod 660 $USER_DATA/stats.log - -echo "v-update-user-disk $user" >> $VESTA/data/queue/disk.pipe - -if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then - mkdir $USER_DATA/ssl - chmod 770 $USER_DATA/ssl - touch $USER_DATA/web.conf - chmod 660 $USER_DATA/web.conf - echo "$BIN/v-update-web-domains-traff $user" \ - >> $VESTA/data/queue/traffic.pipe - echo "v-update-web-domains-disk $user" >> $VESTA/data/queue/disk.pipe -fi - -if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then - mkdir $USER_DATA/dns - chmod 770 $USER_DATA/dns - touch $USER_DATA/dns.conf - chmod 660 $USER_DATA/dns.conf -fi - -if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then - mkdir $USER_DATA/mail - chmod 770 $USER_DATA/mail - touch $USER_DATA/mail.conf - chmod 660 $USER_DATA/mail.conf - echo "v-update-mail-domains-disk $user" >> $VESTA/data/queue/disk.pipe -fi - -if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then - touch $USER_DATA/db.conf - chmod 660 $USER_DATA/db.conf - echo "v-update-databases-disk $user" >> $VESTA/data/queue/disk.pipe -fi - -if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then - touch $USER_DATA/cron.conf - chmod 660 $USER_DATA/cron.conf -fi - -# Filling user config -if [ "$user" != 'admin' ]; then - ip_avail=$($BIN/v-list-user-ips admin plain |grep -w shared|wc -l) - u_users=0 -else - ip_avail=0 - u_users=1 -fi - -echo "FNAME='$fname' -LNAME='$lname' -PACKAGE='$package' -$pkg_data -CONTACT='$email' -CRON_REPORTS='yes' -MD5='$(awk -v user=$user -F : 'user == $1 {print $2}' /etc/shadow)' -RKEY='$(gen_password)' -SUSPENDED='no' -SUSPENDED_USERS='0' -SUSPENDED_WEB='0' -SUSPENDED_DNS='0' -SUSPENDED_MAIL='0' -SUSPENDED_DB='0' -SUSPENDED_CRON='0' -IP_AVAIL='$ip_avail' -IP_OWNED='0' -U_USERS='$u_users' -U_DISK='0' -U_DISK_DIRS='0' -U_DISK_WEB='0' -U_DISK_MAIL='0' -U_DISK_DB='0' -U_BANDWIDTH='0' -U_WEB_DOMAINS='0' -U_WEB_SSL='0' -U_WEB_ALIASES='0' -U_DNS_DOMAINS='0' -U_DNS_RECORDS='0' -U_MAIL_DOMAINS='0' -U_MAIL_DKIM='0' -U_MAIL_ACCOUNTS='0' -U_DATABASES='0' -U_CRON_JOBS='0' -U_BACKUPS='0' -TIME='$TIME' -DATE='$DATE'" > $USER_DATA/user.conf -chmod 660 $USER_DATA/user.conf - -# Updating admin counter -if [ "$user" != 'admin' ]; then - increase_user_value 'admin' '$U_USERS' -fi - -# Logging -log_history "added system user $user" '' 'admin' -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add system user +# options: USER PASSWORD EMAIL [PACKAGE] [FNAME] [LNAME] +# +# The function creates new user account. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +password=$2 +email=$3 +package=${4-default} +fname=$5 +lname=$6 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + +# Hiding password +A2='******' +EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'" +EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'" + +is_user_free() { + check_sysuser=$(cut -f 1 -d : /etc/passwd | grep -w "$user" ) + if [ ! -z "$check_sysuser" ] || [ -e "$USER_DATA" ]; then + echo "Error: user $user exist" + log_event "$E_EXISTS" "$EVENT" + exit $E_EXISTS + fi +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER PASSWORD EMAIL [PACKAGE] [FNAME] [LNAME]' +validate_format 'user' 'password' 'email' 'package' +if [ ! -z "$fname" ]; then + validate_format 'fname' 'lname' +fi + +is_user_free "$user" +is_package_valid + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Parsing package data +pkg_data=$(cat $VESTA/data/packages/$package.pkg |grep -v TIME |grep -v DATE) + +# Checking shell +shell_conf=$(echo "$pkg_data" | grep 'SHELL' | cut -f 2 -d \') +shell=$(/usr/bin/chsh --list-shells | grep -w "$shell_conf" |head -n1) + +# Adding user +/usr/sbin/adduser "$user" -s "$shell" -c "$email" -m -d "$HOMEDIR/$user" + +# Adding password +echo "$password" | /usr/bin/passwd "$user" --stdin &>/dev/null + +# Building directory tree +mkdir $HOMEDIR/$user/conf + +if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then + mkdir $HOMEDIR/$user/conf/web + mkdir $HOMEDIR/$user/web + mkdir $HOMEDIR/$user/tmp + chmod 751 $HOMEDIR/$user/conf/web + chmod 751 $HOMEDIR/$user/web + chmod 771 $HOMEDIR/$user/tmp + chown $user:$user $HOMEDIR/$user/web + chown $user:$user $HOMEDIR/$user/tmp +fi + +if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then + mkdir $HOMEDIR/$user/conf/mail + mkdir $HOMEDIR/$user/mail + chmod 751 $HOMEDIR/$user/mail + chmod 751 $HOMEDIR/$user/conf/mail +fi + +if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then + mkdir $HOMEDIR/$user/conf/dns + chmod 751 $HOMEDIR/$user/conf/dns +fi + + +# Set permissions +chmod a+x $HOMEDIR/$user + +# Checking quota +if [ ! -z "$DISK_QUOTA" ] && [ "$DISK_QUOTA" != 'no' ]; then + DISK_QUOTA=$(echo "$pkg_data" | grep 'DISK_QUOTA' | cut -f 2 -d \') + #$BIN/v-add-user_quota "$user" "$DISK_QUOTA" +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Adding user dir +mkdir $USER_DATA +chmod 770 $USER_DATA + +# Creating configuration files and pipes +touch $USER_DATA/backup.conf +chmod 660 $USER_DATA/backup.conf +touch $USER_DATA/history.log +chmod 660 $USER_DATA/history.log +touch $USER_DATA/stats.log +chmod 660 $USER_DATA/stats.log + +echo "v-update-user-disk $user" >> $VESTA/data/queue/disk.pipe + +if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then + mkdir $USER_DATA/ssl + chmod 770 $USER_DATA/ssl + touch $USER_DATA/web.conf + chmod 660 $USER_DATA/web.conf + echo "$BIN/v-update-web-domains-traff $user" \ + >> $VESTA/data/queue/traffic.pipe + echo "v-update-web-domains-disk $user" >> $VESTA/data/queue/disk.pipe +fi + +if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then + mkdir $USER_DATA/dns + chmod 770 $USER_DATA/dns + touch $USER_DATA/dns.conf + chmod 660 $USER_DATA/dns.conf +fi + +if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then + mkdir $USER_DATA/mail + chmod 770 $USER_DATA/mail + touch $USER_DATA/mail.conf + chmod 660 $USER_DATA/mail.conf + echo "v-update-mail-domains-disk $user" >> $VESTA/data/queue/disk.pipe +fi + +if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then + touch $USER_DATA/db.conf + chmod 660 $USER_DATA/db.conf + echo "v-update-databases-disk $user" >> $VESTA/data/queue/disk.pipe +fi + +if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then + touch $USER_DATA/cron.conf + chmod 660 $USER_DATA/cron.conf +fi + +# Filling user config +if [ "$user" != 'admin' ]; then + ip_avail=$($BIN/v-list-user-ips admin plain |grep -w shared|wc -l) + u_users=0 +else + ip_avail=0 + u_users=1 +fi + +echo "FNAME='$fname' +LNAME='$lname' +PACKAGE='$package' +$pkg_data +CONTACT='$email' +CRON_REPORTS='yes' +MD5='$(awk -v user=$user -F : 'user == $1 {print $2}' /etc/shadow)' +RKEY='$(gen_password)' +SUSPENDED='no' +SUSPENDED_USERS='0' +SUSPENDED_WEB='0' +SUSPENDED_DNS='0' +SUSPENDED_MAIL='0' +SUSPENDED_DB='0' +SUSPENDED_CRON='0' +IP_AVAIL='$ip_avail' +IP_OWNED='0' +U_USERS='$u_users' +U_DISK='0' +U_DISK_DIRS='0' +U_DISK_WEB='0' +U_DISK_MAIL='0' +U_DISK_DB='0' +U_BANDWIDTH='0' +U_WEB_DOMAINS='0' +U_WEB_SSL='0' +U_WEB_ALIASES='0' +U_DNS_DOMAINS='0' +U_DNS_RECORDS='0' +U_MAIL_DOMAINS='0' +U_MAIL_DKIM='0' +U_MAIL_ACCOUNTS='0' +U_DATABASES='0' +U_CRON_JOBS='0' +U_BACKUPS='0' +TIME='$TIME' +DATE='$DATE'" > $USER_DATA/user.conf +chmod 660 $USER_DATA/user.conf + +# Updating admin counter +if [ "$user" != 'admin' ]; then + increase_user_value 'admin' '$U_USERS' +fi + +# Logging +log_history "added system user $user" '' 'admin' +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-user-backup b/bin/v-add-user-backup index 9a3889264..f76894ec6 100755 --- a/bin/v-add-user-backup +++ b/bin/v-add-user-backup @@ -1,46 +1,46 @@ -#!/bin/bash -# info: schedule user backup creation -# options: user -# -# The function for scheduling user backup creation. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user' -validate_format 'user' -is_system_enabled "$BACKUP_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_backup_enabled - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding backup to pipe -echo "$user" >> $VESTA/data/queue/backup.pipe - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: schedule user backup creation +# options: USER +# +# The function for scheduling user backup creation. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_system_enabled "$BACKUP_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_backup_enabled + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Adding backup to pipe +echo "$user" >> $VESTA/data/queue/backup.pipe + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-user-package b/bin/v-add-user-package index 8d3d8626e..d75c886a1 100755 --- a/bin/v-add-user-package +++ b/bin/v-add-user-package @@ -1,79 +1,79 @@ -#!/bin/bash -# info: adding user package -# options: pkg_dir package [rewrite] -# -# The function adds new user package to the system. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -pkg_dir=$1 -package=$2 -rewrite=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - -# Functions -is_package_new() { - if [ -e "$VESTA/data/packages/$package.pkg" ]; then - echo "Error: package $package already exists." - log_event "$E_EXISTS" "$EVENT" - exit $E_EXISTS - fi -} - -is_package_consistent() { - source $pkg_dir/$package.pkg - validate_format_int $WEB_DOMAINS - validate_format_int $WEB_ALIASES - validate_format_int $DNS_DOMAINS - validate_format_int $DNS_RECORDS - validate_format_int $MAIL_DOMAINS - validate_format_int $MAIL_ACCOUNTS - validate_format_int $DATABASES - validate_format_int $CRON_JOBS - validate_format_int $DISK_QUOTA - validate_format_int $BACKUPS - validate_format_shell $SHELL -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'pkg_dir package' 'rewrite' -validate_format 'pkg_dir' 'package' -if [ "$rewrite" != 'yes' ]; then - is_package_new -fi -is_package_valid "$pkg_dir" -is_package_consistent - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -cp -f $pkg_dir/$package.pkg $VESTA/data/packages/ -chmod 644 $VESTA/data/packages/$package.pkg - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -if [ "$rewrite" != 'yes' ]; then - log_history "added user package $package" '' 'admin' -else - log_history "updated user package $package" '' 'admin' -fi -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: adding user package +# options: PKG_DIR PACKAGE [REWRITE] +# +# The function adds new user package to the system. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +pkg_dir=$1 +package=$2 +rewrite=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + +# Functions +is_package_new() { + if [ -e "$VESTA/data/packages/$package.pkg" ]; then + echo "Error: package $package already exists." + log_event "$E_EXISTS" "$EVENT" + exit $E_EXISTS + fi +} + +is_package_consistent() { + source $pkg_dir/$package.pkg + validate_format_int $WEB_DOMAINS + validate_format_int $WEB_ALIASES + validate_format_int $DNS_DOMAINS + validate_format_int $DNS_RECORDS + validate_format_int $MAIL_DOMAINS + validate_format_int $MAIL_ACCOUNTS + validate_format_int $DATABASES + validate_format_int $CRON_JOBS + validate_format_int $DISK_QUOTA + validate_format_int $BACKUPS + validate_format_shell $SHELL +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'PKG_DIR PACKAGE' 'rewrite' +validate_format 'pkg_dir' 'package' +if [ "$rewrite" != 'yes' ]; then + is_package_new +fi +is_package_valid "$pkg_dir" +is_package_consistent + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +cp -f $pkg_dir/$package.pkg $VESTA/data/packages/ +chmod 644 $VESTA/data/packages/$package.pkg + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +if [ "$rewrite" != 'yes' ]; then + log_history "added user package $package" '' 'admin' +else + log_history "updated user package $package" '' 'admin' +fi +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-web-domain b/bin/v-add-web-domain index 908d1ebd0..c07b6cf00 100755 --- a/bin/v-add-web-domain +++ b/bin/v-add-web-domain @@ -1,190 +1,190 @@ -#!/bin/bash -# info: add web domain -# options: user domain ip [template] [restart] -# -# The function adds virtual host to a server. In cases when a template is -# undefined in the script, the template "default" will be used. The alias of -# www.domain.tld type will be automatically assigned to the domain. If ip have -# assocated dns name, this domain will also get the alias domain-tpl.$ipname. -# An alias with the ip name is useful during the site testing while dns isn't -# moved to a server yet. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g') -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -ip=$3 -template=$4 -restart=$5 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/ip.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user domain ip [template] [restart]' -validate_format 'user' 'domain' 'ip' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_domain_new 'web' -is_ip_valid -is_ip_avalable -is_package_full 'WEB_DOMAINS' -if [ ! -z "$template" ]; then - validate_format 'template' - is_apache_template_valid -else - template=$(get_user_value '$TEMPLATE') - is_apache_template_valid -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining domain aliases -IP=$ip -ip_name=$(get_ip_name) -ip_name_idn=$(idn -t --quiet -a "$ip_name") -domain_alias="www.$domain" -domain_alias_idn="www.$domain_idn" -if [ ! -z "$ip_name" ]; then - domain_alias_dash="${domain//./-}.$ip_name" - domain_alias_dash_idn="${domain_idn//./-}.$ip_name_idn" - aliases="$domain_alias,$domain_alias_dash" - aliases_idn="$domain_alias_idn,$domain_alias_dash_idn" - alias_string="ServerAlias $domain_alias_idn $domain_alias_dash_idn" -else - aliases="$domain_alias" - aliases_idn="$domain_alias_idn" - alias_string="ServerAlias $domain_alias_idn" -fi - -# Defining vars for add_config function -group="$user" -email="$user@$domain" -docroot="$HOMEDIR/$user/web/$domain/public_html" -conf="$HOMEDIR/$user/conf/web/httpd.conf" -tpl_file="$WEBTPL/apache_$template.tpl" -elog='' -cgi='' -cgi_option='+ExecCGI' - -# Adding domain to the httpd.conf -add_web_config - -# Building directory tree -mkdir $HOMEDIR/$user/web/$domain \ - $HOMEDIR/$user/web/$domain/public_html \ - $HOMEDIR/$user/web/$domain/public_shtml \ - $HOMEDIR/$user/web/$domain/document_errors \ - $HOMEDIR/$user/web/$domain/cgi-bin \ - $HOMEDIR/$user/web/$domain/private \ - $HOMEDIR/$user/web/$domain/stats \ - $HOMEDIR/$user/web/$domain/logs - -# Adding domain logs -touch /var/log/httpd/domains/$domain.bytes \ - /var/log/httpd/domains/$domain.log \ - /var/log/httpd/domains/$domain.error.log - -# Adding symlink for logs -ln -s /var/log/httpd/domains/$domain.*log $HOMEDIR/$user/web/$domain/logs/ - -# Adding domain skeleton -if [ -e "$WEBTPL/skel/public_html/" ]; then - cp -r $WEBTPL/skel/public_html/ $HOMEDIR/$user/web/$domain/ -fi -if [ -e "$WEBTPL/skel/public_shtml/" ]; then - cp -r $WEBTPL/skel/public_shtml/ $HOMEDIR/$user/web/$domain/ -fi -if [ -e "$WEBTPL/skel/document_errors/" ]; then - cp -r $WEBTPL/skel/document_errors/ $HOMEDIR/$user/web/$domain/ -fi -if [ -e "$WEBTPL/skel/cgi-bin/" ]; then - cp -r $WEBTPL/skel/cgi-bin/ $HOMEDIR/$user/web/$domain/ -fi - -# Changing tpl values -for file in $(find "$HOMEDIR/$user/web/$domain/" -type f); do - sed -i "s/%domain%/$domain/g" $file -done - -# Changing file owner -chown -R $user:$user $HOMEDIR/$user/web/$domain -chown root:$user /var/log/httpd/domains/$domain.* -chown root:apache $conf - -# Changing file permissions -chmod 660 $conf -chmod 551 $HOMEDIR/$user/web/$domain -chmod 771 $HOMEDIR/$user/web/$domain/private -chmod 751 $HOMEDIR/$user/web/$domain/cgi-bin -chmod 771 $HOMEDIR/$user/web/$domain/public_html -chmod 771 $HOMEDIR/$user/web/$domain/public_shtml -chmod 771 $HOMEDIR/$user/web/$domain/document_errors -chmod -f -R 665 $HOMEDIR/$user/web/$domain/cgi-bin/* -chmod -f -R 665 $HOMEDIR/$user/web/$domain/public_html/* -chmod -f -R 665 $HOMEDIR/$user/web/$domain/document_errors/* -chmod 551 $HOMEDIR/$user/web/$domain/stats -chmod 551 $HOMEDIR/$user/web/$domain/logs -chmod 640 /var/log/httpd/domains/$domain.* - -# Running template trigger -if [ -x $WEBTPL/apache_$template.sh ]; then - $WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $docroot -fi - -# Checking main vesta httpd config -main_conf='/etc/httpd/conf.d/vesta.conf' -main_conf_check=$(grep "$conf" $main_conf ) -if [ -z "$main_conf_check" ]; then - echo "Include $conf" >>$main_conf -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Increasing counters -increase_ip_value "$ip" -increase_user_value "$user" '$U_WEB_DOMAINS' -increase_user_value "$user" '$U_WEB_ALIASES' - -# Defining domain variables -str="DOMAIN='$domain' IP='$ip' IP6='' ALIAS='$aliases' TPL='$template'" -str="$str CGI='yes' ELOG='yes' SSL='no' SSL_HOME='same' FTP_USER=''" -str="$str FTP_MD5='' NGINX='' NGINX_EXT='' STATS='' STATS_USER=''" -str="$str STATS_CRYPT='' U_DISK='0' U_BANDWIDTH='0' SUSPENDED='no'" -str="$str TIME='$TIME' DATE='$DATE'" - -# Registering domain -echo "$str" >> $USER_DATA/web.conf -chmod 660 $USER_DATA/web.conf - -# Restart web server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_history "added web domain $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add web domain +# options: USER DOMAIN IP [TEMPLATE] [RESTART] +# +# The function adds virtual host to a server. In cases when a template is +# undefined in the script, the template "default" will be used. The alias of +# www.domain.tld type will be automatically assigned to the domain. If ip have +# assocated dns name, this domain will also get the alias domain-tpl.$ipname. +# An alias with the ip name is useful during the site testing while dns isn't +# moved to a server yet. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g') +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +ip=$3 +template=$4 +restart=$5 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh +source $VESTA/func/ip.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN IP [TEMPLATE] [RESTART]' +validate_format 'user' 'domain' 'ip' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_domain_new 'web' +is_ip_valid +is_ip_avalable +is_package_full 'WEB_DOMAINS' +if [ ! -z "$template" ]; then + validate_format 'template' + is_apache_template_valid +else + template=$(get_user_value '$TEMPLATE') + is_apache_template_valid +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining domain aliases +IP=$ip +ip_name=$(get_ip_name) +ip_name_idn=$(idn -t --quiet -a "$ip_name") +domain_alias="www.$domain" +domain_alias_idn="www.$domain_idn" +if [ ! -z "$ip_name" ]; then + domain_alias_dash="${domain//./-}.$ip_name" + domain_alias_dash_idn="${domain_idn//./-}.$ip_name_idn" + aliases="$domain_alias,$domain_alias_dash" + aliases_idn="$domain_alias_idn,$domain_alias_dash_idn" + alias_string="ServerAlias $domain_alias_idn $domain_alias_dash_idn" +else + aliases="$domain_alias" + aliases_idn="$domain_alias_idn" + alias_string="ServerAlias $domain_alias_idn" +fi + +# Defining vars for add_config function +group="$user" +email="$user@$domain" +docroot="$HOMEDIR/$user/web/$domain/public_html" +conf="$HOMEDIR/$user/conf/web/httpd.conf" +tpl_file="$WEBTPL/apache_$template.tpl" +elog='' +cgi='' +cgi_option='+ExecCGI' + +# Adding domain to the httpd.conf +add_web_config + +# Building directory tree +mkdir $HOMEDIR/$user/web/$domain \ + $HOMEDIR/$user/web/$domain/public_html \ + $HOMEDIR/$user/web/$domain/public_shtml \ + $HOMEDIR/$user/web/$domain/document_errors \ + $HOMEDIR/$user/web/$domain/cgi-bin \ + $HOMEDIR/$user/web/$domain/private \ + $HOMEDIR/$user/web/$domain/stats \ + $HOMEDIR/$user/web/$domain/logs + +# Adding domain logs +touch /var/log/httpd/domains/$domain.bytes \ + /var/log/httpd/domains/$domain.log \ + /var/log/httpd/domains/$domain.error.log + +# Adding symlink for logs +ln -s /var/log/httpd/domains/$domain.*log $HOMEDIR/$user/web/$domain/logs/ + +# Adding domain skeleton +if [ -e "$WEBTPL/skel/public_html/" ]; then + cp -r $WEBTPL/skel/public_html/ $HOMEDIR/$user/web/$domain/ +fi +if [ -e "$WEBTPL/skel/public_shtml/" ]; then + cp -r $WEBTPL/skel/public_shtml/ $HOMEDIR/$user/web/$domain/ +fi +if [ -e "$WEBTPL/skel/document_errors/" ]; then + cp -r $WEBTPL/skel/document_errors/ $HOMEDIR/$user/web/$domain/ +fi +if [ -e "$WEBTPL/skel/cgi-bin/" ]; then + cp -r $WEBTPL/skel/cgi-bin/ $HOMEDIR/$user/web/$domain/ +fi + +# Changing tpl values +for file in $(find "$HOMEDIR/$user/web/$domain/" -type f); do + sed -i "s/%domain%/$domain/g" $file +done + +# Changing file owner +chown -R $user:$user $HOMEDIR/$user/web/$domain +chown root:$user /var/log/httpd/domains/$domain.* +chown root:apache $conf + +# Changing file permissions +chmod 660 $conf +chmod 551 $HOMEDIR/$user/web/$domain +chmod 771 $HOMEDIR/$user/web/$domain/private +chmod 751 $HOMEDIR/$user/web/$domain/cgi-bin +chmod 771 $HOMEDIR/$user/web/$domain/public_html +chmod 771 $HOMEDIR/$user/web/$domain/public_shtml +chmod 771 $HOMEDIR/$user/web/$domain/document_errors +chmod -f -R 665 $HOMEDIR/$user/web/$domain/cgi-bin/* +chmod -f -R 665 $HOMEDIR/$user/web/$domain/public_html/* +chmod -f -R 665 $HOMEDIR/$user/web/$domain/document_errors/* +chmod 551 $HOMEDIR/$user/web/$domain/stats +chmod 551 $HOMEDIR/$user/web/$domain/logs +chmod 640 /var/log/httpd/domains/$domain.* + +# Running template trigger +if [ -x $WEBTPL/apache_$template.sh ]; then + $WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $docroot +fi + +# Checking main vesta httpd config +main_conf='/etc/httpd/conf.d/vesta.conf' +main_conf_check=$(grep "$conf" $main_conf ) +if [ -z "$main_conf_check" ]; then + echo "Include $conf" >>$main_conf +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Increasing counters +increase_ip_value "$ip" +increase_user_value "$user" '$U_WEB_DOMAINS' +increase_user_value "$user" '$U_WEB_ALIASES' + +# Defining domain variables +str="DOMAIN='$domain' IP='$ip' IP6='' ALIAS='$aliases' TPL='$template'" +str="$str CGI='yes' ELOG='yes' SSL='no' SSL_HOME='same' FTP_USER=''" +str="$str FTP_MD5='' NGINX='' NGINX_EXT='' STATS='' STATS_USER=''" +str="$str STATS_CRYPT='' U_DISK='0' U_BANDWIDTH='0' SUSPENDED='no'" +str="$str TIME='$TIME' DATE='$DATE'" + +# Registering domain +echo "$str" >> $USER_DATA/web.conf +chmod 660 $USER_DATA/web.conf + +# Restart web server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_history "added web domain $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-web-domain-alias b/bin/v-add-web-domain-alias index 76f615eb3..4f493fdad 100755 --- a/bin/v-add-web-domain-alias +++ b/bin/v-add-web-domain-alias @@ -1,109 +1,109 @@ -#!/bin/bash -# info: add web domain alias -# options: user domain alias [restart] -# -# The call is intended for adding aliases to a domain (it is also called -# "domain parking"). The function supports wildcards *.domain.tpl. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -dom_alias=$(idn -t --quiet -u "$3" ) -dom_alias=$(echo $dom_alias | sed -e 's/\.*$//g' -e 's/^\.*//g') -dom_alias=$(echo $dom_alias | tr '[:upper:]' '[:lower:]') -dom_alias_idn=$(idn -t --quiet -a "$dom_alias" ) -restart="$4" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user domain dom_alias [restart]' -validate_format 'user' 'domain' 'dom_alias' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_domain_new 'web' "$dom_alias" -is_package_full 'WEB_ALIASES' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain values -get_domain_values 'web' -tpl_file="$WEBTPL/apache_$TPL.tpl" -conf="$HOMEDIR/$user/conf/web/httpd.conf" - -# Parsing domain aliases -if [ -z "$ALIAS" ]; then - ALIAS="$dom_alias" -else - ALIAS="$ALIAS,$dom_alias" -fi - -# Preparing domain values for the template substitution -upd_web_domain_values - -# Recreating vhost -del_web_config -add_web_config - -if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/apache_$TPL.stpl" - conf="$HOMEDIR/$user/conf/web/shttpd.conf" - del_web_config - add_web_config -fi - -# Checking nginx -if [ ! -z "$NGINX" ]; then - tpl_file="$WEBTPL/nginx_$NGINX.tpl" - conf="$HOMEDIR/$user/conf/web/nginx.conf" - del_web_config - add_web_config - - if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web/snginx.conf" - del_web_config - add_web_config - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding new alias -update_object_value 'web' 'DOMAIN' "$domain" '$ALIAS' "$ALIAS" - -# Update counters -increase_user_value "$user" '$U_WEB_ALIASES' - -# Adding task to the vesta pipe -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -log_history "added $dom_alias as alias for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add web domain alias +# options: USER DOMAIN ALIAS [RESTART] +# +# The call is intended for adding aliases to a domain (it is also called +# "domain parking"). The function supports wildcards *.domain.tpl. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +dom_alias=$(idn -t --quiet -u "$3" ) +dom_alias=$(echo $dom_alias | sed -e 's/\.*$//g' -e 's/^\.*//g') +dom_alias=$(echo $dom_alias | tr '[:upper:]' '[:lower:]') +dom_alias_idn=$(idn -t --quiet -a "$dom_alias" ) +restart="$4" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN DOM_ALIAS [RESTART]' +validate_format 'user' 'domain' 'dom_alias' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_domain_new 'web' "$dom_alias" +is_package_full 'WEB_ALIASES' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Parsing domain values +get_domain_values 'web' +tpl_file="$WEBTPL/apache_$TPL.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" + +# Parsing domain aliases +if [ -z "$ALIAS" ]; then + ALIAS="$dom_alias" +else + ALIAS="$ALIAS,$dom_alias" +fi + +# Preparing domain values for the template substitution +upd_web_domain_values + +# Recreating vhost +del_web_config +add_web_config + +if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" + del_web_config + add_web_config +fi + +# Checking nginx +if [ ! -z "$NGINX" ]; then + tpl_file="$WEBTPL/nginx_$NGINX.tpl" + conf="$HOMEDIR/$user/conf/web/nginx.conf" + del_web_config + add_web_config + + if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + del_web_config + add_web_config + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Adding new alias +update_object_value 'web' 'DOMAIN' "$domain" '$ALIAS' "$ALIAS" + +# Update counters +increase_user_value "$user" '$U_WEB_ALIASES' + +# Adding task to the vesta pipe +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +log_history "added $dom_alias as alias for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-web-domain-cgi b/bin/v-add-web-domain-cgi index 02c851333..c06f0c90a 100755 --- a/bin/v-add-web-domain-cgi +++ b/bin/v-add-web-domain-cgi @@ -1,80 +1,80 @@ -#!/bin/bash -# info: add cgi support for domain -# options: user domain -# -# The function switches on cgi support by adding +ExecCGI directive into -# webserver configuration file. The use of this function is provided for -# cases, when temporary cgi support is necessary, for other cases use of -# templates is recommended. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_empty 'web' 'DOMAIN' "$domain" '$CGI' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain values -get_domain_values 'web' -tpl_file="$WEBTPL/apache_$TPL.tpl" -conf="$HOMEDIR/$user/conf/web/httpd.conf" -CGI='yes' - -# Preparing domain values for the template substitution -upd_web_domain_values - -# Recreating vhost -del_web_config -add_web_config - -# Checking ssl -if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/apache_$TPL.stpl" - conf="$HOMEDIR/$user/conf/web/shttpd.conf" - del_web_config - add_web_config -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config value -update_object_value 'web' 'DOMAIN' "$domain" '$CGI' 'yes' - -# Restart web server -$BIN/v-restart-web "$EVENT" - -# Logging -log_history "enabled cgi support for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add cgi support for domain +# options: USER DOMAIN +# +# The function switches on cgi support by adding +ExecCGI directive into +# webserver configuration file. The use of this function is provided for +# cases, when temporary cgi support is necessary, for other cases use of +# templates is recommended. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_empty 'web' 'DOMAIN' "$domain" '$CGI' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Parsing domain values +get_domain_values 'web' +tpl_file="$WEBTPL/apache_$TPL.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" +CGI='yes' + +# Preparing domain values for the template substitution +upd_web_domain_values + +# Recreating vhost +del_web_config +add_web_config + +# Checking ssl +if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" + del_web_config + add_web_config +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config value +update_object_value 'web' 'DOMAIN' "$domain" '$CGI' 'yes' + +# Restart web server +$BIN/v-restart-web "$EVENT" + +# Logging +log_history "enabled cgi support for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-web-domain-elog b/bin/v-add-web-domain-elog index e92dbdb86..b7d0be4e7 100755 --- a/bin/v-add-web-domain-elog +++ b/bin/v-add-web-domain-elog @@ -1,99 +1,99 @@ -#!/bin/bash -# info: add error logging for domain -# options: user domain [restart] -# -# The function enables a separate ErrorLog file for a domain, accessible for -# reading by users. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -restart="$3" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain [restart]' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain values -get_domain_values 'web' -if [ $ELOG == 'yes' ]; then - exit 0 -fi - -tpl_file="$WEBTPL/apache_$TPL.tpl" -conf="$HOMEDIR/$user/conf/web/httpd.conf" -ELOG='yes' - -# Preparing domain values for the template substitution -upd_web_domain_values - -# Recreating vhost -del_web_config -add_web_config - -# Checking ssl -if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/apache_$TPL.stpl" - conf="$HOMEDIR/$user/conf/web/shttpd.conf" - del_web_config - add_web_config -fi - -# Checking nginx -if [ ! -z "$NGINX" ]; then - tpl_file="$WEBTPL/nginx_$NGINX.tpl" - conf="$HOMEDIR/$user/conf/web/nginx.conf" - del_web_config - add_web_config - - if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web/snginx.conf" - del_web_config - add_web_config - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$ELOG' 'yes' - -# Adding task to the vesta pipe -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_history "enabled error logging for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add error logging for domain +# options: USER DOMAIN [RESTART] +# +# The function enables a separate ErrorLog file for a domain, accessible for +# reading by users. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +restart="$3" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [RESTART]' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Parsing domain values +get_domain_values 'web' +if [ $ELOG == 'yes' ]; then + exit 0 +fi + +tpl_file="$WEBTPL/apache_$TPL.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" +ELOG='yes' + +# Preparing domain values for the template substitution +upd_web_domain_values + +# Recreating vhost +del_web_config +add_web_config + +# Checking ssl +if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" + del_web_config + add_web_config +fi + +# Checking nginx +if [ ! -z "$NGINX" ]; then + tpl_file="$WEBTPL/nginx_$NGINX.tpl" + conf="$HOMEDIR/$user/conf/web/nginx.conf" + del_web_config + add_web_config + + if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + del_web_config + add_web_config + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$ELOG' 'yes' + +# Adding task to the vesta pipe +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_history "enabled error logging for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-web-domain-ftp b/bin/v-add-web-domain-ftp index dae270be5..e2d566a8f 100755 --- a/bin/v-add-web-domain-ftp +++ b/bin/v-add-web-domain-ftp @@ -1,71 +1,71 @@ -#!/bin/bash -# info: add ftp account for web domain. -# options: user domain ftp_user ftp_password -# -# The function creates addutional ftp account for web domain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -ftp_user=${1}_${3} -ftp_password=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - -# Hiding password -A4='******' -EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'" -EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'" - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'user domain ftp_user ftp_password' -validate_format 'user' 'domain' 'ftp_user' 'ftp_password' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get domain values -get_domain_values 'web' -if [ ! -z "$FTP_USER" ]; then - /usr/sbin/userdel $FTP_USER -fi - -# Adding user -/usr/sbin/adduser $ftp_user -g $user -s /sbin/nologin -M \ - -d "$HOMEDIR/$user/web/$domain" > /dev/null 2>&1 -echo "$ftp_password" | /usr/bin/passwd "$ftp_user" --stdin &>/dev/null -ftp_md5="$(awk -v user=$ftp_user -F : 'user == $1 {print $2}' /etc/shadow)" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$FTP_USER' "$ftp_user" -update_object_value 'web' 'DOMAIN' "$domain" '$FTP_MD5' "$ftp_md5" - -# Logging -log_history "added ftp account $ftp_user for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add ftp account for web domain. +# options: USER DOMAIN FTP_USER FTP_PASSWORD +# +# The function creates addutional ftp account for web domain. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +ftp_user=${1}_${3} +ftp_password=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + +# Hiding password +A4='******' +EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'" +EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'" + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '4' "$#" 'USER DOMAIN FTP_USER FTP_PASSWORD' +validate_format 'user' 'domain' 'ftp_user' 'ftp_password' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Get domain values +get_domain_values 'web' +if [ ! -z "$FTP_USER" ]; then + /usr/sbin/userdel $FTP_USER +fi + +# Adding user +/usr/sbin/adduser $ftp_user -g $user -s /sbin/nologin -M \ + -d "$HOMEDIR/$user/web/$domain" > /dev/null 2>&1 +echo "$ftp_password" | /usr/bin/passwd "$ftp_user" --stdin &>/dev/null +ftp_md5="$(awk -v user=$ftp_user -F : 'user == $1 {print $2}' /etc/shadow)" + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$FTP_USER' "$ftp_user" +update_object_value 'web' 'DOMAIN' "$domain" '$FTP_MD5' "$ftp_md5" + +# Logging +log_history "added ftp account $ftp_user for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-web-domain-nginx b/bin/v-add-web-domain-nginx index 701f19ef4..6398069cc 100755 --- a/bin/v-add-web-domain-nginx +++ b/bin/v-add-web-domain-nginx @@ -1,111 +1,111 @@ -#!/bin/bash -# info: add webdomain nginx support -# options: user domain [template] [extentions] [restart] -# -# The function enables nginx support for a domain. It can significantly improve -# website speed. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -template=$3 -default_extentions="jpg,jpeg,gif,png,ico,svg,css,zip,tgz,gz,rar,bz2,doc,xls,\ -exe,pdf,ppt,txt,odt,ods,odp,odf,tar,wav,bmp,rtf,js,mp3,avi,mpeg,flv,html,htm" -extentions=${4-$default_extentions} -restart="$5" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain [template] [extentions] [restart]' -validate_format 'user' 'domain' 'extentions' -is_system_enabled "$PROXY_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_empty 'web' 'DOMAIN' "$domain" '$NGINX' -if [ ! -z "$template" ]; then - validate_format 'template' - is_nginx_template_valid -else - template=$(get_user_value '$TEMPLATE') - is_nginx_template_valid -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining domain parameters -get_domain_values 'web' -NGINX="$template" -NGINX_EXT="$extentions" -tpl_file="$WEBTPL/nginx_$NGINX.tpl" -conf="$HOMEDIR/$user/conf/web/nginx.conf" - -# Preparing domain values for the template substitution -upd_web_domain_values -add_web_config - -# Set permission and ownership -chown root:nginx $conf -chmod 640 $conf - -# Checking main vesta httpd config -main_conf='/etc/nginx/conf.d/vesta_users.conf' -main_conf_check=$(grep "$conf" $main_conf ) -if [ -z "$main_conf_check" ]; then - echo "include $conf;" >>$main_conf -fi - -# Checking ssl -if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web/snginx.conf" - add_web_config - - chown root:nginx $conf - chmod 640 $conf - - main_conf='/etc/nginx/conf.d/vesta_users.conf' - main_conf_check=$(grep "$conf" $main_conf ) - if [ -z "$main_conf_check" ]; then - echo "include $conf;" >>$main_conf - fi -fi - - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$NGINX' "$NGINX" -update_object_value 'web' 'DOMAIN' "$domain" '$NGINX_EXT' "$extentions" - -# Restart web server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -log_history "enabled nginx support for $domain" -log_event "$OK" "$EVENT" - -exit - +#!/bin/bash +# info: add webdomain nginx support +# options: USER DOMAIN [TEMPLATE] [EXTENTIONS] [RESTART] +# +# The function enables nginx support for a domain. It can significantly improve +# website speed. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +template=$3 +default_extentions="jpg,jpeg,gif,png,ico,svg,css,zip,tgz,gz,rar,bz2,doc,xls,\ +exe,pdf,ppt,txt,odt,ods,odp,odf,tar,wav,bmp,rtf,js,mp3,avi,mpeg,flv,html,htm" +extentions=${4-$default_extentions} +restart="$5" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [TEMPLATE] [EXTENTIONS] [RESTART]' +validate_format 'user' 'domain' 'extentions' +is_system_enabled "$PROXY_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_empty 'web' 'DOMAIN' "$domain" '$NGINX' +if [ ! -z "$template" ]; then + validate_format 'template' + is_nginx_template_valid +else + template=$(get_user_value '$TEMPLATE') + is_nginx_template_valid +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining domain parameters +get_domain_values 'web' +NGINX="$template" +NGINX_EXT="$extentions" +tpl_file="$WEBTPL/nginx_$NGINX.tpl" +conf="$HOMEDIR/$user/conf/web/nginx.conf" + +# Preparing domain values for the template substitution +upd_web_domain_values +add_web_config + +# Set permission and ownership +chown root:nginx $conf +chmod 640 $conf + +# Checking main vesta httpd config +main_conf='/etc/nginx/conf.d/vesta_users.conf' +main_conf_check=$(grep "$conf" $main_conf ) +if [ -z "$main_conf_check" ]; then + echo "include $conf;" >>$main_conf +fi + +# Checking ssl +if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + add_web_config + + chown root:nginx $conf + chmod 640 $conf + + main_conf='/etc/nginx/conf.d/vesta_users.conf' + main_conf_check=$(grep "$conf" $main_conf ) + if [ -z "$main_conf_check" ]; then + echo "include $conf;" >>$main_conf + fi +fi + + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$NGINX' "$NGINX" +update_object_value 'web' 'DOMAIN' "$domain" '$NGINX_EXT' "$extentions" + +# Restart web server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +log_history "enabled nginx support for $domain" +log_event "$OK" "$EVENT" + +exit + diff --git a/bin/v-add-web-domain-ssl b/bin/v-add-web-domain-ssl index db7705bdb..cc46432a2 100755 --- a/bin/v-add-web-domain-ssl +++ b/bin/v-add-web-domain-ssl @@ -1,136 +1,136 @@ -#!/bin/bash -# info: adding ssl for domain -# options: user domain ssl_dir [ssl_home] [restart] -# -# The function turns on SSL support for a domain. Parameter ssl_dir is a path -# to directory where 2 or 3 ssl files can be found. Certificate file -# domain.tld.crt and its key domain.tld.key are mandatory. Certificate -# authority domain.tld.ca file is optional. If home directory parameter -# (ssl_home) is not set, https domain uses public_shtml as separate -# documentroot directory. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -ssl_dir=$3 -ssl_home=${4-same} -restart="$5" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/ip.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user domain ssl_dir [ssl_home] [restart]' -validate_format 'user' 'domain' 'ssl_dir' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_empty 'web' 'DOMAIN' "$domain" '$SSL' -is_ip_owner -is_web_domain_cert_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding certificate to user data directory -cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.crt -cp -f $ssl_dir/$domain.key $USER_DATA/ssl/$domain.key -cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.pem -if [ -e "$ssl_dir/$domain.ca" ]; then - cp -f $ssl_dir/$domain.ca $USER_DATA/ssl/$domain.ca - cat $USER_DATA/ssl/$domain.ca >> $USER_DATA/ssl/$domain.pem -fi -chmod 660 $USER_DATA/ssl/$domain.* - -# Parsing domain values -get_domain_values 'web' -conf="$HOMEDIR/$user/conf/web/shttpd.conf" -tpl_file="$WEBTPL/apache_$TPL.stpl" -SSL_HOME="$ssl_home" - -# Preparing domain values for the template substitution -upd_web_domain_values - -# Adding domain to the shttpd.conf -add_web_config - -chown root:apache $conf -chmod 640 $conf - -# Adding certificate to user dir -cp -f $USER_DATA/ssl/$domain.crt $HOMEDIR/$user/conf/web/ssl.$domain.crt -cp -f $USER_DATA/ssl/$domain.key $HOMEDIR/$user/conf/web/ssl.$domain.key -cp -f $USER_DATA/ssl/$domain.pem $HOMEDIR/$user/conf/web/ssl.$domain.pem -if [ -e "$USER_DATA/ssl/$domain.ca" ]; then - cp -f $USER_DATA/ssl/$domain.ca $HOMEDIR/$user/conf/web/ssl.$domain.ca -fi - -# Running template trigger -if [ -x $WEBTPL/apache_$template.sh ]; then - $WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $sdocroot -fi - -# Checking main vesta httpd config -main_conf='/etc/httpd/conf.d/vesta.conf' -main_conf_check=$(grep "$conf" $main_conf ) -if [ -z "$main_conf_check" ]; then - echo "Include $conf" >> $main_conf -fi - -# Checking nginx -if [ ! -z "$NGINX" ]; then - # Adding domain to the snginx.conf - conf="$HOMEDIR/$user/conf/web/snginx.conf" - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - add_web_config - - chown root:nginx $conf - chmod 640 $conf - - # Checking vesta nginx config - main_conf='/etc/nginx/conf.d/vesta_users.conf' - main_conf_check=$(grep "$conf" $main_conf ) - if [ -z "$main_conf_check" ]; then - echo "include $conf;" >>$main_conf - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Increasing domain value -increase_user_value "$user" '$U_WEB_SSL' - -# Adding ssl values -update_object_value 'web' 'DOMAIN' "$domain" '$SSL_HOME' "$SSL_HOME" -update_object_value 'web' 'DOMAIN' "$domain" '$SSL' "yes" - -# Restart web server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_history "enabled ssl support for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: adding ssl for domain +# options: USER DOMAIN SSL_DIR [SSL_HOME] [RESTART] +# +# The function turns on SSL support for a domain. Parameter ssl_dir is a path +# to directory where 2 or 3 ssl files can be found. Certificate file +# domain.tld.crt and its key domain.tld.key are mandatory. Certificate +# authority domain.tld.ca file is optional. If home directory parameter +# (ssl_home) is not set, https domain uses public_shtml as separate +# documentroot directory. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +ssl_dir=$3 +ssl_home=${4-same} +restart="$5" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh +source $VESTA/func/ip.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN SSL_DIR [SSL_HOME] [RESTART]' +validate_format 'user' 'domain' 'ssl_dir' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_empty 'web' 'DOMAIN' "$domain" '$SSL' +is_ip_owner +is_web_domain_cert_valid + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Adding certificate to user data directory +cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.crt +cp -f $ssl_dir/$domain.key $USER_DATA/ssl/$domain.key +cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.pem +if [ -e "$ssl_dir/$domain.ca" ]; then + cp -f $ssl_dir/$domain.ca $USER_DATA/ssl/$domain.ca + cat $USER_DATA/ssl/$domain.ca >> $USER_DATA/ssl/$domain.pem +fi +chmod 660 $USER_DATA/ssl/$domain.* + +# Parsing domain values +get_domain_values 'web' +conf="$HOMEDIR/$user/conf/web/shttpd.conf" +tpl_file="$WEBTPL/apache_$TPL.stpl" +SSL_HOME="$ssl_home" + +# Preparing domain values for the template substitution +upd_web_domain_values + +# Adding domain to the shttpd.conf +add_web_config + +chown root:apache $conf +chmod 640 $conf + +# Adding certificate to user dir +cp -f $USER_DATA/ssl/$domain.crt $HOMEDIR/$user/conf/web/ssl.$domain.crt +cp -f $USER_DATA/ssl/$domain.key $HOMEDIR/$user/conf/web/ssl.$domain.key +cp -f $USER_DATA/ssl/$domain.pem $HOMEDIR/$user/conf/web/ssl.$domain.pem +if [ -e "$USER_DATA/ssl/$domain.ca" ]; then + cp -f $USER_DATA/ssl/$domain.ca $HOMEDIR/$user/conf/web/ssl.$domain.ca +fi + +# Running template trigger +if [ -x $WEBTPL/apache_$template.sh ]; then + $WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $sdocroot +fi + +# Checking main vesta httpd config +main_conf='/etc/httpd/conf.d/vesta.conf' +main_conf_check=$(grep "$conf" $main_conf ) +if [ -z "$main_conf_check" ]; then + echo "Include $conf" >> $main_conf +fi + +# Checking nginx +if [ ! -z "$NGINX" ]; then + # Adding domain to the snginx.conf + conf="$HOMEDIR/$user/conf/web/snginx.conf" + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + add_web_config + + chown root:nginx $conf + chmod 640 $conf + + # Checking vesta nginx config + main_conf='/etc/nginx/conf.d/vesta_users.conf' + main_conf_check=$(grep "$conf" $main_conf ) + if [ -z "$main_conf_check" ]; then + echo "include $conf;" >>$main_conf + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Increasing domain value +increase_user_value "$user" '$U_WEB_SSL' + +# Adding ssl values +update_object_value 'web' 'DOMAIN' "$domain" '$SSL_HOME' "$SSL_HOME" +update_object_value 'web' 'DOMAIN' "$domain" '$SSL' "yes" + +# Restart web server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_history "enabled ssl support for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-web-domain-stats b/bin/v-add-web-domain-stats index 90592b325..dceed0050 100755 --- a/bin/v-add-web-domain-stats +++ b/bin/v-add-web-domain-stats @@ -1,91 +1,91 @@ -#!/bin/bash -# info: add log analyzer to generate domain statitics -# options: user domain type -# -# The call is used for enabling log analyzer system to a domain. At this time -# two types of these system is supported - awstats and webalizer. For viewing -# the domain statistics use http://domain.tld/vstats/ link. Access this page -# is not protected by default. If you want to secure it with passwords you -# should use v-add-web-domain_stat_auth script. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -type=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user domain type' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_type_valid "$STATS_SYSTEM" "$type" -is_object_valid 'user' 'USER' "$user" "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_empty 'web' 'DOMAIN' "$domain" '$STATS' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parse aliases -get_domain_values 'web' - -# Preparing domain values for the template substitution -upd_web_domain_values - -# Adding statistic config -cat $WEBTPL/$type.tpl |\ - sed -e "s/%ip%/$ip/g" \ - -e "s/%web_port%/$WEB_PORT/g" \ - -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \ - -e "s/%proxy_port%/$PROXY_PORT/g" \ - -e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \ - -e "s/%domain_idn%/$domain_idn/g" \ - -e "s/%domain%/$domain/g" \ - -e "s/%user%/$user/g" \ - -e "s/%home%/${HOMEDIR////\/}/g" \ - -e "s/%alias%/${aliases//,/ }/g" \ - -e "s/%alias_idn%/${aliases_idn//,/ }/g" \ - > $HOMEDIR/$user/conf/web/$type.$domain.conf - -if [ "$type" == 'awstats' ]; then - ln -s $HOMEDIR/$user/conf/web/$type.$domain.conf /etc/awstats/ -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Schedule statistic processing -echo "$BIN/v-update-web-domain-stat $user $domain" >> \ - $VESTA/data/queue/webstats.pipe - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$STATS' "$type" - -# Logging -log_history "enabled web log analyzer for $domain" -log_event "$OK" "$EVENT" - -# Build stats -exec $BIN/v-update-web-domain-stat $user $domain - -exit +#!/bin/bash +# info: add log analyzer to generate domain statitics +# options: USER DOMAIN TYPE +# +# The call is used for enabling log analyzer system to a domain. At this time +# two types of these system is supported - awstats and webalizer. For viewing +# the domain statistics use http://domain.tld/vstats/ link. Access this page +# is not protected by default. If you want to secure it with passwords you +# should use v-add-web-domain_stat_auth script. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +type=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN TYPE' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_type_valid "$STATS_SYSTEM" "$type" +is_object_valid 'user' 'USER' "$user" "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_empty 'web' 'DOMAIN' "$domain" '$STATS' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Parse aliases +get_domain_values 'web' + +# Preparing domain values for the template substitution +upd_web_domain_values + +# Adding statistic config +cat $WEBTPL/$type.tpl |\ + sed -e "s/%ip%/$ip/g" \ + -e "s/%web_port%/$WEB_PORT/g" \ + -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \ + -e "s/%proxy_port%/$PROXY_PORT/g" \ + -e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \ + -e "s/%domain_idn%/$domain_idn/g" \ + -e "s/%domain%/$domain/g" \ + -e "s/%user%/$user/g" \ + -e "s/%home%/${HOMEDIR////\/}/g" \ + -e "s/%alias%/${aliases//,/ }/g" \ + -e "s/%alias_idn%/${aliases_idn//,/ }/g" \ + > $HOMEDIR/$user/conf/web/$type.$domain.conf + +if [ "$type" == 'awstats' ]; then + ln -s $HOMEDIR/$user/conf/web/$type.$domain.conf /etc/awstats/ +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Schedule statistic processing +echo "$BIN/v-update-web-domain-stat $user $domain" >> \ + $VESTA/data/queue/webstats.pipe + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$STATS' "$type" + +# Logging +log_history "enabled web log analyzer for $domain" +log_event "$OK" "$EVENT" + +# Build stats +exec $BIN/v-update-web-domain-stat $user $domain + +exit diff --git a/bin/v-add-web-domain-stats-user b/bin/v-add-web-domain-stats-user index d4d2d0b4e..2f8cc40b1 100755 --- a/bin/v-add-web-domain-stats-user +++ b/bin/v-add-web-domain-stats-user @@ -1,72 +1,72 @@ -#!/bin/bash -# info: add password protection to web domain statistics -# options: user domain stats_user stats_password -# -# The call is used for securing the web statistics page. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -stats_user=$3 -stats_pass=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - -# Hiding password -A4='******' -EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'" -EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'" - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'user domain stats_user stats_pass' -validate_format 'user' 'domain' 'stats_user' 'stats_pass' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Definining statistic dir -stats_dir="$HOMEDIR/$user/web/$domain/stats" - -# Adding htaccess file -echo "AuthUserFile $stats_dir/.htpasswd -AuthName \"Web Statistics\" -AuthType Basic -Require valid-user" > $stats_dir/.htaccess - -# Generating htaccess user and password -rm -f $stats_dir/.htpasswd -htpasswd -bc $stats_dir/.htpasswd "$stats_user" "$stats_pass" &>/dev/null -stats_crypt=$(grep $stats_user: $stats_dir/.htpasswd |cut -f 2 -d :) - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding stats user in config -update_object_value 'web' 'DOMAIN' "$domain" '$STATS_USER' "$stats_user" -update_object_value 'web' 'DOMAIN' "$domain" '$STATS_CRYPT' "$stats_crypt" - -# Logging -log_history "added password protection for web stats on $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add password protection to web domain statistics +# options: USER DOMAIN STATS_USER STATS_PASSWORD +# +# The call is used for securing the web statistics page. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +stats_user=$3 +stats_pass=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + +# Hiding password +A4='******' +EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'" +EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'" + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '4' "$#" 'USER DOMAIN STATS_USER STATS_PASS' +validate_format 'user' 'domain' 'stats_user' 'stats_pass' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Definining statistic dir +stats_dir="$HOMEDIR/$user/web/$domain/stats" + +# Adding htaccess file +echo "AuthUserFile $stats_dir/.htpasswd +AuthName \"Web Statistics\" +AuthType Basic +Require valid-user" > $stats_dir/.htaccess + +# Generating htaccess user and password +rm -f $stats_dir/.htpasswd +htpasswd -bc $stats_dir/.htpasswd "$stats_user" "$stats_pass" &>/dev/null +stats_crypt=$(grep $stats_user: $stats_dir/.htpasswd |cut -f 2 -d :) + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Adding stats user in config +update_object_value 'web' 'DOMAIN' "$domain" '$STATS_USER' "$stats_user" +update_object_value 'web' 'DOMAIN' "$domain" '$STATS_CRYPT' "$stats_crypt" + +# Logging +log_history "added password protection for web stats on $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-backup-user b/bin/v-backup-user index 2e6518e4f..da6800d75 100755 --- a/bin/v-backup-user +++ b/bin/v-backup-user @@ -1,523 +1,523 @@ -#!/bin/bash -# info: backup system user with all its objects -# options: user -# -# The call is used for backing up user with all its domains and databases. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/db.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user' -validate_format 'user' -is_system_enabled "$BACKUP_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_backup_enabled -la=$(cat /proc/loadavg |cut -f 1 -d ' '|cut -f 1 -d '.') -i=0 -while [ "$la" -ge "$BACKUP_LA_LIMIT" ]; do - echo "$(date "+%F %T") Load Average $la" - echo - sleep 60 - if [ "$i" -ge "15" ]; then - echo "Error: LA is too high" - log_event "$E_LA" "$EVENT" - exit $E_LA - fi - (( ++i)) -done - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get current time -start_time=$(date '+%s') - -# Creating temporary random directory -tmpdir=$(mktemp -p $BACKUP -d) - -# Prinitng status -echo "$(date "+%F %T") System backup for user $user" -echo "TMPDIR is $tmpdir" -echo - -# Addding backup and vesta version -echo "1.0" > $tmpdir/backup_version -echo "$VERSION" > $tmpdir/vesta_version - -# Vesta -echo "-- VESTA --" -vst='yes' -mkdir $tmpdir/vesta - -# Backingup vesta configs -echo -e "$(date "+%F %T") user.conf" - -cp -r $USER_DATA/user.conf $tmpdir/vesta/ - -if [ -e "$USER_DATA/stats.log" ]; then - echo -e "$(date "+%F %T") stats.log" - cp -r $USER_DATA/stats.log $tmpdir/vesta/ -fi - -if [ -e "$USER_DATA/history.log" ]; then - echo -e "$(date "+%F %T") history.log" - cp -r $USER_DATA/history.log $tmpdir/vesta/ -fi - -if [ -e "$USER_DATA/backup.excludes" ]; then - echo -e "$(date "+%F %T") backup.excludes" - cp -r $USER_DATA/backup.excludes $tmpdir/vesta/ -fi - -echo - -# PAM -echo "-- PAM --" -mkdir $tmpdir/pam -echo -e "$(date "+%F %T") passwd / shadow /group" -grep "^$user:" /etc/passwd > $tmpdir/pam/passwd -grep "^$user:" /etc/shadow > $tmpdir/pam/shadow -grep "^$user:" /etc/group > $tmpdir/pam/group -echo - -# Checking excludes -OLD_IFS="$IFS" -IFS=$'\n' -if [ -e "$USER_DATA/backup.excludes" ]; then - echo "-- Excludes --" - - for exclude in $(cat $USER_DATA/backup.excludes); do - echo -e "$exclude" - # Indirect variable references (a bit of black magic) - eval ${exclude%%=*}=${exclude#*=} - done - echo -fi -IFS="$OLD_IFS" - -# WEB domains -if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ] && [ "$WEB" != '*' ] -then - echo "-- WEB --" - mkdir $tmpdir/web/ - - # Parsing unsuspeneded domains - conf="$USER_DATA/web.conf" - for domain in $(search_objects 'web' 'SUSPENDED' "*" 'DOMAIN'); do - check_exl=$(echo "$WEB"|grep -w $domain) - if [ -z "$check_exl" ]; then - web_list="$web_list $domain" - fi - done - web_list=$(echo "$web_list" | sed -e "s/ */\ /g" -e "s/^ //") - - for domain in $web_list; do - echo -e "$(date "+%F %T") $domain" - mkdir -p $tmpdir/web/$domain/conf - mkdir -p $tmpdir/web/$domain/vesta - - # Defining domain variables - domain_idn=$(idn -t --quiet -a "$domain") - get_domain_values 'web' - - # Creating web.config - cd $tmpdir/web/$domain/ - conf="$USER_DATA/web.conf" - grep "DOMAIN='$domain'" $conf > vesta/web.conf - - # Apache config - if [ "$WEB_SYSTEM" = 'apache' ]; then - # Parsing httpd.conf - tpl_file="$WEBTPL/apache_$TPL.tpl" - conf="$HOMEDIR/$user/conf/web/httpd.conf" - get_web_config_brds - sed -n "$top_line,$bottom_line p" $conf > conf/httpd.conf - - # SSL check - if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/apache_$TPL.stpl" - conf="$HOMEDIR/$user/conf/web/shttpd.conf" - get_web_config_brds - sed -n "$top_line,$bottom_line p" $conf > conf/shttpd.conf - fi - fi - - # Nginx config - if [ ! -z "$NGINX" ] ; then - tpl_file="$WEBTPL/nginx_$NGINX.tpl" - conf="$HOMEDIR/$user/conf/web/nginx.conf" - get_web_config_brds - sed -n "$top_line,$bottom_line p" $conf > conf/nginx.conf - - # SSL check - if [ "$SSL" = 'yes' ] ; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web/snginx.conf" - get_web_config_brds - sed -n "$top_line,$bottom_line p" $conf > conf/snginx.conf - fi - fi - - # Suplemental configs - for sconfig in $(ls $HOMEDIR/$user/conf/web/|grep ".$domain.conf"); do - cp $HOMEDIR/$user/conf/web/$sconfig conf/ - done - - # SSL Certificates - if [ "$SSL" = 'yes' ] ; then - cp $HOMEDIR/$user/conf/web/ssl.$domain.* conf/ - cp $USER_DATA/ssl/$domain.* vesta/ - fi - - # Packing data folders - cd $HOMEDIR/$user/web/$domain - domain_direcotries=$(ls |grep -v logs) - tar -cf $tmpdir/web/$domain/domain_data.tar $domain_direcotries - - if [ ! -z "$BACKUP_GZIP" ]; then - gzip -$BACKUP_GZIP $tmpdir/web/$domain/domain_data.tar - fi - done - echo -fi - -# DNS domains -if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ] && [ "$DNS" != '*' ] -then - echo "-- DNS --" - mkdir $tmpdir/dns/ - - # Parsing unsuspeneded domains - for domain in $(search_objects 'dns' 'SUSPENDED' "*" 'DOMAIN'); do - check_exl=$(echo "$DNS"|grep -w $domain) - if [ -z "$check_exl" ]; then - dns_list="$dns_list $domain" - fi - done - dns_list=$(echo "$dns_list" | sed -e "s/ */\ /g" -e "s/^ //") - - for domain in $dns_list; do - echo -e "$(date "+%F %T") $domain" - # Building directory tree - mkdir -p $tmpdir/dns/$domain/conf - mkdir -p $tmpdir/dns/$domain/vesta - - # Creating dns_domains config - cd $tmpdir/dns/$domain/ - conf="$USER_DATA/dns.conf" - grep "DOMAIN='$domain'" $conf > vesta/dns.conf - - # Backingup dns recods - cp $USER_DATA/dns/$domain.conf vesta/$domain.conf - cp $HOMEDIR/$user/conf/dns/$domain.db conf/$domain.db - done - echo -fi - - -# Mail domains -if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ] && [ "$MAIL" != '*' ] -then - echo "-- MAIL --" - mkdir $tmpdir/mail/ - - # Parsing unsuspeneded domains - conf="$USER_DATA/mail.conf" - for domain in $(search_objects 'mail' 'SUSPENDED' "*" 'DOMAIN'); do - check_exl=$(echo "$MAIL"|grep -w $domain) - if [ -z "$check_exl" ]; then - mail_list="$mail_list $domain" - fi - done - mail_list=$(echo "$mail_list" | sed -e "s/ */\ /g" -e "s/^ //") - - for domain in $mail_list; do - echo -e "$(date "+%F %T") $domain" - #mkdir -p $tmpdir/mail/$domain/accounts - mkdir -p $tmpdir/mail/$domain/conf - mkdir -p $tmpdir/mail/$domain/vesta - - # Creating exim config - cd $tmpdir/mail/$domain/ - cp $HOMEDIR/$user/conf/mail/$domain/* conf/ - - # Creating vesta config - conf="$USER_DATA/mail.conf" - grep "DOMAIN='$domain'" $conf > vesta/mail.conf - cp $USER_DATA/mail/$domain.* vesta/ - if [ ! -z "$(ls $USER_DATA/mail/|grep *@$domain)" ]; then - cp $USER_DATA/mail/*@$domain.* vesta/ - fi - - # Packing mailboxes - cd $HOMEDIR/$user/mail/$domain - accounts=$(ls) - if [ ! -z "$accounts" ]; then - tar -cf $tmpdir/mail/$domain/accounts.tar $accounts - fi - - if [ ! -z "$BACKUP_GZIP" ] && [ ! -z $accounts ]; then - gzip -$BACKUP_GZIP $tmpdir/mail/$domain/accounts.tar - fi - done - echo -fi - - -# DatbaBases -if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ] && [ "$DB" != '*' ]; then - echo "-- DB --" - mkdir $tmpdir/db/ - - # Parsing unsuspeneded domains - for database in $(search_objects 'db' 'SUSPENDED' "*" 'DB'); do - check_exl=$(echo "$DB"|grep -w $database) - if [ -z "$check_exl" ]; then - db_list="$db_list $database" - fi - done - db_list=$(echo "$db_list" | sed -e "s/ */\ /g" -e "s/^ //") - - for database in $db_list; do - mkdir -p $tmpdir/db/$database/conf - mkdir -p $tmpdir/db/$database/vesta - cd $tmpdir/db/$database/ - - conf="$USER_DATA/db.conf" - grep "DB='$database'" $conf > vesta/db.conf - - get_database_values - dump="$tmpdir/db/$database/$database.$TYPE.sql" - grants="$tmpdir/db/$database/conf/$database.$TYPE.$DBUSER" - echo -e "$(date "+%F %T") $database $TYPE" - case $TYPE in - mysql) dump_mysql_database ;; - pgsql) dump_pgsql_database ;; - esac - if [ ! -z "$BACKUP_GZIP" ]; then - gzip -$BACKUP_GZIP $dump - fi - done - echo -fi - -# Cron jobs -if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ] && [ "$CRON" != '*' ] -then - echo "-- CRON --" - mkdir $tmpdir/cron/ - - # Backingup cron recods - echo -e "$(date "+%F %T") cron.conf" - cp $USER_DATA/cron.conf $tmpdir/cron/ - echo -e "$(date "+%F %T") system cron" - - if [ -e "/var/spool/cron/$user" ]; then - cron_list='yes' - cp /var/spool/cron/$user $tmpdir/cron/ - fi - echo -fi - -# Get backup size -size="$(du -shm $tmpdir | cut -f 1)" - -# Get current time -end_time=$(date '+%s') -DATE=$(date +%F) -TIME=$(date +%T) - - -# Defining local storage function -local_backup(){ - echo "-- STORAGE --" - echo -e "$(date "+%F %T") ARCHIVE $BACKUP/$user.$DATE.tar" - - # Removing dublicate for this day - if [ -e "$BACKUP/$user.$DATE.tar" ]; then - deprecated="$DATE" - echo -e "Deleting old backup for $DATE" - rm -f $BACKUP/$user.$DATE.tar - fi - - # Checking retention - backup_list=$(ls -lrt $BACKUP/ | awk '{print $9}' |grep "^$user\.") - backups_count=$(echo "$backup_list" | wc -l) - if [ "$BACKUPS" -le "$backups_count" ]; then - backups_rm_number=$((backups_count - BACKUPS)) - (( ++backups_rm_number)) - - for backup in $(echo "$backup_list" | head -n $backups_rm_number); do - # Removing old backup - backup_date=$(echo $backup | sed -e "s/$user.//" -e "s/.tar$//") - deprecated="$deprecated $backup_date" - echo -e "\tDeleteing old backup for $backup_date" - rm -f $BACKUP/$backup - done - fi - - # Checking disk space - disk_usage=$(df $BACKUP |tail -n1 |tr ' ' '\n' |grep % |cut -f 1 -d %) - - if [ "$disk_usage" -ge "$BACKUP_DISK_LIMIT" ]; then - echo "Error: Not enough disk space" - log_event "$E_DISK" "$EVENT" - exit $E_DISK - fi - - # Creating final tarball - cd $tmpdir - tar -cf $BACKUP/$user.$DATE.tar . - chmod 640 $BACKUP/$user.$DATE.tar - chown admin:$user $BACKUP/$user.$DATE.tar - localbackup='yes' - echo - - U_BACKUPS=$(ls $BACKUP/|grep "^$user."|wc -l) - update_user_value "$user" '$U_BACKUPS' "$U_BACKUPS" -} - - -# Defining ftp command function -ftpc() { - ftp -n $HOST $PORT <> $USER_DATA/backup.conf -chmod 660 $USER_DATA/backup.conf - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: backup system user with all its objects +# options: USER +# +# The call is used for backing up user with all its domains and databases. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh +source $VESTA/func/db.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_system_enabled "$BACKUP_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_backup_enabled +la=$(cat /proc/loadavg |cut -f 1 -d ' '|cut -f 1 -d '.') +i=0 +while [ "$la" -ge "$BACKUP_LA_LIMIT" ]; do + echo "$(date "+%F %T") Load Average $la" + echo + sleep 60 + if [ "$i" -ge "15" ]; then + echo "Error: LA is too high" + log_event "$E_LA" "$EVENT" + exit $E_LA + fi + (( ++i)) +done + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Get current time +start_time=$(date '+%s') + +# Creating temporary random directory +tmpdir=$(mktemp -p $BACKUP -d) + +# Prinitng status +echo "$(date "+%F %T") System backup for user $user" +echo "TMPDIR is $tmpdir" +echo + +# Addding backup and vesta version +echo "1.0" > $tmpdir/backup_version +echo "$VERSION" > $tmpdir/vesta_version + +# Vesta +echo "-- VESTA --" +vst='yes' +mkdir $tmpdir/vesta + +# Backingup vesta configs +echo -e "$(date "+%F %T") user.conf" + +cp -r $USER_DATA/user.conf $tmpdir/vesta/ + +if [ -e "$USER_DATA/stats.log" ]; then + echo -e "$(date "+%F %T") stats.log" + cp -r $USER_DATA/stats.log $tmpdir/vesta/ +fi + +if [ -e "$USER_DATA/history.log" ]; then + echo -e "$(date "+%F %T") history.log" + cp -r $USER_DATA/history.log $tmpdir/vesta/ +fi + +if [ -e "$USER_DATA/backup.excludes" ]; then + echo -e "$(date "+%F %T") backup.excludes" + cp -r $USER_DATA/backup.excludes $tmpdir/vesta/ +fi + +echo + +# PAM +echo "-- PAM --" +mkdir $tmpdir/pam +echo -e "$(date "+%F %T") passwd / shadow /group" +grep "^$user:" /etc/passwd > $tmpdir/pam/passwd +grep "^$user:" /etc/shadow > $tmpdir/pam/shadow +grep "^$user:" /etc/group > $tmpdir/pam/group +echo + +# Checking excludes +OLD_IFS="$IFS" +IFS=$'\n' +if [ -e "$USER_DATA/backup.excludes" ]; then + echo "-- Excludes --" + + for exclude in $(cat $USER_DATA/backup.excludes); do + echo -e "$exclude" + # Indirect variable references (a bit of black magic) + eval ${exclude%%=*}=${exclude#*=} + done + echo +fi +IFS="$OLD_IFS" + +# WEB domains +if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ] && [ "$WEB" != '*' ] +then + echo "-- WEB --" + mkdir $tmpdir/web/ + + # Parsing unsuspeneded domains + conf="$USER_DATA/web.conf" + for domain in $(search_objects 'web' 'SUSPENDED' "*" 'DOMAIN'); do + check_exl=$(echo "$WEB"|grep -w $domain) + if [ -z "$check_exl" ]; then + web_list="$web_list $domain" + fi + done + web_list=$(echo "$web_list" | sed -e "s/ */\ /g" -e "s/^ //") + + for domain in $web_list; do + echo -e "$(date "+%F %T") $domain" + mkdir -p $tmpdir/web/$domain/conf + mkdir -p $tmpdir/web/$domain/vesta + + # Defining domain variables + domain_idn=$(idn -t --quiet -a "$domain") + get_domain_values 'web' + + # Creating web.config + cd $tmpdir/web/$domain/ + conf="$USER_DATA/web.conf" + grep "DOMAIN='$domain'" $conf > vesta/web.conf + + # Apache config + if [ "$WEB_SYSTEM" = 'apache' ]; then + # Parsing httpd.conf + tpl_file="$WEBTPL/apache_$TPL.tpl" + conf="$HOMEDIR/$user/conf/web/httpd.conf" + get_web_config_brds + sed -n "$top_line,$bottom_line p" $conf > conf/httpd.conf + + # SSL check + if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" + get_web_config_brds + sed -n "$top_line,$bottom_line p" $conf > conf/shttpd.conf + fi + fi + + # Nginx config + if [ ! -z "$NGINX" ] ; then + tpl_file="$WEBTPL/nginx_$NGINX.tpl" + conf="$HOMEDIR/$user/conf/web/nginx.conf" + get_web_config_brds + sed -n "$top_line,$bottom_line p" $conf > conf/nginx.conf + + # SSL check + if [ "$SSL" = 'yes' ] ; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + get_web_config_brds + sed -n "$top_line,$bottom_line p" $conf > conf/snginx.conf + fi + fi + + # Suplemental configs + for sconfig in $(ls $HOMEDIR/$user/conf/web/|grep ".$domain.conf"); do + cp $HOMEDIR/$user/conf/web/$sconfig conf/ + done + + # SSL Certificates + if [ "$SSL" = 'yes' ] ; then + cp $HOMEDIR/$user/conf/web/ssl.$domain.* conf/ + cp $USER_DATA/ssl/$domain.* vesta/ + fi + + # Packing data folders + cd $HOMEDIR/$user/web/$domain + domain_direcotries=$(ls |grep -v logs) + tar -cf $tmpdir/web/$domain/domain_data.tar $domain_direcotries + + if [ ! -z "$BACKUP_GZIP" ]; then + gzip -$BACKUP_GZIP $tmpdir/web/$domain/domain_data.tar + fi + done + echo +fi + +# DNS domains +if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ] && [ "$DNS" != '*' ] +then + echo "-- DNS --" + mkdir $tmpdir/dns/ + + # Parsing unsuspeneded domains + for domain in $(search_objects 'dns' 'SUSPENDED' "*" 'DOMAIN'); do + check_exl=$(echo "$DNS"|grep -w $domain) + if [ -z "$check_exl" ]; then + dns_list="$dns_list $domain" + fi + done + dns_list=$(echo "$dns_list" | sed -e "s/ */\ /g" -e "s/^ //") + + for domain in $dns_list; do + echo -e "$(date "+%F %T") $domain" + # Building directory tree + mkdir -p $tmpdir/dns/$domain/conf + mkdir -p $tmpdir/dns/$domain/vesta + + # Creating dns_domains config + cd $tmpdir/dns/$domain/ + conf="$USER_DATA/dns.conf" + grep "DOMAIN='$domain'" $conf > vesta/dns.conf + + # Backingup dns recods + cp $USER_DATA/dns/$domain.conf vesta/$domain.conf + cp $HOMEDIR/$user/conf/dns/$domain.db conf/$domain.db + done + echo +fi + + +# Mail domains +if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ] && [ "$MAIL" != '*' ] +then + echo "-- MAIL --" + mkdir $tmpdir/mail/ + + # Parsing unsuspeneded domains + conf="$USER_DATA/mail.conf" + for domain in $(search_objects 'mail' 'SUSPENDED' "*" 'DOMAIN'); do + check_exl=$(echo "$MAIL"|grep -w $domain) + if [ -z "$check_exl" ]; then + mail_list="$mail_list $domain" + fi + done + mail_list=$(echo "$mail_list" | sed -e "s/ */\ /g" -e "s/^ //") + + for domain in $mail_list; do + echo -e "$(date "+%F %T") $domain" + #mkdir -p $tmpdir/mail/$domain/accounts + mkdir -p $tmpdir/mail/$domain/conf + mkdir -p $tmpdir/mail/$domain/vesta + + # Creating exim config + cd $tmpdir/mail/$domain/ + cp $HOMEDIR/$user/conf/mail/$domain/* conf/ + + # Creating vesta config + conf="$USER_DATA/mail.conf" + grep "DOMAIN='$domain'" $conf > vesta/mail.conf + cp $USER_DATA/mail/$domain.* vesta/ + if [ ! -z "$(ls $USER_DATA/mail/|grep *@$domain)" ]; then + cp $USER_DATA/mail/*@$domain.* vesta/ + fi + + # Packing mailboxes + cd $HOMEDIR/$user/mail/$domain + accounts=$(ls) + if [ ! -z "$accounts" ]; then + tar -cf $tmpdir/mail/$domain/accounts.tar $accounts + fi + + if [ ! -z "$BACKUP_GZIP" ] && [ ! -z $accounts ]; then + gzip -$BACKUP_GZIP $tmpdir/mail/$domain/accounts.tar + fi + done + echo +fi + + +# DatbaBases +if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ] && [ "$DB" != '*' ]; then + echo "-- DB --" + mkdir $tmpdir/db/ + + # Parsing unsuspeneded domains + for database in $(search_objects 'db' 'SUSPENDED' "*" 'DB'); do + check_exl=$(echo "$DB"|grep -w $database) + if [ -z "$check_exl" ]; then + db_list="$db_list $database" + fi + done + db_list=$(echo "$db_list" | sed -e "s/ */\ /g" -e "s/^ //") + + for database in $db_list; do + mkdir -p $tmpdir/db/$database/conf + mkdir -p $tmpdir/db/$database/vesta + cd $tmpdir/db/$database/ + + conf="$USER_DATA/db.conf" + grep "DB='$database'" $conf > vesta/db.conf + + get_database_values + dump="$tmpdir/db/$database/$database.$TYPE.sql" + grants="$tmpdir/db/$database/conf/$database.$TYPE.$DBUSER" + echo -e "$(date "+%F %T") $database $TYPE" + case $TYPE in + mysql) dump_mysql_database ;; + pgsql) dump_pgsql_database ;; + esac + if [ ! -z "$BACKUP_GZIP" ]; then + gzip -$BACKUP_GZIP $dump + fi + done + echo +fi + +# Cron jobs +if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ] && [ "$CRON" != '*' ] +then + echo "-- CRON --" + mkdir $tmpdir/cron/ + + # Backingup cron recods + echo -e "$(date "+%F %T") cron.conf" + cp $USER_DATA/cron.conf $tmpdir/cron/ + echo -e "$(date "+%F %T") system cron" + + if [ -e "/var/spool/cron/$user" ]; then + cron_list='yes' + cp /var/spool/cron/$user $tmpdir/cron/ + fi + echo +fi + +# Get backup size +size="$(du -shm $tmpdir | cut -f 1)" + +# Get current time +end_time=$(date '+%s') +DATE=$(date +%F) +TIME=$(date +%T) + + +# Defining local storage function +local_backup(){ + echo "-- STORAGE --" + echo -e "$(date "+%F %T") ARCHIVE $BACKUP/$user.$DATE.tar" + + # Removing dublicate for this day + if [ -e "$BACKUP/$user.$DATE.tar" ]; then + deprecated="$DATE" + echo -e "Deleting old backup for $DATE" + rm -f $BACKUP/$user.$DATE.tar + fi + + # Checking retention + backup_list=$(ls -lrt $BACKUP/ | awk '{print $9}' |grep "^$user\.") + backups_count=$(echo "$backup_list" | wc -l) + if [ "$BACKUPS" -le "$backups_count" ]; then + backups_rm_number=$((backups_count - BACKUPS)) + (( ++backups_rm_number)) + + for backup in $(echo "$backup_list" | head -n $backups_rm_number); do + # Removing old backup + backup_date=$(echo $backup | sed -e "s/$user.//" -e "s/.tar$//") + deprecated="$deprecated $backup_date" + echo -e "\tDeleteing old backup for $backup_date" + rm -f $BACKUP/$backup + done + fi + + # Checking disk space + disk_usage=$(df $BACKUP |tail -n1 |tr ' ' '\n' |grep % |cut -f 1 -d %) + + if [ "$disk_usage" -ge "$BACKUP_DISK_LIMIT" ]; then + echo "Error: Not enough disk space" + log_event "$E_DISK" "$EVENT" + exit $E_DISK + fi + + # Creating final tarball + cd $tmpdir + tar -cf $BACKUP/$user.$DATE.tar . + chmod 640 $BACKUP/$user.$DATE.tar + chown admin:$user $BACKUP/$user.$DATE.tar + localbackup='yes' + echo + + U_BACKUPS=$(ls $BACKUP/|grep "^$user."|wc -l) + update_user_value "$user" '$U_BACKUPS' "$U_BACKUPS" +} + + +# Defining ftp command function +ftpc() { + ftp -n $HOST $PORT <> $USER_DATA/backup.conf +chmod 660 $USER_DATA/backup.conf + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-backup-users b/bin/v-backup-users index fd33721bf..6dd888197 100755 --- a/bin/v-backup-users +++ b/bin/v-backup-users @@ -1,39 +1,39 @@ -#!/bin/bash -# info: backup all users -# options: none -# -# The function backups all system users. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Importing system enviroment as we run this script -# mostly by cron wich not read it by itself -source /etc/profile - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -for user in $(ls $VESTA/data/users); do - check_suspend=$(grep "SUSPENDED='no'" $VESTA/data/users/$user/user.conf) - if [ ! -z "$check_suspend" ]; then - $BIN/v-backup-user $user >> $VESTA/log/backup.log 2>&1 - fi -done - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# No Logging -#log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: backup all users +# options: NONE +# +# The function backups all system users. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Importing system enviroment as we run this script +# mostly by cron wich not read it by itself +source /etc/profile + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +for user in $(ls $VESTA/data/users); do + check_suspend=$(grep "SUSPENDED='no'" $VESTA/data/users/$user/user.conf) + if [ ! -z "$check_suspend" ]; then + $BIN/v-backup-user $user >> $VESTA/log/backup.log 2>&1 + fi +done + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# No Logging +#log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-cron-job b/bin/v-change-cron-job index 00d300dee..6274aca7b 100755 --- a/bin/v-change-cron-job +++ b/bin/v-change-cron-job @@ -1,73 +1,73 @@ -#!/bin/bash -# info: change cron job -# options: user job min hour day month wday command -# -# The function is used for changing existing job. It fully replace job -# parameters with new one but with same id. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -job=$2 -min=$3 -hour=$4 -day=$5 -month=$6 -wday=$7 -command=$8 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '7' "$#" 'user job min hour day month wday command' -validate_format 'user' 'job' 'min' 'hour' 'day' 'month' 'wday' 'command' -is_system_enabled $CRON_SYSTEM -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'cron' 'JOB' "$job" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Concatenating cron string -command=$(echo $command | sed -e "s/'/%quote%/g" -e "s/:/%dots%/g") -str="JOB='$job' MIN='$min' HOUR='$hour' DAY='$day' MONTH='$month' WDAY='$wday'" -str="$str CMD='$command' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" - -# Deleting old job -sed -i "/JOB='$job' /d" $USER_DATA/cron.conf - -# Adding new -echo "$str" >> $USER_DATA/cron.conf - -# Sorting jobs by id -sort_cron_jobs - -# Sync system cron with user -sync_cron_jobs - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart crond -$BIN/v-restart-cron "$EVENT" - -# Logging -log_history "changed cron job $job" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change cron job +# options: USER JOB MIN HOUR DAY MONTH WDAY COMMAND +# +# The function is used for changing existing job. It fully replace job +# parameters with new one but with same id. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +job=$2 +min=$3 +hour=$4 +day=$5 +month=$6 +wday=$7 +command=$8 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '7' "$#" 'USER JOB MIN HOUR DAY MONTH WDAY COMMAND' +validate_format 'user' 'job' 'min' 'hour' 'day' 'month' 'wday' 'command' +is_system_enabled $CRON_SYSTEM +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'cron' 'JOB' "$job" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Concatenating cron string +command=$(echo $command | sed -e "s/'/%quote%/g" -e "s/:/%dots%/g") +str="JOB='$job' MIN='$min' HOUR='$hour' DAY='$day' MONTH='$month' WDAY='$wday'" +str="$str CMD='$command' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" + +# Deleting old job +sed -i "/JOB='$job' /d" $USER_DATA/cron.conf + +# Adding new +echo "$str" >> $USER_DATA/cron.conf + +# Sorting jobs by id +sort_cron_jobs + +# Sync system cron with user +sync_cron_jobs + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart crond +$BIN/v-restart-cron "$EVENT" + +# Logging +log_history "changed cron job $job" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-database-password b/bin/v-change-database-password index a4ffdbc1c..507c7e9af 100755 --- a/bin/v-change-database-password +++ b/bin/v-change-database-password @@ -1,65 +1,65 @@ -#!/bin/bash -# info: change database password -# options: user database dbpass -# -# The function for changing database user password to a database. It uses the -# full name of database as argument. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -database=$2 -dbpass=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/db.sh - -# Hiding password -A3='******' -EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'" -EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'" - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user database dbpass' -validate_format 'user' 'database' 'dbpass' -is_system_enabled "$DB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'db' 'DB' "$database" -is_object_unsuspended 'db' 'DB' "$database" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# -# Get database values -get_database_values - -case $TYPE in - mysql) change_mysql_password ;; - pgsql) change_pgsql_password ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config value -update_object_value 'db' 'DB' "$database" '$MD5' "$md5" - -# Logging -log_history "changed $database database password" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change database password +# options: USER DATABASE DBPASS +# +# The function for changing database user password to a database. It uses the +# full name of database as argument. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +database=$2 +dbpass=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/db.sh + +# Hiding password +A3='******' +EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'" +EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'" + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DATABASE DBPASS' +validate_format 'user' 'database' 'dbpass' +is_system_enabled "$DB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'db' 'DB' "$database" +is_object_unsuspended 'db' 'DB' "$database" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# +# Get database values +get_database_values + +case $TYPE in + mysql) change_mysql_password ;; + pgsql) change_pgsql_password ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config value +update_object_value 'db' 'DB' "$database" '$MD5' "$md5" + +# Logging +log_history "changed $database database password" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-dns-domain-exp b/bin/v-change-dns-domain-exp index 8ee2c0ae3..7f7647b63 100755 --- a/bin/v-change-dns-domain-exp +++ b/bin/v-change-dns-domain-exp @@ -1,53 +1,53 @@ -#!/bin/bash -# info: change dns domain expiriation date -# options: user domain exp -# -# The function of changing the term of expiration domain's registration. The -# serial number will be refreshed automatically during update. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -exp=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user domain exp' -validate_format 'user' 'domain' 'exp' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing exp -update_object_value 'dns' 'DOMAIN' "$domain" '$EXP' "$exp" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "changed whois expiriation date for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change dns domain expiriation date +# options: USER DOMAIN EXP +# +# The function of changing the term of expiration domain's registration. The +# serial number will be refreshed automatically during update. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +exp=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN EXP' +validate_format 'user' 'domain' 'exp' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" +is_object_unsuspended 'dns' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Changing exp +update_object_value 'dns' 'DOMAIN' "$domain" '$EXP' "$exp" + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_history "changed whois expiriation date for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-dns-domain-ip b/bin/v-change-dns-domain-ip index ce671b045..13ae9c7f8 100755 --- a/bin/v-change-dns-domain-ip +++ b/bin/v-change-dns-domain-ip @@ -1,69 +1,69 @@ -#!/bin/bash -# info: change dns domain ip address -# options: user domain ip -# -# The function for changing the main ip of DNS zone. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -ip=$3 -restart=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user domain ip' -validate_format 'user' 'domain' 'ip' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get old ip -get_domain_values 'dns' -old=$IP - -# Changing ip -update_object_value 'dns' 'DOMAIN' "$domain" '$IP' "$ip" - -# Changing records -sed -i "s/$old/$ip/g" $USER_DATA/dns/$domain.conf - -# Updating zone -update_domain_zone - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart named -if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" -fi - -# Logging -log_history "changed dns ip for $domain to $ip" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change dns domain ip address +# options: USER DOMAIN IP +# +# The function for changing the main ip of DNS zone. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +ip=$3 +restart=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN IP' +validate_format 'user' 'domain' 'ip' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" +is_object_unsuspended 'dns' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Get old ip +get_domain_values 'dns' +old=$IP + +# Changing ip +update_object_value 'dns' 'DOMAIN' "$domain" '$IP' "$ip" + +# Changing records +sed -i "s/$old/$ip/g" $USER_DATA/dns/$domain.conf + +# Updating zone +update_domain_zone + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart named +if [ "$restart" != 'no' ]; then + $BIN/v-restart-dns "$EVENT" +fi + +# Logging +log_history "changed dns ip for $domain to $ip" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-dns-domain-record b/bin/v-change-dns-domain-record index a694b9cb6..2134bfa73 100755 --- a/bin/v-change-dns-domain-record +++ b/bin/v-change-dns-domain-record @@ -1,77 +1,77 @@ -#!/bin/bash -# info: change dns domain record -# options: user domain id value [priority] -# -# The function for changing DNS record. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -id=$3 -dvalue=$(idn -t --quiet -u "$4" ) -dvalue=$(echo $dvalue | tr '[:upper:]' '[:lower:]') -priority=$5 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'user domain id value [priority]' -validate_format 'user' 'domain' 'id' 'dvalue' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" -is_object_valid "dns/$domain" 'ID' "$id" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting old record -line=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf) -eval $line -if [ "$TYPE" != 'MX' ] && [ "$TYPE" != 'SRV' ]; then - priority='' -fi -sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf - -# Adding record -dns_rec="ID='$id' RECORD='$RECORD' TYPE='$TYPE' PRIORITY='$priority'" -dns_rec="$dns_rec VALUE='$dvalue' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" -echo "$dns_rec" >> $USER_DATA/dns/$domain.conf - -# Sorting records -sort_dns_records - -# Updating zone -update_domain_zone - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart named -$BIN/v-restart-dns "$EVENT" - -# Logging -log_history "changed dns record on $domain to $dvalue" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change dns domain record +# options: USER DOMAIN ID VALUE [PRIORITY] +# +# The function for changing DNS record. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +id=$3 +dvalue=$(idn -t --quiet -u "$4" ) +dvalue=$(echo $dvalue | tr '[:upper:]' '[:lower:]') +priority=$5 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '4' "$#" 'USER DOMAIN ID VALUE [PRIORITY]' +validate_format 'user' 'domain' 'id' 'dvalue' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" +is_object_unsuspended 'dns' 'DOMAIN' "$domain" +is_object_valid "dns/$domain" 'ID' "$id" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Deleting old record +line=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf) +eval $line +if [ "$TYPE" != 'MX' ] && [ "$TYPE" != 'SRV' ]; then + priority='' +fi +sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf + +# Adding record +dns_rec="ID='$id' RECORD='$RECORD' TYPE='$TYPE' PRIORITY='$priority'" +dns_rec="$dns_rec VALUE='$dvalue' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" +echo "$dns_rec" >> $USER_DATA/dns/$domain.conf + +# Sorting records +sort_dns_records + +# Updating zone +update_domain_zone + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart named +$BIN/v-restart-dns "$EVENT" + +# Logging +log_history "changed dns record on $domain to $dvalue" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-dns-domain-soa b/bin/v-change-dns-domain-soa index 867fd32ea..f7b040ae5 100755 --- a/bin/v-change-dns-domain-soa +++ b/bin/v-change-dns-domain-soa @@ -1,63 +1,63 @@ -#!/bin/bash -# info: change dns domain soa record -# options: user domain soa -# -# The function for changing SOA record. This type of records can not be -# modified by v-change-dns-domain-record call. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -soa=$(echo $3 | sed -e 's/\.*$//g' -e 's/^\.*//g') -restart=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user domain soa' -validate_format 'user' 'domain' 'soa' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing soa -update_object_value 'dns' 'DOMAIN' "$domain" '$SOA' "$soa" - -# Updating zone -update_domain_zone - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart named -if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" -fi - -# Logging -log_history "changed soa record for $domain to $soa" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change dns domain soa record +# options: USER DOMAIN SOA +# +# The function for changing SOA record. This type of records can not be +# modified by v-change-dns-domain-record call. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +soa=$(echo $3 | sed -e 's/\.*$//g' -e 's/^\.*//g') +restart=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN SOA' +validate_format 'user' 'domain' 'soa' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" +is_object_unsuspended 'dns' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Changing soa +update_object_value 'dns' 'DOMAIN' "$domain" '$SOA' "$soa" + +# Updating zone +update_domain_zone + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart named +if [ "$restart" != 'no' ]; then + $BIN/v-restart-dns "$EVENT" +fi + +# Logging +log_history "changed soa record for $domain to $soa" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-dns-domain-tpl b/bin/v-change-dns-domain-tpl index 00d3752b2..770150c44 100755 --- a/bin/v-change-dns-domain-tpl +++ b/bin/v-change-dns-domain-tpl @@ -1,84 +1,84 @@ -#!/bin/bash -# info: change dns domain template -# options: user domain -# -# The function for changing the template of records. By updating old records -# will be removed and new records will be generated in accordance with -# parameters of new template. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -template=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user domain template' -validate_format 'user' 'domain' 'template' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" -is_dns_template_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining variables -ip=$(get_object_value 'dns' 'DOMAIN' "$domain" '$IP') - -i=1 -ns=$(get_user_value '$NS') -for nameserver in ${ns//,/ };do - eval ns$i=$nameserver - (( ++i)) -done - -# Changing tpl -update_object_value 'dns' 'DOMAIN' "$domain" '$TPL' "$template" - -# Adding zone to dns dir -cat $DNSTPL/$template.tpl |\ - sed -e "s/%ip%/$ip/g" \ - -e "s/%domain_idn%/$domain_idn/g" \ - -e "s/%domain%/$domain/g" \ - -e "s/%ns1%/$ns1/g" \ - -e "s/%ns2%/$ns2/g" \ - -e "s/%ns3%/$ns3/g" \ - -e "s/%ns4%/$ns4/g" \ - -e "s/%time%/$TIME/g" \ - -e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain.conf - -# Updating zone -update_domain_zone - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart named -$BIN/v-restart-dns "$EVENT" - -# Logging -log_history "changed dns template for $domain to $template" '' 'admin' -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change dns domain template +# options: USER DOMAIN +# +# The function for changing the template of records. By updating old records +# will be removed and new records will be generated in accordance with +# parameters of new template. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +template=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN TEMPLATE' +validate_format 'user' 'domain' 'template' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" +is_object_unsuspended 'dns' 'DOMAIN' "$domain" +is_dns_template_valid + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining variables +ip=$(get_object_value 'dns' 'DOMAIN' "$domain" '$IP') + +i=1 +ns=$(get_user_value '$NS') +for nameserver in ${ns//,/ };do + eval ns$i=$nameserver + (( ++i)) +done + +# Changing tpl +update_object_value 'dns' 'DOMAIN' "$domain" '$TPL' "$template" + +# Adding zone to dns dir +cat $DNSTPL/$template.tpl |\ + sed -e "s/%ip%/$ip/g" \ + -e "s/%domain_idn%/$domain_idn/g" \ + -e "s/%domain%/$domain/g" \ + -e "s/%ns1%/$ns1/g" \ + -e "s/%ns2%/$ns2/g" \ + -e "s/%ns3%/$ns3/g" \ + -e "s/%ns4%/$ns4/g" \ + -e "s/%time%/$TIME/g" \ + -e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain.conf + +# Updating zone +update_domain_zone + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart named +$BIN/v-restart-dns "$EVENT" + +# Logging +log_history "changed dns template for $domain to $template" '' 'admin' +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-dns-domain-ttl b/bin/v-change-dns-domain-ttl index f99e94927..17656ce52 100755 --- a/bin/v-change-dns-domain-ttl +++ b/bin/v-change-dns-domain-ttl @@ -1,62 +1,62 @@ -#!/bin/bash -# info: change dns domain ttl -# options: user domain ttl -# -# The function for chaning the time to live TTL parameter for all records. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -ttl=$3 -restart=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user domain ttl' -validate_format 'user' 'domain' 'ttl' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing ttl -update_object_value 'dns' 'DOMAIN' "$domain" '$TTL' "$ttl" - -# Updating zone -update_domain_zone - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart named -if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" -fi - -# Logging -log_history "changed TTL for $domain to $ttl" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change dns domain ttl +# options: USER DOMAIN TTL +# +# The function for chaning the time to live TTL parameter for all records. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +ttl=$3 +restart=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN TTL' +validate_format 'user' 'domain' 'ttl' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" +is_object_unsuspended 'dns' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Changing ttl +update_object_value 'dns' 'DOMAIN' "$domain" '$TTL' "$ttl" + +# Updating zone +update_domain_zone + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart named +if [ "$restart" != 'no' ]; then + $BIN/v-restart-dns "$EVENT" +fi + +# Logging +log_history "changed TTL for $domain to $ttl" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-mail-account-password b/bin/v-change-mail-account-password index ec071057e..55b855535 100755 --- a/bin/v-change-mail-account-password +++ b/bin/v-change-mail-account-password @@ -1,72 +1,72 @@ -#!/bin/bash -# info: change mail account password -# options: user domain account password -# -# The function changes email account password. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -account=$3 -password=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - -# Hiding password -A4='******' -EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'" -EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'" - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'user domain account password' -validate_format 'user' 'domain' 'account' 'password' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -if [ -x '/usr/bin/doveadm' ]; then - md5=$(/usr/bin/doveadm pw -s md5 -p "$password") -else - md5=$(/usr/sbin/dovecotpw -s md5 -p "$password") -fi - -sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd -str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota" -echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update md5 -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$MD5' "$md5" - -# Logging -log_history "changed password for $account@$domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change mail account password +# options: USER DOMAIN ACCOUNT PASSWORD +# +# The function changes email account password. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +account=$3 +password=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + +# Hiding password +A4='******' +EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'" +EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'" + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '4' "$#" 'USER DOMAIN ACCOUNT PASSWORD' +validate_format 'user' 'domain' 'account' 'password' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_valid "mail/$domain" 'ACCOUNT' "$account" +is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +if [ -x '/usr/bin/doveadm' ]; then + md5=$(/usr/bin/doveadm pw -s md5 -p "$password") +else + md5=$(/usr/sbin/dovecotpw -s md5 -p "$password") +fi + +sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd +str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota" +echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update md5 +update_object_value "mail/$domain" 'ACCOUNT' "$account" '$MD5' "$md5" + +# Logging +log_history "changed password for $account@$domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-mail-account-quota b/bin/v-change-mail-account-quota index 005c7e28e..ce1e1e00b 100755 --- a/bin/v-change-mail-account-quota +++ b/bin/v-change-mail-account-quota @@ -1,62 +1,62 @@ -#!/bin/bash -# info: change mail account quota -# options: user domain account quota -# -# The function changes email account disk quota. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -account=$3 -quota=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'user domain account quota' -validate_format 'user' 'domain' 'account' 'quota' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -md5=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$MD5') -sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd -str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota" -echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update quota -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$QUOTA' "$quota" - -# Logging -log_history "changed mail quota for $account@$domain to $quota" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change mail account quota +# options: USER DOMAIN ACCOUNT QUOTA +# +# The function changes email account disk quota. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +account=$3 +quota=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '4' "$#" 'USER DOMAIN ACCOUNT QUOTA' +validate_format 'user' 'domain' 'account' 'quota' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_valid "mail/$domain" 'ACCOUNT' "$account" +is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +md5=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$MD5') +sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd +str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota" +echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update quota +update_object_value "mail/$domain" 'ACCOUNT' "$account" '$QUOTA' "$quota" + +# Logging +log_history "changed mail quota for $account@$domain to $quota" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-mail-domain-catchall b/bin/v-change-mail-domain-catchall index 2f50baa9b..65528a4a1 100755 --- a/bin/v-change-mail-domain-catchall +++ b/bin/v-change-mail-domain-catchall @@ -1,59 +1,59 @@ -#!/bin/bash -# info: change mail domain catchall email -# options: user domain email -# -# The function changes mail domain cathcall. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -email="$3" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user domain email' -validate_format 'user' 'domain' 'email' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Change cathcall alias -sed -i "/*@$domain:/d" $HOMEDIR/$user/conf/mail/$domain/aliases -echo "*@$domain:$email" >> $HOMEDIR/$user/conf/mail/$domain/aliases - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Change catchall in config -update_object_value 'mail' 'DOMAIN' "$domain" '$CATCHALL' "$email" - - -# Logging -log_history "changed catchall email for $domain to $email" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change mail domain catchall email +# options: USER DOMAIN EMAIL +# +# The function changes mail domain cathcall. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +email="$3" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN EMAIL' +validate_format 'user' 'domain' 'email' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Change cathcall alias +sed -i "/*@$domain:/d" $HOMEDIR/$user/conf/mail/$domain/aliases +echo "*@$domain:$email" >> $HOMEDIR/$user/conf/mail/$domain/aliases + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Change catchall in config +update_object_value 'mail' 'DOMAIN' "$domain" '$CATCHALL' "$email" + + +# Logging +log_history "changed catchall email for $domain to $email" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-sys-config-value b/bin/v-change-sys-config-value index e2fca61e6..c318da1de 100755 --- a/bin/v-change-sys-config-value +++ b/bin/v-change-sys-config-value @@ -1,51 +1,51 @@ -#!/bin/bash -# info: change sysconfig value -# options: key value -# -# The function is for changing main config settings such as COMPANY_NAME or -# COMPANY_EMAIL and so on. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -key=$(echo "$1" | tr '[:lower:]' '[:upper:]' ) -value=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'key value' -validate_format 'key' -check_ckey=$(grep "^$key='" $VESTA/conf/vesta.conf) -if [ -z "$check_ckey" ]; then - echo "Error: key $key not found" - log_event "$E_INVALID" "$EVENT" - exit $E_INVALID -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Updating conf -sed -i "s/$key=.*/$key='$value'/g" $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change sysconfig value +# options: KEY VALUE +# +# The function is for changing main config settings such as COMPANY_NAME or +# COMPANY_EMAIL and so on. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +key=$(echo "$1" | tr '[:lower:]' '[:upper:]' ) +value=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'KEY VALUE' +validate_format 'key' +check_ckey=$(grep "^$key='" $VESTA/conf/vesta.conf) +if [ -z "$check_ckey" ]; then + echo "Error: key $key not found" + log_event "$E_INVALID" "$EVENT" + exit $E_INVALID +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Updating conf +sed -i "s/$key=.*/$key='$value'/g" $VESTA/conf/vesta.conf + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-sys-ip-name b/bin/v-change-sys-ip-name index dfb6b9546..4ecbffd7f 100755 --- a/bin/v-change-sys-ip-name +++ b/bin/v-change-sys-ip-name @@ -1,47 +1,47 @@ -#!/bin/bash -# info: change ip name -# options: ip name -# -# The function for changing dns domain associated with ip. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -ip=$1 -ip_name=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/ip.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'ip ip_name' -validate_format 'ip' 'ip_name' -is_ip_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing ip name -update_ip_value '$NAME' "$ip_name" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "changed associated dns on $ip to $domain" '' 'admin' -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change ip name +# options: IP NAME +# +# The function for changing dns domain associated with ip. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +ip=$1 +ip_name=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/ip.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'IP IP_NAME' +validate_format 'ip' 'ip_name' +is_ip_valid + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Changing ip name +update_ip_value '$NAME' "$ip_name" + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_history "changed associated dns on $ip to $domain" '' 'admin' +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-sys-ip-owner b/bin/v-change-sys-ip-owner index 105c4ad24..47c171388 100755 --- a/bin/v-change-sys-ip-owner +++ b/bin/v-change-sys-ip-owner @@ -1,81 +1,81 @@ -#!/bin/bash -# info: change ip owner -# options: ip user -# -# The function of changing ip address ownership. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -ip=$1 -user=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/ip.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'ip user' -validate_format 'ip' 'user' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_ip_valid -is_ip_key_empty '$U_WEB_DOMAINS' -is_ip_key_empty '$U_SYS_USERS' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing ip owner -ip_owner=$(get_ip_value '$OWNER') -if [ "$ip_owner" != "$user" ]; then - ip_status="$(get_ip_value '$STATUS')" - update_ip_value '$OWNER' "$user" - decrease_user_value "$ip_owner" '$IP_OWNED' - if [ "$ip_owner" = 'admin' ]; then - if [ "$ip_status" = 'shared' ]; then - for vesta_user in $(ls $VESTA/data/users); do - decrease_user_value "$vesta_user" '$IP_AVAIL' - done - else - decrease_user_value 'admin' '$IP_AVAIL' - fi - else - decrease_user_value "$ip_owner" '$IP_AVAIL' - decrease_user_value 'admin' '$IP_AVAIL' - fi - - increase_user_value "$user" '$IP_OWNED' - if [ "$user" = 'admin' ]; then - if [ "$ip_status" = 'shared' ]; then - for user in $(ls $VESTA/data/users); do - increase_user_value "$user" '$IP_AVAIL' - done - else - increase_user_value 'admin' '$IP_AVAIL' - fi - else - increase_user_value "$user" '$IP_AVAIL' - increase_user_value 'admin' '$IP_AVAIL' - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "changed owner of $ip to $user" '' 'admin' -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change ip owner +# options: IP USER +# +# The function of changing ip address ownership. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +ip=$1 +user=$2 + +# Includes +source $VESTA/func/main.sh +source $VESTA/func/ip.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'IP USER' +validate_format 'ip' 'user' +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_ip_valid +is_ip_key_empty '$U_WEB_DOMAINS' +is_ip_key_empty '$U_SYS_USERS' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Changing ip owner +ip_owner=$(get_ip_value '$OWNER') +if [ "$ip_owner" != "$user" ]; then + ip_status="$(get_ip_value '$STATUS')" + update_ip_value '$OWNER' "$user" + decrease_user_value "$ip_owner" '$IP_OWNED' + if [ "$ip_owner" = 'admin' ]; then + if [ "$ip_status" = 'shared' ]; then + for vesta_user in $(ls $VESTA/data/users); do + decrease_user_value "$vesta_user" '$IP_AVAIL' + done + else + decrease_user_value 'admin' '$IP_AVAIL' + fi + else + decrease_user_value "$ip_owner" '$IP_AVAIL' + decrease_user_value 'admin' '$IP_AVAIL' + fi + + increase_user_value "$user" '$IP_OWNED' + if [ "$user" = 'admin' ]; then + if [ "$ip_status" = 'shared' ]; then + for user in $(ls $VESTA/data/users); do + increase_user_value "$user" '$IP_AVAIL' + done + else + increase_user_value 'admin' '$IP_AVAIL' + fi + else + increase_user_value "$user" '$IP_AVAIL' + increase_user_value 'admin' '$IP_AVAIL' + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_history "changed owner of $ip to $user" '' 'admin' +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-sys-ip-status b/bin/v-change-sys-ip-status index e498895f7..40d5713a5 100755 --- a/bin/v-change-sys-ip-status +++ b/bin/v-change-sys-ip-status @@ -1,60 +1,60 @@ -#!/bin/bash -# info: change ip status -# options: ip ip_status -# -# The function of changing an ip address's status. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -ip=$1 -ip_status=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/ip.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'ip ip_status' -validate_format 'ip' 'ip_status' -is_ip_valid -if [ "$ip_status" = "$(get_ip_value '$STATUS')" ]; then - echo "Error: status $ip_status is already set" - log_event "$E_EXISTS" "$EVENT" - exit $E_EXISTS -fi - -web_domains=$(get_ip_value '$U_WEB_DOMAINS') -sys_user=$(get_ip_value '$U_SYS_USERS') -ip_owner=$(get_ip_value '$OWNER') -if [ "$web_domains" -ne '0' ] && [ "$sys_user" != "$ip_owner" ]; then - echo "Error: ip $ip is used" - log_event "$E_INUSE" "$EVENT" - exit $E_INUSE -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing ip name -update_ip_value '$STATUS' "$ip_status" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "changed $ip status to $ip_status" '' 'admin' -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change ip status +# options: IP IP_STATUS +# +# The function of changing an ip address's status. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +ip=$1 +ip_status=$2 + +# Includes +source $VESTA/func/main.sh +source $VESTA/func/ip.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'IP IP_STATUS' +validate_format 'ip' 'ip_status' +is_ip_valid +if [ "$ip_status" = "$(get_ip_value '$STATUS')" ]; then + echo "Error: status $ip_status is already set" + log_event "$E_EXISTS" "$EVENT" + exit $E_EXISTS +fi + +web_domains=$(get_ip_value '$U_WEB_DOMAINS') +sys_user=$(get_ip_value '$U_SYS_USERS') +ip_owner=$(get_ip_value '$OWNER') +if [ "$web_domains" -ne '0' ] && [ "$sys_user" != "$ip_owner" ]; then + echo "Error: ip $ip is used" + log_event "$E_INUSE" "$EVENT" + exit $E_INUSE +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Changing ip name +update_ip_value '$STATUS' "$ip_status" + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_history "changed $ip status to $ip_status" '' 'admin' +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-user-contact b/bin/v-change-user-contact index a0883e64e..81da8e5be 100755 --- a/bin/v-change-user-contact +++ b/bin/v-change-user-contact @@ -1,51 +1,51 @@ -#!/bin/bash -# info: change user contact email -# options: user email -# -# The function for changing of e-mail associated with a certain user. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -email=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user email' -validate_format 'user' 'email' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing user contact email -old_email=$(get_user_value '$CONTACT') -update_user_value "$user" '$CONTACT' "$email" -pw_str=$(grep -n "^$user:" /etc/passwd) -str=$(echo "$pw_str" | cut -f 1 -d :) -sed -i "$str s/$old_email/$email/g" /etc/passwd - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "changed contact email to $email" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change user contact email +# options: USER EMAIL +# +# The function for changing of e-mail associated with a certain user. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +email=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER EMAIL' +validate_format 'user' 'email' +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Changing user contact email +old_email=$(get_user_value '$CONTACT') +update_user_value "$user" '$CONTACT' "$email" +pw_str=$(grep -n "^$user:" /etc/passwd) +str=$(echo "$pw_str" | cut -f 1 -d :) +sed -i "$str s/$old_email/$email/g" /etc/passwd + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_history "changed contact email to $email" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-user-name b/bin/v-change-user-name index 833a59fdc..8e32f2d86 100755 --- a/bin/v-change-user-name +++ b/bin/v-change-user-name @@ -1,53 +1,53 @@ -#!/bin/bash -# info: change user full name -# options: user fname lname -# -# The function allow to change user's full name. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -fname=$2 -lname=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user fname lname' -validate_format 'user' 'fname' 'lname' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get old values -old_fname=$(get_user_value '$FNAME') -old_lname=$(get_user_value '$LNAME') - -# Changing ns values -update_user_value "$user" '$FNAME' "$fname" -update_user_value "$user" '$LNAME' "$lname" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "changed user name to $fname $lname" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change user full name +# options: USER FNAME LNAME +# +# The function allow to change user's full name. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +fname=$2 +lname=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER FNAME LNAME' +validate_format 'user' 'fname' 'lname' +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Get old values +old_fname=$(get_user_value '$FNAME') +old_lname=$(get_user_value '$LNAME') + +# Changing ns values +update_user_value "$user" '$FNAME' "$fname" +update_user_value "$user" '$LNAME' "$lname" + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_history "changed user name to $fname $lname" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-user-ns b/bin/v-change-user-ns index 9decfa804..6d8af7ec5 100755 --- a/bin/v-change-user-ns +++ b/bin/v-change-user-ns @@ -1,66 +1,66 @@ -#!/bin/bash -# info: change user nameservers -# options: user ns1 ns2 [ns3] [ns4] -# -# The function for changing default nameservers for speciefic user. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -ns1=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g') -ns2=$(echo $3 | sed -e 's/\.*$//g' -e 's/^\.*//g') -ns3=$4 -ns4=$5 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -# Checking args -check_args '3' "$#" 'user ns1 ns2 [ns3] [ns4]' - -# Checking argument format -validate_format 'user' 'ns1' 'ns2' -if [ ! -z "$ns3" ]; then - ns3=$(echo $4 | sed -e 's/\.*$//g' -e 's/^\.*//g') - validate_format 'ns3' -fi -if [ ! -z "$ns4" ]; then - ns4=$(echo $5 | sed -e 's/\.*$//g' -e 's/^\.*//g') - validate_format 'ns4' -fi - -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Merging values -ns="$ns1,$ns2,$ns3,$ns4" -ns=$(echo "$ns"|sed -e "s/,,//g" -e "s/,$//") - -# Changing ns values -update_user_value "$user" '$NS' "$ns" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "changed user nameservers to $ns1, $ns2" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change user nameservers +# options: USER NS1 NS2 [NS3] [NS4] +# +# The function for changing default nameservers for speciefic user. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +ns1=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g') +ns2=$(echo $3 | sed -e 's/\.*$//g' -e 's/^\.*//g') +ns3=$4 +ns4=$5 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +# Checking args +check_args '3' "$#" 'USER NS1 NS2 [NS3] [NS4]' + +# Checking argument format +validate_format 'user' 'ns1' 'ns2' +if [ ! -z "$ns3" ]; then + ns3=$(echo $4 | sed -e 's/\.*$//g' -e 's/^\.*//g') + validate_format 'ns3' +fi +if [ ! -z "$ns4" ]; then + ns4=$(echo $5 | sed -e 's/\.*$//g' -e 's/^\.*//g') + validate_format 'ns4' +fi + +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Merging values +ns="$ns1,$ns2,$ns3,$ns4" +ns=$(echo "$ns"|sed -e "s/,,//g" -e "s/,$//") + +# Changing ns values +update_user_value "$user" '$NS' "$ns" + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_history "changed user nameservers to $ns1, $ns2" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-user-package b/bin/v-change-user-package index 1ad24352d..3480fc119 100755 --- a/bin/v-change-user-package +++ b/bin/v-change-user-package @@ -1,144 +1,144 @@ -#!/bin/bash -# info: change user package -# options: user package [force] -# -# The function changes user's hosting package. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -package=$2 -force=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - -is_package_avalable() { - # Parsing user data - usr_data=$(cat $USER_DATA/user.conf) - IFS=$'\n' - for key in $usr_data; do - eval ${key%%=*}=${key#*=} - done - - WEB_DOMAINS='0' - DATABASES='0' - MAIL_DOMAINS='0' - DNS_DOMAINS='0' - DISK_QUOTA='0' - BANDWIDTH='0' - - pkg_data=$(cat $VESTA/data/packages/$package.pkg |grep -v TIME |\ - grep -v DATE) - eval $pkg_data - - # Comparing user data with package - if [[ "$WEB_DOMAINS" -lt "$U_WEB_DOMAINS" ]] ||\ - [[ "$DNS_DOMAINS" -lt "$U_DNS_DOMAINS" ]] ||\ - [[ "$MAIL_DOMAINS" -lt "$U_MAIL_DOMAINS" ]] ||\ - [[ "$DATABASES" -lt "$U_DATABASES" ]] ||\ - [[ "$CRON_JOBS" -lt "$U_CRON_JOBS" ]] ||\ - [[ "$DISK_QUOTA" -lt "$U_DISK" ]] ||\ - [[ "$BANDWIDTH" -lt "$U_BANDWIDTH" ]]; then - echo "Error: Package not cover current usage" - log_event "$E_LIMIT" "$EVENT" - exit $E_LIMIT - fi -} - -change_user_package() { - usr_data=$(cat $USER_DATA/user.conf) - eval $usr_data - - pkg_data=$(cat $VESTA/data/packages/$package.pkg |grep -v TIME |\ - grep -v DATE) - eval $pkg_data - - echo "FNAME='$FNAME' -LNAME='$LNAME' -PACKAGE='$package' -TEMPLATE='$TEMPLATE' -WEB_DOMAINS='$WEB_DOMAINS' -WEB_ALIASES='$WEB_ALIASES' -DNS_DOMAINS='$DNS_DOMAINS' -DNS_RECORDS='$DNS_RECORDS' -MAIL_DOMAINS='$MAIL_DOMAINS' -MAIL_ACCOUNTS='$MAIL_ACCOUNTS' -DATABASES='$DATABASES' -CRON_JOBS='$CRON_JOBS' -DISK_QUOTA='$DISK_QUOTA' -BANDWIDTH='$BANDWIDTH' -NS='$NS' -SHELL='$SHELL' -BACKUPS='$BACKUPS' -CONTACT='$CONTACT' -CRON_REPORTS='$CRON_REPORTS' -MD5='$MD5' -RKEY='$RKEY' -SUSPENDED='$SUSPENDED' -SUSPENDED_USERS='$SUSPENDED_USERS' -SUSPENDED_WEB='$SUSPENDED_WEB' -SUSPENDED_DNS='$SUSPENDED_DNS' -SUSPENDED_MAIL='$SUSPENDED_MAIL' -SUSPENDED_DB='$SUSPENDED_DB' -SUSPENDED_CRON='$SUSPENDED_CRON' -IP_AVAIL='$IP_AVAIL' -IP_OWNED='$IP_OWNED' -U_USERS='$U_USERS' -U_DISK='$U_DISK' -U_DISK_DIRS='$U_DISK_DIRS' -U_DISK_WEB='$U_DISK_WEB' -U_DISK_MAIL='$U_DISK_MAIL' -U_DISK_DB='$U_DISK_DB' -U_BANDWIDTH='$U_BANDWIDTH' -U_WEB_DOMAINS='$U_WEB_DOMAINS' -U_WEB_SSL='$U_WEB_SSL' -U_WEB_ALIASES='$U_WEB_ALIASES' -U_DNS_DOMAINS='$U_DNS_DOMAINS' -U_DNS_RECORDS='$U_DNS_RECORDS' -U_MAIL_DOMAINS='$U_MAIL_DOMAINS' -U_MAIL_DKIM='$U_MAIL_DKIM' -U_MAIL_ACCOUNTS='$U_MAIL_ACCOUNTS' -U_DATABASES='$U_DATABASES' -U_CRON_JOBS='$U_CRON_JOBS' -U_BACKUPS='$U_BACKUPS' -TIME='$TIME' -DATE='$DATE'" > $USER_DATA/user.conf -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user package [force]' -validate_format 'user' 'package' -is_object_valid 'user' 'USER' "$user" -is_package_valid -if [ "$force" != 'yes' ];then - is_package_avalable -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing user package -change_user_package - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "changed $user package to $package" '' 'admin' -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change user package +# options: USER PACKAGE [FORCE] +# +# The function changes user's hosting package. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +package=$2 +force=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + +is_package_avalable() { + # Parsing user data + usr_data=$(cat $USER_DATA/user.conf) + IFS=$'\n' + for key in $usr_data; do + eval ${key%%=*}=${key#*=} + done + + WEB_DOMAINS='0' + DATABASES='0' + MAIL_DOMAINS='0' + DNS_DOMAINS='0' + DISK_QUOTA='0' + BANDWIDTH='0' + + pkg_data=$(cat $VESTA/data/packages/$package.pkg |grep -v TIME |\ + grep -v DATE) + eval $pkg_data + + # Comparing user data with package + if [[ "$WEB_DOMAINS" -lt "$U_WEB_DOMAINS" ]] ||\ + [[ "$DNS_DOMAINS" -lt "$U_DNS_DOMAINS" ]] ||\ + [[ "$MAIL_DOMAINS" -lt "$U_MAIL_DOMAINS" ]] ||\ + [[ "$DATABASES" -lt "$U_DATABASES" ]] ||\ + [[ "$CRON_JOBS" -lt "$U_CRON_JOBS" ]] ||\ + [[ "$DISK_QUOTA" -lt "$U_DISK" ]] ||\ + [[ "$BANDWIDTH" -lt "$U_BANDWIDTH" ]]; then + echo "Error: Package not cover current usage" + log_event "$E_LIMIT" "$EVENT" + exit $E_LIMIT + fi +} + +change_user_package() { + usr_data=$(cat $USER_DATA/user.conf) + eval $usr_data + + pkg_data=$(cat $VESTA/data/packages/$package.pkg |grep -v TIME |\ + grep -v DATE) + eval $pkg_data + + echo "FNAME='$FNAME' +LNAME='$LNAME' +PACKAGE='$package' +TEMPLATE='$TEMPLATE' +WEB_DOMAINS='$WEB_DOMAINS' +WEB_ALIASES='$WEB_ALIASES' +DNS_DOMAINS='$DNS_DOMAINS' +DNS_RECORDS='$DNS_RECORDS' +MAIL_DOMAINS='$MAIL_DOMAINS' +MAIL_ACCOUNTS='$MAIL_ACCOUNTS' +DATABASES='$DATABASES' +CRON_JOBS='$CRON_JOBS' +DISK_QUOTA='$DISK_QUOTA' +BANDWIDTH='$BANDWIDTH' +NS='$NS' +SHELL='$SHELL' +BACKUPS='$BACKUPS' +CONTACT='$CONTACT' +CRON_REPORTS='$CRON_REPORTS' +MD5='$MD5' +RKEY='$RKEY' +SUSPENDED='$SUSPENDED' +SUSPENDED_USERS='$SUSPENDED_USERS' +SUSPENDED_WEB='$SUSPENDED_WEB' +SUSPENDED_DNS='$SUSPENDED_DNS' +SUSPENDED_MAIL='$SUSPENDED_MAIL' +SUSPENDED_DB='$SUSPENDED_DB' +SUSPENDED_CRON='$SUSPENDED_CRON' +IP_AVAIL='$IP_AVAIL' +IP_OWNED='$IP_OWNED' +U_USERS='$U_USERS' +U_DISK='$U_DISK' +U_DISK_DIRS='$U_DISK_DIRS' +U_DISK_WEB='$U_DISK_WEB' +U_DISK_MAIL='$U_DISK_MAIL' +U_DISK_DB='$U_DISK_DB' +U_BANDWIDTH='$U_BANDWIDTH' +U_WEB_DOMAINS='$U_WEB_DOMAINS' +U_WEB_SSL='$U_WEB_SSL' +U_WEB_ALIASES='$U_WEB_ALIASES' +U_DNS_DOMAINS='$U_DNS_DOMAINS' +U_DNS_RECORDS='$U_DNS_RECORDS' +U_MAIL_DOMAINS='$U_MAIL_DOMAINS' +U_MAIL_DKIM='$U_MAIL_DKIM' +U_MAIL_ACCOUNTS='$U_MAIL_ACCOUNTS' +U_DATABASES='$U_DATABASES' +U_CRON_JOBS='$U_CRON_JOBS' +U_BACKUPS='$U_BACKUPS' +TIME='$TIME' +DATE='$DATE'" > $USER_DATA/user.conf +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER PACKAGE [FORCE]' +validate_format 'user' 'package' +is_object_valid 'user' 'USER' "$user" +is_package_valid +if [ "$force" != 'yes' ];then + is_package_avalable +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Changing user package +change_user_package + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_history "changed $user package to $package" '' 'admin' +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-user-password b/bin/v-change-user-password index ecc5c2883..f5443b966 100755 --- a/bin/v-change-user-password +++ b/bin/v-change-user-password @@ -1,57 +1,57 @@ -#!/bin/bash -# info: change user password -# options: user password -# -# The function changes user's password and updates RKEY value. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -password=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - -# Hiding password -A2="******" -EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'" -EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'" - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user password' -validate_format 'user' 'password' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing user password -echo "$password" | /usr/bin/passwd "$user" --stdin &>/dev/null -md5=$(awk -v user=$user -F : 'user == $1 {print $2}' /etc/shadow) - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Changing RKEY value -update_user_value "$user" '$RKEY' "$(gen_password)" -update_user_value "$user" '$MD5' "$md5" - -# Logging -log_history "changed password" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change user password +# options: USER PASSWORD +# +# The function changes user's password and updates RKEY value. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +password=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + +# Hiding password +A2="******" +EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'" +EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'" + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER PASSWORD' +validate_format 'user' 'password' +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Changing user password +echo "$password" | /usr/bin/passwd "$user" --stdin &>/dev/null +md5=$(awk -v user=$user -F : 'user == $1 {print $2}' /etc/shadow) + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Changing RKEY value +update_user_value "$user" '$RKEY' "$(gen_password)" +update_user_value "$user" '$MD5' "$md5" + +# Logging +log_history "changed password" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-user-shell b/bin/v-change-user-shell index f28c8b796..b55a1f869 100755 --- a/bin/v-change-user-shell +++ b/bin/v-change-user-shell @@ -1,54 +1,54 @@ -#!/bin/bash -# info: change user shell -# options: user shell -# -# The function changes system shell of a user. Shell gives abilty to use ssh. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -shell=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user shell' -validate_format 'user' 'shell' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get shell full path -shell_path=$(/usr/bin/chsh --list-shells | grep -w "$shell" |head -n1) - -# Changing passwd file -/usr/bin/chsh -s "$shell_path" "$user" &>/dev/null -shell=$(basename $shell_path) - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Changing user shell -update_user_value "$user" '$SHELL' "$shell" - -# Logging -log_history "changed $user shell to $shell" '' 'admin' -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change user shell +# options: USER SHELL +# +# The function changes system shell of a user. Shell gives abilty to use ssh. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +shell=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER SHELL' +validate_format 'user' 'shell' +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Get shell full path +shell_path=$(/usr/bin/chsh --list-shells | grep -w "$shell" |head -n1) + +# Changing passwd file +/usr/bin/chsh -s "$shell_path" "$user" &>/dev/null +shell=$(basename $shell_path) + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Changing user shell +update_user_value "$user" '$SHELL' "$shell" + +# Logging +log_history "changed $user shell to $shell" '' 'admin' +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-user-template b/bin/v-change-user-template index 4e8456a3b..a7bb42e10 100755 --- a/bin/v-change-user-template +++ b/bin/v-change-user-template @@ -1,49 +1,49 @@ -#!/bin/bash -# info: change user default template -# options: user template -# -# The function changes default user web template. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -template=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user template' -validate_format 'user' 'template' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_apache_template_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Changing user shell -update_user_value "$user" '$TEMPLATE' "$template" - -# Logging -log_history "changed $user template to $template" '' 'admin' -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change user default template +# options: USER TEMPLATE +# +# The function changes default user web template. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +template=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER TEMPLATE' +validate_format 'user' 'template' +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_apache_template_valid + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Changing user shell +update_user_value "$user" '$TEMPLATE' "$template" + +# Logging +log_history "changed $user template to $template" '' 'admin' +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-web-domain-ftp b/bin/v-change-web-domain-ftp index e870a67b4..827698797 100755 --- a/bin/v-change-web-domain-ftp +++ b/bin/v-change-web-domain-ftp @@ -1,62 +1,62 @@ -#!/bin/bash -# info: add ftp account for web domain. -# options: user domain ftp_user ftp_password -# -# The function creates addutional ftp account for web domain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -ftp_user=${1}_${3} -ftp_password=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'user domain ftp_user ftp_password' -validate_format 'user' 'domain' 'ftp_user' 'ftp_password' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_empty 'web' 'DOMAIN' "$domain" '$FTP_USER' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding user -/usr/sbin/adduser $ftp_user -g $user -s /sbin/nologin -M \ - -d "$HOMEDIR/$user/web/$domain" > /dev/null 2>&1 -echo "$ftp_password" | /usr/bin/passwd "$ftp_user" --stdin &>/dev/null -ftp_md5="$(awk -v user=$ftp_user -F : 'user == $1 {print $2}' /etc/shadow)" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$FTP_USER' "$ftp_user" -update_object_value 'web' 'DOMAIN' "$domain" '$FTP_MD5' "$ftp_md5" - -# Logging -log_history "added ftp account $ftp_user for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add ftp account for web domain. +# options: USER DOMAIN FTP_USER FTP_PASSWORD +# +# The function creates addutional ftp account for web domain. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +ftp_user=${1}_${3} +ftp_password=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '4' "$#" 'USER DOMAIN FTP_USER FTP_PASSWORD' +validate_format 'user' 'domain' 'ftp_user' 'ftp_password' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_empty 'web' 'DOMAIN' "$domain" '$FTP_USER' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Adding user +/usr/sbin/adduser $ftp_user -g $user -s /sbin/nologin -M \ + -d "$HOMEDIR/$user/web/$domain" > /dev/null 2>&1 +echo "$ftp_password" | /usr/bin/passwd "$ftp_user" --stdin &>/dev/null +ftp_md5="$(awk -v user=$ftp_user -F : 'user == $1 {print $2}' /etc/shadow)" + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$FTP_USER' "$ftp_user" +update_object_value 'web' 'DOMAIN' "$domain" '$FTP_MD5' "$ftp_md5" + +# Logging +log_history "added ftp account $ftp_user for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-web-domain-ip b/bin/v-change-web-domain-ip index 936689d66..380d67f9a 100755 --- a/bin/v-change-web-domain-ip +++ b/bin/v-change-web-domain-ip @@ -1,96 +1,96 @@ -#!/bin/bash -# info: change web domain ip address -# options: user domain ip [restart] -# -# The call is used for changing the site ip address. The ip change will be -# performed for a virtual apache host and for a configuration nginx file both. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -ip=$3 -restart=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/ip.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user domain ip [restart]' -validate_format 'user' 'domain' 'ip' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_ip_valid -is_ip_avalable - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Define variable for replace -get_domain_values 'web' -tpl_file="$WEBTPL/apache_$TPL.tpl" -conf="$HOMEDIR/$user/conf/web/httpd.conf" -old=$IP -new=$ip -replace_web_config - -# Checking ssl -if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/apache_$TPL.stpl" - conf="$HOMEDIR/$user/conf/web/shttpd.conf" - replace_web_config -fi - -# Checking nginx -if [ ! -z "$NGINX" ]; then - tpl_file="$WEBTPL/nginx_$NGINX.tpl" - conf="$HOMEDIR/$user/conf/web/nginx.conf" - replace_web_config -fi - -# Checking nginx -if [ "$SSL" = 'yes' ] && [ ! -z "$NGINX" ]; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web/snginx.conf" - replace_web_config -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update counters -increase_ip_value "$new" -decrease_ip_value "$old" - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$IP' "$ip" - -# Restart web server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_history "changed web domain $domain ip to $ip" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change web domain ip address +# options: USER DOMAIN IP [RESTART] +# +# The call is used for changing the site ip address. The ip change will be +# performed for a virtual apache host and for a configuration nginx file both. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +ip=$3 +restart=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh +source $VESTA/func/ip.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN IP [RESTART]' +validate_format 'user' 'domain' 'ip' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_ip_valid +is_ip_avalable + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Define variable for replace +get_domain_values 'web' +tpl_file="$WEBTPL/apache_$TPL.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" +old=$IP +new=$ip +replace_web_config + +# Checking ssl +if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" + replace_web_config +fi + +# Checking nginx +if [ ! -z "$NGINX" ]; then + tpl_file="$WEBTPL/nginx_$NGINX.tpl" + conf="$HOMEDIR/$user/conf/web/nginx.conf" + replace_web_config +fi + +# Checking nginx +if [ "$SSL" = 'yes' ] && [ ! -z "$NGINX" ]; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + replace_web_config +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update counters +increase_ip_value "$new" +decrease_ip_value "$old" + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$IP' "$ip" + +# Restart web server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_history "changed web domain $domain ip to $ip" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-web-domain-nginx-tpl b/bin/v-change-web-domain-nginx-tpl index 23b6ed076..957e82643 100755 --- a/bin/v-change-web-domain-nginx-tpl +++ b/bin/v-change-web-domain-nginx-tpl @@ -1,101 +1,101 @@ -#!/bin/bash -# info: change web domain nginx template -# options: user domain template [extentions] [restart] -# -# The function changes template of nginx.conf configuration file. The content -# of webdomain directories remains untouched. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -template=$3 -default_extentions="jpg,jpeg,gif,png,ico,svg,css,zip,tgz,gz,rar,bz2,doc,xls,\ -exe,pdf,ppt,txt,odt,ods,odp,odf,tar,wav,bmp,rtf,js,mp3,avi,mpeg,flv,html,htm" -extentions=${4-$default_extentions} -restart="$5" - - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user domain template [extentions] [restart]' -validate_format 'user' 'domain' 'template' -is_system_enabled "$PROXY_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$NGINX' -is_nginx_template_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain values -get_domain_values 'web' -tpl_file="$WEBTPL/nginx_$NGINX.tpl" -conf="$HOMEDIR/$user/conf/web/nginx.conf" - -# Delete old vhost -del_web_config - -# Checking ssl -if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web/snginx.conf" - del_web_config -fi - -# Add new vhost -NGINX="$template" -NGINX_EXT="$extentions" -tpl_file="$WEBTPL/nginx_$NGINX.tpl" -conf="$HOMEDIR/$user/conf/web/nginx.conf" -upd_web_domain_values -add_web_config -chown root:nginx $conf -chmod 640 $conf - -# Checking ssl -if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web/snginx.conf" - add_web_config - chown root:nginx $conf - chmod 640 $conf -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$NGINX' "$NGINX" -update_object_value 'web' 'DOMAIN' "$domain" '$NGINX_EXT' "$extentions" - -# Restart web -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_history "changed nginx template for $domain to $template" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change web domain nginx template +# options: USER DOMAIN TEMPLATE [EXTENTIONS] [RESTART] +# +# The function changes template of nginx.conf configuration file. The content +# of webdomain directories remains untouched. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +template=$3 +default_extentions="jpg,jpeg,gif,png,ico,svg,css,zip,tgz,gz,rar,bz2,doc,xls,\ +exe,pdf,ppt,txt,odt,ods,odp,odf,tar,wav,bmp,rtf,js,mp3,avi,mpeg,flv,html,htm" +extentions=${4-$default_extentions} +restart="$5" + + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN TEMPLATE [EXTENTIONS] [RESTART]' +validate_format 'user' 'domain' 'template' +is_system_enabled "$PROXY_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_exist 'web' 'DOMAIN' "$domain" '$NGINX' +is_nginx_template_valid + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Parsing domain values +get_domain_values 'web' +tpl_file="$WEBTPL/nginx_$NGINX.tpl" +conf="$HOMEDIR/$user/conf/web/nginx.conf" + +# Delete old vhost +del_web_config + +# Checking ssl +if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + del_web_config +fi + +# Add new vhost +NGINX="$template" +NGINX_EXT="$extentions" +tpl_file="$WEBTPL/nginx_$NGINX.tpl" +conf="$HOMEDIR/$user/conf/web/nginx.conf" +upd_web_domain_values +add_web_config +chown root:nginx $conf +chmod 640 $conf + +# Checking ssl +if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + add_web_config + chown root:nginx $conf + chmod 640 $conf +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$NGINX' "$NGINX" +update_object_value 'web' 'DOMAIN' "$domain" '$NGINX_EXT' "$extentions" + +# Restart web +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_history "changed nginx template for $domain to $template" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-web-domain-sslcert b/bin/v-change-web-domain-sslcert index fbc8f03f6..244a683c8 100755 --- a/bin/v-change-web-domain-sslcert +++ b/bin/v-change-web-domain-sslcert @@ -1,79 +1,79 @@ -#!/bin/bash -# info: change domain ssl certificate -# options: user domain ssl_dir -# -# The function changes SSL domain certificate and the key. If ca file present -# it will be replaced as well. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -ssl_dir=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user domain ssl_dir' -validate_format 'user' 'domain' 'ssl_dir' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL' -is_web_domain_cert_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting old certificate -tmpdir=$(mktemp -p $HOMEDIR/$user/web/$domain/private -d) -rm -f $HOMEDIR/$user/conf/ssl.$domain.* -mv $USER_DATA/ssl/$domain.* $tmpdir -chown -R $user:$user $tmpdir - -# Adding new certificate to user data directory -cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.crt -cp -f $ssl_dir/$domain.key $USER_DATA/ssl/$domain.key -cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.pem -if [ -e "$ssl_dir/$domain.ca" ]; then - cp -f $ssl_dir/$domain.ca $USER_DATA/ssl/$domain.ca - cat $USER_DATA/ssl/$domain.ca >> $USER_DATA/ssl/$domain.pem -fi - -# Adding new certificate to user dir -cp -f $USER_DATA/ssl/$domain.crt $HOMEDIR/$user/conf/ssl.$domain.crt -cp -f $USER_DATA/ssl/$domain.key $HOMEDIR/$user/conf/ssl.$domain.key -cp -f $USER_DATA/ssl/$domain.pem $HOMEDIR/$user/conf/ssl.$domain.pem -if [ -e "$USER_DATA/ssl/$domain.ca" ]; then - cp -f $USER_DATA/ssl/$domain.ca $HOMEDIR/$user/conf/ssl.$domain.ca -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart web server -$BIN/v-restart-web "$EVENT" - -# Logging -log_history "changed ssl certificate for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change domain ssl certificate +# options: USER DOMAIN SSL_DIR +# +# The function changes SSL domain certificate and the key. If ca file present +# it will be replaced as well. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +ssl_dir=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN SSL_DIR' +validate_format 'user' 'domain' 'ssl_dir' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL' +is_web_domain_cert_valid + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Deleting old certificate +tmpdir=$(mktemp -p $HOMEDIR/$user/web/$domain/private -d) +rm -f $HOMEDIR/$user/conf/ssl.$domain.* +mv $USER_DATA/ssl/$domain.* $tmpdir +chown -R $user:$user $tmpdir + +# Adding new certificate to user data directory +cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.crt +cp -f $ssl_dir/$domain.key $USER_DATA/ssl/$domain.key +cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.pem +if [ -e "$ssl_dir/$domain.ca" ]; then + cp -f $ssl_dir/$domain.ca $USER_DATA/ssl/$domain.ca + cat $USER_DATA/ssl/$domain.ca >> $USER_DATA/ssl/$domain.pem +fi + +# Adding new certificate to user dir +cp -f $USER_DATA/ssl/$domain.crt $HOMEDIR/$user/conf/ssl.$domain.crt +cp -f $USER_DATA/ssl/$domain.key $HOMEDIR/$user/conf/ssl.$domain.key +cp -f $USER_DATA/ssl/$domain.pem $HOMEDIR/$user/conf/ssl.$domain.pem +if [ -e "$USER_DATA/ssl/$domain.ca" ]; then + cp -f $USER_DATA/ssl/$domain.ca $HOMEDIR/$user/conf/ssl.$domain.ca +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart web server +$BIN/v-restart-web "$EVENT" + +# Logging +log_history "changed ssl certificate for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-web-domain-sslhome b/bin/v-change-web-domain-sslhome index 633a602ce..defa40de9 100755 --- a/bin/v-change-web-domain-sslhome +++ b/bin/v-change-web-domain-sslhome @@ -1,79 +1,79 @@ -#!/bin/bash -# info: changing domain ssl home - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -ssl_home=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user domain ssl_home' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get domain values -get_domain_values 'web' -old_ssl_home=$SSL_HOME -SSL_HOME=$ssl_home -tpl_file="$WEBTPL/apache_$TPL.stpl" -conf="$HOMEDIR/$user/conf/web/shttpd.conf" - -# Parsing tpl_option -case $SSL_HOME in - single) new="$HOMEDIR/$user/web/$domain/public_shtml" ; - old="$HOMEDIR/$user/web/$domain/public_html" ;; - same) new="$HOMEDIR/$user/web/$domain/public_html" ; - old="$HOMEDIR/$user/web/$domain/public_shtml" ;; - *) check_args '3' "2" 'user domain sslhome' -esac - -# Changing sslhome directory -replace_web_config - -# Checking nginx config -if [ ! -z "$NGINX" ]; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web//snginx.conf" - replace_web_config -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$SSL_HOME' "$SSL_HOME" - -# Restart web server -$BIN/v-restart-web "$EVENT" - -# Logging -log_history "changed ssl home for $domain to $ssl_home" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: changing domain ssl home + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +ssl_home=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN SSL_HOME' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Get domain values +get_domain_values 'web' +old_ssl_home=$SSL_HOME +SSL_HOME=$ssl_home +tpl_file="$WEBTPL/apache_$TPL.stpl" +conf="$HOMEDIR/$user/conf/web/shttpd.conf" + +# Parsing tpl_option +case $SSL_HOME in + single) new="$HOMEDIR/$user/web/$domain/public_shtml" ; + old="$HOMEDIR/$user/web/$domain/public_html" ;; + same) new="$HOMEDIR/$user/web/$domain/public_html" ; + old="$HOMEDIR/$user/web/$domain/public_shtml" ;; + *) check_args '3' "2" 'USER DOMAIN SSLHOME' +esac + +# Changing sslhome directory +replace_web_config + +# Checking nginx config +if [ ! -z "$NGINX" ]; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web//snginx.conf" + replace_web_config +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$SSL_HOME' "$SSL_HOME" + +# Restart web server +$BIN/v-restart-web "$EVENT" + +# Logging +log_history "changed ssl home for $domain to $ssl_home" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-web-domain-stats b/bin/v-change-web-domain-stats index 4abcd2001..05ee2b614 100755 --- a/bin/v-change-web-domain-stats +++ b/bin/v-change-web-domain-stats @@ -1,95 +1,95 @@ -#!/bin/bash -# info: change web domain statistics -# options: user domain type -# -# The function of deleting site's system of statistics. Its type is -# automatically chooses from client's configuration file. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -type=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user domain type' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_type_valid "$STATS_SYSTEM" "$type" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining statistic type -get_domain_values 'web' - -# Comparing stats types -if [ "$STATS" == $type ]; then - log_event "$OK" "$EVENT" - exit 0 -fi - -# Defining statistic dir -stats_dir="$HOMEDIR/$user/web/$domain/stats" - -# Deleting dir content -rm -rf $stats_dir/* - -# Deleting config -rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf - -# Preparing domain values for the template substitution -upd_web_domain_values - -# Adding statistic config -cat $WEBTPL/$type.tpl |\ - sed -e "s/%ip%/$ip/g" \ - -e "s/%web_port%/$WEB_PORT/g" \ - -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \ - -e "s/%proxy_port%/$PROXY_PORT/g" \ - -e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \ - -e "s/%domain_idn%/$domain_idn/g" \ - -e "s/%domain%/$domain/g" \ - -e "s/%user%/$user/g" \ - -e "s/%home%/${HOMEDIR////\/}/g" \ - -e "s/%alias%/${aliases//,/ }/g" \ - -e "s/%alias_idn%/${aliases_idn//,/ }/g" \ - > $HOMEDIR/$user/conf/web/$type.$domain.conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$STATS' "$type" - -# Logging -log_history "changed web log stats for $domain to $type" -log_event "$OK" "$EVENT" - -# Build stats -exec $BIN/v-update-web-domain-stat $user $domain - -exit +#!/bin/bash +# info: change web domain statistics +# options: USER DOMAIN TYPE +# +# The function of deleting site's system of statistics. Its type is +# automatically chooses from client's configuration file. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +type=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN TYPE' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_type_valid "$STATS_SYSTEM" "$type" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining statistic type +get_domain_values 'web' + +# Comparing stats types +if [ "$STATS" == $type ]; then + log_event "$OK" "$EVENT" + exit 0 +fi + +# Defining statistic dir +stats_dir="$HOMEDIR/$user/web/$domain/stats" + +# Deleting dir content +rm -rf $stats_dir/* + +# Deleting config +rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf + +# Preparing domain values for the template substitution +upd_web_domain_values + +# Adding statistic config +cat $WEBTPL/$type.tpl |\ + sed -e "s/%ip%/$ip/g" \ + -e "s/%web_port%/$WEB_PORT/g" \ + -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \ + -e "s/%proxy_port%/$PROXY_PORT/g" \ + -e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \ + -e "s/%domain_idn%/$domain_idn/g" \ + -e "s/%domain%/$domain/g" \ + -e "s/%user%/$user/g" \ + -e "s/%home%/${HOMEDIR////\/}/g" \ + -e "s/%alias%/${aliases//,/ }/g" \ + -e "s/%alias_idn%/${aliases_idn//,/ }/g" \ + > $HOMEDIR/$user/conf/web/$type.$domain.conf + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$STATS' "$type" + +# Logging +log_history "changed web log stats for $domain to $type" +log_event "$OK" "$EVENT" + +# Build stats +exec $BIN/v-update-web-domain-stat $user $domain + +exit diff --git a/bin/v-change-web-domain-tpl b/bin/v-change-web-domain-tpl index 35964da7c..19b411521 100755 --- a/bin/v-change-web-domain-tpl +++ b/bin/v-change-web-domain-tpl @@ -1,110 +1,110 @@ -#!/bin/bash -# info: change web domain template -# options: user domain template [restart] -# -# The function changes template of httpd.conf configuration file. The content -# of webdomain directories remains untouched. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -template=$3 -restart=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user domain template [restart]' -validate_format 'user' 'domain' 'template' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_apache_template_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain values -get_domain_values 'web' - -# Deleting domain -tpl_file="$WEBTPL/apache_$TPL.tpl" -old_tpl=$TPL -conf="$HOMEDIR/$user/conf/web/httpd.conf" -del_web_config - -# Deleting ssl vhost -if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/apache_$TPL.stpl" - conf="$HOMEDIR/$user/conf/web/shttpd.conf" - del_web_config -fi - -# Defining variables for new vhost config -upd_web_domain_values -tpl_file="$WEBTPL/apache_$template.tpl" - -# Checking error log -if [ "$ELOG" = 'no' ]; then - elog='#' -else - elog='' -fi - -# Adding domain to the httpd.conf -add_web_config - -# Running template trigger -if [ -x $WEBTPL/apache_$template.sh ]; then - $WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $docroot -fi - -# Checking ssl -if [ "$SSL" = 'yes' ]; then - conf="$HOMEDIR/$user/conf/web/shttpd.conf" - tpl_file="$WEBTPL/apache_$template.stpl" - - add_web_config - - # Running template trigger - if [ -x $WEBTPL/apache_$template.sh ]; then - $WEBTPL/apache_$template.sh \ - "$user" "$domain" "$ip" "$HOMEDIR" "$sdocroot" - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Changing tpl in config -update_object_value 'web' 'DOMAIN' "$domain" '$TPL' "$template" - -# Restart web -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_history "changed web domain template for $domain to $template" '' 'admin' -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change web domain template +# options: USER DOMAIN TEMPLATE [RESTART] +# +# The function changes template of httpd.conf configuration file. The content +# of webdomain directories remains untouched. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +template=$3 +restart=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN TEMPLATE [RESTART]' +validate_format 'user' 'domain' 'template' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_apache_template_valid + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Parsing domain values +get_domain_values 'web' + +# Deleting domain +tpl_file="$WEBTPL/apache_$TPL.tpl" +old_tpl=$TPL +conf="$HOMEDIR/$user/conf/web/httpd.conf" +del_web_config + +# Deleting ssl vhost +if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" + del_web_config +fi + +# Defining variables for new vhost config +upd_web_domain_values +tpl_file="$WEBTPL/apache_$template.tpl" + +# Checking error log +if [ "$ELOG" = 'no' ]; then + elog='#' +else + elog='' +fi + +# Adding domain to the httpd.conf +add_web_config + +# Running template trigger +if [ -x $WEBTPL/apache_$template.sh ]; then + $WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $docroot +fi + +# Checking ssl +if [ "$SSL" = 'yes' ]; then + conf="$HOMEDIR/$user/conf/web/shttpd.conf" + tpl_file="$WEBTPL/apache_$template.stpl" + + add_web_config + + # Running template trigger + if [ -x $WEBTPL/apache_$template.sh ]; then + $WEBTPL/apache_$template.sh \ + "$user" "$domain" "$ip" "$HOMEDIR" "$sdocroot" + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Changing tpl in config +update_object_value 'web' 'DOMAIN' "$domain" '$TPL' "$template" + +# Restart web +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_history "changed web domain template for $domain to $template" '' 'admin' +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-cron-job b/bin/v-delete-cron-job index fd71812fe..82a463658 100755 --- a/bin/v-delete-cron-job +++ b/bin/v-delete-cron-job @@ -1,62 +1,62 @@ -#!/bin/bash -# info: delete cron job -# options: user job -# -# The function deletes cron job. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -job=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user job' -validate_format 'user' 'job' -is_system_enabled "$CRON_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'cron' 'JOB' "$job" -is_object_unsuspended 'cron' 'JOB' "$job" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting job -sed -i "/JOB='$job' /d" $USER_DATA/cron.conf - -# Sorting jobs by id -sort_cron_jobs - -# Sync system cron with user -sync_cron_jobs - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Decreasing cron value -decrease_user_value "$user" '$U_CRON_JOBS' - -# Restart crond -$BIN/v-restart-cron "$EVENT" - -# Logging -log_history "deleted cron job $job" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete cron job +# options: USER JOB +# +# The function deletes cron job. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +job=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER JOB' +validate_format 'user' 'job' +is_system_enabled "$CRON_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'cron' 'JOB' "$job" +is_object_unsuspended 'cron' 'JOB' "$job" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Deleting job +sed -i "/JOB='$job' /d" $USER_DATA/cron.conf + +# Sorting jobs by id +sort_cron_jobs + +# Sync system cron with user +sync_cron_jobs + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Decreasing cron value +decrease_user_value "$user" '$U_CRON_JOBS' + +# Restart crond +$BIN/v-restart-cron "$EVENT" + +# Logging +log_history "deleted cron job $job" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-cron-reports b/bin/v-delete-cron-reports index 22fbc0b1b..0dc28ee4e 100755 --- a/bin/v-delete-cron-reports +++ b/bin/v-delete-cron-reports @@ -1,54 +1,54 @@ -#!/bin/bash -# info: delete cron reports -# options: user -# -# The script for disabling reports on cron tasks and administrative -# notifications. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user' -validate_format 'user' -is_system_enabled "$CRON_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing user report value -update_user_value "$user" '$CRON_REPORTS' 'no' - -# Sync system cron with user -sync_cron_jobs - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart crond -$BIN/v-restart-cron "$EVENT" - -# Logging -log_history "disabled cron reporting" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete cron reports +# options: USER +# +# The script for disabling reports on cron tasks and administrative +# notifications. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_system_enabled "$CRON_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Changing user report value +update_user_value "$user" '$CRON_REPORTS' 'no' + +# Sync system cron with user +sync_cron_jobs + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart crond +$BIN/v-restart-cron "$EVENT" + +# Logging +log_history "disabled cron reporting" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-database b/bin/v-delete-database index 3a657865f..438aada60 100755 --- a/bin/v-delete-database +++ b/bin/v-delete-database @@ -1,65 +1,65 @@ -#!/bin/bash -# info: delete database -# options: user database -# -# The function for deleting the database. If database user have access to -# another database, he will not be deleted. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -database=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/db.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user database' -validate_format 'user' 'database' -is_system_enabled "$DB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'db' 'DB' "$database" -is_object_unsuspended 'db' 'DB' "$database" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get database values -get_database_values - -# Switching on db type -case $TYPE in - mysql) delete_mysql_database ;; - pgsql) delete_pgsql_database ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Deleting database -sed -i "/DB='$database' /d" $USER_DATA/db.conf - -# Decreasing counters -decrease_dbhost_values -decrease_user_value "$user" '$U_DATABASES' - -# Logging -log_history "deleted $database database" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete database +# options: USER DATABASE +# +# The function for deleting the database. If database user have access to +# another database, he will not be deleted. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +database=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/db.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DATABASE' +validate_format 'user' 'database' +is_system_enabled "$DB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'db' 'DB' "$database" +is_object_unsuspended 'db' 'DB' "$database" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Get database values +get_database_values + +# Switching on db type +case $TYPE in + mysql) delete_mysql_database ;; + pgsql) delete_pgsql_database ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Deleting database +sed -i "/DB='$database' /d" $USER_DATA/db.conf + +# Decreasing counters +decrease_dbhost_values +decrease_user_value "$user" '$U_DATABASES' + +# Logging +log_history "deleted $database database" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-database-server b/bin/v-delete-database-server index 843d50456..5bd03a5f4 100755 --- a/bin/v-delete-database-server +++ b/bin/v-delete-database-server @@ -1,50 +1,50 @@ -#!/bin/bash -# info: delete database server -# options: type host -# -# The function for deleting the database host from vesta configuration. It will -# be deleted if there are no databases created on it only. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -type=$1 -host=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/db.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" "type host" -validate_format 'type' 'host' -is_system_enabled "$DB_SYSTEM" -is_type_valid "$DB_SYSTEM" "$type" -is_object_valid "../../conf/$type" 'HOST' "$host" -is_dbhost_free - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# -# Deleting server -sed -i "/HOST='$host' /d" $VESTA/conf/$type.conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "deleted $type database server $host" '' 'admin' -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete database server +# options: TYPE HOST +# +# The function for deleting the database host from vesta configuration. It will +# be deleted if there are no databases created on it only. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +type=$1 +host=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/db.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'TYPE HOST' +validate_format 'type' 'host' +is_system_enabled "$DB_SYSTEM" +is_type_valid "$DB_SYSTEM" "$type" +is_object_valid "../../conf/$type" 'HOST' "$host" +is_dbhost_free + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# +# Deleting server +sed -i "/HOST='$host' /d" $VESTA/conf/$type.conf + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_history "deleted $type database server $host" '' 'admin' +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-databases b/bin/v-delete-databases index 2069be0bf..5394afa4f 100755 --- a/bin/v-delete-databases +++ b/bin/v-delete-databases @@ -1,48 +1,48 @@ -#!/bin/bash -# info: delete user databases -# options: user -# -# The function deletes all user databases. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user' -validate_format 'user' -is_system_enabled "$DB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting delete loop -for database in $(search_objects 'db' 'SUSPENDED' "no" 'DB'); do - $BIN/v-delete-database "$user" "$database" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete user databases +# options: USER +# +# The function deletes all user databases. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_system_enabled "$DB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting delete loop +for database in $(search_objects 'db' 'SUSPENDED' "no" 'DB'); do + $BIN/v-delete-database "$user" "$database" +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-dns-domain b/bin/v-delete-dns-domain index 529764c70..88aaa98b8 100755 --- a/bin/v-delete-dns-domain +++ b/bin/v-delete-dns-domain @@ -1,70 +1,70 @@ -#!/bin/bash -# info: delete dns domain -# options: user domain -# -# The function for deleting DNS domain. By deleting it all records will also be -# deleted. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -restart="$3" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain' -validate_format 'user' 'domain' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -records=$(wc -l $USER_DATA/dns/$domain.conf | cut -f 1 -d ' ') - -# Deleting domain in named.conf -sed -i "/\/$domain.db\"/d" /etc/named.conf -rm -f $HOMEDIR/$user/conf/dns/$domain.db - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Deleting domain -sed -i "/DOMAIN='$domain'/ d" $USER_DATA/dns.conf -rm -f $USER_DATA/dns/$domain.conf - -# Decreasing domain value -decrease_user_value "$user" '$U_DNS_DOMAINS' -decrease_user_value "$user" '$U_DNS_RECORDS' "$records" - -# Restart named -if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" -fi - - -# Logging -log_history "deleted dns domain $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete dns domain +# options: USER DOMAIN +# +# The function for deleting DNS domain. By deleting it all records will also be +# deleted. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +restart="$3" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" +is_object_unsuspended 'dns' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +records=$(wc -l $USER_DATA/dns/$domain.conf | cut -f 1 -d ' ') + +# Deleting domain in named.conf +sed -i "/\/$domain.db\"/d" /etc/named.conf +rm -f $HOMEDIR/$user/conf/dns/$domain.db + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Deleting domain +sed -i "/DOMAIN='$domain'/ d" $USER_DATA/dns.conf +rm -f $USER_DATA/dns/$domain.conf + +# Decreasing domain value +decrease_user_value "$user" '$U_DNS_DOMAINS' +decrease_user_value "$user" '$U_DNS_RECORDS' "$records" + +# Restart named +if [ "$restart" != 'no' ]; then + $BIN/v-restart-dns "$EVENT" +fi + + +# Logging +log_history "deleted dns domain $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-dns-domain-record b/bin/v-delete-dns-domain-record index 5b6aa1a06..5f5ae64e4 100755 --- a/bin/v-delete-dns-domain-record +++ b/bin/v-delete-dns-domain-record @@ -1,64 +1,64 @@ -#!/bin/bash -# info: delete dns record -# options: user domain id -# -# The function for deleting a certain record of DNS zone. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -id=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user domain id' -validate_format 'user' 'domain' 'id' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" -is_object_valid "dns/$domain" 'ID' "$id" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting record -sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf - -# Updating zone -update_domain_zone - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Upddate counters -records="$(wc -l $USER_DATA/dns/$domain.conf | cut -f1 -d ' ')" -update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records" -decrease_user_value "$user" '$U_DNS_RECORDS' - -# Restart named -$BIN/v-restart-dns "$EVENT" - -# Logging -log_history "deleted dns record $id on $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete dns record +# options: USER DOMAIN ID +# +# The function for deleting a certain record of DNS zone. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +id=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN ID' +validate_format 'user' 'domain' 'id' +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" +is_object_unsuspended 'dns' 'DOMAIN' "$domain" +is_object_valid "dns/$domain" 'ID' "$id" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Deleting record +sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf + +# Updating zone +update_domain_zone + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Upddate counters +records="$(wc -l $USER_DATA/dns/$domain.conf | cut -f1 -d ' ')" +update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records" +decrease_user_value "$user" '$U_DNS_RECORDS' + +# Restart named +$BIN/v-restart-dns "$EVENT" + +# Logging +log_history "deleted dns record $id on $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-dns-domains b/bin/v-delete-dns-domains index 378beb20f..2523cc499 100755 --- a/bin/v-delete-dns-domains +++ b/bin/v-delete-dns-domains @@ -1,50 +1,50 @@ -#!/bin/bash -# info: delete dns domains -# options: user -# -# The function for deleting all users DNS domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user' -validate_format 'user' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting delete loop -for domain in $(search_objects 'dns' 'SUSPENDED' "no" 'DOMAIN'); do - $BIN/v-delete-dns-domain "$user" "$domain" 'no' -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart named -$BIN/v-restart-dns "$EVENT" - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete dns domains +# options: USER +# +# The function for deleting all users DNS domains. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting delete loop +for domain in $(search_objects 'dns' 'SUSPENDED' "no" 'DOMAIN'); do + $BIN/v-delete-dns-domain "$user" "$domain" 'no' +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart named +$BIN/v-restart-dns "$EVENT" + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-dns-on-web-alias b/bin/v-delete-dns-on-web-alias index aac8ea1d5..cd30be8cb 100755 --- a/bin/v-delete-dns-on-web-alias +++ b/bin/v-delete-dns-on-web-alias @@ -1,79 +1,79 @@ -#!/bin/bash -# info: delete dns domain or dns record based on web domain alias -# options: user domain -# -# The function deletes dns domain or dns record based on web domain alias. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g') -domain_idn=$(idn -t --quiet -a "$domain") -dom_alias=$(idn -t --quiet -u "$3" ) -dom_alias=$(echo $dom_alias | sed -e 's/\.*$//g' -e 's/^\.*//g') -dom_alias=$(echo $dom_alias | tr '[:upper:]' '[:lower:]') -dom_alias_idn=$(idn -t --quiet -a "$dom_alias" ) -restart="$4" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user domain alias' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain values -get_domain_values 'web' - -# Check if it a simple domain -if [ $(echo -e "${dom_alias//\./\n}" | wc -l) -le 2 ]; then - if [ -e "$USER_DATA/dns/$dom_alias.conf" ]; then - $BIN/v-delete-dns-domain $user $dom_alias $IP $restart - fi -else - # Check subdomain - sub=$(echo "$dom_alias" | cut -f1 -d . -s) - root=$(echo "$dom_alias" | sed -e "s/^$sub.//" ) - if [ -e "$USER_DATA/dns/$root.conf" ]; then - if [ "$sub" == '*' ]; then - rec=$(grep -w "RECORD='\*'" $USER_DATA/dns/$root.conf) - else - rec=$(grep -w "RECORD='$sub'" $USER_DATA/dns/$root.conf) - fi - if [ ! -z "$rec" ]; then - eval "$rec" - $BIN/v-delete-dns-domain-record $user "$root" "$ID" - fi - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete dns domain or dns record based on web domain alias +# options: USER DOMAIN +# +# The function deletes dns domain or dns record based on web domain alias. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g') +domain_idn=$(idn -t --quiet -a "$domain") +dom_alias=$(idn -t --quiet -u "$3" ) +dom_alias=$(echo $dom_alias | sed -e 's/\.*$//g' -e 's/^\.*//g') +dom_alias=$(echo $dom_alias | tr '[:upper:]' '[:lower:]') +dom_alias_idn=$(idn -t --quiet -a "$dom_alias" ) +restart="$4" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN ALIAS' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Parsing domain values +get_domain_values 'web' + +# Check if it a simple domain +if [ $(echo -e "${dom_alias//\./\n}" | wc -l) -le 2 ]; then + if [ -e "$USER_DATA/dns/$dom_alias.conf" ]; then + $BIN/v-delete-dns-domain $user $dom_alias $IP $restart + fi +else + # Check subdomain + sub=$(echo "$dom_alias" | cut -f1 -d . -s) + root=$(echo "$dom_alias" | sed -e "s/^$sub.//" ) + if [ -e "$USER_DATA/dns/$root.conf" ]; then + if [ "$sub" == '*' ]; then + rec=$(grep -w "RECORD='\*'" $USER_DATA/dns/$root.conf) + else + rec=$(grep -w "RECORD='$sub'" $USER_DATA/dns/$root.conf) + fi + if [ ! -z "$rec" ]; then + eval "$rec" + $BIN/v-delete-dns-domain-record $user "$root" "$ID" + fi + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-mail-account b/bin/v-delete-mail-account index ad8a127fb..840aa9f4d 100755 --- a/bin/v-delete-mail-account +++ b/bin/v-delete-mail-account @@ -1,70 +1,70 @@ -#!/bin/bash -# info: delete mail account -# options: user domain account -# -# The function deletes email account. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -account=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user domain account' -validate_format 'user' 'domain' 'account' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# -aliases=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS') -for al in ${aliases//,/ }; do - sed -i "/^$al@$domain:$account/d" $HOMEDIR/$user/conf/mail/$domain/aliases -done - -sed -i "/^$account@$domain:/d" $HOMEDIR/$user/conf/mail/$domain/aliases -sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd -rm -rf $HOMEDIR/$user/mail/$domain/$account - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -sed -i "/ACCOUNT='$account'/d" $USER_DATA/mail/$domain.conf - -# Decrease mail accounts counter -accounts=$(wc -l $USER_DATA/mail/$domain.conf | cut -f 1 -d ' ') -decrease_user_value "$user" '$U_MAIL_ACCOUNTS' -update_object_value 'mail' 'DOMAIN' "$domain" '$ACCOUNTS' "$accounts" - - -# Logging -log_history "deleted $account@$domain mail account" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete mail account +# options: USER DOMAIN ACCOUNT +# +# The function deletes email account. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +account=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN ACCOUNT' +validate_format 'user' 'domain' 'account' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_valid "mail/$domain" 'ACCOUNT' "$account" +is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# +aliases=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS') +for al in ${aliases//,/ }; do + sed -i "/^$al@$domain:$account/d" $HOMEDIR/$user/conf/mail/$domain/aliases +done + +sed -i "/^$account@$domain:/d" $HOMEDIR/$user/conf/mail/$domain/aliases +sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd +rm -rf $HOMEDIR/$user/mail/$domain/$account + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +sed -i "/ACCOUNT='$account'/d" $USER_DATA/mail/$domain.conf + +# Decrease mail accounts counter +accounts=$(wc -l $USER_DATA/mail/$domain.conf | cut -f 1 -d ' ') +decrease_user_value "$user" '$U_MAIL_ACCOUNTS' +update_object_value 'mail' 'DOMAIN' "$domain" '$ACCOUNTS' "$accounts" + + +# Logging +log_history "deleted $account@$domain mail account" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-mail-account-alias b/bin/v-delete-mail-account-alias index 6a3744a85..eb628ea30 100755 --- a/bin/v-delete-mail-account-alias +++ b/bin/v-delete-mail-account-alias @@ -1,70 +1,70 @@ -#!/bin/bash -# info: delete mail account alias aka nickname -# options: user domain account alias -# -# The function deletes email account alias. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -account=$3 -malias=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'user domain account alias' -validate_format 'user' 'domain' 'account' 'malias' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" -aliases=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS') -if [ -z "$(echo $aliases | grep -w $malias)" ]; then - echo "Error: alias $malias is not exist" - log_event "$E_NOTEXIST $EVENT" - exit $E_NOTEXIST -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -sed -i "/^$malias@$domain:$account/d" $HOMEDIR/$user/conf/mail/$domain/aliases -aliases=$(echo "$aliases" |\ - sed -e "s/,/\n/g"|\ - sed -e "s/^$malias$//g"|\ - sed -e "/^$/d"|\ - sed -e ':a;N;$!ba;s/\n/,/g') - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS' "$aliases" - -# Logging -log_history "deleted alias $malias on $account@$domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete mail account alias aka nickname +# options: USER DOMAIN ACCOUNT ALIAS +# +# The function deletes email account alias. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +account=$3 +malias=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '4' "$#" 'USER DOMAIN ACCOUNT ALIAS' +validate_format 'user' 'domain' 'account' 'malias' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_valid "mail/$domain" 'ACCOUNT' "$account" +is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" +aliases=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS') +if [ -z "$(echo $aliases | grep -w $malias)" ]; then + echo "Error: alias $malias is not exist" + log_event "$E_NOTEXIST $EVENT" + exit $E_NOTEXIST +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +sed -i "/^$malias@$domain:$account/d" $HOMEDIR/$user/conf/mail/$domain/aliases +aliases=$(echo "$aliases" |\ + sed -e "s/,/\n/g"|\ + sed -e "s/^$malias$//g"|\ + sed -e "/^$/d"|\ + sed -e ':a;N;$!ba;s/\n/,/g') + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS' "$aliases" + +# Logging +log_history "deleted alias $malias on $account@$domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-mail-account-autoreply b/bin/v-delete-mail-account-autoreply index 6e72dba3b..05c8d15c3 100755 --- a/bin/v-delete-mail-account-autoreply +++ b/bin/v-delete-mail-account-autoreply @@ -1,61 +1,61 @@ -#!/bin/bash -# info: delete mail account autoreply message -# options: user domain account alias -# -# The function delete email account autoreply. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -account=$3 -malias=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user domain account' -validate_format 'user' 'domain' 'account' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" -is_object_value_exist "mail/$domain" 'ACCOUNT' "$account" '$AUTOREPLY' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -rm -f $HOMEDIR/$user/conf/mail/$domain/autoreply.$account.msg -rm -f $USER_DATA/mail/$domain/$account@$domain.msg - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$AUTOREPLY' 'no' - -# Logging -log_history "$EVENT" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete mail account autoreply message +# options: USER DOMAIN ACCOUNT ALIAS +# +# The function delete email account autoreply. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +account=$3 +malias=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN ACCOUNT' +validate_format 'user' 'domain' 'account' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_valid "mail/$domain" 'ACCOUNT' "$account" +is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" +is_object_value_exist "mail/$domain" 'ACCOUNT' "$account" '$AUTOREPLY' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +rm -f $HOMEDIR/$user/conf/mail/$domain/autoreply.$account.msg +rm -f $USER_DATA/mail/$domain/$account@$domain.msg + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value "mail/$domain" 'ACCOUNT' "$account" '$AUTOREPLY' 'no' + +# Logging +log_history "$EVENT" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-mail-account-forward b/bin/v-delete-mail-account-forward index 7066e0a72..083ca5316 100755 --- a/bin/v-delete-mail-account-forward +++ b/bin/v-delete-mail-account-forward @@ -1,72 +1,72 @@ -#!/bin/bash -# info: delte mail account forward -# options: user domain account email -# -# The function add delete email account forward address. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -account=$3 -forward=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'user domain account forward' -validate_format 'user' 'domain' 'account' 'forward' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" -fwd=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD') -if [ -z "$(echo $fwd | grep -w $forward)" ]; then - echo "Error: forward $forward is not exist" - log_event "$E_NOTEXIST $EVENT" - exit $E_NOTEXIST -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -fwd=$(echo "$fwd" |\ - sed -e "s/,/\n/g"|\ - sed -e "s/^$forward$//g"|\ - sed -e "/^$/d"|\ - sed -e ':a;N;$!ba;s/\n/,/g') - -sed -i "/^$account@$domain:/ d" $HOMEDIR/$user/conf/mail/$domain/aliases -echo "$account@$domain:$fwd" >> $HOMEDIR/$user/conf/mail/$domain/aliases - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD' "$fwd" - -# Logging -log_history "deleted $forward forward on $account@$domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delte mail account forward +# options: USER DOMAIN ACCOUNT EMAIL +# +# The function add delete email account forward address. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +account=$3 +forward=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '4' "$#" 'USER DOMAIN ACCOUNT FORWARD' +validate_format 'user' 'domain' 'account' 'forward' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_valid "mail/$domain" 'ACCOUNT' "$account" +is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" +fwd=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD') +if [ -z "$(echo $fwd | grep -w $forward)" ]; then + echo "Error: forward $forward is not exist" + log_event "$E_NOTEXIST $EVENT" + exit $E_NOTEXIST +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +fwd=$(echo "$fwd" |\ + sed -e "s/,/\n/g"|\ + sed -e "s/^$forward$//g"|\ + sed -e "/^$/d"|\ + sed -e ':a;N;$!ba;s/\n/,/g') + +sed -i "/^$account@$domain:/ d" $HOMEDIR/$user/conf/mail/$domain/aliases +echo "$account@$domain:$fwd" >> $HOMEDIR/$user/conf/mail/$domain/aliases + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD' "$fwd" + +# Logging +log_history "deleted $forward forward on $account@$domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-mail-domain b/bin/v-delete-mail-domain index 1d50f83bf..9d940a3cc 100755 --- a/bin/v-delete-mail-domain +++ b/bin/v-delete-mail-domain @@ -1,72 +1,72 @@ -#!/bin/bash -# info: delete mail domain -# options: user domain -# -# The function for deleting MAIL domain. By deleting it all accounts will -# also be deleted. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain' -validate_format 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get domain values -get_domain_values 'mail' -accounts=$(wc -l $USER_DATA/mail/$domain.conf|cut -f 1 -d ' ') - -rm -f /etc/exim/domains/$domain -rm -rf $HOMEDIR/$user/conf/$domain -rm -rf $HOMEDIR/$user/mail/$domain - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Delete domain config -sed -i "/DOMAIN='$domain'/ d" $USER_DATA/mail.conf -rm -f $USER_DATA/mail/$domain.conf -rm -f $USER_DATA/mail/$domain.pem -rm -f $USER_DATA/mail/$domain.pub -rm -f $USER_DATA/mail/*@$domain.msg - -# Decreasing domain value -decrease_user_value "$user" '$U_MAIL_DOMAINS' -if [ "$DKIM" = 'yes' ]; then - decrease_user_value "$user" '$U_MAIL_DKMI' -fi -decrease_user_value "$user" '$U_MAIL_ACCOUNTS' "$accounts" - - -# Logging -log_history "deleted mail domain $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete mail domain +# options: USER DOMAIN +# +# The function for deleting MAIL domain. By deleting it all accounts will +# also be deleted. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Get domain values +get_domain_values 'mail' +accounts=$(wc -l $USER_DATA/mail/$domain.conf|cut -f 1 -d ' ') + +rm -f /etc/exim/domains/$domain +rm -rf $HOMEDIR/$user/conf/$domain +rm -rf $HOMEDIR/$user/mail/$domain + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Delete domain config +sed -i "/DOMAIN='$domain'/ d" $USER_DATA/mail.conf +rm -f $USER_DATA/mail/$domain.conf +rm -f $USER_DATA/mail/$domain.pem +rm -f $USER_DATA/mail/$domain.pub +rm -f $USER_DATA/mail/*@$domain.msg + +# Decreasing domain value +decrease_user_value "$user" '$U_MAIL_DOMAINS' +if [ "$DKIM" = 'yes' ]; then + decrease_user_value "$user" '$U_MAIL_DKMI' +fi +decrease_user_value "$user" '$U_MAIL_ACCOUNTS' "$accounts" + + +# Logging +log_history "deleted mail domain $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-mail-domain-antispam b/bin/v-delete-mail-domain-antispam index 01ecb9190..f19631e15 100755 --- a/bin/v-delete-mail-domain-antispam +++ b/bin/v-delete-mail-domain-antispam @@ -1,57 +1,57 @@ -#!/bin/bash -# info: delete mail domain antispam support -# options: user domain -# -# The function disable spamassasin for incomming emails. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain' -validate_format 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_value_exist 'mail' 'DOMAIN' "$domain" '$ANTISPAM' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Delete antispam key -sed -i "/antispam/d" $HOMEDIR/$user/conf/mail/$domain/protection - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Delete antispam in config -update_object_value 'mail' 'DOMAIN' "$domain" '$ANTISPAM' 'no' - -# Logging -log_history "disabled antispam support for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete mail domain antispam support +# options: USER DOMAIN +# +# The function disable spamassasin for incomming emails. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_value_exist 'mail' 'DOMAIN' "$domain" '$ANTISPAM' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Delete antispam key +sed -i "/antispam/d" $HOMEDIR/$user/conf/mail/$domain/protection + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Delete antispam in config +update_object_value 'mail' 'DOMAIN' "$domain" '$ANTISPAM' 'no' + +# Logging +log_history "disabled antispam support for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-mail-domain-antivirus b/bin/v-delete-mail-domain-antivirus index 3fcc6ec75..c09ac61d9 100755 --- a/bin/v-delete-mail-domain-antivirus +++ b/bin/v-delete-mail-domain-antivirus @@ -1,57 +1,57 @@ -#!/bin/bash -# info: delete mail domain antivirus support -# options: user domain -# -# The function disables clamav scan for incomming emails. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain' -validate_format 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_value_exist 'mail' 'DOMAIN' "$domain" '$ANTIVIRUS' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Delete antivirus key -sed -i "/antivirus/d" $HOMEDIR/$user/conf/mail/$domain/protection - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Delete antivirus in config -update_object_value 'mail' 'DOMAIN' "$domain" '$ANTIVIRUS' 'no' - -# Logging -log_history "disabled antivirus support on $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete mail domain antivirus support +# options: USER DOMAIN +# +# The function disables clamav scan for incomming emails. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_value_exist 'mail' 'DOMAIN' "$domain" '$ANTIVIRUS' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Delete antivirus key +sed -i "/antivirus/d" $HOMEDIR/$user/conf/mail/$domain/protection + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Delete antivirus in config +update_object_value 'mail' 'DOMAIN' "$domain" '$ANTIVIRUS' 'no' + +# Logging +log_history "disabled antivirus support on $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-mail-domain-catchall b/bin/v-delete-mail-domain-catchall index 6f90b3548..4ec0fc0d7 100755 --- a/bin/v-delete-mail-domain-catchall +++ b/bin/v-delete-mail-domain-catchall @@ -1,57 +1,57 @@ -#!/bin/bash -# info: delete mail domain catchall email -# options: user domain -# -# The function disables mail domain cathcall. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain' -validate_format 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_value_exist 'mail' 'DOMAIN' "$domain" '$CATCHALL' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Delete cathcall alias -sed -i "/*@$domain:/d" $HOMEDIR/$user/conf/mail/$domain/aliases - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Delete catchall in config -update_object_value 'mail' 'DOMAIN' "$domain" '$CATCHALL' '' - -# Logging -log_history "delted catchall email on $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete mail domain catchall email +# options: USER DOMAIN +# +# The function disables mail domain cathcall. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_value_exist 'mail' 'DOMAIN' "$domain" '$CATCHALL' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Delete cathcall alias +sed -i "/*@$domain:/d" $HOMEDIR/$user/conf/mail/$domain/aliases + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Delete catchall in config +update_object_value 'mail' 'DOMAIN' "$domain" '$CATCHALL' '' + +# Logging +log_history "delted catchall email on $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-mail-domain-dkim b/bin/v-delete-mail-domain-dkim index 6e639703b..16c4943bb 100755 --- a/bin/v-delete-mail-domain-dkim +++ b/bin/v-delete-mail-domain-dkim @@ -1,69 +1,69 @@ -#!/bin/bash -# info: delete mail domain dkim support -# options: user domain [dkim_size] -# -# The function delete DKIM domain pem. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain' -validate_format 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_value_exist 'mail' 'DOMAIN' "$domain" '$DKIM' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Generating dkim -rm -f $USER_DATA/mail/$domain.pem -rm -f $USER_DATA/mail/$domain.pub -rm -f $HOMEDIR/$user/conf/mail/$domain/dkim.pem - -# Checking dns domain -check_dns_domain=$(is_object_valid 'dns' 'DOMAIN' "$domain") -if [ "$?" -eq 0 ]; then - records=$($BIN/v-list-dns-domain-records $user $domain plain) - dkim_records=$(echo "$records" |grep -w '_domainkey' | cut -f 1 -d ' ') - for id in $dkim_records; do - $BIN/v-delete-dns-domain-record $user $domain $id - done -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updatoing config -update_object_value 'mail' 'DOMAIN' "$domain" '$DKIM' 'no' -decrease_user_value "$user" '$U_MAIL_DKMI' - -# Logging -log_history "disabled DKIM support on $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete mail domain dkim support +# options: USER DOMAIN [DKIM_SIZE] +# +# The function delete DKIM domain pem. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_value_exist 'mail' 'DOMAIN' "$domain" '$DKIM' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Generating dkim +rm -f $USER_DATA/mail/$domain.pem +rm -f $USER_DATA/mail/$domain.pub +rm -f $HOMEDIR/$user/conf/mail/$domain/dkim.pem + +# Checking dns domain +check_dns_domain=$(is_object_valid 'dns' 'DOMAIN' "$domain") +if [ "$?" -eq 0 ]; then + records=$($BIN/v-list-dns-domain-records $user $domain plain) + dkim_records=$(echo "$records" |grep -w '_domainkey' | cut -f 1 -d ' ') + for id in $dkim_records; do + $BIN/v-delete-dns-domain-record $user $domain $id + done +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Updatoing config +update_object_value 'mail' 'DOMAIN' "$domain" '$DKIM' 'no' +decrease_user_value "$user" '$U_MAIL_DKMI' + +# Logging +log_history "disabled DKIM support on $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-mail-domains b/bin/v-delete-mail-domains index 27a9e1299..051eab84c 100755 --- a/bin/v-delete-mail-domains +++ b/bin/v-delete-mail-domains @@ -1,47 +1,47 @@ -#!/bin/bash -# info: delete mail domains -# options: user -# -# The function for deleting all users mail domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user' -validate_format 'user' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting delete loop -for domain in $(search_objects 'mail' 'SUSPENDED' "no" 'DOMAIN'); do - $BIN/v-delete-mail-domain "$user" "$domain" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete mail domains +# options: USER +# +# The function for deleting all users mail domains. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting delete loop +for domain in $(search_objects 'mail' 'SUSPENDED' "no" 'DOMAIN'); do + $BIN/v-delete-mail-domain "$user" "$domain" +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-sys-ip b/bin/v-delete-sys-ip index 92c0a39b7..a2fa6f2e4 100755 --- a/bin/v-delete-sys-ip +++ b/bin/v-delete-sys-ip @@ -1,94 +1,94 @@ -#!/bin/bash -# info: delete system ip -# options: ip -# -# The function for deleting a system ip. It does not allow to delete first ip -# on interface and do not allow to delete ip which is used by a web domain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -ip=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/ip.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'ip' -validate_format 'ip' -is_ip_valid "$ip" -is_ip_key_empty '$U_WEB_DOMAINS' -is_ip_key_empty '$U_SYS_USERS' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config paths -conf='/etc/httpd/conf.d/vesta.conf' -nconf='/etc/nginx/conf.d/vesta_ip.conf' -iconf='/etc/sysconfig/network-scripts/ifcfg' -rconf='/etc/httpd/conf.d/mod_extract_forwarded.conf' - -# Get ip owner -user="$(get_ip_value '$OWNER')" -ip_status="$(get_ip_value '$STATUS')" - -# Deleting interface -get_current_interface -/sbin/ifconfig "$interface" down - -# Deleting startup script -rm -f $iconf-$interface - -# Deleting vesta ip -rm -f $VESTA/data/ips/$ip - -# Deleting namehosting support -namehost_ip_disable - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating user conf -if [ ! -z "$user" ]; then - decrease_user_value "$user" '$IP_OWNED' -fi - -if [ "$user" = 'admin' ]; then - if [ "$ip_status" = 'shared' ]; then - for user in $(ls $VESTA/data/users/); do - decrease_user_value "$user" '$IP_AVAIL' - done - else - decrease_user_value 'admin' '$IP_AVAIL' - fi -else - decrease_user_value "$user" '$IP_AVAIL' - decrease_user_value 'admin' '$IP_AVAIL' -fi - - -# Adding task to the vesta pipe -if [ "$web_restart" = 'yes' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_history "delted system ip address $ip" '' 'admin' -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete system ip +# options: IP +# +# The function for deleting a system ip. It does not allow to delete first ip +# on interface and do not allow to delete ip which is used by a web domain. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +ip=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/ip.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'IP' +validate_format 'ip' +is_ip_valid "$ip" +is_ip_key_empty '$U_WEB_DOMAINS' +is_ip_key_empty '$U_SYS_USERS' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config paths +conf='/etc/httpd/conf.d/vesta.conf' +nconf='/etc/nginx/conf.d/vesta_ip.conf' +iconf='/etc/sysconfig/network-scripts/ifcfg' +rconf='/etc/httpd/conf.d/mod_extract_forwarded.conf' + +# Get ip owner +user="$(get_ip_value '$OWNER')" +ip_status="$(get_ip_value '$STATUS')" + +# Deleting interface +get_current_interface +/sbin/ifconfig "$interface" down + +# Deleting startup script +rm -f $iconf-$interface + +# Deleting vesta ip +rm -f $VESTA/data/ips/$ip + +# Deleting namehosting support +namehost_ip_disable + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Updating user conf +if [ ! -z "$user" ]; then + decrease_user_value "$user" '$IP_OWNED' +fi + +if [ "$user" = 'admin' ]; then + if [ "$ip_status" = 'shared' ]; then + for user in $(ls $VESTA/data/users/); do + decrease_user_value "$user" '$IP_AVAIL' + done + else + decrease_user_value 'admin' '$IP_AVAIL' + fi +else + decrease_user_value "$user" '$IP_AVAIL' + decrease_user_value 'admin' '$IP_AVAIL' +fi + + +# Adding task to the vesta pipe +if [ "$web_restart" = 'yes' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_history "delted system ip address $ip" '' 'admin' +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-user b/bin/v-delete-user index 927f49c10..8007b0993 100755 --- a/bin/v-delete-user +++ b/bin/v-delete-user @@ -1,113 +1,113 @@ -#!/bin/bash -# info: delete user -# options: user -# -# This function deletes a certain user and all his resourses such as domains, -# databases, cron jobs, etc. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -restart=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/db.sh -source $VESTA/func/ip.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -if [ "$user" = 'admin' ]; then - exit -fi - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Checking web system is enabled -if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then - $BIN/v-unsuspend-web-domains $user $restart - $BIN/v-delete-web-domains $user $restart - rv="$?" - if [ "$rv" -ne '0' ]; then - exit $rv - fi -fi - -# Checking dns system is enabled -if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then - $BIN/v-unsuspend-dns-domains $user $restart - $BIN/v-delete-dns-domains $user $restart - rv="$?" - if [ "$rv" -ne '0' ]; then - exit $rv - fi -fi - -# Checking mail system is enabled -if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then - $BIN/v-unsuspend-mail-domains $user - $BIN/v-delete-mail-domains $user - rv="$?" - if [ "$rv" -ne '0' ]; then - exit $rv - fi -fi - -# Checking db system is enabled -if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then - $BIN/v-unsuspend-databases $user - $BIN/v-delete-databases $user - rv="$?" - if [ "$rv" -ne '0' ]; then - exit $rv - fi -fi - -# Checking ip -$BIN/v-delete-user-ips "$user" -rv="$?" -if [ "$rv" -ne '0' ]; then - exit $rv -fi - -# Deleteing user pipes -sed -i "/ $user$/d" $VESTA/data/queue/disk.pipe -sed -i "/ $user$/d" $VESTA/data/queue/traffic.pipe - -# Removing system user -/usr/sbin/userdel -f $user -rm -rf $HOMEDIR/$user -rm -f /var/spool/mail/$user -rm -f /var/spool/cron/$user -rm -rf $USER_DATA - -# Updating admin counter -if [ "$user" != 'admin' ]; then - decrease_user_value 'admin' '$U_USERS' -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "deleted system user $user" '' 'admin' -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete user +# options: USER +# +# This function deletes a certain user and all his resourses such as domains, +# databases, cron jobs, etc. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +restart=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh +source $VESTA/func/db.sh +source $VESTA/func/ip.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +if [ "$user" = 'admin' ]; then + exit +fi + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Checking web system is enabled +if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then + $BIN/v-unsuspend-web-domains $user $restart + $BIN/v-delete-web-domains $user $restart + rv="$?" + if [ "$rv" -ne '0' ]; then + exit $rv + fi +fi + +# Checking dns system is enabled +if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then + $BIN/v-unsuspend-dns-domains $user $restart + $BIN/v-delete-dns-domains $user $restart + rv="$?" + if [ "$rv" -ne '0' ]; then + exit $rv + fi +fi + +# Checking mail system is enabled +if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then + $BIN/v-unsuspend-mail-domains $user + $BIN/v-delete-mail-domains $user + rv="$?" + if [ "$rv" -ne '0' ]; then + exit $rv + fi +fi + +# Checking db system is enabled +if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then + $BIN/v-unsuspend-databases $user + $BIN/v-delete-databases $user + rv="$?" + if [ "$rv" -ne '0' ]; then + exit $rv + fi +fi + +# Checking ip +$BIN/v-delete-user-ips "$user" +rv="$?" +if [ "$rv" -ne '0' ]; then + exit $rv +fi + +# Deleteing user pipes +sed -i "/ $user$/d" $VESTA/data/queue/disk.pipe +sed -i "/ $user$/d" $VESTA/data/queue/traffic.pipe + +# Removing system user +/usr/sbin/userdel -f $user +rm -rf $HOMEDIR/$user +rm -f /var/spool/mail/$user +rm -f /var/spool/cron/$user +rm -rf $USER_DATA + +# Updating admin counter +if [ "$user" != 'admin' ]; then + decrease_user_value 'admin' '$U_USERS' +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_history "deleted system user $user" '' 'admin' +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-user-backup b/bin/v-delete-user-backup index ba3bb5f6b..89aad3b3b 100755 --- a/bin/v-delete-user-backup +++ b/bin/v-delete-user-backup @@ -1,53 +1,53 @@ -#!/bin/bash -# info: delete user backup -# options: user nackup -# -# The function deletes user backup. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -backup=$(echo $2| cut -f 2 -d \.) - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user backup' -validate_format 'user' 'backup' -is_system_enabled "$BACKUP_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'backup' 'BACKUP' "$2" - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting backup -rm -f $BACKUP/$2 -sed -i "/BACKUP='$2' /d" $USER_DATA/backup.conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update counter -U_BACKUPS=$(ls $BACKUP/|grep "^$user."|wc -l) -update_user_value "$user" '$U_BACKUPS' "$U_BACKUPS" - -# Logging -log_history "deleted backup archive $backup" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete user backup +# options: USER NACKUP +# +# The function deletes user backup. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +backup=$(echo $2| cut -f 2 -d \.) + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER BACKUP' +validate_format 'user' 'backup' +is_system_enabled "$BACKUP_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'backup' 'BACKUP' "$2" + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Deleting backup +rm -f $BACKUP/$2 +sed -i "/BACKUP='$2' /d" $USER_DATA/backup.conf + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update counter +U_BACKUPS=$(ls $BACKUP/|grep "^$user."|wc -l) +update_user_value "$user" '$U_BACKUPS' "$U_BACKUPS" + +# Logging +log_history "deleted backup archive $backup" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-user-ips b/bin/v-delete-user-ips index 864694e06..42def91a4 100755 --- a/bin/v-delete-user-ips +++ b/bin/v-delete-user-ips @@ -1,63 +1,63 @@ -#!/bin/bash -# info: delete user ips -# options: user -# -# The function deletes all user's ip addresses. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/ip.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -if [ "$user" = 'admin' ]; then - exit -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing user ips -ip_list=$(grep -H "OWNER='$user'" $VESTA/data/ips/* | cut -f 1 -d:) - -for ip in $ip_list; do - ip=$(basename $ip) - - # Checking webdomains and users - is_ip_key_empty '$U_WEB_DOMAINS' - is_ip_key_empty '$U_SYS_USERS' - - # Assig ip to main account - update_ip_value '$OWNER' 'admin' - update_ip_value '$STATUS' 'dedicated' - increase_user_value 'admin' '$IP_OWNED' - increase_user_value 'admin' '$IP_AVAIL' -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete user ips +# options: USER +# +# The function deletes all user's ip addresses. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/ip.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +if [ "$user" = 'admin' ]; then + exit +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Parsing user ips +ip_list=$(grep -H "OWNER='$user'" $VESTA/data/ips/* | cut -f 1 -d:) + +for ip in $ip_list; do + ip=$(basename $ip) + + # Checking webdomains and users + is_ip_key_empty '$U_WEB_DOMAINS' + is_ip_key_empty '$U_SYS_USERS' + + # Assig ip to main account + update_ip_value '$OWNER' 'admin' + update_ip_value '$STATUS' 'dedicated' + increase_user_value 'admin' '$IP_OWNED' + increase_user_value 'admin' '$IP_AVAIL' +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-user-package b/bin/v-delete-user-package index 1867bf961..d6157eed0 100755 --- a/bin/v-delete-user-package +++ b/bin/v-delete-user-package @@ -1,55 +1,55 @@ -#!/bin/bash -# info: delete user package -# options: package -# -# The function for deleting user package. It does not allow to delete pacakge -# if it is in use. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -package=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - -# Functions -is_package_in_use() { - check_package=$(grep "PACKAGE='$package'" $USER_DATA/*/user.conf) - if [ ! -z "$check_package" ]; then - echo "Error: package $package is in use" - log_event "$E_INUSE" "$EVENT" - exit $E_INUSE - fi -} - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'package' -validate_format 'package' -is_package_valid -is_package_in_use - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting user package -rm -f $VESTA/data/packages/$package.pkg - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -log_history "deleted user package $package" '' 'admin' -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete user package +# options: PACKAGE +# +# The function for deleting user package. It does not allow to delete pacakge +# if it is in use. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +package=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + +# Functions +is_package_in_use() { + check_package=$(grep "PACKAGE='$package'" $USER_DATA/*/user.conf) + if [ ! -z "$check_package" ]; then + echo "Error: package $package is in use" + log_event "$E_INUSE" "$EVENT" + exit $E_INUSE + fi +} + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'PACKAGE' +validate_format 'package' +is_package_valid +is_package_in_use + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Deleting user package +rm -f $VESTA/data/packages/$package.pkg + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +log_history "deleted user package $package" '' 'admin' +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-web-domain b/bin/v-delete-web-domain index d58cd70c9..6c54a7cd0 100755 --- a/bin/v-delete-web-domain +++ b/bin/v-delete-web-domain @@ -1,165 +1,165 @@ -#!/bin/bash -# info: delete web domain -# options: user domain -# -# The call of function leads to the removal of domain and all its components -# (statistics, folders contents, ssl certificates, etc.). This operation is -# not fully supported by "undo" function, so the data recovery is possible -# only with a help of reserve copy. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -restart=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/ip.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get template name -get_domain_values 'web' -tpl_file="$WEBTPL/apache_$TPL.tpl" -conf="$HOMEDIR/$user/conf/web/httpd.conf" - -# Deleting domain -del_web_config - -# Checking aliases -if [ ! -z "$ALIAS" ]; then - aliases=$(echo $ALIAS | tr ',' '\n' | wc -l ) -else - aliases=0 -fi - -# Checking ssl -if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/apache_$TPL.stpl" - conf="$HOMEDIR/$user/conf/web/shttpd.conf" - del_web_config - - # Deleting certificates - rm -f $HOMEDIR/$user/conf/web/ssl.$domain.* - rm -f $USER_DATA/ssl/$domain.* -fi - -# Checking nginx -if [ ! -z "$NGINX" ]; then - tpl_file="$WEBTPL/nginx_$NGINX.tpl" - conf="$HOMEDIR/$user/conf/web/nginx.conf" - del_web_config - - if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web/snginx.conf" - del_web_config - fi -fi - -# Checking stats -if [ ! -z "$STATS" ] && [ "$STATS" != 'no' ]; then - sed -i "/ $domain$/d" $VESTA/data/queue/webstats.pipe - rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf - rm -f /etc/awstats/$STATS.$domain.conf -fi - -# Deleting ftp account -if [ ! -z "$FTP_USER" ]; then - /usr/sbin/userdel $FTP_USER -fi - -# Deleting directory -rm -rf $HOMEDIR/$user/web/$domain - -# Deleting logs -rm -f /var/log/httpd/domains/$domain.log* -rm -f /var/log/httpd/domains/$domain.bytes -rm -f /var/log/httpd/domains/$domain.error* - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Deleting domain -sed -i "/DOMAIN='$domain'/ d" $USER_DATA/web.conf - -# Checking last ssl domain -ssl_dom=$(grep "SSL='yes'" $USER_DATA/web.conf | wc -l) -if [ "$ssl_dom" -eq '0' ]; then - sed -i "s/ Include /#Include /" $HOMEDIR/$user/conf/web/httpd.conf -fi - -# Checking last domain -domains=$(wc -l $USER_DATA/web.conf|cut -f 1 -d ' ') -if [ "$domains" -eq '0' ]; then - conf='/etc/httpd/conf.d/vesta.conf' - line=$(grep -n "$HOMEDIR/$user/conf/web/httpd.conf" $conf | cut -f 1 -d : ) - if [ ! -z "$line" ]; then - sed -i "$line d" $conf - fi -fi - -# Checking last nginx domain -conf='/etc/nginx/conf.d/vesta_users.conf' -last_nginx=$(grep -v "NGINX=''" $USER_DATA/web.conf) -last_snginx=$(echo "$last_nginx" | grep "SSL='yes'") -if [ -z "$last_snginx" ]; then - sline=$(grep -n "$HOMEDIR/$user/conf/web/snginx.conf" $conf |cut -f 1 -d :) - if [ ! -z "$sline" ]; then - sed -i "$sline d" $conf - fi - rm -f $HOMEDIR/$user/conf/web/snginx.conf -fi - -if [ -z "$last_nginx" ]; then - line=$(grep -n "$HOMEDIR/$user/conf/web/nginx.conf" $conf | cut -f 1 -d : ) - if [ ! -z "$line" ]; then - sed -i "$line d" $conf - fi - rm -f $HOMEDIR/$user/conf/web/nginx.conf -fi - -# Decrease counters -decrease_ip_value "$IP" -decrease_user_value "$user" '$U_WEB_DOMAINS' -decrease_user_value "$user" '$U_WEB_ALIASES' "$aliases" -if [ "$SSL" = 'yes' ]; then - decrease_user_value "$user" '$U_WEB_SSL' -fi - -# Restart web server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_history "deleted web domain $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete web domain +# options: USER DOMAIN +# +# The call of function leads to the removal of domain and all its components +# (statistics, folders contents, ssl certificates, etc.). This operation is +# not fully supported by "undo" function, so the data recovery is possible +# only with a help of reserve copy. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +restart=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh +source $VESTA/func/ip.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Get template name +get_domain_values 'web' +tpl_file="$WEBTPL/apache_$TPL.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" + +# Deleting domain +del_web_config + +# Checking aliases +if [ ! -z "$ALIAS" ]; then + aliases=$(echo $ALIAS | tr ',' '\n' | wc -l ) +else + aliases=0 +fi + +# Checking ssl +if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" + del_web_config + + # Deleting certificates + rm -f $HOMEDIR/$user/conf/web/ssl.$domain.* + rm -f $USER_DATA/ssl/$domain.* +fi + +# Checking nginx +if [ ! -z "$NGINX" ]; then + tpl_file="$WEBTPL/nginx_$NGINX.tpl" + conf="$HOMEDIR/$user/conf/web/nginx.conf" + del_web_config + + if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + del_web_config + fi +fi + +# Checking stats +if [ ! -z "$STATS" ] && [ "$STATS" != 'no' ]; then + sed -i "/ $domain$/d" $VESTA/data/queue/webstats.pipe + rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf + rm -f /etc/awstats/$STATS.$domain.conf +fi + +# Deleting ftp account +if [ ! -z "$FTP_USER" ]; then + /usr/sbin/userdel $FTP_USER +fi + +# Deleting directory +rm -rf $HOMEDIR/$user/web/$domain + +# Deleting logs +rm -f /var/log/httpd/domains/$domain.log* +rm -f /var/log/httpd/domains/$domain.bytes +rm -f /var/log/httpd/domains/$domain.error* + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Deleting domain +sed -i "/DOMAIN='$domain'/ d" $USER_DATA/web.conf + +# Checking last ssl domain +ssl_dom=$(grep "SSL='yes'" $USER_DATA/web.conf | wc -l) +if [ "$ssl_dom" -eq '0' ]; then + sed -i "s/ Include /#Include /" $HOMEDIR/$user/conf/web/httpd.conf +fi + +# Checking last domain +domains=$(wc -l $USER_DATA/web.conf|cut -f 1 -d ' ') +if [ "$domains" -eq '0' ]; then + conf='/etc/httpd/conf.d/vesta.conf' + line=$(grep -n "$HOMEDIR/$user/conf/web/httpd.conf" $conf | cut -f 1 -d : ) + if [ ! -z "$line" ]; then + sed -i "$line d" $conf + fi +fi + +# Checking last nginx domain +conf='/etc/nginx/conf.d/vesta_users.conf' +last_nginx=$(grep -v "NGINX=''" $USER_DATA/web.conf) +last_snginx=$(echo "$last_nginx" | grep "SSL='yes'") +if [ -z "$last_snginx" ]; then + sline=$(grep -n "$HOMEDIR/$user/conf/web/snginx.conf" $conf |cut -f 1 -d :) + if [ ! -z "$sline" ]; then + sed -i "$sline d" $conf + fi + rm -f $HOMEDIR/$user/conf/web/snginx.conf +fi + +if [ -z "$last_nginx" ]; then + line=$(grep -n "$HOMEDIR/$user/conf/web/nginx.conf" $conf | cut -f 1 -d : ) + if [ ! -z "$line" ]; then + sed -i "$line d" $conf + fi + rm -f $HOMEDIR/$user/conf/web/nginx.conf +fi + +# Decrease counters +decrease_ip_value "$IP" +decrease_user_value "$user" '$U_WEB_DOMAINS' +decrease_user_value "$user" '$U_WEB_ALIASES' "$aliases" +if [ "$SSL" = 'yes' ]; then + decrease_user_value "$user" '$U_WEB_SSL' +fi + +# Restart web server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_history "deleted web domain $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-web-domain-alias b/bin/v-delete-web-domain-alias index 7bb7d8fa5..5a901d967 100755 --- a/bin/v-delete-web-domain-alias +++ b/bin/v-delete-web-domain-alias @@ -1,108 +1,108 @@ -#!/bin/bash -# info: delete web domain alias -# options: user domain alias [restart] -# -# The function of deleting the alias domain (parked domain). By this call -# default www aliase can be removed as well. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain" ) -dom_alias=$(idn -t --quiet -u "$3" ) -dom_alias_idn=$(idn -t --quiet -a "$dom_alias" ) -restart="$4" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user domain dom_alias [restart]' -validate_format 'user' 'domain' 'dom_alias' -is_system_enabled 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -get_domain_values 'web' -if [ -z "$(echo $ALIAS | tr ',' '\n' | grep ^$dom_alias$)" ]; then - echo "Error: alias $dom_alias not exist" - log_event "$E_NOTEXIST" "$EVENT" - exit $E_NOTEXIST -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining new alias string -ALIAS=$(echo "$ALIAS" |\ - sed -e "s/,/\n/g"|\ - sed -e "s/^$dom_alias$//g"|\ - sed -e "/^$/d"|\ - sed -e ':a;N;$!ba;s/\n/,/g') -tpl_file="$WEBTPL/apache_$TPL.tpl" -conf="$HOMEDIR/$user/conf/web/httpd.conf" - -# Preparing domain values for the template substitution -upd_web_domain_values - -# Recreating vhost -del_web_config -add_web_config - -if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/apache_$TPL.stpl" - conf="$HOMEDIR/$user/conf/web/shttpd.conf" - del_web_config - add_web_config -fi - -# Checking nginx -if [ ! -z "$NGINX" ]; then - tpl_file="$WEBTPL/nginx_$NGINX.tpl" - conf="$HOMEDIR/$user/conf/web/nginx.conf" - del_web_config - add_web_config - - if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web/snginx.conf" - del_web_config - add_web_config - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$ALIAS' "$ALIAS" - -# Update counters -decrease_user_value "$user" '$U_WEB_ALIASES' - -# Restart web server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_history "deleted alias $dom_alias on $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete web domain alias +# options: USER DOMAIN ALIAS [RESTART] +# +# The function of deleting the alias domain (parked domain). By this call +# default www aliase can be removed as well. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain" ) +dom_alias=$(idn -t --quiet -u "$3" ) +dom_alias_idn=$(idn -t --quiet -a "$dom_alias" ) +restart="$4" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN DOM_ALIAS [RESTART]' +validate_format 'user' 'domain' 'dom_alias' +is_system_enabled 'WEB_SYSTEM' +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +get_domain_values 'web' +if [ -z "$(echo $ALIAS | tr ',' '\n' | grep ^$dom_alias$)" ]; then + echo "Error: alias $dom_alias not exist" + log_event "$E_NOTEXIST" "$EVENT" + exit $E_NOTEXIST +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining new alias string +ALIAS=$(echo "$ALIAS" |\ + sed -e "s/,/\n/g"|\ + sed -e "s/^$dom_alias$//g"|\ + sed -e "/^$/d"|\ + sed -e ':a;N;$!ba;s/\n/,/g') +tpl_file="$WEBTPL/apache_$TPL.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" + +# Preparing domain values for the template substitution +upd_web_domain_values + +# Recreating vhost +del_web_config +add_web_config + +if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" + del_web_config + add_web_config +fi + +# Checking nginx +if [ ! -z "$NGINX" ]; then + tpl_file="$WEBTPL/nginx_$NGINX.tpl" + conf="$HOMEDIR/$user/conf/web/nginx.conf" + del_web_config + add_web_config + + if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + del_web_config + add_web_config + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$ALIAS' "$ALIAS" + +# Update counters +decrease_user_value "$user" '$U_WEB_ALIASES' + +# Restart web server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_history "deleted alias $dom_alias on $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-web-domain-cgi b/bin/v-delete-web-domain-cgi index 47b057cdd..dea6e7733 100755 --- a/bin/v-delete-web-domain-cgi +++ b/bin/v-delete-web-domain-cgi @@ -1,79 +1,79 @@ -#!/bin/bash -# info: delete web domain cgi support -# options: user domain -# -# The function for deleting cgi support (adds -ExecCGI directive into -# configuration file). It is recommended to apply this function only for a -# temporary use (for lightening the consequences of DDoS, for example); -# otherwise it is preferable to use templates. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$CGI' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -get_domain_values 'web' -tpl_file="$WEBTPL/apache_$TPL.tpl" -conf="$HOMEDIR/$user/conf/web/httpd.conf" -CGI='no' - -# Preparing domain values for the template substitution -upd_web_domain_values - -# Recreating vhost -del_web_config -add_web_config - -# Checking ssl -if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/apache_$TPL.stpl" - conf="$HOMEDIR/$user/conf/web/shttpd.conf" - del_web_config - add_web_config -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$CGI' 'no' - -# Restart web server -$BIN/v-restart-web "$EVENT" - -# Logging -log_history "disabled cgi support for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete web domain cgi support +# options: USER DOMAIN +# +# The function for deleting cgi support (adds -ExecCGI directive into +# configuration file). It is recommended to apply this function only for a +# temporary use (for lightening the consequences of DDoS, for example); +# otherwise it is preferable to use templates. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_exist 'web' 'DOMAIN' "$domain" '$CGI' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +get_domain_values 'web' +tpl_file="$WEBTPL/apache_$TPL.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" +CGI='no' + +# Preparing domain values for the template substitution +upd_web_domain_values + +# Recreating vhost +del_web_config +add_web_config + +# Checking ssl +if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" + del_web_config + add_web_config +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$CGI' 'no' + +# Restart web server +$BIN/v-restart-web "$EVENT" + +# Logging +log_history "disabled cgi support for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-web-domain-elog b/bin/v-delete-web-domain-elog index 4b33fa7f4..9ca171c30 100755 --- a/bin/v-delete-web-domain-elog +++ b/bin/v-delete-web-domain-elog @@ -1,97 +1,97 @@ -#!/bin/bash -# info: delete web domain error loggin support -# options: user domain [restart] -# -# The function of disabling error logging feature. It comments ErrorLog -# direcitve in apache or/and nginx configuration. The data already collected -# remains untouched. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -restart=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain [restart]' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$ELOG' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain values -get_domain_values 'web' -tpl_file="$WEBTPL/apache_$TPL.tpl" -conf="$HOMEDIR/$user/conf/web/httpd.conf" -ELOG='no' - -# Preparing domain values for the template substitution -upd_web_domain_values - -# Recreating vhost -del_web_config -add_web_config - -# Checking ssl -if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/apache_$TPL.stpl" - conf="$HOMEDIR/$user/conf/web/shttpd.conf" - del_web_config - add_web_config -fi - -# Checking nginx -if [ ! -z "$NGINX" ]; then - tpl_file="$WEBTPL/nginx_$NGINX.tpl" - conf="$HOMEDIR/$user/conf/web/nginx.conf" - del_web_config - add_web_config - - if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web/snginx.conf" - del_web_config - add_web_config - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$ELOG' 'no' - -# Restart web server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_history "disabled error logging for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete web domain error loggin support +# options: USER DOMAIN [RESTART] +# +# The function of disabling error logging feature. It comments ErrorLog +# direcitve in apache or/and nginx configuration. The data already collected +# remains untouched. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +restart=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [RESTART]' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_exist 'web' 'DOMAIN' "$domain" '$ELOG' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Parsing domain values +get_domain_values 'web' +tpl_file="$WEBTPL/apache_$TPL.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" +ELOG='no' + +# Preparing domain values for the template substitution +upd_web_domain_values + +# Recreating vhost +del_web_config +add_web_config + +# Checking ssl +if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" + del_web_config + add_web_config +fi + +# Checking nginx +if [ ! -z "$NGINX" ]; then + tpl_file="$WEBTPL/nginx_$NGINX.tpl" + conf="$HOMEDIR/$user/conf/web/nginx.conf" + del_web_config + add_web_config + + if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + del_web_config + add_web_config + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$ELOG' 'no' + +# Restart web server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_history "disabled error logging for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-web-domain-ftp b/bin/v-delete-web-domain-ftp index 80942be77..78183f101 100755 --- a/bin/v-delete-web-domain-ftp +++ b/bin/v-delete-web-domain-ftp @@ -1,58 +1,58 @@ -#!/bin/bash -# info: delete webdomain ftp account. -# options: user domain -# -# The function deletes additional ftp account. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$FTP_USER' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding user -get_domain_values 'web' -/usr/sbin/userdel $FTP_USER - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$FTP_USER' '' -update_object_value 'web' 'DOMAIN' "$domain" '$FTP_MD5' '' - -# Logging -log_history "deleted ftp account $FTP_USER for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete webdomain ftp account. +# options: USER DOMAIN +# +# The function deletes additional ftp account. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_exist 'web' 'DOMAIN' "$domain" '$FTP_USER' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Adding user +get_domain_values 'web' +/usr/sbin/userdel $FTP_USER + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$FTP_USER' '' +update_object_value 'web' 'DOMAIN' "$domain" '$FTP_MD5' '' + +# Logging +log_history "deleted ftp account $FTP_USER for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-web-domain-nginx b/bin/v-delete-web-domain-nginx index f7613ae20..23c8c0f54 100755 --- a/bin/v-delete-web-domain-nginx +++ b/bin/v-delete-web-domain-nginx @@ -1,87 +1,87 @@ -#!/bin/bash -# info: deleting web domain nginx configuration -# options: user domain -# -# The function of deleting the virtualhost nginx configuration. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -restart=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$NGINX' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining domain parameters -get_domain_values 'web' -tpl_file="$WEBTPL/nginx_$NGINX.tpl" -conf="$HOMEDIR/$user/conf/web/nginx.conf" -del_web_config - -# Checking ssl -if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web/snginx.conf" - del_web_config -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$NGINX' '' -update_object_value 'web' 'DOMAIN' "$domain" '$NGINX_EXT' '' - -# Checking last nginx domain -conf='/etc/nginx/conf.d/vesta_users.conf' -last_nginx=$(grep -v "NGINX=''" $USER_DATA/web.conf) -last_snginx=$(echo "$last_nginx" | grep "SSL='yes'") -if [ -z "$last_snginx" ]; then - sed -i "/$user\/conf\/web\/snginx.conf/d" $conf - rm -f $HOMEDIR/$user/conf/web/snginx.conf -fi - -if [ -z "$last_nginx" ]; then - sed -i "/$user\/conf\/web\/nginx.conf/d" $conf - rm -f $HOMEDIR/$user/conf/web/nginx.conf -fi - -# Restart web server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_history "disabled nginx support for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: deleting web domain nginx configuration +# options: USER DOMAIN +# +# The function of deleting the virtualhost nginx configuration. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +restart=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_exist 'web' 'DOMAIN' "$domain" '$NGINX' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining domain parameters +get_domain_values 'web' +tpl_file="$WEBTPL/nginx_$NGINX.tpl" +conf="$HOMEDIR/$user/conf/web/nginx.conf" +del_web_config + +# Checking ssl +if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + del_web_config +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$NGINX' '' +update_object_value 'web' 'DOMAIN' "$domain" '$NGINX_EXT' '' + +# Checking last nginx domain +conf='/etc/nginx/conf.d/vesta_users.conf' +last_nginx=$(grep -v "NGINX=''" $USER_DATA/web.conf) +last_snginx=$(echo "$last_nginx" | grep "SSL='yes'") +if [ -z "$last_snginx" ]; then + sed -i "/$user\/conf\/web\/snginx.conf/d" $conf + rm -f $HOMEDIR/$user/conf/web/snginx.conf +fi + +if [ -z "$last_nginx" ]; then + sed -i "/$user\/conf\/web\/nginx.conf/d" $conf + rm -f $HOMEDIR/$user/conf/web/nginx.conf +fi + +# Restart web server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_history "disabled nginx support for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-web-domain-ssl b/bin/v-delete-web-domain-ssl index c3361514b..99252e428 100755 --- a/bin/v-delete-web-domain-ssl +++ b/bin/v-delete-web-domain-ssl @@ -1,101 +1,101 @@ -#!/bin/bash -# info: delete web domain ssl support -# options: user domain -# -# The function disable https support and deletes SSL certificates. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -restart=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain values -get_domain_values 'web' -conf="$HOMEDIR/$user/conf/web/shttpd.conf" -tpl_file="$WEBTPL/apache_$TPL.stpl" - -# Deleting domain -del_web_config - -# Checking nginx -if [ ! -z "$NGINX" ]; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web/snginx.conf" - del_web_config -fi - -# Deleting old certificate -tmpdir=$(mktemp -p $HOMEDIR/$user/web/$domain/private -d) -rm -f $HOMEDIR/$user/conf/ssl.$domain.* -mv $USER_DATA/ssl/$domain.* $tmpdir -chown -R $user:$user $tmpdir - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$SSL' 'no' - -# Checking last ssl domain -ssl_dom=$(grep "SSL='yes'" $USER_DATA/web.conf) -main_conf='/etc/httpd/conf.d/vesta.conf' -conf="$HOMEDIR/$user/conf/web/shttpd.conf" -if [ -z "$ssl_dom" ]; then - sed -i "/Include ${conf////\/}/d" $main_conf - rm -f $conf -fi - -# Checking last nginx domain -conf='/etc/nginx/conf.d/vesta_users.conf' -last_nginx=$(grep -v "NGINX=''" $USER_DATA/web.conf) -last_snginx=$(echo "$last_nginx" | grep "SSL='yes'") -if [ -z "$last_snginx" ]; then - sed -i "/$user\/conf\/web\/snginx.conf/d" $conf - rm -f $HOMEDIR/$user/conf/web/snginx.conf -fi - -# Decreasing domain value -decrease_user_value "$user" '$U_WEB_SSL' - -# Restart web server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_history "disabled ssl support for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete web domain ssl support +# options: USER DOMAIN +# +# The function disable https support and deletes SSL certificates. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +restart=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Parsing domain values +get_domain_values 'web' +conf="$HOMEDIR/$user/conf/web/shttpd.conf" +tpl_file="$WEBTPL/apache_$TPL.stpl" + +# Deleting domain +del_web_config + +# Checking nginx +if [ ! -z "$NGINX" ]; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + del_web_config +fi + +# Deleting old certificate +tmpdir=$(mktemp -p $HOMEDIR/$user/web/$domain/private -d) +rm -f $HOMEDIR/$user/conf/ssl.$domain.* +mv $USER_DATA/ssl/$domain.* $tmpdir +chown -R $user:$user $tmpdir + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$SSL' 'no' + +# Checking last ssl domain +ssl_dom=$(grep "SSL='yes'" $USER_DATA/web.conf) +main_conf='/etc/httpd/conf.d/vesta.conf' +conf="$HOMEDIR/$user/conf/web/shttpd.conf" +if [ -z "$ssl_dom" ]; then + sed -i "/Include ${conf////\/}/d" $main_conf + rm -f $conf +fi + +# Checking last nginx domain +conf='/etc/nginx/conf.d/vesta_users.conf' +last_nginx=$(grep -v "NGINX=''" $USER_DATA/web.conf) +last_snginx=$(echo "$last_nginx" | grep "SSL='yes'") +if [ -z "$last_snginx" ]; then + sed -i "/$user\/conf\/web\/snginx.conf/d" $conf + rm -f $HOMEDIR/$user/conf/web/snginx.conf +fi + +# Decreasing domain value +decrease_user_value "$user" '$U_WEB_SSL' + +# Restart web server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_history "disabled ssl support for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-web-domain-stats b/bin/v-delete-web-domain-stats index 041246752..8974752b7 100755 --- a/bin/v-delete-web-domain-stats +++ b/bin/v-delete-web-domain-stats @@ -1,69 +1,69 @@ -#!/bin/bash -# info: delete web domain statistics -# options: user domain -# -# The function of deleting site's system of statistics. Its type is -# automatically chooses from client's configuration file. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining statistic type -get_domain_values 'web' - -# Defining statistic dir -stats_dir="$HOMEDIR/$user/web/$domain/stats" - -# Deleting dir content -rm -rf $stats_dir/* - -# Deleting config -rm -f /etc/awstats/$STATS.$domain.conf -rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Deleting pipe command -sed -i "/ $domain$/d" $VESTA/data/queue/webstats.pipe - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$STATS' '' - -# Logging -log_history "disabled web log analyzer for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete web domain statistics +# options: USER DOMAIN +# +# The function of deleting site's system of statistics. Its type is +# automatically chooses from client's configuration file. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining statistic type +get_domain_values 'web' + +# Defining statistic dir +stats_dir="$HOMEDIR/$user/web/$domain/stats" + +# Deleting dir content +rm -rf $stats_dir/* + +# Deleting config +rm -f /etc/awstats/$STATS.$domain.conf +rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Deleting pipe command +sed -i "/ $domain$/d" $VESTA/data/queue/webstats.pipe + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$STATS' '' + +# Logging +log_history "disabled web log analyzer for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-web-domain-stats-user b/bin/v-delete-web-domain-stats-user index 35f244414..84e043b0d 100755 --- a/bin/v-delete-web-domain-stats-user +++ b/bin/v-delete-web-domain-stats-user @@ -1,61 +1,61 @@ -#!/bin/bash -# info: disable webdomain stats authentication support -# options: user domain -# -# The function removes authentication of statistics system. If the script is -# called without naming a certain user, all users will be removed. After -# deleting all of them statistics will be accessible for view without an -# authentication. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS_USER' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Definining statistic dir -rm -f $HOMEDIR/$user/web/$domain/stats/.htpasswd -rm -f $HOMEDIR/$user/web/$domain/stats/.htaccess - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$STATS_USER' '' -update_object_value 'web' 'DOMAIN' "$domain" '$STATS_CRYPT' '' - - -# Logging -log_history "disabled web stats password protection for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: disable webdomain stats authentication support +# options: USER DOMAIN +# +# The function removes authentication of statistics system. If the script is +# called without naming a certain user, all users will be removed. After +# deleting all of them statistics will be accessible for view without an +# authentication. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS_USER' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Definining statistic dir +rm -f $HOMEDIR/$user/web/$domain/stats/.htpasswd +rm -f $HOMEDIR/$user/web/$domain/stats/.htaccess + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$STATS_USER' '' +update_object_value 'web' 'DOMAIN' "$domain" '$STATS_CRYPT' '' + + +# Logging +log_history "disabled web stats password protection for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-web-domains b/bin/v-delete-web-domains index fe7910068..fa87e67c3 100755 --- a/bin/v-delete-web-domains +++ b/bin/v-delete-web-domains @@ -1,53 +1,53 @@ -#!/bin/bash -# info: delete web domains -# options: user [restart] -# -# The function deteles all user's webdomains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -restart=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user [restart]' -validate_format 'user' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting delete loop -for domain in $(search_objects 'web' 'SUSPENDED' "no" 'DOMAIN'); do - $BIN/v-delete-web-domain "$user" "$domain" 'no' -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart web server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete web domains +# options: USER [RESTART] +# +# The function deteles all user's webdomains. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +restart=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [RESTART]' +validate_format 'user' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting delete loop +for domain in $(search_objects 'web' 'SUSPENDED' "no" 'DOMAIN'); do + $BIN/v-delete-web-domain "$user" "$domain" 'no' +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart web server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-get-dns-domain-value b/bin/v-get-dns-domain-value index a69ae2696..90bdcbfe7 100755 --- a/bin/v-get-dns-domain-value +++ b/bin/v-get-dns-domain-value @@ -1,47 +1,47 @@ -#!/bin/bash -# info: get dns domain value -# options: user domain key -# -# The function for getting a certain DNS domain parameter. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -key=$(echo "$3"| tr '[:lower:]' '[:upper:]'|sed -e "s/^/$/") - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user domain key' -validate_format 'user' 'domain' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Print -get_object_value 'dns' 'DOMAIN' "$domain" "$key" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: get dns domain value +# options: USER DOMAIN KEY +# +# The function for getting a certain DNS domain parameter. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +key=$(echo "$3"| tr '[:lower:]' '[:upper:]'|sed -e "s/^/$/") + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN KEY' +validate_format 'user' 'domain' +is_object_valid 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Print +get_object_value 'dns' 'DOMAIN' "$domain" "$key" + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-get-mail-account-value b/bin/v-get-mail-account-value new file mode 100755 index 000000000..d53a71aef --- /dev/null +++ b/bin/v-get-mail-account-value @@ -0,0 +1,49 @@ +#!/bin/bash +# info: get mail account value +# options: USER DOMAIN ACCOUNT KEY +# +# The function for getting a certain mail account parameter. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +account=$3 +key=$(echo "$4"| tr '[:lower:]' '[:upper:]'|sed -e "s/^/$/") + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN KEY' +validate_format 'user' 'domain' +is_object_valid 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_valid "mail/$domain" 'ACCOUNT' "$account" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Print +get_object_value "mail/$domain" 'ACCOUNT' "$account" "$key" + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-get-mail-domain-value b/bin/v-get-mail-domain-value new file mode 100755 index 000000000..65ca0492b --- /dev/null +++ b/bin/v-get-mail-domain-value @@ -0,0 +1,47 @@ +#!/bin/bash +# info: get mail domain value +# options: USER DOMAIN KEY +# +# The function for getting a certain mail domain parameter. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +key=$(echo "$3"| tr '[:lower:]' '[:upper:]'|sed -e "s/^/$/") + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN KEY' +validate_format 'user' 'domain' +is_object_valid 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Print +get_object_value 'mail' 'DOMAIN' "$domain" "$key" + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-get-user-value b/bin/v-get-user-value index d8c193fdc..d7a4c8aee 100755 --- a/bin/v-get-user-value +++ b/bin/v-get-user-value @@ -1,45 +1,45 @@ -#!/bin/bash -# info: get user value -# options: user key -# -# The function for obtaining certain user's parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -key=$(echo "$2"| tr '[:lower:]' '[:upper:]'|sed -e "s/^/$/") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user key' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Checking key -value=$(get_user_value "$key") - -# Printing value -echo "$value" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: get user value +# options: USER KEY +# +# The function for obtaining certain user's parameters. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +key=$(echo "$2"| tr '[:lower:]' '[:upper:]'|sed -e "s/^/$/") + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER KEY' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Checking key +value=$(get_user_value "$key") + +# Printing value +echo "$value" + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-get-web-domain-value b/bin/v-get-web-domain-value index 1d968261d..b05b62376 100755 --- a/bin/v-get-web-domain-value +++ b/bin/v-get-web-domain-value @@ -1,49 +1,49 @@ -#!/bin/bash -# info: get web domain value -# options: user domain key -# -# The function is intended for obtaining a domain value by the key. This call -# is useful for arranging composite queries. The answer is displayed only in -# raw form; output formats aren't supported. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -key=$(echo "$3"| tr '[:lower:]' '[:upper:]'|sed -e "s/^/$/") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user domain key' -validate_format 'user' 'domain' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -get_domain_values 'web' -eval echo $key - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: get web domain value +# options: USER DOMAIN KEY +# +# The function is intended for obtaining a domain value by the key. This call +# is useful for arranging composite queries. The answer is displayed only in +# raw form; output formats aren't supported. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +key=$(echo "$3"| tr '[:lower:]' '[:upper:]'|sed -e "s/^/$/") + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN KEY' +validate_format 'user' 'domain' +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +get_domain_values 'web' +eval echo $key + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-cron-job b/bin/v-list-cron-job index 3e9488be1..95068ab2c 100755 --- a/bin/v-list-cron-job +++ b/bin/v-list-cron-job @@ -1,91 +1,91 @@ -#!/bin/bash -# info: list cron job -# options: user job [format] -# -# The function of obtaining cron job settings. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -job=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_job() { - i=1 - fileds_count=$(echo "$fields" | wc -w) - line=$(grep "JOB='$job'" $conf) - echo '{' - eval $line - for field in $fields; do - eval value=$field - value=$(echo "$value"|sed -e 's/"/\\"/g' -e "s/%quote%/'/g") - if [ "$i" -eq 1 ]; then - echo -e "\t\"$value\": {" - else - if [ "$fileds_count" -eq "$i" ]; then - echo -e "\t\t\"${field//$/}\": \"$value\"" - else - echo -e "\t\t\"${field//$/}\": \"$value\"," - fi - fi - (( ++i)) - done - if [ -n "$value" ]; then - echo -e ' }' - fi - echo -e "}" -} - -# Shell function -shell_list_job() { - line=$(grep "JOB='$job'" $conf) - eval $line - for field in $fields; do - eval key="$field" - if [ -z "$key" ]; then - key=NULL - fi - echo "${field//$/}: $key " - done -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user job [format]' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config and fields to select -conf=$USER_DATA/cron.conf -fields="\$JOB \$MIN \$HOUR \$DAY \$MONTH \$WDAY \$CMD \$SUSPENDED" -fields="$fields \$TIME \$DATE" - -# Listing domains -case $format in - json) json_list_job ;; - plain) nohead=1; shell_list_job ;; - shell) shell_list_job |column -t ;; - *) check_args '2' '0' 'user job [format]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list cron job +# options: USER JOB [FORMAT] +# +# The function of obtaining cron job settings. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +job=$2 +format=${3-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_job() { + i=1 + fileds_count=$(echo "$fields" | wc -w) + line=$(grep "JOB='$job'" $conf) + echo '{' + eval $line + for field in $fields; do + eval value=$field + value=$(echo "$value"|sed -e 's/"/\\"/g' -e "s/%quote%/'/g") + if [ "$i" -eq 1 ]; then + echo -e "\t\"$value\": {" + else + if [ "$fileds_count" -eq "$i" ]; then + echo -e "\t\t\"${field//$/}\": \"$value\"" + else + echo -e "\t\t\"${field//$/}\": \"$value\"," + fi + fi + (( ++i)) + done + if [ -n "$value" ]; then + echo -e ' }' + fi + echo -e "}" +} + +# Shell function +shell_list_job() { + line=$(grep "JOB='$job'" $conf) + eval $line + for field in $fields; do + eval key="$field" + if [ -z "$key" ]; then + key=NULL + fi + echo "${field//$/}: $key " + done +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER JOB [FORMAT]' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config and fields to select +conf=$USER_DATA/cron.conf +fields="\$JOB \$MIN \$HOUR \$DAY \$MONTH \$WDAY \$CMD \$SUSPENDED" +fields="$fields \$TIME \$DATE" + +# Listing domains +case $format in + json) json_list_job ;; + plain) nohead=1; shell_list_job ;; + shell) shell_list_job |column -t ;; + *) check_args '2' '0' 'USER JOB [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-cron-jobs b/bin/v-list-cron-jobs index 944bada2c..1d2c3ce72 100755 --- a/bin/v-list-cron-jobs +++ b/bin/v-list-cron-jobs @@ -1,106 +1,106 @@ -#!/bin/bash -# info: list user cron jobs -# options: user [format] -# -# The function for obtaining the list of all users cron jobs. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - -# Json list function -json_list_cron() { - echo '{' - fileds_count=$(echo $fields| wc -w ) - while read line; do - eval $line - if [ -n "$data" ]; then - echo -e ' },' - fi - i=1 - IFS=' ' - for field in $fields; do - eval value=\"$field\" - value=$(echo "$value"|sed -e 's/"/\\"/g' -e "s/%quote%/'/g") - if [ $i -eq 1 ]; then - (( ++i)) - echo -e "\t\"$value\": {" - else - if [ $i -lt $fileds_count ]; then - (( ++i)) - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," - else - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" - data=1 - fi - fi - done - done < $conf - if [ -n "$data" ]; then - echo -e ' }' - fi - echo -e '}' -} - -# Shell list function -shell_list_cron() { - if [ -z "$nohead" ] ; then - echo "${fields//$/}" - for a in $fields; do - echo -e "------ \c" - done - echo - fi - while read line ; do - eval $line - eval echo "$fields" | sed -e "s/%quote%/'/g" - done < $conf -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user [format]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config -conf=$USER_DATA/cron.conf - -# Defining fileds to select -fields='$JOB $MIN $HOUR $DAY $MONTH $WDAY $CMD $JOB $SUSPENDED $TIME $DATE' - -# Listing domains -case $format in - json) json_list_cron ;; - plain) nohead=1; - fields="\"\$JOB\" \"\$SUSPENDED\" \"\$MIN\" \"\$HOUR\" \"\$DAY\"" - fields="$fields \"\$MONTH\" \"\$WDAY\" \"\$CMD\" "; - fields="$fields \"\$TIME\" \"\$DATE\"" - shell_list_cron ;; - shell) fields='$JOB~$SUSPENDED~$MIN~$HOUR~$DAY~$MONTH~$WDAY~$CMD'; - shell_list_cron |column -t -s '~';; - *) check_args '1' '0' 'user [format]' ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list user cron jobs +# options: USER [FORMAT] +# +# The function for obtaining the list of all users cron jobs. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + +# Json list function +json_list_cron() { + echo '{' + fileds_count=$(echo $fields| wc -w ) + while read line; do + eval $line + if [ -n "$data" ]; then + echo -e ' },' + fi + i=1 + IFS=' ' + for field in $fields; do + eval value=\"$field\" + value=$(echo "$value"|sed -e 's/"/\\"/g' -e "s/%quote%/'/g") + if [ $i -eq 1 ]; then + (( ++i)) + echo -e "\t\"$value\": {" + else + if [ $i -lt $fileds_count ]; then + (( ++i)) + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," + else + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" + data=1 + fi + fi + done + done < $conf + if [ -n "$data" ]; then + echo -e ' }' + fi + echo -e '}' +} + +# Shell list function +shell_list_cron() { + if [ -z "$nohead" ] ; then + echo "${fields//$/}" + for a in $fields; do + echo -e "------ \c" + done + echo + fi + while read line ; do + eval $line + eval echo "$fields" | sed -e "s/%quote%/'/g" + done < $conf +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config +conf=$USER_DATA/cron.conf + +# Defining fileds to select +fields='$JOB $MIN $HOUR $DAY $MONTH $WDAY $CMD $JOB $SUSPENDED $TIME $DATE' + +# Listing domains +case $format in + json) json_list_cron ;; + plain) nohead=1; + fields="\"\$JOB\" \"\$SUSPENDED\" \"\$MIN\" \"\$HOUR\" \"\$DAY\"" + fields="$fields \"\$MONTH\" \"\$WDAY\" \"\$CMD\" "; + fields="$fields \"\$TIME\" \"\$DATE\"" + shell_list_cron ;; + shell) fields='$JOB~$SUSPENDED~$MIN~$HOUR~$DAY~$MONTH~$WDAY~$CMD'; + shell_list_cron |column -t -s '~';; + *) check_args '1' '0' 'USER [FORMAT]' ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-database b/bin/v-list-database index 16cbbe907..8a3e4807a 100755 --- a/bin/v-list-database +++ b/bin/v-list-database @@ -1,89 +1,89 @@ -#!/bin/bash -# info: list database -# options: user database [format] -# -# The function for obtaining of all database's parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -database=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_db() { - i=1 - last_word=$(echo "$fields" | wc -w) - line=$(grep "DB='$database'" $conf) - echo '{' - eval $line - for field in $fields; do - eval value=$field - if [ "$i" -eq 1 ]; then - echo -e "\t\"$value\": {" - else - if [ "$last_word" -eq "$i" ]; then - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" - else - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," - fi - fi - (( ++i)) - done - if [ -n "$value" ]; then - echo -e "\t}" - fi - echo -e '}' -} - -# Shell list for single database -shell_list_db() { - line=$(grep "DB='$database'" $conf) - eval $line - for field in $fields; do - eval key="$field" - echo "${field//$/}: $key " - done -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user database [format]' -validate_format 'user' 'database' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'db' 'DB' "$database" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - - -# Defining fileds to select -conf=$USER_DATA/db.conf -fields='$DB $DBUSER $HOST $TYPE $CHARSET $U_DISK $SUSPENDED $TIME $DATE' - -# Listing database -case $format in - json) json_list_db ;; - plain) shell_list_db ;; - shell) shell_list_db | column -t ;; - *) check_args '2' '0' 'user database [format]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list database +# options: USER DATABASE [FORMAT] +# +# The function for obtaining of all database's parameters. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +database=$2 +format=${3-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_db() { + i=1 + last_word=$(echo "$fields" | wc -w) + line=$(grep "DB='$database'" $conf) + echo '{' + eval $line + for field in $fields; do + eval value=$field + if [ "$i" -eq 1 ]; then + echo -e "\t\"$value\": {" + else + if [ "$last_word" -eq "$i" ]; then + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" + else + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," + fi + fi + (( ++i)) + done + if [ -n "$value" ]; then + echo -e "\t}" + fi + echo -e '}' +} + +# Shell list for single database +shell_list_db() { + line=$(grep "DB='$database'" $conf) + eval $line + for field in $fields; do + eval key="$field" + echo "${field//$/}: $key " + done +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DATABASE [FORMAT]' +validate_format 'user' 'database' +is_object_valid 'user' 'USER' "$user" +is_object_valid 'db' 'DB' "$database" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + + +# Defining fileds to select +conf=$USER_DATA/db.conf +fields='$DB $DBUSER $HOST $TYPE $CHARSET $U_DISK $SUSPENDED $TIME $DATE' + +# Listing database +case $format in + json) json_list_db ;; + plain) shell_list_db ;; + shell) shell_list_db | column -t ;; + *) check_args '2' '0' 'USER DATABASE [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-database-server b/bin/v-list-database-server index 36776ddcc..366933107 100755 --- a/bin/v-list-database-server +++ b/bin/v-list-database-server @@ -1,88 +1,88 @@ -#!/bin/bash -# info: list database server -# options: type host [format] -# -# The function for obtaining database server parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -type=$1 -host=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_dbhost() { - i=1 - fields_count=$(echo "$fields" | wc -w) - line=$(grep "HOST='$host'" $conf) - echo '{' - eval $line - for field in $fields; do - eval value=$field - if [ "$i" -eq 1 ]; then - echo -e "\t\"$value\": {" - else - if [ "$fields_count" -eq "$i" ]; then - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" - else - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," - fi - fi - (( ++i)) - done - if [ -n "$value" ]; then - echo -e "\t}" - fi - echo -e "}" -} - -# Shell function -shell_list_dbhost() { - line=$(grep "HOST='$host'" $conf) - eval $line - for field in $fields; do - eval key="$field" - echo "${field//$/}: $key" - done -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'type host [format]' -validate_format 'host' -is_object_valid "../../conf/$type" 'HOST' "$host" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining fileds to select -conf=$VESTA/conf/$type.conf -fields='$HOST $PORT $CHARSETS $MAX_DB $U_SYS_USERS $U_DB_BASES $TPL $SUSPENDED' -fields="$fields \$TIME \$DATE" - -# Listing database -case $format in - json) json_list_dbhost ;; - plain) nohead=1; shell_list_dbhost ;; - shell) shell_list_dbhost | column -t;; - *) check_args '2' '0' 'type host [format]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list database server +# options: TYPE HOST [FORMAT] +# +# The function for obtaining database server parameters. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +type=$1 +host=$2 +format=${3-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_dbhost() { + i=1 + fields_count=$(echo "$fields" | wc -w) + line=$(grep "HOST='$host'" $conf) + echo '{' + eval $line + for field in $fields; do + eval value=$field + if [ "$i" -eq 1 ]; then + echo -e "\t\"$value\": {" + else + if [ "$fields_count" -eq "$i" ]; then + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" + else + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," + fi + fi + (( ++i)) + done + if [ -n "$value" ]; then + echo -e "\t}" + fi + echo -e "}" +} + +# Shell function +shell_list_dbhost() { + line=$(grep "HOST='$host'" $conf) + eval $line + for field in $fields; do + eval key="$field" + echo "${field//$/}: $key" + done +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'TYPE HOST [FORMAT]' +validate_format 'host' +is_object_valid "../../conf/$type" 'HOST' "$host" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining fileds to select +conf=$VESTA/conf/$type.conf +fields='$HOST $PORT $CHARSETS $MAX_DB $U_SYS_USERS $U_DB_BASES $TPL $SUSPENDED' +fields="$fields \$TIME \$DATE" + +# Listing database +case $format in + json) json_list_dbhost ;; + plain) nohead=1; shell_list_dbhost ;; + shell) shell_list_dbhost | column -t;; + *) check_args '2' '0' 'TYPE HOST [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-database-servers b/bin/v-list-database-servers index 32b1d340e..a83a43a23 100755 --- a/bin/v-list-database-servers +++ b/bin/v-list-database-servers @@ -1,51 +1,51 @@ -#!/bin/bash -# info: list database servers -# options: type [format] -# -# The function for obtaining the list of all hosts of the same databases' type. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -type=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -# Checking args -check_args '1' "$#" 'type [format]' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining fileds to select -conf=$VESTA/conf/$type.conf -fields='$HOST $PORT $CHARSETS $MAX_DB $U_SYS_USERS $U_DB_BASES $TPL $SUSPENDED' -fields="$fields \$TIME \$DATE" - -# Listing database -case $format in - json) json_list ;; - plain) nohead=1; shell_list;; - shell) fields='$HOST $PORT $MAX_DB $U_DB_BASES $SUSPENDED $DATE'; - shell_list | column -t ;; - *) check_args '2' '0' 'type [format]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list database servers +# options: TYPE [FORMAT] +# +# The function for obtaining the list of all hosts of the same databases' type. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +type=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +# Checking args +check_args '1' "$#" 'TYPE [FORMAT]' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining fileds to select +conf=$VESTA/conf/$type.conf +fields='$HOST $PORT $CHARSETS $MAX_DB $U_SYS_USERS $U_DB_BASES $TPL $SUSPENDED' +fields="$fields \$TIME \$DATE" + +# Listing database +case $format in + json) json_list ;; + plain) nohead=1; shell_list;; + shell) fields='$HOST $PORT $MAX_DB $U_DB_BASES $SUSPENDED $DATE'; + shell_list | column -t ;; + *) check_args '2' '0' 'TYPE [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-database-types b/bin/v-list-database-types index a3bf247ba..757644a45 100755 --- a/bin/v-list-database-types +++ b/bin/v-list-database-types @@ -1,66 +1,66 @@ -#!/bin/bash -# info: list supported database types -# options: [format] -# -# The function for obtaining the list of database types. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# Json function -json_list_dbtypes() { - types=$(echo "${DB_SYSTEM//,/ }") - t_counter=$(echo "$types" | wc -w) - i=1 - echo '[' - for type in $types; do - if [ "$i" -lt "$t_counter" ]; then - echo -e "\t\"$type\"," - else - echo -e "\t\"$type\"" - fi - (( ++i)) - done - echo "]" -} - -# Shell function -shell_list_dbtypes() { - types=$(echo "${DB_SYSTEM//,/ }") - if [ -z "$nohead" ]; then - echo "TYPES" - echo "----------" - fi - for type in $types; do - echo "$type" - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing domains -case $format in - json) json_list_dbtypes ;; - plain) nohead=1; shell_list_dbtypes ;; - shell) shell_list_dbtypes ;; - *) check_args '1' '0' '[format]' ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list supported database types +# options: [FORMAT] +# +# The function for obtaining the list of database types. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +format=${1-shell} + +# Includes +source $VESTA/func/main.sh +source $VESTA/conf/vesta.conf + +# Json function +json_list_dbtypes() { + types=$(echo "${DB_SYSTEM//,/ }") + t_counter=$(echo "$types" | wc -w) + i=1 + echo '[' + for type in $types; do + if [ "$i" -lt "$t_counter" ]; then + echo -e "\t\"$type\"," + else + echo -e "\t\"$type\"" + fi + (( ++i)) + done + echo "]" +} + +# Shell function +shell_list_dbtypes() { + types=$(echo "${DB_SYSTEM//,/ }") + if [ -z "$nohead" ]; then + echo "TYPES" + echo "----------" + fi + for type in $types; do + echo "$type" + done +} + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Listing domains +case $format in + json) json_list_dbtypes ;; + plain) nohead=1; shell_list_dbtypes ;; + shell) shell_list_dbtypes ;; + *) check_args '1' '0' '[FORMAT]' ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-databases b/bin/v-list-databases index 2e2c545ef..c5d4b6db8 100755 --- a/bin/v-list-databases +++ b/bin/v-list-databases @@ -1,51 +1,51 @@ -#!/bin/bash -# info: listing databases -# options: user [format] -# -# The function for obtaining the list of all user's databases. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user [format]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining fileds to select -conf=$USER_DATA/db.conf -fields='$DB $DBUSER $HOST $TYPE $CHARSET $U_DISK $SUSPENDED $TIME $DATE' - -# Listing databases -case $format in - json) json_list ;; - plain) nohead=1; shell_list ;; - shell) fields='$DB $DBUSER $HOST $TYPE $U_DISK $DATE'; - shell_list | column -t ;; - *) check_args '1' '0' 'user [format]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: listing databases +# options: USER [FORMAT] +# +# The function for obtaining the list of all user's databases. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining fileds to select +conf=$USER_DATA/db.conf +fields='$DB $DBUSER $HOST $TYPE $CHARSET $U_DISK $SUSPENDED $TIME $DATE' + +# Listing databases +case $format in + json) json_list ;; + plain) nohead=1; shell_list ;; + shell) fields='$DB $DBUSER $HOST $TYPE $U_DISK $DATE'; + shell_list | column -t ;; + *) check_args '1' '0' 'USER [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-dns-domain b/bin/v-list-dns-domain index db3da01c4..b46a0cd45 100755 --- a/bin/v-list-dns-domain +++ b/bin/v-list-dns-domain @@ -1,105 +1,105 @@ -#!/bin/bash -# info: list dns domain -# options: user domain [format] -# -# The function of obtaining the list of domain parameters. This call, just as -# all v_list_* calls, supports 3 formats - json, shell and plain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_domain() { - i=1 - fileds_count=$(echo "$fields" | wc -w) - line=$(grep "DOMAIN='$domain'" $conf) - - # Print top bracket - echo '{' - - # Assing key=value - eval $line - - # Starting output loop - for field in $fields; do - # Parsing key=value - eval value=$field - - # Checking first field - if [ "$i" -eq 1 ]; then - echo -e "\t\"$value\": {" - else - if [ "$fileds_count" -eq "$i" ]; then - echo -e "\t\t\"${field//$/}\": \"$value\"" - else - echo -e "\t\t\"${field//$/}\": \"$value\"," - fi - fi - # Updating iterator - (( ++i)) - done - - # If there was any output - if [ -n "$value" ]; then - echo -e ' }' - fi - # Printing bottom json bracket - echo -e "}" -} - -# Shell function -shell_list_domain() { - line=$(grep "DOMAIN='$domain'" $conf) - - # Parsing key=value - eval $line - - # Print result line - for field in $fields; do - eval key="$field" - echo "${field//$/}: $key " - done -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain [format]' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config and fields to select -conf=$USER_DATA/dns.conf -fields='$DOMAIN $IP $TPL $TTL $EXP $SOA $RECORDS $SUSPENDED $TIME $DATE' - -# Listing domains -case $format in - json) json_list_domain ;; - plain) nohead=1; shell_list_domain ;; - shell) shell_list_domain |column -t ;; - *) check_args '2' '0' 'user domain [format]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list dns domain +# options: USER DOMAIN [FORMAT] +# +# The function of obtaining the list of domain parameters. This call, just as +# all v_list_* calls, supports 3 formats - json, shell and plain. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$2 +format=${3-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_domain() { + i=1 + fileds_count=$(echo "$fields" | wc -w) + line=$(grep "DOMAIN='$domain'" $conf) + + # Print top bracket + echo '{' + + # Assing key=value + eval $line + + # Starting output loop + for field in $fields; do + # Parsing key=value + eval value=$field + + # Checking first field + if [ "$i" -eq 1 ]; then + echo -e "\t\"$value\": {" + else + if [ "$fileds_count" -eq "$i" ]; then + echo -e "\t\t\"${field//$/}\": \"$value\"" + else + echo -e "\t\t\"${field//$/}\": \"$value\"," + fi + fi + # Updating iterator + (( ++i)) + done + + # If there was any output + if [ -n "$value" ]; then + echo -e ' }' + fi + # Printing bottom json bracket + echo -e "}" +} + +# Shell function +shell_list_domain() { + line=$(grep "DOMAIN='$domain'" $conf) + + # Parsing key=value + eval $line + + # Print result line + for field in $fields; do + eval key="$field" + echo "${field//$/}: $key " + done +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [FORMAT]' +is_object_valid 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config and fields to select +conf=$USER_DATA/dns.conf +fields='$DOMAIN $IP $TPL $TTL $EXP $SOA $RECORDS $SUSPENDED $TIME $DATE' + +# Listing domains +case $format in + json) json_list_domain ;; + plain) nohead=1; shell_list_domain ;; + shell) shell_list_domain |column -t ;; + *) check_args '2' '0' 'USER DOMAIN [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-dns-domain-records b/bin/v-list-dns-domain-records index 785a8441e..58c53bf9e 100755 --- a/bin/v-list-dns-domain-records +++ b/bin/v-list-dns-domain-records @@ -1,105 +1,105 @@ -#!/bin/bash -# info: list dns domain records -# options: user domain [format] -# -# The function for getting all DNS domain records. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - -# Json func -json_list_dns() { - echo '{' - fileds_count=$(echo $fields| wc -w ) - while read line; do - IFS=$'\n' - eval $line - if [ -n "$data" ]; then - echo -e ' },' - fi - i=1 - IFS=' ' - for field in $fields; do - eval value=\"$field\" - value=$(echo "$value" | sed -e 's/"/\\"/g' -e "s/%quote%/'/g") - if [ $i -eq 1 ]; then - (( ++i)) - echo -e "\t\"$value\": {" - else - if [ $i -lt $fileds_count ]; then - (( ++i)) - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," - else - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" - data=1 - fi - fi - done - done < $conf - if [ -n "$data" ]; then - echo -e ' }' - fi - echo -e '}' -} - -# Shell function -shell_list_dns() { - - if [ -z "$nohead" ] ; then - echo "${fields//$/}" - for a in $fields; do - echo -e "------ \c" - done - echo - fi - while read line ; do - IFS=$'\n' - eval $line - eval echo "$fields" | sed -e "s/%quote%/'/g" - done < $conf -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain [format]' -validate_format 'user' 'domain' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config and fields -conf=$USER_DATA/dns/$domain.conf -fields='$ID $RECORD $TYPE $PRIORITY $VALUE $ID $SUSPENDED $TIME $DATE' - -# Listing domains -case $format in - json) json_list_dns ;; - plain) nohead=1; shell_list_dns ;; - shell) fields='$ID $RECORD $TYPE $VALUE'; - shell_list_dns | column -t ;; - *) check_args '2' '0' 'user domain [format]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list dns domain records +# options: USER DOMAIN [FORMAT] +# +# The function for getting all DNS domain records. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$2 +format=${3-shell} + +# Includes +source $VESTA/func/main.sh + +# Json func +json_list_dns() { + echo '{' + fileds_count=$(echo $fields| wc -w ) + while read line; do + IFS=$'\n' + eval $line + if [ -n "$data" ]; then + echo -e ' },' + fi + i=1 + IFS=' ' + for field in $fields; do + eval value=\"$field\" + value=$(echo "$value" | sed -e 's/"/\\"/g' -e "s/%quote%/'/g") + if [ $i -eq 1 ]; then + (( ++i)) + echo -e "\t\"$value\": {" + else + if [ $i -lt $fileds_count ]; then + (( ++i)) + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," + else + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" + data=1 + fi + fi + done + done < $conf + if [ -n "$data" ]; then + echo -e ' }' + fi + echo -e '}' +} + +# Shell function +shell_list_dns() { + + if [ -z "$nohead" ] ; then + echo "${fields//$/}" + for a in $fields; do + echo -e "------ \c" + done + echo + fi + while read line ; do + IFS=$'\n' + eval $line + eval echo "$fields" | sed -e "s/%quote%/'/g" + done < $conf +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [FORMAT]' +validate_format 'user' 'domain' +is_object_valid 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config and fields +conf=$USER_DATA/dns/$domain.conf +fields='$ID $RECORD $TYPE $PRIORITY $VALUE $ID $SUSPENDED $TIME $DATE' + +# Listing domains +case $format in + json) json_list_dns ;; + plain) nohead=1; shell_list_dns ;; + shell) fields='$ID $RECORD $TYPE $VALUE'; + shell_list_dns | column -t ;; + *) check_args '2' '0' 'USER DOMAIN [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-dns-domains b/bin/v-list-dns-domains index 0ad1dd2f5..ebad12328 100755 --- a/bin/v-list-dns-domains +++ b/bin/v-list-dns-domains @@ -1,51 +1,51 @@ -#!/bin/bash -# info: list dns domains -# options: user [format] -# -# The function for obtaining all DNS domains of a user. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user [format]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config and fields -conf=$USER_DATA/dns.conf -fields='$DOMAIN $IP $TPL $TTL $EXP $SOA $RECORDS $SUSPENDED $TIME $DATE' - -# Listing domains -case $format in - json) json_list ;; - plain) nohead=1; shell_list ;; - shell) fields='$DOMAIN $IP $TPL $TTL $EXP $DATE'; - shell_list| column -t ;; - *) check_args '1' '0' 'user [format]';; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list dns domains +# options: USER [FORMAT] +# +# The function for obtaining all DNS domains of a user. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config and fields +conf=$USER_DATA/dns.conf +fields='$DOMAIN $IP $TPL $TTL $EXP $SOA $RECORDS $SUSPENDED $TIME $DATE' + +# Listing domains +case $format in + json) json_list ;; + plain) nohead=1; shell_list ;; + shell) fields='$DOMAIN $IP $TPL $TTL $EXP $DATE'; + shell_list| column -t ;; + *) check_args '1' '0' 'USER [FORMAT]';; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-dns-template b/bin/v-list-dns-template index c6f4abe16..5faa9dc2b 100755 --- a/bin/v-list-dns-template +++ b/bin/v-list-dns-template @@ -1,102 +1,102 @@ -#!/bin/bash -# info: list dns template -# options: template [format] -# -# The function for obtaining the DNS template parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -template=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - -# Json func -json_list_dns() { - echo '{' - fileds_count=$(echo $fields| wc -w ) - while read line; do - IFS=$'\n' - eval $line - if [ -n "$data" ]; then - echo -e ' },' - fi - i=1 - IFS=' ' - for field in $fields; do - eval value=\"$field\" - value=$(echo "$value" | sed -e 's/"/\\"/g' -e "s/%quote%/'/g") - if [ $i -eq 1 ]; then - (( ++i)) - echo -e "\t\"$value\": {" - else - if [ $i -lt $fileds_count ]; then - (( ++i)) - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," - else - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" - data=1 - fi - fi - done - done < $conf - if [ -n "$data" ]; then - echo -e ' }' - fi - echo -e '}' -} - -# Shell function -shell_list_dns() { - if [ -z "$nohead" ] ; then - echo "${fields//$/}" - for a in $fields; do - echo -e "------ \c" - done - echo - fi - - while read line ; do - eval $line - eval echo "$fields" | sed -e "s/%quote%/'/g" - done < $conf -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'template [format]' -validate_format 'template' -is_dns_template_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config and fields -conf=$DNSTPL/$template.tpl -fields='$RECORD $TYPE $PRIORITY $VALUE' - -# Listing templates -case $format in - json) json_list_dns ;; - plain) nohead=1; shell_list_dns ;; - shell) shell_list_dns | column -t ;; - *) check_args '1' '0' 'template [format]';; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list dns template +# options: TEMPLATE [FORMAT] +# +# The function for obtaining the DNS template parameters. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +template=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + +# Json func +json_list_dns() { + echo '{' + fileds_count=$(echo $fields| wc -w ) + while read line; do + IFS=$'\n' + eval $line + if [ -n "$data" ]; then + echo -e ' },' + fi + i=1 + IFS=' ' + for field in $fields; do + eval value=\"$field\" + value=$(echo "$value" | sed -e 's/"/\\"/g' -e "s/%quote%/'/g") + if [ $i -eq 1 ]; then + (( ++i)) + echo -e "\t\"$value\": {" + else + if [ $i -lt $fileds_count ]; then + (( ++i)) + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," + else + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" + data=1 + fi + fi + done + done < $conf + if [ -n "$data" ]; then + echo -e ' }' + fi + echo -e '}' +} + +# Shell function +shell_list_dns() { + if [ -z "$nohead" ] ; then + echo "${fields//$/}" + for a in $fields; do + echo -e "------ \c" + done + echo + fi + + while read line ; do + eval $line + eval echo "$fields" | sed -e "s/%quote%/'/g" + done < $conf +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'TEMPLATE [FORMAT]' +validate_format 'template' +is_dns_template_valid + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config and fields +conf=$DNSTPL/$template.tpl +fields='$RECORD $TYPE $PRIORITY $VALUE' + +# Listing templates +case $format in + json) json_list_dns ;; + plain) nohead=1; shell_list_dns ;; + shell) shell_list_dns | column -t ;; + *) check_args '1' '0' 'TEMPLATE [FORMAT]';; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-dns-templates b/bin/v-list-dns-templates index a837fc44e..42409db79 100755 --- a/bin/v-list-dns-templates +++ b/bin/v-list-dns-templates @@ -1,65 +1,65 @@ -#!/bin/bash -# info: list dns templates -# options: [format] -# -# The function for obtaining the list of all DNS templates available. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_dnstpl() { - templates=$(ls -t $DNSTPL |grep '\.tpl' |cut -f 1 -d '.') - t_counter=$(echo "$templates" | wc -w) - i=1 - echo '[' - for template in $templates; do - if [ "$i" -lt "$t_counter" ]; then - echo -e "\t\"$template\"," - else - echo -e "\t\"$template\"" - fi - (( ++i)) - done - echo "]" -} - -# Shell function -shell_list_dnstpl() { - templates=$(ls -t $DNSTPL |grep '\.tpl' |cut -f 1 -d '.') - if [ -z "$nohead" ]; then - echo "Templates" - echo "----------" - fi - for template in $templates; do - echo "$template" - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing domains -case $format in - json) json_list_dnstpl;; - plain) nohead=1; shell_list_dnstpl ;; - shell) shell_list_dnstpl ;; - *) check_args '1' '0' '[format] [limit] [offset]';; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list dns templates +# options: [FORMAT] +# +# The function for obtaining the list of all DNS templates available. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +format=${1-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_dnstpl() { + templates=$(ls -t $DNSTPL |grep '\.tpl' |cut -f 1 -d '.') + t_counter=$(echo "$templates" | wc -w) + i=1 + echo '[' + for template in $templates; do + if [ "$i" -lt "$t_counter" ]; then + echo -e "\t\"$template\"," + else + echo -e "\t\"$template\"" + fi + (( ++i)) + done + echo "]" +} + +# Shell function +shell_list_dnstpl() { + templates=$(ls -t $DNSTPL |grep '\.tpl' |cut -f 1 -d '.') + if [ -z "$nohead" ]; then + echo "Templates" + echo "----------" + fi + for template in $templates; do + echo "$template" + done +} + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Listing domains +case $format in + json) json_list_dnstpl;; + plain) nohead=1; shell_list_dnstpl ;; + shell) shell_list_dnstpl ;; + *) check_args '1' '0' '[FORMAT] [LIMIT] [OFFSET]';; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-mail-account b/bin/v-list-mail-account index a9e3bc671..e3524e45c 100755 --- a/bin/v-list-mail-account +++ b/bin/v-list-mail-account @@ -1,94 +1,94 @@ -#!/bin/bash -# info: list mail domain account -# options: user domain account [format] -# -# The function of obtaining the list of account parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$2 -account=$3 -format=${4-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_account() { - i=1 - fileds_count=$(echo "$fields" | wc -w) - line=$(grep "ACCOUNT='$account'" $conf) - echo '{' - eval $line - for field in $fields; do - eval value=$field - if [ "$i" -eq 1 ]; then - echo -e "\t\"$value\": {" - else - if [ "$fileds_count" -eq "$i" ]; then - echo -e "\t\t\"${field//$/}\": \"$value\"" - else - echo -e "\t\t\"${field//$/}\": \"$value\"," - fi - fi - (( ++i)) - done - if [ -n "$value" ]; then - echo -e ' }' - fi - echo -e "}" -} - -# Shell function -shell_list_account() { - line=$(grep "ACCOUNT='$account'" $conf) - eval $line - for field in $fields; do - eval key="$field" - if [ -z "$key" ]; then - key=NULL - fi - echo "${field//$/}: $key " - done -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user domain account [format]' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" - - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config and fields to select -conf=$USER_DATA/mail/$domain.conf -fields="\$ACCOUNT \$ALIAS \$FWD \$QUOTA \$AUTOREPLY \$U_DISK \$SUSPENDED" -fields="$fields \$TIME \$DATE" - -# Listing domains -case $format in - json) json_list_account ;; - plain) nohead=1; shell_list_account ;; - shell) shell_list_account |column -t ;; - *) check_args '2' '0' 'user domain account [format]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list mail domain account +# options: USER DOMAIN ACCOUNT [FORMAT] +# +# The function of obtaining the list of account parameters. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$2 +account=$3 +format=${4-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_account() { + i=1 + fileds_count=$(echo "$fields" | wc -w) + line=$(grep "ACCOUNT='$account'" $conf) + echo '{' + eval $line + for field in $fields; do + eval value=$field + if [ "$i" -eq 1 ]; then + echo -e "\t\"$value\": {" + else + if [ "$fileds_count" -eq "$i" ]; then + echo -e "\t\t\"${field//$/}\": \"$value\"" + else + echo -e "\t\t\"${field//$/}\": \"$value\"," + fi + fi + (( ++i)) + done + if [ -n "$value" ]; then + echo -e ' }' + fi + echo -e "}" +} + +# Shell function +shell_list_account() { + line=$(grep "ACCOUNT='$account'" $conf) + eval $line + for field in $fields; do + eval key="$field" + if [ -z "$key" ]; then + key=NULL + fi + echo "${field//$/}: $key " + done +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN ACCOUNT [FORMAT]' +is_object_valid 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_valid "mail/$domain" 'ACCOUNT' "$account" + + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config and fields to select +conf=$USER_DATA/mail/$domain.conf +fields="\$ACCOUNT \$ALIAS \$FWD \$QUOTA \$AUTOREPLY \$U_DISK \$SUSPENDED" +fields="$fields \$TIME \$DATE" + +# Listing domains +case $format in + json) json_list_account ;; + plain) nohead=1; shell_list_account ;; + shell) shell_list_account |column -t ;; + *) check_args '2' '0' 'USER DOMAIN ACCOUNT [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-mail-account-autoreply b/bin/v-list-mail-account-autoreply index f8de66f3e..b8351f076 100755 --- a/bin/v-list-mail-account-autoreply +++ b/bin/v-list-mail-account-autoreply @@ -1,72 +1,72 @@ -#!/bin/bash -# info: list mail account autoreply -# options: user domain account [format] -# -# The function of obtainin mail account autoreply message. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$2 -account=$3 -format=${4-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_msg() { - i='1' # iterator - echo '{' - echo -e "\t\"$account\": {" - echo " \"MSG\": \"$msg\"" - echo -e "\t}\n}" -} - -# Shell function -shell_list_msg() { - if [ ! -z "$msg" ]; then - echo -e "$msg" - fi -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain [format]' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -if [ -e "$USER_DATA/mail/$account@$domain.msg" ]; then - msg=$(cat $USER_DATA/mail/$account@$domain.msg |\ - sed -e ':a;N;$!ba;s/\n/\\n/g' ) -fi - -# Listing domains -case $format in - json) json_list_msg ;; - plain) nohead=1; shell_list_msg ;; - shell) shell_list_msg ;; - *) check_args '1' '0' '[format]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list mail account autoreply +# options: USER DOMAIN ACCOUNT [FORMAT] +# +# The function of obtainin mail account autoreply message. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$2 +account=$3 +format=${4-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_msg() { + i='1' # iterator + echo '{' + echo -e "\t\"$account\": {" + echo " \"MSG\": \"$msg\"" + echo -e "\t}\n}" +} + +# Shell function +shell_list_msg() { + if [ ! -z "$msg" ]; then + echo -e "$msg" + fi +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [FORMAT]' +is_object_valid 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_valid "mail/$domain" 'ACCOUNT' "$account" +is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +if [ -e "$USER_DATA/mail/$account@$domain.msg" ]; then + msg=$(cat $USER_DATA/mail/$account@$domain.msg |\ + sed -e ':a;N;$!ba;s/\n/\\n/g' ) +fi + +# Listing domains +case $format in + json) json_list_msg ;; + plain) nohead=1; shell_list_msg ;; + shell) shell_list_msg ;; + *) check_args '1' '0' '[FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-mail-accounts b/bin/v-list-mail-accounts index 7100b70f3..2dc97dac7 100755 --- a/bin/v-list-mail-accounts +++ b/bin/v-list-mail-accounts @@ -1,54 +1,54 @@ -#!/bin/bash -# info: list mail domain accounts -# options: user domain [format] -# -# The function of obtaining the list of all user domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain [format]' -validate_format 'user' 'domain' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining fileds to select -conf=$USER_DATA/mail/$domain.conf -fields="\$ACCOUNT \$ALIAS \$FWD \$AUTOREPLY \$QUOTA \$U_DISK \$SUSPENDED" -fields="$fields \$TIME \$DATE" - -# Listing domain accounts -case $format in - json) json_list ;; - plain) nohead=1; shell_list ;; - shell) fields='$ACCOUNT $AUTOREPLY $QUOTA $U_DISK $SUSPENDED $TIME $DATE'; - shell_list | column -t ;; - *) check_args '1' '0' 'user [format]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list mail domain accounts +# options: USER DOMAIN [FORMAT] +# +# The function of obtaining the list of all user domains. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$2 +format=${3-shell} + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [FORMAT]' +validate_format 'user' 'domain' +is_object_valid 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining fileds to select +conf=$USER_DATA/mail/$domain.conf +fields="\$ACCOUNT \$ALIAS \$FWD \$AUTOREPLY \$QUOTA \$U_DISK \$SUSPENDED" +fields="$fields \$TIME \$DATE" + +# Listing domain accounts +case $format in + json) json_list ;; + plain) nohead=1; shell_list ;; + shell) fields='$ACCOUNT $AUTOREPLY $QUOTA $U_DISK $SUSPENDED $TIME $DATE'; + shell_list | column -t ;; + *) check_args '1' '0' 'USER [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-mail-domain b/bin/v-list-mail-domain index aeaf08061..289ed7136 100755 --- a/bin/v-list-mail-domain +++ b/bin/v-list-mail-domain @@ -1,90 +1,90 @@ -#!/bin/bash -# info: list web domain -# options: user domain [format] -# -# The function of obtaining the list of domain parameters. This call, just as -# all v_list_* calls, supports 3 formats - json, shell and plain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_domain() { - i=1 - fileds_count=$(echo "$fields" | wc -w) - line=$(grep "DOMAIN='$domain'" $conf) - echo '{' - eval $line - for field in $fields; do - eval value=$field - if [ "$i" -eq 1 ]; then - echo -e "\t\"$value\": {" - else - if [ "$fileds_count" -eq "$i" ]; then - echo -e "\t\t\"${field//$/}\": \"$value\"" - else - echo -e "\t\t\"${field//$/}\": \"$value\"," - fi - fi - (( ++i)) - done - - if [ -n "$value" ]; then - echo -e ' }' - fi - echo -e "}" -} - -# Shell function -shell_list_domain() { - line=$(grep "DOMAIN='$domain'" $conf) - eval $line - for field in $fields; do - eval key="$field" - echo "${field//$/}: $key " - done -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain [format]' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining fileds to select -conf=$USER_DATA/mail.conf -fields='$DOMAIN $ANTIVIRUS $ANTISPAM $DKIM $ACCOUNTS $U_DISK $CATCHALL -$SUSPENDED $TIME $DATE' - -# Listing domains -case $format in - json) json_list_domain ;; - plain) nohead=1; shell_list_domain ;; - shell) shell_list_domain |column -t ;; - *) check_args '2' '0' 'user domain [format]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list web domain +# options: USER DOMAIN [FORMAT] +# +# The function of obtaining the list of domain parameters. This call, just as +# all v_list_* calls, supports 3 formats - json, shell and plain. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$2 +format=${3-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_domain() { + i=1 + fileds_count=$(echo "$fields" | wc -w) + line=$(grep "DOMAIN='$domain'" $conf) + echo '{' + eval $line + for field in $fields; do + eval value=$field + if [ "$i" -eq 1 ]; then + echo -e "\t\"$value\": {" + else + if [ "$fileds_count" -eq "$i" ]; then + echo -e "\t\t\"${field//$/}\": \"$value\"" + else + echo -e "\t\t\"${field//$/}\": \"$value\"," + fi + fi + (( ++i)) + done + + if [ -n "$value" ]; then + echo -e ' }' + fi + echo -e "}" +} + +# Shell function +shell_list_domain() { + line=$(grep "DOMAIN='$domain'" $conf) + eval $line + for field in $fields; do + eval key="$field" + echo "${field//$/}: $key " + done +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [FORMAT]' +is_object_valid 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining fileds to select +conf=$USER_DATA/mail.conf +fields='$DOMAIN $ANTIVIRUS $ANTISPAM $DKIM $ACCOUNTS $U_DISK $CATCHALL +$SUSPENDED $TIME $DATE' + +# Listing domains +case $format in + json) json_list_domain ;; + plain) nohead=1; shell_list_domain ;; + shell) shell_list_domain |column -t ;; + *) check_args '2' '0' 'USER DOMAIN [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-mail-domain-dkim b/bin/v-list-mail-domain-dkim index 3985c2c39..f3b70f7fa 100755 --- a/bin/v-list-mail-domain-dkim +++ b/bin/v-list-mail-domain-dkim @@ -1,73 +1,73 @@ -#!/bin/bash -# info: list mail domain dkim -# options: user domain [format] -# -# The function of obtaining domain dkim files. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_ssl() { - echo '{' - echo -e "\t\"$domain\": {" - echo " \"PEM\": \"$pem\"," - echo " \"PUB\": \"$pub\"," - echo -e "\t}\n}" -} - -# Shell function -shell_list_ssl() { - if [ ! -z "$pem" ]; then - echo -e "$pem" - fi - if [ ! -z "$pub" ]; then - echo -e "\n$pub" - fi -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain [format]' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# -if [ -e "$USER_DATA/mail/$domain.pem" ]; then - pem=$(cat $USER_DATA/mail/$domain.pem |sed -e ':a;N;$!ba;s/\n/\\n/g') -fi - -if [ -e "$USER_DATA/mail/$domain.pub" ]; then - pub=$(cat $USER_DATA/mail/$domain.pub |sed -e ':a;N;$!ba;s/\n/\\n/g') -fi - -# Listing domains -case $format in - json) json_list_ssl ;; - plain) nohead=1; shell_list_ssl ;; - shell) shell_list_ssl ;; - *) check_args '1' '0' '[format]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list mail domain dkim +# options: USER DOMAIN [FORMAT] +# +# The function of obtaining domain dkim files. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$2 +format=${3-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_ssl() { + echo '{' + echo -e "\t\"$domain\": {" + echo " \"PEM\": \"$pem\"," + echo " \"PUB\": \"$pub\"," + echo -e "\t}\n}" +} + +# Shell function +shell_list_ssl() { + if [ ! -z "$pem" ]; then + echo -e "$pem" + fi + if [ ! -z "$pub" ]; then + echo -e "\n$pub" + fi +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [FORMAT]' +is_object_valid 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# +if [ -e "$USER_DATA/mail/$domain.pem" ]; then + pem=$(cat $USER_DATA/mail/$domain.pem |sed -e ':a;N;$!ba;s/\n/\\n/g') +fi + +if [ -e "$USER_DATA/mail/$domain.pub" ]; then + pub=$(cat $USER_DATA/mail/$domain.pub |sed -e ':a;N;$!ba;s/\n/\\n/g') +fi + +# Listing domains +case $format in + json) json_list_ssl ;; + plain) nohead=1; shell_list_ssl ;; + shell) shell_list_ssl ;; + *) check_args '1' '0' '[FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-mail-domains b/bin/v-list-mail-domains index 87a74515c..ae92318d7 100755 --- a/bin/v-list-mail-domains +++ b/bin/v-list-mail-domains @@ -1,52 +1,52 @@ -#!/bin/bash -# info: list mail domains -# options: user [format] -# -# The function of obtaining the list of all user domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user [format]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining fileds to select -conf=$USER_DATA/mail.conf -fields="\$DOMAIN \$ANTIVIRUS \$ANTISPAM \$DKIM \$ACCOUNTS \$U_DISK \$CATCHALL" -fields="$fields \$SUSPENDED \$TIME \$DATE" - -# Listing domains -case $format in - json) json_list ;; - plain) nohead=1; shell_list ;; - shell) fields='$DOMAIN $ANTIVIRUS $ANTISPAM $DKIM $ACCOUNTS $U_DISK $DATE'; - shell_list | column -t ;; - *) check_args '1' '0' 'user [format]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list mail domains +# options: USER [FORMAT] +# +# The function of obtaining the list of all user domains. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining fileds to select +conf=$USER_DATA/mail.conf +fields="\$DOMAIN \$ANTIVIRUS \$ANTISPAM \$DKIM \$ACCOUNTS \$U_DISK \$CATCHALL" +fields="$fields \$SUSPENDED \$TIME \$DATE" + +# Listing domains +case $format in + json) json_list ;; + plain) nohead=1; shell_list ;; + shell) fields='$DOMAIN $ANTIVIRUS $ANTISPAM $DKIM $ACCOUNTS $U_DISK $DATE'; + shell_list | column -t ;; + *) check_args '1' '0' 'USER [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-sys-config b/bin/v-list-sys-config index 47df57ab2..61f8063e7 100755 --- a/bin/v-list-sys-config +++ b/bin/v-list-sys-config @@ -1,61 +1,61 @@ -#!/bin/bash -# info: list system config -# options: [format] -# -# The function for obtaining the list of system parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -format=${1-shell} - -# Json function -json_list_conf() { - lines=$(wc -l $VESTA/conf/vesta.conf | cut -f 1 -d ' ') - i='0' - IFS=$'\n' - echo -e "{\n\t\"config\": {" - for str in $(cat $VESTA/conf/vesta.conf); do - (( ++i)) - key=${str%%=*} - value=${str#*=} - if [ "$i" -lt "$lines" ]; then - echo -e "\t\t\"$key\": \"${value//\'/}\"," - else - echo -e "\t\t\"$key\": \"${value//\'/}\"" - fi - done - echo -e "\t}\n}" -} - -# Shell function -shell_list_conf() { - IFS=$'\n' - for str in $(cat $VESTA/conf/vesta.conf); do - key=${str%%=*} - value=${str#*=} - echo "$key: ${value//\'/}" - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing system config -case $format in - json) json_list_conf ;; - plain) shell_list_conf ;; - shell) shell_list_conf | column -t ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list system config +# options: [FORMAT] +# +# The function for obtaining the list of system parameters. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +format=${1-shell} + +# Json function +json_list_conf() { + lines=$(wc -l $VESTA/conf/vesta.conf | cut -f 1 -d ' ') + i='0' + IFS=$'\n' + echo -e "{\n\t\"config\": {" + for str in $(cat $VESTA/conf/vesta.conf); do + (( ++i)) + key=${str%%=*} + value=${str#*=} + if [ "$i" -lt "$lines" ]; then + echo -e "\t\t\"$key\": \"${value//\'/}\"," + else + echo -e "\t\t\"$key\": \"${value//\'/}\"" + fi + done + echo -e "\t}\n}" +} + +# Shell function +shell_list_conf() { + IFS=$'\n' + for str in $(cat $VESTA/conf/vesta.conf); do + key=${str%%=*} + value=${str#*=} + echo "$key: ${value//\'/}" + done +} + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Listing system config +case $format in + json) json_list_conf ;; + plain) shell_list_conf ;; + shell) shell_list_conf | column -t ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-sys-interfaces b/bin/v-list-sys-interfaces index b039f5314..23fdf6c27 100755 --- a/bin/v-list-sys-interfaces +++ b/bin/v-list-sys-interfaces @@ -1,65 +1,65 @@ -#!/bin/bash -# info: list system interfaces -# options: [format] -# -# The function for obtaining the list of network interfaces. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_iface() { - dev=$(cat /proc/net/dev |grep : |cut -f 1 -d : |tr -d ' ' |grep -v lo) - int_counter=$(echo "$dev" | wc -l) - i=1 - echo '[' - for interface in $dev; do - if [ "$i" -lt "$int_counter" ]; then - echo -e "\t\"$interface\"," - else - echo -e "\t\"$interface\"" - fi - (( ++i)) - done - echo "]" -} - -# Shell function -shell_list_iface() { - dev=$(cat /proc/net/dev |grep : |cut -f 1 -d : |tr -d ' ' |grep -v lo) - if [ -z "$nohead" ]; then - echo "INTERFACES" - echo "----------" - fi - for interface in $dev; do - echo "$interface" - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing domains -case $format in - json) json_list_iface ;; - plain) nohead=1; shell_list_iface ;; - shell) shell_list_iface ;; - *) check_args '1' '0' '[format]' ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list system interfaces +# options: [FORMAT] +# +# The function for obtaining the list of network interfaces. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +format=${1-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_iface() { + dev=$(cat /proc/net/dev |grep : |cut -f 1 -d : |tr -d ' ' |grep -v lo) + int_counter=$(echo "$dev" | wc -l) + i=1 + echo '[' + for interface in $dev; do + if [ "$i" -lt "$int_counter" ]; then + echo -e "\t\"$interface\"," + else + echo -e "\t\"$interface\"" + fi + (( ++i)) + done + echo "]" +} + +# Shell function +shell_list_iface() { + dev=$(cat /proc/net/dev |grep : |cut -f 1 -d : |tr -d ' ' |grep -v lo) + if [ -z "$nohead" ]; then + echo "INTERFACES" + echo "----------" + fi + for interface in $dev; do + echo "$interface" + done +} + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Listing domains +case $format in + json) json_list_iface ;; + plain) nohead=1; shell_list_iface ;; + shell) shell_list_iface ;; + *) check_args '1' '0' '[FORMAT]' ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-sys-ip b/bin/v-list-sys-ip index d6552186b..8f609933a 100755 --- a/bin/v-list-sys-ip +++ b/bin/v-list-sys-ip @@ -1,92 +1,92 @@ -#!/bin/bash -# info: list system ip -# options: ip [format] -# -# The function for getting the list of system ip parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -ip=$1 -IP=$ip -format=${2-shell} - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/ip.sh - -# Json function -json_list_ip() { - i=1 - fileds_count=$(echo "$fields" | wc -w) - ip_data=$(cat $VESTA/data/ips/$IP) - echo '{' - eval $ip_data - for field in $fields; do - eval value=$field - if [ $i -eq 1 ]; then - echo -e "\t\"$value\": {" - else - if [ $fileds_count -eq $i ]; then - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" - else - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," - fi - fi - (( ++i)) - done - if [ -n "$value" ]; then - echo -e ' }' - fi - echo -e '}' -} - -# Shell function -shell_list_ip() { - line=$(cat $VESTA/data/ips/$IP) - eval $line - for field in $fields; do - eval key="$field" - if [ -z "$key" ]; then - key='NULL' - fi - echo "${field//$/}: $key " - done -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -# Checking args -check_args '1' "$#" 'ip [format]' -validate_format 'ip' -is_ip_valid - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# -conf=$VESTA/data/ips/$IP - -# Defining fileds to select -fields='$IP $OWNER $STATUS $NAME $U_SYS_USERS $U_WEB_DOMAINS $INTERFACE - $NETMASK $TIME $DATE' - -# Listing ip -case $format in - json) json_list_ip ;; - plain) shell_list_ip ;; - shell) shell_list_ip | column -t ;; - *) check_args '1' '0' 'ip [format]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list system ip +# options: IP [FORMAT] +# +# The function for getting the list of system ip parameters. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +ip=$1 +IP=$ip +format=${2-shell} + +# Includes +source $VESTA/func/main.sh +source $VESTA/func/ip.sh + +# Json function +json_list_ip() { + i=1 + fileds_count=$(echo "$fields" | wc -w) + ip_data=$(cat $VESTA/data/ips/$IP) + echo '{' + eval $ip_data + for field in $fields; do + eval value=$field + if [ $i -eq 1 ]; then + echo -e "\t\"$value\": {" + else + if [ $fileds_count -eq $i ]; then + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" + else + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," + fi + fi + (( ++i)) + done + if [ -n "$value" ]; then + echo -e ' }' + fi + echo -e '}' +} + +# Shell function +shell_list_ip() { + line=$(cat $VESTA/data/ips/$IP) + eval $line + for field in $fields; do + eval key="$field" + if [ -z "$key" ]; then + key='NULL' + fi + echo "${field//$/}: $key " + done +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +# Checking args +check_args '1' "$#" 'IP [FORMAT]' +validate_format 'ip' +is_ip_valid + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# +conf=$VESTA/data/ips/$IP + +# Defining fileds to select +fields='$IP $OWNER $STATUS $NAME $U_SYS_USERS $U_WEB_DOMAINS $INTERFACE + $NETMASK $TIME $DATE' + +# Listing ip +case $format in + json) json_list_ip ;; + plain) shell_list_ip ;; + shell) shell_list_ip | column -t ;; + *) check_args '1' '0' 'IP [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-sys-ips b/bin/v-list-sys-ips index c23fe8874..7cee61ee8 100755 --- a/bin/v-list-sys-ips +++ b/bin/v-list-sys-ips @@ -1,94 +1,94 @@ -#!/bin/bash -# info: list system ips -# options: [format] -# -# The function for obtaining the list of system ip's. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_ips() { - echo '{' - ip_list=$(ls $VESTA/data/ips/) - fileds_count=$(echo "$fields" | wc -w) - for IP in $ip_list; do - ip_data=$(cat $VESTA/data/ips/$IP) - eval $ip_data - if [ -n "$data" ]; then - echo -e ' },' - fi - i=1 - for field in $fields; do - eval value=$field - if [ $i -eq 1 ]; then - (( ++i)) - echo -e "\t\"$value\": {" - else - if [ $i -lt $fileds_count ]; then - (( ++i)) - echo -e "\t\t\"${field//$/}\": \"$value\"," - else - echo -e "\t\t\"${field//$/}\": \"$value\"" - data=1 - fi - fi - done - done - if [ -n "$data" ]; then - echo -e ' }' - fi - echo -e '}' -} - -# Shell function -shell_list_ips() { - ip_list=$(ls $VESTA/data/ips/) - if [ -z "$nohead" ]; then - echo "${fields//$/}" - for a in $fields; do - echo -e "--------- \c" - done - echo - fi - - for IP in $ip_list; do - ip_data=$(cat $VESTA/data/ips/$IP) - eval $ip_data - eval echo "$fields" - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining fileds to select -conf=$VESTA/data/ips/* -fields="\$IP \$OWNER \$STATUS \$NAME \$U_SYS_USERS \$U_WEB_DOMAINS" -fields="$fields \$INTERFACE \$NETMASK \$TIME \$DATE" - -# Listing ip addresses -case $format in - json) json_list_ips ;; - plain) nohead=1; shell_list_ips ;; - shell) fields='$IP $NETMASK $OWNER $STATUS $U_WEB_DOMAINS'; - shell_list_ips | column -t ;; - *) check_args '1' '0' '[format]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list system ips +# options: [FORMAT] +# +# The function for obtaining the list of system ip's. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +format=${1-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_ips() { + echo '{' + ip_list=$(ls $VESTA/data/ips/) + fileds_count=$(echo "$fields" | wc -w) + for IP in $ip_list; do + ip_data=$(cat $VESTA/data/ips/$IP) + eval $ip_data + if [ -n "$data" ]; then + echo -e ' },' + fi + i=1 + for field in $fields; do + eval value=$field + if [ $i -eq 1 ]; then + (( ++i)) + echo -e "\t\"$value\": {" + else + if [ $i -lt $fileds_count ]; then + (( ++i)) + echo -e "\t\t\"${field//$/}\": \"$value\"," + else + echo -e "\t\t\"${field//$/}\": \"$value\"" + data=1 + fi + fi + done + done + if [ -n "$data" ]; then + echo -e ' }' + fi + echo -e '}' +} + +# Shell function +shell_list_ips() { + ip_list=$(ls $VESTA/data/ips/) + if [ -z "$nohead" ]; then + echo "${fields//$/}" + for a in $fields; do + echo -e "--------- \c" + done + echo + fi + + for IP in $ip_list; do + ip_data=$(cat $VESTA/data/ips/$IP) + eval $ip_data + eval echo "$fields" + done +} + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining fileds to select +conf=$VESTA/data/ips/* +fields="\$IP \$OWNER \$STATUS \$NAME \$U_SYS_USERS \$U_WEB_DOMAINS" +fields="$fields \$INTERFACE \$NETMASK \$TIME \$DATE" + +# Listing ip addresses +case $format in + json) json_list_ips ;; + plain) nohead=1; shell_list_ips ;; + shell) fields='$IP $NETMASK $OWNER $STATUS $U_WEB_DOMAINS'; + shell_list_ips | column -t ;; + *) check_args '1' '0' '[FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-sys-rrd b/bin/v-list-sys-rrd index 0d425d2fd..b5cd7ff61 100755 --- a/bin/v-list-sys-rrd +++ b/bin/v-list-sys-rrd @@ -1,114 +1,114 @@ -#!/bin/bash -# info: list system rrd charts -# options: [format] -# -# List available rrd graphics, its titles and paths. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -format=${1-shell} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# Define json function -json_list_rrd() { - i=1 - echo "{" - for type in $rrd_types; do - for rrd in $(ls $RRD/$type |grep rrd$ |sed "s/\.rrd$//g"); do - if [ "$i" -ne 1 ]; then - echo -e "\t}," - fi - if [ "$type" = 'la' ]; then - title="Load Average" - fi - if [ "$type" = 'mem' ]; then - title="Memory Usage" - fi - if [ "$type" = 'net' ]; then - title="Bandwidth Usage $rrd" - fi - if [ "$type" = 'web' ] || [ "$type" = 'ftp' ] ||\ - [ "$type" = 'ssh' ]; then - title="$(echo $rrd| tr '[:lower:]' '[:upper:]') Usage" - fi - if [ "$type" = 'db' ]; then - db_type=$(echo $rrd|cut -f 1 -d _ |sed -e 's/mysql/MySQL/g' \ - -e 's/pgsql/PostgreSQL/g' ) - db_host=$(echo $rrd|cut -f 2 -d _ ) - title="$db_type Usage on $db_host" - fi - echo -e "\t\"$i\": {" - echo -e "\t\t\"TYPE\": \"$type\"", - echo -e "\t\t\"RRD\": \"$rrd\"", - echo -e "\t\t\"TITLE\": \"$title\"," - echo -e "\t\t\"TIME\": \"$TIME\"," - echo -e "\t\t\"DATE\": \"$DATE\"" - (( ++i)) - done - done - if [ "$i" -gt 1 ]; then - echo -e "\t}" - fi - echo "}" -} - -# Define jshell function -shell_list_rrd() { - if [ -z "$nohead" ]; then - echo "PATH" - echo "---------" - fi - for type in $rrd_types; do - for rrd in $(ls $RRD/$type |grep rrd$ |sed "s/\.rrd$//g"); do - echo "$RRD/$type/$rrd.rrd" - done - done -} - - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Checking enabled systems -rrd_types="la mem net" - -if [ -n "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then - rrd_types="$rrd_types web" -fi - -if [ -n "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then - rrd_types="$rrd_types db" -fi - -if [ -n "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then - rrd_types="$rrd_types mail" -fi - -if [ -n "$FTP_SYSTEM" ] && [ "$FTP_SYSTEM" != 'no' ]; then - rrd_types="$rrd_types ftp" -fi - -rrd_types="$rrd_types ssh" - - -# Listing domains -case $format in - json) json_list_rrd ;; - plain) nohead=1; shell_list_rrd ;; - shell) shell_list_rrd | column -t ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list system rrd charts +# options: [FORMAT] +# +# List available rrd graphics, its titles and paths. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +format=${1-shell} + +# Includes +source $VESTA/func/main.sh +source $VESTA/conf/vesta.conf + +# Define json function +json_list_rrd() { + i=1 + echo "{" + for type in $rrd_types; do + for rrd in $(ls $RRD/$type |grep rrd$ |sed "s/\.rrd$//g"); do + if [ "$i" -ne 1 ]; then + echo -e "\t}," + fi + if [ "$type" = 'la' ]; then + title="Load Average" + fi + if [ "$type" = 'mem' ]; then + title="Memory Usage" + fi + if [ "$type" = 'net' ]; then + title="Bandwidth Usage $rrd" + fi + if [ "$type" = 'web' ] || [ "$type" = 'ftp' ] ||\ + [ "$type" = 'ssh' ]; then + title="$(echo $rrd| tr '[:lower:]' '[:upper:]') Usage" + fi + if [ "$type" = 'db' ]; then + db_type=$(echo $rrd|cut -f 1 -d _ |sed -e 's/mysql/MySQL/g' \ + -e 's/pgsql/PostgreSQL/g' ) + db_host=$(echo $rrd|cut -f 2 -d _ ) + title="$db_type Usage on $db_host" + fi + echo -e "\t\"$i\": {" + echo -e "\t\t\"TYPE\": \"$type\"", + echo -e "\t\t\"RRD\": \"$rrd\"", + echo -e "\t\t\"TITLE\": \"$title\"," + echo -e "\t\t\"TIME\": \"$TIME\"," + echo -e "\t\t\"DATE\": \"$DATE\"" + (( ++i)) + done + done + if [ "$i" -gt 1 ]; then + echo -e "\t}" + fi + echo "}" +} + +# Define jshell function +shell_list_rrd() { + if [ -z "$nohead" ]; then + echo "PATH" + echo "---------" + fi + for type in $rrd_types; do + for rrd in $(ls $RRD/$type |grep rrd$ |sed "s/\.rrd$//g"); do + echo "$RRD/$type/$rrd.rrd" + done + done +} + + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Checking enabled systems +rrd_types="la mem net" + +if [ -n "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then + rrd_types="$rrd_types web" +fi + +if [ -n "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then + rrd_types="$rrd_types db" +fi + +if [ -n "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then + rrd_types="$rrd_types mail" +fi + +if [ -n "$FTP_SYSTEM" ] && [ "$FTP_SYSTEM" != 'no' ]; then + rrd_types="$rrd_types ftp" +fi + +rrd_types="$rrd_types ssh" + + +# Listing domains +case $format in + json) json_list_rrd ;; + plain) nohead=1; shell_list_rrd ;; + shell) shell_list_rrd | column -t ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-sys-shells b/bin/v-list-sys-shells index 587019bc1..19a25738c 100755 --- a/bin/v-list-sys-shells +++ b/bin/v-list-sys-shells @@ -1,67 +1,67 @@ -#!/bin/bash -# info: list system shells -# options: [format] -# -# The function for obtaining the list of system shells. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_sh() { - shells=$(cat /etc/shells) - sh_counter=$(echo "$shells" | wc -l) - i=1 - echo '[' - for shell in $shells; do - shell=$(basename $shell) - if [ "$i" -lt "$sh_counter" ]; then - echo -e "\t\"$shell\"," - else - echo -e "\t\"$shell\"" - fi - (( ++i)) - done - echo "]" -} - -# Shell function -shell_list_sh() { - shells=$(cat /etc/shells) - if [ -z "$nohead" ]; then - echo "SHELLS" - echo "----------" - fi - for shell in $shells; do - shell=$(basename $shell) - echo "$shell" - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing domains -case $format in - json) json_list_sh ;; - plain) nohead=1; shell_list_sh ;; - shell) shell_list_sh ;; - *) check_args '1' '0' '[format]' ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list system shells +# options: [FORMAT] +# +# The function for obtaining the list of system shells. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +format=${1-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_sh() { + shells=$(cat /etc/shells) + sh_counter=$(echo "$shells" | wc -l) + i=1 + echo '[' + for shell in $shells; do + shell=$(basename $shell) + if [ "$i" -lt "$sh_counter" ]; then + echo -e "\t\"$shell\"," + else + echo -e "\t\"$shell\"" + fi + (( ++i)) + done + echo "]" +} + +# Shell function +shell_list_sh() { + shells=$(cat /etc/shells) + if [ -z "$nohead" ]; then + echo "SHELLS" + echo "----------" + fi + for shell in $shells; do + shell=$(basename $shell) + echo "$shell" + done +} + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Listing domains +case $format in + json) json_list_sh ;; + plain) nohead=1; shell_list_sh ;; + shell) shell_list_sh ;; + *) check_args '1' '0' '[FORMAT]' ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-sys-users b/bin/v-list-sys-users index f210ee72c..988ad1f35 100755 --- a/bin/v-list-sys-users +++ b/bin/v-list-sys-users @@ -1,65 +1,65 @@ -#!/bin/bash -# info: list system users -# options: [format] -# -# The function for obtaining the list of system users without -# detailed information. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_users() { - users=$(grep @ /etc/passwd|cut -f 1 -d :) - int_counter=$(echo "$users" | wc -l) - i=1 - echo '[' - for user in $users; do - if [ "$i" -lt "$int_counter" ]; then - echo -e "\t\"$user\"," - else - echo -e "\t\"$user\"" - fi - (( ++i)) - done - echo "]" -} - -# Shell function -shell_list_users() { - if [ -z "$nohead" ]; then - echo "USERS" - echo "----------" - fi - for user in $(grep @ /etc/passwd|cut -f 1 -d :); do - echo "$user" - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing domains -case $format in - json) json_list_users ;; - plain) nohead=1; shell_list_users ;; - shell) shell_list_users ;; - *) check_args '1' '0' '[format]' ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list system users +# options: [FORMAT] +# +# The function for obtaining the list of system users without +# detailed information. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +format=${1-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_users() { + users=$(grep @ /etc/passwd|cut -f 1 -d :) + int_counter=$(echo "$users" | wc -l) + i=1 + echo '[' + for user in $users; do + if [ "$i" -lt "$int_counter" ]; then + echo -e "\t\"$user\"," + else + echo -e "\t\"$user\"" + fi + (( ++i)) + done + echo "]" +} + +# Shell function +shell_list_users() { + if [ -z "$nohead" ]; then + echo "USERS" + echo "----------" + fi + for user in $(grep @ /etc/passwd|cut -f 1 -d :); do + echo "$user" + done +} + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Listing domains +case $format in + json) json_list_users ;; + plain) nohead=1; shell_list_users ;; + shell) shell_list_users ;; + *) check_args '1' '0' '[FORMAT]' ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-user b/bin/v-list-user index 3b56d380a..a0af9694c 100755 --- a/bin/v-list-user +++ b/bin/v-list-user @@ -1,97 +1,97 @@ -#!/bin/bash -# info: list system user -# options: user [format] -# -# The function for obtainig the list of all user's parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Includes -source $VESTA/func/main.sh - -# Argument defenition -user=$1 -USER="$user" -format=${2-shell} - -# Json function -json_list_user() { - i=1 - fileds_count=$(echo "$fields" | wc -w) - source $VESTA/data/users/$user/user.conf - echo '{' - for field in $fields; do - eval value=$field - if [ "$i" -eq 1 ]; then - echo -e "\t\"$value\": {" - else - if [ "$fileds_count" -eq "$i" ]; then - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" - else - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," - fi - fi - (( ++i)) - done - if [ -n "$value" ]; then - echo -e ' }' - fi - echo -e "}" -} - -# Shell function -shell_list_user() { - source $VESTA/data/users/$user/user.conf - for field in $fields; do - eval key="$field" - if [ -z "$key" ]; then - key='NULL' - fi - echo "${field//$/}: $key " - done -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user [format]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config -conf=$USER_DATA/user.conf - -# Defining fileds to select -fields='$USER $FNAME $LNAME $PACKAGE $TEMPLATE $WEB_DOMAINS $WEB_ALIASES - $DNS_DOMAINS $DNS_RECORDS $MAIL_DOMAINS $MAIL_ACCOUNTS $DATABASES - $CRON_JOBS $DISK_QUOTA $BANDWIDTH $NS $SHELL $BACKUPS $CONTACT - $CRON_REPORTS $RKEY $SUSPENDED $SUSPENDED_USERS $SUSPENDED_WEB - $SUSPENDED_DNS $SUSPENDED_MAIL $SUSPENDED_DB $SUSPENDED_CRON $IP_AVAIL - $IP_OWNED $U_USERS $U_DISK $U_DISK_DIRS $U_DISK_WEB $U_DISK_MAIL $U_DISK_DB - $U_BANDWIDTH $U_WEB_DOMAINS $U_WEB_SSL $U_WEB_ALIASES $U_DNS_DOMAINS - $U_DNS_RECORDS $U_MAIL_DOMAINS $U_MAIL_DKIM $U_MAIL_ACCOUNTS $U_DATABASES - $U_CRON_JOBS $U_BACKUPS $TIME $DATE' - -# Listing user -case $format in - json) json_list_user ;; - plain) nohead=1; shell_list_user ;; - shell) shell_list_user | column -t ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list system user +# options: USER [FORMAT] +# +# The function for obtainig the list of all user's parameters. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Includes +source $VESTA/func/main.sh + +# Argument defenition +user=$1 +USER="$user" +format=${2-shell} + +# Json function +json_list_user() { + i=1 + fileds_count=$(echo "$fields" | wc -w) + source $VESTA/data/users/$user/user.conf + echo '{' + for field in $fields; do + eval value=$field + if [ "$i" -eq 1 ]; then + echo -e "\t\"$value\": {" + else + if [ "$fileds_count" -eq "$i" ]; then + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" + else + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," + fi + fi + (( ++i)) + done + if [ -n "$value" ]; then + echo -e ' }' + fi + echo -e "}" +} + +# Shell function +shell_list_user() { + source $VESTA/data/users/$user/user.conf + for field in $fields; do + eval key="$field" + if [ -z "$key" ]; then + key='NULL' + fi + echo "${field//$/}: $key " + done +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config +conf=$USER_DATA/user.conf + +# Defining fileds to select +fields='$USER $FNAME $LNAME $PACKAGE $TEMPLATE $WEB_DOMAINS $WEB_ALIASES + $DNS_DOMAINS $DNS_RECORDS $MAIL_DOMAINS $MAIL_ACCOUNTS $DATABASES + $CRON_JOBS $DISK_QUOTA $BANDWIDTH $NS $SHELL $BACKUPS $CONTACT + $CRON_REPORTS $RKEY $SUSPENDED $SUSPENDED_USERS $SUSPENDED_WEB + $SUSPENDED_DNS $SUSPENDED_MAIL $SUSPENDED_DB $SUSPENDED_CRON $IP_AVAIL + $IP_OWNED $U_USERS $U_DISK $U_DISK_DIRS $U_DISK_WEB $U_DISK_MAIL $U_DISK_DB + $U_BANDWIDTH $U_WEB_DOMAINS $U_WEB_SSL $U_WEB_ALIASES $U_DNS_DOMAINS + $U_DNS_RECORDS $U_MAIL_DOMAINS $U_MAIL_DKIM $U_MAIL_ACCOUNTS $U_DATABASES + $U_CRON_JOBS $U_BACKUPS $TIME $DATE' + +# Listing user +case $format in + json) json_list_user ;; + plain) nohead=1; shell_list_user ;; + shell) shell_list_user | column -t ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-user-backups b/bin/v-list-user-backups index 5fc61819b..9a04c7f06 100755 --- a/bin/v-list-user-backups +++ b/bin/v-list-user-backups @@ -1,56 +1,56 @@ -#!/bin/bash -# info: list user backups -# options: user [format] -# -# The function for obtainig the list of available user backups. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user [format]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Checking config -conf=$USER_DATA/backup.conf -if [ ! -e "$conf" ]; then - touch $conf -fi - -# Defining fileds to select -fields="\$BACKUP \$TYPE \$SIZE \$VESTA \$PAM \$WEB \$DNS \$DB" -fields="$fields \$MAIL \$CRON \$RUNTIME \$TIME \$DATE" - -# Listing domains -case $format in - json) json_list ;; - plain) nohead=1; shell_list ;; - shell) fields='$BACKUP $TYPE $SIZE $RUNTIME $TIME $DATE'; - shell_list |column -t;; - *) check_args '1' '0' '[format]' ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list user backups +# options: USER [FORMAT] +# +# The function for obtainig the list of available user backups. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Checking config +conf=$USER_DATA/backup.conf +if [ ! -e "$conf" ]; then + touch $conf +fi + +# Defining fileds to select +fields="\$BACKUP \$TYPE \$SIZE \$VESTA \$PAM \$WEB \$DNS \$DB" +fields="$fields \$MAIL \$CRON \$RUNTIME \$TIME \$DATE" + +# Listing domains +case $format in + json) json_list ;; + plain) nohead=1; shell_list ;; + shell) fields='$BACKUP $TYPE $SIZE $RUNTIME $TIME $DATE'; + shell_list |column -t;; + *) check_args '1' '0' '[FORMAT]' ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-user-ips b/bin/v-list-user-ips index 717ad5026..7bc0dd3c0 100755 --- a/bin/v-list-user-ips +++ b/bin/v-list-user-ips @@ -1,121 +1,121 @@ -#!/bin/bash -# info: list user ips -# options: user [format] -# -# The function for obtainig the list of available ip addresses. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_user_ips() { - echo '{' - fileds_count=$(echo "$fields" | wc -w) - for IP in $(ls $VESTA/data/ips/); do - source $VESTA/data/ips/$IP - if [ "$OWNER" = "$user" ]; then - if [ -n "$data" ]; then - echo -e ' },' - fi - i=1 - for field in $fields; do - eval value=$field - if [ $i -eq 1 ]; then - (( ++i)) - echo -e "\t\"$value\": {" - else - if [ $i -lt $fileds_count ]; then - (( ++i)) - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," - else - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" - data=1 - fi - fi - done - else - if [ "$OWNER" = 'admin' ] && [ "$STATUS" = 'shared' ]; then - if [ -n "$data" ]; then - echo -e ' },' - fi - i=1 - - for field in $fields; do - eval value=$field - if [ $i -eq 1 ]; then - (( ++i)) - echo -e "\t\"$value\": {" - else - if [ $i -lt $fileds_count ]; then - (( ++i)) - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," - else - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" - data=1 - fi - fi - done - fi - fi - done - if [ -n "$data" ]; then - echo -e ' }' - fi - echo -e '}' - -} - -# Shell function -shell_list_user_ips() { - for IP in $(ls $VESTA/data/ips/); do - source $VESTA/data/ips/$IP - if [ "$OWNER" = "$user" ]; then - eval echo "$fields" - else - if [ "$OWNER" = 'admin' ] && [ "$STATUS" = 'shared' ]; then - eval echo "$fields" - fi - fi - done -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user [format]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining fileds to select -fields='$IP $OWNER $STATUS $NAME' - -# Listing ips -case $format in - json) json_list_user_ips ;; - plain) nohead=1; shell_list_user_ips ;; - shell) shell_list_user_ips | column -t ;; - *) check_args '1' '0' 'user [format]' ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list user ips +# options: USER [FORMAT] +# +# The function for obtainig the list of available ip addresses. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_user_ips() { + echo '{' + fileds_count=$(echo "$fields" | wc -w) + for IP in $(ls $VESTA/data/ips/); do + source $VESTA/data/ips/$IP + if [ "$OWNER" = "$user" ]; then + if [ -n "$data" ]; then + echo -e ' },' + fi + i=1 + for field in $fields; do + eval value=$field + if [ $i -eq 1 ]; then + (( ++i)) + echo -e "\t\"$value\": {" + else + if [ $i -lt $fileds_count ]; then + (( ++i)) + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," + else + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" + data=1 + fi + fi + done + else + if [ "$OWNER" = 'admin' ] && [ "$STATUS" = 'shared' ]; then + if [ -n "$data" ]; then + echo -e ' },' + fi + i=1 + + for field in $fields; do + eval value=$field + if [ $i -eq 1 ]; then + (( ++i)) + echo -e "\t\"$value\": {" + else + if [ $i -lt $fileds_count ]; then + (( ++i)) + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," + else + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" + data=1 + fi + fi + done + fi + fi + done + if [ -n "$data" ]; then + echo -e ' }' + fi + echo -e '}' + +} + +# Shell function +shell_list_user_ips() { + for IP in $(ls $VESTA/data/ips/); do + source $VESTA/data/ips/$IP + if [ "$OWNER" = "$user" ]; then + eval echo "$fields" + else + if [ "$OWNER" = 'admin' ] && [ "$STATUS" = 'shared' ]; then + eval echo "$fields" + fi + fi + done +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining fileds to select +fields='$IP $OWNER $STATUS $NAME' + +# Listing ips +case $format in + json) json_list_user_ips ;; + plain) nohead=1; shell_list_user_ips ;; + shell) shell_list_user_ips | column -t ;; + *) check_args '1' '0' 'USER [FORMAT]' ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-user-log b/bin/v-list-user-log index 0054b8c36..1c3ee19cc 100755 --- a/bin/v-list-user-log +++ b/bin/v-list-user-log @@ -1,88 +1,88 @@ -#!/bin/bash -# info: list user log -# options: user [format] -# -# The function of obtaining the list of 100 last users commands. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - -# Json func -json_list_history() { - echo '{' - fileds_count=$(echo $fields| wc -w ) - while read line; do - IFS=$'\n' - eval $line - if [ -n "$data" ]; then - echo -e ' },' - fi - i=1 - IFS=' ' - for field in $fields; do - eval value=\"$field\" - value=$(echo "$value" | sed -e 's/"/\\"/g' -e "s/%quote%/'/g") - if [ $i -eq 1 ]; then - (( ++i)) - echo -e "\t\"$value\": {" - else - if [ $i -lt $fileds_count ]; then - (( ++i)) - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," - else - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" - data=1 - fi - fi - done - done < $conf - if [ -n "$data" ]; then - echo -e ' }' - fi - echo -e '}' -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user [format]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config -conf=$USER_DATA/history.log - -# Defining fileds to select -fields="\$ID \$DATE \$TIME \$CMD \$UNDO" - -# Listing domains -case $format in - json) json_list_history ;; - plain) nohead=1; shell_list ;; - shell) fields='$ID~$DATE~$TIME~$CMD'; - shell_list |column -t -s '~';; - *) check_args '1' '0' 'user [format]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list user log +# options: USER [FORMAT] +# +# The function of obtaining the list of 100 last users commands. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + +# Json func +json_list_history() { + echo '{' + fileds_count=$(echo $fields| wc -w ) + while read line; do + IFS=$'\n' + eval $line + if [ -n "$data" ]; then + echo -e ' },' + fi + i=1 + IFS=' ' + for field in $fields; do + eval value=\"$field\" + value=$(echo "$value" | sed -e 's/"/\\"/g' -e "s/%quote%/'/g") + if [ $i -eq 1 ]; then + (( ++i)) + echo -e "\t\"$value\": {" + else + if [ $i -lt $fileds_count ]; then + (( ++i)) + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," + else + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" + data=1 + fi + fi + done + done < $conf + if [ -n "$data" ]; then + echo -e ' }' + fi + echo -e '}' +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config +conf=$USER_DATA/history.log + +# Defining fileds to select +fields="\$ID \$DATE \$TIME \$CMD \$UNDO" + +# Listing domains +case $format in + json) json_list_history ;; + plain) nohead=1; shell_list ;; + shell) fields='$ID~$DATE~$TIME~$CMD'; + shell_list |column -t -s '~';; + *) check_args '1' '0' 'USER [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-user-ns b/bin/v-list-user-ns index 21c5bcd6e..9b2163275 100755 --- a/bin/v-list-user-ns +++ b/bin/v-list-user-ns @@ -1,75 +1,75 @@ -#!/bin/bash -# info: list user nameservers -# options: user [format] -# -# Function for obtainig the list of user's DNS servers. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_ns() { - ns=$(grep "^NS='" $USER_DATA/user.conf |cut -f 2 -d \') - echo '[' - i=1 - nslistc=$(echo -e "${ns//,/\n}"|wc -l) - for nameserver in ${ns//,/ };do - if [ "$i" -ne "$nslistc" ]; then - echo -e "\t\"$nameserver\"," - else - echo -e "\t\"$nameserver\"" - fi - (( ++i)) - done - echo "]" -} - -# Shell function -shell_list_ns() { - ns=$(grep "^NS='" $USER_DATA/user.conf |cut -f 2 -d \') - if [ -z "$nohead" ]; then - echo "NAMESERVER" - echo "----------" - fi - for nameserver in ${ns//,/ };do - echo "$nameserver" - done -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user [format]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing nameservers -case $format in - json) json_list_ns ;; - plain) nohead=1; shell_list_ns ;; - shell) shell_list_ns ;; - *) check_args '1' '0' 'user [format]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list user nameservers +# options: USER [FORMAT] +# +# Function for obtainig the list of user's DNS servers. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_ns() { + ns=$(grep "^NS='" $USER_DATA/user.conf |cut -f 2 -d \') + echo '[' + i=1 + nslistc=$(echo -e "${ns//,/\n}"|wc -l) + for nameserver in ${ns//,/ };do + if [ "$i" -ne "$nslistc" ]; then + echo -e "\t\"$nameserver\"," + else + echo -e "\t\"$nameserver\"" + fi + (( ++i)) + done + echo "]" +} + +# Shell function +shell_list_ns() { + ns=$(grep "^NS='" $USER_DATA/user.conf |cut -f 2 -d \') + if [ -z "$nohead" ]; then + echo "NAMESERVER" + echo "----------" + fi + for nameserver in ${ns//,/ };do + echo "$nameserver" + done +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Listing nameservers +case $format in + json) json_list_ns ;; + plain) nohead=1; shell_list_ns ;; + shell) shell_list_ns ;; + *) check_args '1' '0' 'USER [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-user-package b/bin/v-list-user-package index dd89bbc87..2c30f9667 100755 --- a/bin/v-list-user-package +++ b/bin/v-list-user-package @@ -1,92 +1,92 @@ -#!/bin/bash -# info: list user package -# options: package [format] -# -# The function for getting the list of system ip parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -package=$1 -PACKAGE=$package -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_package() { - i=1 - fileds_count=$(echo "$fields" | wc -w) - pkg_data=$(cat $VESTA/data/packages/$PACKAGE.pkg) - echo '{' - eval $pkg_data - for field in $fields; do - eval value=$field - if [ $i -eq 1 ]; then - echo -e "\t\"$value\": {" - else - if [ $fileds_count -eq $i ]; then - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" - else - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," - fi - fi - (( ++i)) - done - if [ -n "$value" ]; then - echo -e ' }' - fi - echo -e '}' -} - -# Shell function -shell_list_package() { - line=$(cat $VESTA/data/packages/$PACKAGE.pkg) - eval $line - for field in $fields; do - eval key="$field" - if [ -z "$key" ]; then - key='NULL' - fi - echo "${field//$/}: $key " - done -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -# Checking args -check_args '1' "$#" 'package [format]' -validate_format 'package' -is_package_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining fileds to select -fields='$PACKAGE $TEMPLATE $WEB_DOMAINS $WEB_ALIASES $DNS_DOMAINS $DNS_RECORDS - $MAIL_DOMAINS $MAIL_ACCOUNTS $DATABASES $CRON_JOBS $DISK_QUOTA $BANDWIDTH - $NS $SHELL $BACKUPS $TIME $DATE' - -# Listing ip -case $format in - json) json_list_package ;; - plain) shell_list_package ;; - shell) shell_list_package | column -t ;; - *) check_args '1' '0' 'ip [format]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list user package +# options: PACKAGE [FORMAT] +# +# The function for getting the list of system ip parameters. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +package=$1 +PACKAGE=$package +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_package() { + i=1 + fileds_count=$(echo "$fields" | wc -w) + pkg_data=$(cat $VESTA/data/packages/$PACKAGE.pkg) + echo '{' + eval $pkg_data + for field in $fields; do + eval value=$field + if [ $i -eq 1 ]; then + echo -e "\t\"$value\": {" + else + if [ $fileds_count -eq $i ]; then + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" + else + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," + fi + fi + (( ++i)) + done + if [ -n "$value" ]; then + echo -e ' }' + fi + echo -e '}' +} + +# Shell function +shell_list_package() { + line=$(cat $VESTA/data/packages/$PACKAGE.pkg) + eval $line + for field in $fields; do + eval key="$field" + if [ -z "$key" ]; then + key='NULL' + fi + echo "${field//$/}: $key " + done +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +# Checking args +check_args '1' "$#" 'PACKAGE [FORMAT]' +validate_format 'package' +is_package_valid + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining fileds to select +fields='$PACKAGE $TEMPLATE $WEB_DOMAINS $WEB_ALIASES $DNS_DOMAINS $DNS_RECORDS + $MAIL_DOMAINS $MAIL_ACCOUNTS $DATABASES $CRON_JOBS $DISK_QUOTA $BANDWIDTH + $NS $SHELL $BACKUPS $TIME $DATE' + +# Listing ip +case $format in + json) json_list_package ;; + plain) shell_list_package ;; + shell) shell_list_package | column -t ;; + *) check_args '1' '0' 'IP [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-user-packages b/bin/v-list-user-packages index 1cf32535c..348337537 100755 --- a/bin/v-list-user-packages +++ b/bin/v-list-user-packages @@ -1,91 +1,91 @@ -#!/bin/bash -# info: list user packages -# options: [format] -# -# The function for obtaining the list of available hosting packages. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_pkgs() { - echo '{' - fileds_count=$(echo "$fields" | wc -w) - for package in $(ls $VESTA/data/packages); do - PACKAGE=${package/.pkg/} - pkg_data=$(cat $VESTA/data/packages/$package) - eval $pkg_data - if [ -n "$data" ]; then - echo -e ' },' - fi - i=1 - for field in $fields; do - eval value=$field - if [ $i -eq 1 ]; then - (( ++i)) - echo -e "\t\"$value\": {" - else - if [ $i -lt $fileds_count ]; then - (( ++i)) - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," - else - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" - data=1 - fi - fi - done - done - if [ -n "$data" ]; then - echo -e ' }' - fi - echo -e '}' -} - -# Shell fnction -shell_list_pkgs() { - for package in $(ls $VESTA/data/packages); do - PACKAGE=${package/.pkg/} - pkg_descr=$(cat $VESTA/data/packages/$package) - eval $pkg_descr - if [ -z "$nohead" ]; then - echo '----------' - fi - for field in $fields; do - eval value=$field - echo -e "${field//$/}: $value" - done - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining fields -fields='$PACKAGE $TEMPLATE $WEB_DOMAINS $WEB_ALIASES $DNS_DOMAINS $DNS_RECORDS - $MAIL_DOMAINS $MAIL_ACCOUNTS $DATABASES $CRON_JOBS $DISK_QUOTA $BANDWIDTH - $NS $SHELL $BACKUPS $TIME $DATE' - -# Listing domains -case $format in - json) json_list_pkgs ;; - plain) nohead=1; shell_list_pkgs ;; - shell) shell_list_pkgs | column -t ;; - *) check_args '1' '0' '[format]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list user packages +# options: [FORMAT] +# +# The function for obtaining the list of available hosting packages. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +format=${1-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_pkgs() { + echo '{' + fileds_count=$(echo "$fields" | wc -w) + for package in $(ls $VESTA/data/packages); do + PACKAGE=${package/.pkg/} + pkg_data=$(cat $VESTA/data/packages/$package) + eval $pkg_data + if [ -n "$data" ]; then + echo -e ' },' + fi + i=1 + for field in $fields; do + eval value=$field + if [ $i -eq 1 ]; then + (( ++i)) + echo -e "\t\"$value\": {" + else + if [ $i -lt $fileds_count ]; then + (( ++i)) + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," + else + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" + data=1 + fi + fi + done + done + if [ -n "$data" ]; then + echo -e ' }' + fi + echo -e '}' +} + +# Shell fnction +shell_list_pkgs() { + for package in $(ls $VESTA/data/packages); do + PACKAGE=${package/.pkg/} + pkg_descr=$(cat $VESTA/data/packages/$package) + eval $pkg_descr + if [ -z "$nohead" ]; then + echo '----------' + fi + for field in $fields; do + eval value=$field + echo -e "${field//$/}: $value" + done + done +} + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining fields +fields='$PACKAGE $TEMPLATE $WEB_DOMAINS $WEB_ALIASES $DNS_DOMAINS $DNS_RECORDS + $MAIL_DOMAINS $MAIL_ACCOUNTS $DATABASES $CRON_JOBS $DISK_QUOTA $BANDWIDTH + $NS $SHELL $BACKUPS $TIME $DATE' + +# Listing domains +case $format in + json) json_list_pkgs ;; + plain) nohead=1; shell_list_pkgs ;; + shell) shell_list_pkgs | column -t ;; + *) check_args '1' '0' '[FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-user-stats b/bin/v-list-user-stats index a958b9fc6..eac6e9142 100755 --- a/bin/v-list-user-stats +++ b/bin/v-list-user-stats @@ -1,58 +1,58 @@ -#!/bin/bash -# info: list user stats -# options: user [format] -# -# The function for listing user statistics - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user [format]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config -conf=$USER_DATA/stats.log - -# Defining fileds to select -fields="\$DATE \$TIME \$PACKAGE \$IP_OWNED \$DISK_QUOTA \$U_DISK \$U_DISK_DIRS" -fields="$fields \$U_DISK_WEB \$U_DISK_MAIL \$U_DISK_DB \$BANDWIDTH" -fields="$fields \$U_BANDWIDTH \$U_WEB_DOMAINS \$U_WEB_SSL \$U_WEB_ALIASES" -fields="$fields \$U_DNS_DOMAINS \$U_DNS_RECORDS \$U_MAIL_DOMAINS \$U_MAIL_DKIM" -fields="$fields \$U_MAIL_ACCOUNTS \$U_DATABASES \$U_CRON_JOBS \$U_BACKUPS" - -# Listing domains -case $format in - json) json_list ;; - plain) nohead=1; shell_list ;; - shell) fields='$DATE $PACKAGE $U_DISK $U_BANDWIDTH $U_WEB_DOMAINS'; - fields="$fields \$U_DATABASES" - shell_list | column -t ;; - *) check_args '1' '0' 'user [format]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list user stats +# options: USER [FORMAT] +# +# The function for listing user statistics + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config +conf=$USER_DATA/stats.log + +# Defining fileds to select +fields="\$DATE \$TIME \$PACKAGE \$IP_OWNED \$DISK_QUOTA \$U_DISK \$U_DISK_DIRS" +fields="$fields \$U_DISK_WEB \$U_DISK_MAIL \$U_DISK_DB \$BANDWIDTH" +fields="$fields \$U_BANDWIDTH \$U_WEB_DOMAINS \$U_WEB_SSL \$U_WEB_ALIASES" +fields="$fields \$U_DNS_DOMAINS \$U_DNS_RECORDS \$U_MAIL_DOMAINS \$U_MAIL_DKIM" +fields="$fields \$U_MAIL_ACCOUNTS \$U_DATABASES \$U_CRON_JOBS \$U_BACKUPS" + +# Listing domains +case $format in + json) json_list ;; + plain) nohead=1; shell_list ;; + shell) fields='$DATE $PACKAGE $U_DISK $U_BANDWIDTH $U_WEB_DOMAINS'; + fields="$fields \$U_DATABASES" + shell_list | column -t ;; + *) check_args '1' '0' 'USER [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-users b/bin/v-list-users index 1aa67ea6d..699292277 100755 --- a/bin/v-list-users +++ b/bin/v-list-users @@ -1,102 +1,102 @@ -#!/bin/bash -# info: list system users -# options: [format] -# -# The function for obtainig the list of all server's users. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -format=${1-shell} - -# Json function -json_list_users() { - echo '{' - fileds_count=$(echo "$fields" | wc -w) - for USER in $(grep @ /etc/passwd|cut -f 1 -d :); do - source $VESTA/data/users/$USER/user.conf - if [ -n "$data" ]; then - echo -e ' },' - fi - i=1 - for field in $fields; do - eval value=$field - if [ $i -eq 1 ]; then - (( ++i)) - echo -e "\t\"$value\": {" - else - if [ $i -lt $fileds_count ]; then - (( ++i)) - echo -e "\t\t\"${field//$/}\": \"$value\"," - else - echo -e "\t\t\"${field//$/}\": \"$value\"" - data=1 - fi - fi - done - done - if [ -n "$data" ]; then - echo -e ' }' - fi - echo -e '}' -} - -# Shell function -shell_list_users() { - if [ -z "$nohead" ]; then - echo "${fields//$/}" - for a in $fields; do - echo -e "--------- \c" - done - echo - fi - - for USER in $(grep @ /etc/passwd|cut -f 1 -d :); do - source $VESTA/data/users/$USER/user.conf - for field in $fields; do - eval value=$field - if [ -z "$value" ]; then - value='NULL' - fi - echo -n "$value " - done - echo - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining fileds to select -fields="\$USER \$FNAME \$LNAME \$PACKAGE \$TEMPLATE \$WEB_DOMAINS" -fields="$fields \$WEB_ALIASES \$DNS_DOMAINS \$DNS_RECORDS \$MAIL_DOMAINS" -fields="$fields \$MAIL_ACCOUNTS \$DATABASES \$CRON_JOBS \$DISK_QUOTA" -fields="$fields \$BANDWIDTH \$NS \$SHELL \$BACKUPS \$CONTACT" -fields="$fields \$CRON_REPORTS \$RKEY \$SUSPENDED \$SUSPENDED_USERS" -fields="$fields \$SUSPENDED_WEB \$SUSPENDED_DNS \$SUSPENDED_MAIL" -fields="$fields \$SUSPENDED_DB \$SUSPENDED_CRON \$IP_AVAIL \$IP_OWNED" -fields="$fields \$U_USERS \$U_DISK \$U_DISK_DIRS \$U_DISK_WEB \$U_DISK_MAIL" -fields="$fields \$U_DISK_DB \$U_BANDWIDTH \$U_WEB_DOMAINS \$U_WEB_SSL" -fields="$fields \$U_WEB_ALIASES \$U_DNS_DOMAINS \$U_DNS_RECORDS" -fields="$fields \$U_MAIL_DOMAINS \$U_MAIL_DKIM \$U_MAIL_ACCOUNTS" -fields="$fields \$U_DATABASES \$U_CRON_JOBS \$U_BACKUPS \$TIME \$DATE" - -# Listing domains -case $format in - json) json_list_users ;; - plain) nohead=1; shell_list_users ;; - shell) fields='$USER $PACKAGE $U_DISK $U_BANDWIDTH $SUSPENDED $DATE'; - shell_list_users | column -t ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list system users +# options: [FORMAT] +# +# The function for obtainig the list of all server's users. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +format=${1-shell} + +# Json function +json_list_users() { + echo '{' + fileds_count=$(echo "$fields" | wc -w) + for USER in $(grep @ /etc/passwd|cut -f 1 -d :); do + source $VESTA/data/users/$USER/user.conf + if [ -n "$data" ]; then + echo -e ' },' + fi + i=1 + for field in $fields; do + eval value=$field + if [ $i -eq 1 ]; then + (( ++i)) + echo -e "\t\"$value\": {" + else + if [ $i -lt $fileds_count ]; then + (( ++i)) + echo -e "\t\t\"${field//$/}\": \"$value\"," + else + echo -e "\t\t\"${field//$/}\": \"$value\"" + data=1 + fi + fi + done + done + if [ -n "$data" ]; then + echo -e ' }' + fi + echo -e '}' +} + +# Shell function +shell_list_users() { + if [ -z "$nohead" ]; then + echo "${fields//$/}" + for a in $fields; do + echo -e "--------- \c" + done + echo + fi + + for USER in $(grep @ /etc/passwd|cut -f 1 -d :); do + source $VESTA/data/users/$USER/user.conf + for field in $fields; do + eval value=$field + if [ -z "$value" ]; then + value='NULL' + fi + echo -n "$value " + done + echo + done +} + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining fileds to select +fields="\$USER \$FNAME \$LNAME \$PACKAGE \$TEMPLATE \$WEB_DOMAINS" +fields="$fields \$WEB_ALIASES \$DNS_DOMAINS \$DNS_RECORDS \$MAIL_DOMAINS" +fields="$fields \$MAIL_ACCOUNTS \$DATABASES \$CRON_JOBS \$DISK_QUOTA" +fields="$fields \$BANDWIDTH \$NS \$SHELL \$BACKUPS \$CONTACT" +fields="$fields \$CRON_REPORTS \$RKEY \$SUSPENDED \$SUSPENDED_USERS" +fields="$fields \$SUSPENDED_WEB \$SUSPENDED_DNS \$SUSPENDED_MAIL" +fields="$fields \$SUSPENDED_DB \$SUSPENDED_CRON \$IP_AVAIL \$IP_OWNED" +fields="$fields \$U_USERS \$U_DISK \$U_DISK_DIRS \$U_DISK_WEB \$U_DISK_MAIL" +fields="$fields \$U_DISK_DB \$U_BANDWIDTH \$U_WEB_DOMAINS \$U_WEB_SSL" +fields="$fields \$U_WEB_ALIASES \$U_DNS_DOMAINS \$U_DNS_RECORDS" +fields="$fields \$U_MAIL_DOMAINS \$U_MAIL_DKIM \$U_MAIL_ACCOUNTS" +fields="$fields \$U_DATABASES \$U_CRON_JOBS \$U_BACKUPS \$TIME \$DATE" + +# Listing domains +case $format in + json) json_list_users ;; + plain) nohead=1; shell_list_users ;; + shell) fields='$USER $PACKAGE $U_DISK $U_BANDWIDTH $SUSPENDED $DATE'; + shell_list_users | column -t ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-users-stats b/bin/v-list-users-stats index b731747d4..8a6fbf583 100755 --- a/bin/v-list-users-stats +++ b/bin/v-list-users-stats @@ -1,55 +1,55 @@ -#!/bin/bash -# info: list overall user stats -# options: [format] -# -# The function for listing overall user statistics - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '0' "$#" '[format]' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config -conf=$VESTA/data/users/admin/overall_stats.log - -# Defining fileds to select -fields="\$DATE \$TIME \$PACKAGE \$IP_OWNED \$DISK_QUOTA \$U_DISK \$U_DISK_DIRS" -fields="$fields \$U_DISK_WEB \$U_DISK_MAIL \$U_DISK_DB \$BANDWIDTH" -fields="$fields \$U_BANDWIDTH \$U_WEB_DOMAINS \$U_WEB_SSL \$U_WEB_ALIASES" -fields="$fields \$U_DNS_DOMAINS \$U_DNS_RECORDS \$U_MAIL_DOMAINS \$U_MAIL_DKIM" -fields="$fields \$U_MAIL_ACCOUNTS \$U_DATABASES \$U_CRON_JOBS \$U_BACKUPS" - -# Listing domains -case $format in - json) json_list ;; - plain) nohead=1; shell_list ;; - shell) fields='$DATE $U_DISK $U_BANDWIDTH $U_WEB_DOMAINS $U_DATABASES'; - fields="$fields \$U_DATABASES" - shell_list | column -t ;; - *) check_args '1' '0' '[format]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list overall user stats +# options: [FORMAT] +# +# The function for listing overall user statistics + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +format=${1-shell} + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '0' "$#" '[FORMAT]' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config +conf=$VESTA/data/users/admin/overall_stats.log + +# Defining fileds to select +fields="\$DATE \$TIME \$PACKAGE \$IP_OWNED \$DISK_QUOTA \$U_DISK \$U_DISK_DIRS" +fields="$fields \$U_DISK_WEB \$U_DISK_MAIL \$U_DISK_DB \$BANDWIDTH" +fields="$fields \$U_BANDWIDTH \$U_WEB_DOMAINS \$U_WEB_SSL \$U_WEB_ALIASES" +fields="$fields \$U_DNS_DOMAINS \$U_DNS_RECORDS \$U_MAIL_DOMAINS \$U_MAIL_DKIM" +fields="$fields \$U_MAIL_ACCOUNTS \$U_DATABASES \$U_CRON_JOBS \$U_BACKUPS" + +# Listing domains +case $format in + json) json_list ;; + plain) nohead=1; shell_list ;; + shell) fields='$DATE $U_DISK $U_BANDWIDTH $U_WEB_DOMAINS $U_DATABASES'; + fields="$fields \$U_DATABASES" + shell_list | column -t ;; + *) check_args '1' '0' '[FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-web-domain b/bin/v-list-web-domain index bf6e0190b..da1b8ce8d 100755 --- a/bin/v-list-web-domain +++ b/bin/v-list-web-domain @@ -1,94 +1,94 @@ -#!/bin/bash -# info: list web domain -# options: user domain [format] -# -# The function of obtaining the list of domain parameters. This call, just as -# all v_list_* calls, supports 3 formats - json, shell and plain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_domain() { - i=1 - fileds_count=$(echo "$fields" | wc -w) - line=$(grep "DOMAIN='$domain'" $conf) - echo '{' - eval $line - for field in $fields; do - eval value=$field - if [ "$i" -eq 1 ]; then - echo -e "\t\"$value\": {" - else - if [ "$fileds_count" -eq "$i" ]; then - echo -e "\t\t\"${field//$/}\": \"$value\"" - else - echo -e "\t\t\"${field//$/}\": \"$value\"," - fi - fi - (( ++i)) - done - if [ -n "$value" ]; then - echo -e ' }' - fi - echo -e "}" -} - -# Shell function -shell_list_domain() { - line=$(grep "DOMAIN='$domain'" $conf) - eval $line - for field in $fields; do - eval key="$field" - if [ -z "$key" ]; then - key='NULL' - fi - echo "${field//$/}: $key " - done -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain [format]' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config -conf=$USER_DATA/web.conf - -# Defining fileds to select -fields='$DOMAIN $IP $IP6 $U_DISK $U_BANDWIDTH $TPL $ALIAS $CGI $ELOG $STATS - $STATS_USER $SSL $SSL_HOME $FTP_USER $NGINX $NGINX_EXT $SUSPENDED $TIME $DATE' - -# Listing domains -case $format in - json) json_list_domain ;; - plain) nohead=1; shell_list_domain ;; - shell) shell_list_domain |column -t;; - *) check_args '2' '0' 'user domain [format]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list web domain +# options: USER DOMAIN [FORMAT] +# +# The function of obtaining the list of domain parameters. This call, just as +# all v_list_* calls, supports 3 formats - json, shell and plain. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$2 +format=${3-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_domain() { + i=1 + fileds_count=$(echo "$fields" | wc -w) + line=$(grep "DOMAIN='$domain'" $conf) + echo '{' + eval $line + for field in $fields; do + eval value=$field + if [ "$i" -eq 1 ]; then + echo -e "\t\"$value\": {" + else + if [ "$fileds_count" -eq "$i" ]; then + echo -e "\t\t\"${field//$/}\": \"$value\"" + else + echo -e "\t\t\"${field//$/}\": \"$value\"," + fi + fi + (( ++i)) + done + if [ -n "$value" ]; then + echo -e ' }' + fi + echo -e "}" +} + +# Shell function +shell_list_domain() { + line=$(grep "DOMAIN='$domain'" $conf) + eval $line + for field in $fields; do + eval key="$field" + if [ -z "$key" ]; then + key='NULL' + fi + echo "${field//$/}: $key " + done +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [FORMAT]' +is_object_valid 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config +conf=$USER_DATA/web.conf + +# Defining fileds to select +fields='$DOMAIN $IP $IP6 $U_DISK $U_BANDWIDTH $TPL $ALIAS $CGI $ELOG $STATS + $STATS_USER $SSL $SSL_HOME $FTP_USER $NGINX $NGINX_EXT $SUSPENDED $TIME $DATE' + +# Listing domains +case $format in + json) json_list_domain ;; + plain) nohead=1; shell_list_domain ;; + shell) shell_list_domain |column -t;; + *) check_args '2' '0' 'USER DOMAIN [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-web-domain-ssl b/bin/v-list-web-domain-ssl index 2b17707e7..0843b1a61 100755 --- a/bin/v-list-web-domain-ssl +++ b/bin/v-list-web-domain-ssl @@ -1,81 +1,81 @@ -#!/bin/bash -# info: list web domain ssl certificate -# options: user domain [format] -# -# The function of obtaining domain ssl files. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_ssl() { - i='1' # iterator - echo '{' - echo -e "\t\"$domain\": {" - echo " \"CRT\": \"$crt\"," - echo " \"KEY\": \"$key\"," - echo " \"CA\": \"$ca\"" - echo -e "\t}\n}" -} - -# Shell function -shell_list_ssl() { - if [ ! -z "$crt" ]; then - echo -e "$crt" - fi - if [ ! -z "$key" ]; then - echo -e "\n$key" - fi - if [ ! -z "$ca" ]; then - echo -e "\n$ca" - fi -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain [format]' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# -if [ -e "$USER_DATA/ssl/$domain.crt" ]; then - crt=$(cat $USER_DATA/ssl/$domain.crt |sed -e ':a;N;$!ba;s/\n/\\n/g' ) -fi - -if [ -e "$USER_DATA/ssl/$domain.key" ]; then - key=$(cat $USER_DATA/ssl/$domain.key |sed -e ':a;N;$!ba;s/\n/\\n/g' ) -fi - -if [ -e "$USER_DATA/ssl/$domain.ca" ]; then - ca=$(cat $USER_DATA/ssl/$domain.ca |sed -e ':a;N;$!ba;s/\n/\\n/g' ) -fi - -# Listing domains -case $format in - json) json_list_ssl ;; - plain) nohead=1; shell_list_ssl ;; - shell) shell_list_ssl ;; - *) check_args '1' '0' '[format]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list web domain ssl certificate +# options: USER DOMAIN [FORMAT] +# +# The function of obtaining domain ssl files. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$2 +format=${3-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_ssl() { + i='1' # iterator + echo '{' + echo -e "\t\"$domain\": {" + echo " \"CRT\": \"$crt\"," + echo " \"KEY\": \"$key\"," + echo " \"CA\": \"$ca\"" + echo -e "\t}\n}" +} + +# Shell function +shell_list_ssl() { + if [ ! -z "$crt" ]; then + echo -e "$crt" + fi + if [ ! -z "$key" ]; then + echo -e "\n$key" + fi + if [ ! -z "$ca" ]; then + echo -e "\n$ca" + fi +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [FORMAT]' +is_object_valid 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# +if [ -e "$USER_DATA/ssl/$domain.crt" ]; then + crt=$(cat $USER_DATA/ssl/$domain.crt |sed -e ':a;N;$!ba;s/\n/\\n/g' ) +fi + +if [ -e "$USER_DATA/ssl/$domain.key" ]; then + key=$(cat $USER_DATA/ssl/$domain.key |sed -e ':a;N;$!ba;s/\n/\\n/g' ) +fi + +if [ -e "$USER_DATA/ssl/$domain.ca" ]; then + ca=$(cat $USER_DATA/ssl/$domain.ca |sed -e ':a;N;$!ba;s/\n/\\n/g' ) +fi + +# Listing domains +case $format in + json) json_list_ssl ;; + plain) nohead=1; shell_list_ssl ;; + shell) shell_list_ssl ;; + *) check_args '1' '0' '[FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-web-domains b/bin/v-list-web-domains index 95442a347..0d8e052d1 100755 --- a/bin/v-list-web-domains +++ b/bin/v-list-web-domains @@ -1,55 +1,55 @@ -#!/bin/bash -# info: list web domains -# options: user [format] -# -# The function of obtaining the list of all user domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user [format]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config -conf=$USER_DATA/web.conf - -# Defining fileds to select -fields="\$DOMAIN \$IP \$IP6 \$U_DISK \$U_BANDWIDTH \$TPL \$ALIAS \$CGI" -fields="$fields \$ELOG \$STATS \$STATS_USER \$SSL \$SSL_HOME \$FTP_USER" -fields="$fields \$NGINX \$NGINX_EXT \$SUSPENDED \$TIME \$DATE" - -# Listing domains -case $format in - json) json_list ;; - plain) nohead=1; shell_list ;; - shell) fields='$DOMAIN $IP $U_DISK $U_BANDWIDTH $TPL $DATE'; - shell_list | column -t ;; - *) check_args '1' '0' 'user [format]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list web domains +# options: USER [FORMAT] +# +# The function of obtaining the list of all user domains. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config +conf=$USER_DATA/web.conf + +# Defining fileds to select +fields="\$DOMAIN \$IP \$IP6 \$U_DISK \$U_BANDWIDTH \$TPL \$ALIAS \$CGI" +fields="$fields \$ELOG \$STATS \$STATS_USER \$SSL \$SSL_HOME \$FTP_USER" +fields="$fields \$NGINX \$NGINX_EXT \$SUSPENDED \$TIME \$DATE" + +# Listing domains +case $format in + json) json_list ;; + plain) nohead=1; shell_list ;; + shell) fields='$DOMAIN $IP $U_DISK $U_BANDWIDTH $TPL $DATE'; + shell_list | column -t ;; + *) check_args '1' '0' 'USER [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-web-domains-alias b/bin/v-list-web-domains-alias index 81a886664..977bab93c 100755 --- a/bin/v-list-web-domains-alias +++ b/bin/v-list-web-domains-alias @@ -1,54 +1,54 @@ -#!/bin/bash -# info: list web domains and alias key -# options: user [format] -# -# The function for obtaining the list of aliases of all user's domains. This -# call was arranged for filling in the lack of information by applying -# v-list-web-domains call in the shell format. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user [format]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config -conf=$USER_DATA/web.conf - -# Defining fileds to select -fields="\$DOMAIN \$ALIAS" - -# Listing domains -case $format in - json) json_list ;; - plain) nohead=1; shell_list ;; - shell) shell_list;; - *) check_args '1' '0' 'user [format]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list web domains and alias key +# options: USER [FORMAT] +# +# The function for obtaining the list of aliases of all user's domains. This +# call was arranged for filling in the lack of information by applying +# v-list-web-domains call in the shell format. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config +conf=$USER_DATA/web.conf + +# Defining fileds to select +fields="\$DOMAIN \$ALIAS" + +# Listing domains +case $format in + json) json_list ;; + plain) nohead=1; shell_list ;; + shell) shell_list;; + *) check_args '1' '0' 'USER [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-web-domains-elog b/bin/v-list-web-domains-elog index 95f75051f..7487e38cc 100755 --- a/bin/v-list-web-domains-elog +++ b/bin/v-list-web-domains-elog @@ -1,54 +1,54 @@ -#!/bin/bash -# info: list web domains and elog key -# options: user [format] -# -# The function for obtaining the list of domains with parameter ErrorLog -# displayed. This call was arranged for filling in the lack of information by -# applying v-list-web-domains call in the shell format. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user [format]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config -conf=$USER_DATA/web.conf - -# Defining fileds to select -fields="\$DOMAIN \$ELOG \$SUSPENDED \$TIME \$DATE" - -# Listing domains -case $format in - json) json_list ;; - plain) nohead=1; shell_list ;; - shell) shell_list | column -t ;; - *) check_args '1' '0' 'user [format]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list web domains and elog key +# options: USER [FORMAT] +# +# The function for obtaining the list of domains with parameter ErrorLog +# displayed. This call was arranged for filling in the lack of information by +# applying v-list-web-domains call in the shell format. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config +conf=$USER_DATA/web.conf + +# Defining fileds to select +fields="\$DOMAIN \$ELOG \$SUSPENDED \$TIME \$DATE" + +# Listing domains +case $format in + json) json_list ;; + plain) nohead=1; shell_list ;; + shell) shell_list | column -t ;; + *) check_args '1' '0' 'USER [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-web-domains-nginx b/bin/v-list-web-domains-nginx index 5bcb30829..2b95ae5d4 100755 --- a/bin/v-list-web-domains-nginx +++ b/bin/v-list-web-domains-nginx @@ -1,54 +1,54 @@ -#!/bin/bash -# info: list web domains and nginx key -# options: user [format] -# -# The function for obtaining the list of domains with nginx parameter -# displayed. This call was arranged for filling in the lack of information by -# applying v-list-web-domains call in the shell format. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user [format]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config -conf=$USER_DATA/web.conf - -# Defining fileds to select -fields="\$DOMAIN \$NGINX \$NGINX_EXT" - -# Listing domains -case $format in - json) json_list ;; - plain) nohead=1; shell_list ;; - shell) shell_list | column -t ;; - *) check_args '1' '0' 'user [format]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list web domains and nginx key +# options: USER [FORMAT] +# +# The function for obtaining the list of domains with nginx parameter +# displayed. This call was arranged for filling in the lack of information by +# applying v-list-web-domains call in the shell format. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config +conf=$USER_DATA/web.conf + +# Defining fileds to select +fields="\$DOMAIN \$NGINX \$NGINX_EXT" + +# Listing domains +case $format in + json) json_list ;; + plain) nohead=1; shell_list ;; + shell) shell_list | column -t ;; + *) check_args '1' '0' 'USER [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-web-domains-ssl b/bin/v-list-web-domains-ssl index 35c742004..6fc4bd093 100755 --- a/bin/v-list-web-domains-ssl +++ b/bin/v-list-web-domains-ssl @@ -1,54 +1,54 @@ -#!/bin/bash -# info: list web domains and alias key -# options: user [format] -# -# The function for obtaining the list of domains with SSL parameter displayed. -# This call was arranged for filling in the lack of information by applying -# v-list-web-domains call in the shell format. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user [format]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config -conf="$USER_DATA/web.conf" - -# Defining fileds to select -fields="\$DOMAIN \$IP \$TPL \$SSL \$SSL_HOME \$SUSPENDED" - -# Listing domains -case $format in - json) json_list ;; - plain) nohead=1; shell_list ;; - shell) shell_list | column -t ;; - *) check_args '1' "0" 'user [format]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list web domains and alias key +# options: USER [FORMAT] +# +# The function for obtaining the list of domains with SSL parameter displayed. +# This call was arranged for filling in the lack of information by applying +# v-list-web-domains call in the shell format. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config +conf="$USER_DATA/web.conf" + +# Defining fileds to select +fields="\$DOMAIN \$IP \$TPL \$SSL \$SSL_HOME \$SUSPENDED" + +# Listing domains +case $format in + json) json_list ;; + plain) nohead=1; shell_list ;; + shell) shell_list | column -t ;; + *) check_args '1' "0" 'USER [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-web-domains-stats b/bin/v-list-web-domains-stats index b0b890cae..369aef895 100755 --- a/bin/v-list-web-domains-stats +++ b/bin/v-list-web-domains-stats @@ -1,55 +1,55 @@ -#!/bin/bash -# info: list web domains and stats key -# options: user [format] -# -# The function for obtaining the list of domains with statistics parameter -# displayed, including authentication settings. This call was arranged for -# filling in the lack of information by applying v-list-web-domains call in -# the shell format. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user [format]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config -conf=$USER_DATA/web.conf - -# Defining fileds to select -fields="\$DOMAIN \$STATS \$STATS_AUTH \$SUSPENDED \$TIME \$DATE" - -# Listing domains -case $format in - json) json_list ;; - plain) nohead=1; shell_list ;; - shell) shell_list | column -t ;; - *) check_args '1' "0" 'user [format]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list web domains and stats key +# options: USER [FORMAT] +# +# The function for obtaining the list of domains with statistics parameter +# displayed, including authentication settings. This call was arranged for +# filling in the lack of information by applying v-list-web-domains call in +# the shell format. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config +conf=$USER_DATA/web.conf + +# Defining fileds to select +fields="\$DOMAIN \$STATS \$STATS_AUTH \$SUSPENDED \$TIME \$DATE" + +# Listing domains +case $format in + json) json_list ;; + plain) nohead=1; shell_list ;; + shell) shell_list | column -t ;; + *) check_args '1' "0" 'USER [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-web-stats b/bin/v-list-web-stats index 086dcc8fc..88499eece 100755 --- a/bin/v-list-web-stats +++ b/bin/v-list-web-stats @@ -1,66 +1,66 @@ -#!/bin/bash -# info: list web statistics -# options: [format] -# -# The function for obtaining the list of web statistics analyzer. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# Json function -json_list_st() { - stats=$(echo "${STATS_SYSTEM//,/ } none") - st_counter=$(echo "$stats" | wc -w) - i=1 - echo '[' - for st in $stats; do - if [ "$i" -lt "$st_counter" ]; then - echo -e "\t\"$st\"," - else - echo -e "\t\"$st\"" - fi - (( ++i)) - done - echo "]" -} - -# Shell function -shell_list_st() { - stats=$(echo "none ${STATS_SYSTEM//,/ }") - if [ -z "$nohead" ]; then - echo "STATS" - echo "----------" - fi - for st in $stats; do - echo "$st" - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing domains -case $format in - json) json_list_st ;; - plain) nohead=1; shell_list_st ;; - shell) shell_list_st ;; - *) check_args '1' '0' '[format]' ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list web statistics +# options: [FORMAT] +# +# The function for obtaining the list of web statistics analyzer. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +format=${1-shell} + +# Includes +source $VESTA/func/main.sh +source $VESTA/conf/vesta.conf + +# Json function +json_list_st() { + stats=$(echo "${STATS_SYSTEM//,/ } none") + st_counter=$(echo "$stats" | wc -w) + i=1 + echo '[' + for st in $stats; do + if [ "$i" -lt "$st_counter" ]; then + echo -e "\t\"$st\"," + else + echo -e "\t\"$st\"" + fi + (( ++i)) + done + echo "]" +} + +# Shell function +shell_list_st() { + stats=$(echo "none ${STATS_SYSTEM//,/ }") + if [ -z "$nohead" ]; then + echo "STATS" + echo "----------" + fi + for st in $stats; do + echo "$st" + done +} + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Listing domains +case $format in + json) json_list_st ;; + plain) nohead=1; shell_list_st ;; + shell) shell_list_st ;; + *) check_args '1' '0' '[FORMAT]' ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-web-templates b/bin/v-list-web-templates index f3009dc34..9004ca9ae 100755 --- a/bin/v-list-web-templates +++ b/bin/v-list-web-templates @@ -1,68 +1,68 @@ -#!/bin/bash -# info: list web templates -# options: user [format] -# -# The function for obtaining the list of apache templates available to a user. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_wtpl() { - templates=$(ls -t $WEBTPL |grep 'apache' |grep '\.tpl' |cut -f 2 -d '_'\ - |cut -f 1 -d '.') - t_counter=$(echo "$templates" | wc -w) - i=1 - echo '[' - for template in $templates; do - if [ "$i" -lt "$t_counter" ]; then - echo -e "\t\"$template\"," - else - echo -e "\t\"$template\"" - fi - (( ++i)) - done - echo "]" -} - -# Shell function -shell_list_wtpl() { - templates=$(ls -t $WEBTPL |grep 'apache' |grep '\.tpl' |cut -f 2 -d '_'\ - |cut -f 1 -d '.') - if [ -z "$nohead" ]; then - echo "Templates" - echo "----------" - fi - for template in $templates; do - echo "$template" - done -} - - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing domains -case $format in - json) json_list_wtpl ;; - plain) nohead=1; shell_list_wtpl ;; - shell) shell_list_wtpl ;; - *) check_args '1' '0' '[format]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list web templates +# options: USER [FORMAT] +# +# The function for obtaining the list of apache templates available to a user. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +format=${1-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_wtpl() { + templates=$(ls -t $WEBTPL |grep 'apache' |grep '\.tpl' |cut -f 2 -d '_'\ + |cut -f 1 -d '.') + t_counter=$(echo "$templates" | wc -w) + i=1 + echo '[' + for template in $templates; do + if [ "$i" -lt "$t_counter" ]; then + echo -e "\t\"$template\"," + else + echo -e "\t\"$template\"" + fi + (( ++i)) + done + echo "]" +} + +# Shell function +shell_list_wtpl() { + templates=$(ls -t $WEBTPL |grep 'apache' |grep '\.tpl' |cut -f 2 -d '_'\ + |cut -f 1 -d '.') + if [ -z "$nohead" ]; then + echo "Templates" + echo "----------" + fi + for template in $templates; do + echo "$template" + done +} + + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Listing domains +case $format in + json) json_list_wtpl ;; + plain) nohead=1; shell_list_wtpl ;; + shell) shell_list_wtpl ;; + *) check_args '1' '0' '[FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-web-templates-nginx b/bin/v-list-web-templates-nginx index aa4993ddf..73d13cea1 100755 --- a/bin/v-list-web-templates-nginx +++ b/bin/v-list-web-templates-nginx @@ -1,67 +1,67 @@ -#!/bin/bash -# info: listing nginx templates -# options: [format] -# -# The function for obtaining the list of nginx templates available to a user. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_wtpl() { - templates=$(ls -t $WEBTPL |grep 'nginx' |grep '\.tpl' |cut -f 2 -d '_'\ - |cut -f 1 -d '.') - t_counter=$(echo "$templates" | wc -w) - i=1 - echo '[' - for template in $templates; do - if [ "$i" -lt "$t_counter" ]; then - echo -e "\t\"$template\"," - else - echo -e "\t\"$template\"" - fi - (( ++i)) - done - echo "]" - } - -# Shell function -shell_list_wtpl() { - templates=$(ls -t $WEBTPL |grep 'nginx' |grep '\.tpl' |cut -f 2 -d '_'\ - |cut -f 1 -d '.') - if [ -z "$nohead" ]; then - echo "Templates" - echo "----------" - fi - for template in $templates; do - echo "$template" - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing domains -case $format in - json) json_list_wtpl ;; - plain) nohead=1; shell_list_wtpl ;; - shell) shell_list_wtpl ;; - *) check_args '1' '0' '[format]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: listing nginx templates +# options: [FORMAT] +# +# The function for obtaining the list of nginx templates available to a user. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +format=${1-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_wtpl() { + templates=$(ls -t $WEBTPL |grep 'nginx' |grep '\.tpl' |cut -f 2 -d '_'\ + |cut -f 1 -d '.') + t_counter=$(echo "$templates" | wc -w) + i=1 + echo '[' + for template in $templates; do + if [ "$i" -lt "$t_counter" ]; then + echo -e "\t\"$template\"," + else + echo -e "\t\"$template\"" + fi + (( ++i)) + done + echo "]" + } + +# Shell function +shell_list_wtpl() { + templates=$(ls -t $WEBTPL |grep 'nginx' |grep '\.tpl' |cut -f 2 -d '_'\ + |cut -f 1 -d '.') + if [ -z "$nohead" ]; then + echo "Templates" + echo "----------" + fi + for template in $templates; do + echo "$template" + done +} + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Listing domains +case $format in + json) json_list_wtpl ;; + plain) nohead=1; shell_list_wtpl ;; + shell) shell_list_wtpl ;; + *) check_args '1' '0' '[FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-rebuild-cron-jobs b/bin/v-rebuild-cron-jobs index 84f5fa6be..52f412bd2 100755 --- a/bin/v-rebuild-cron-jobs +++ b/bin/v-rebuild-cron-jobs @@ -1,51 +1,51 @@ -#!/bin/bash -# info: rebuild cron jobs -# options: user [restart] -# -# The function rebuilds system cron config file for specified user. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -restart=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user [restart]' -validate_format 'user' -is_system_enabled "$CRON_SYSTEM" -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Rebuild cron jobs -sync_cron_jobs - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart crond -if [ "$restart" != 'no' ]; then - $BIN/v-restart-cron "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: rebuild cron jobs +# options: USER [RESTART] +# +# The function rebuilds system cron config file for specified user. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +restart=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [RESTART]' +validate_format 'user' +is_system_enabled "$CRON_SYSTEM" +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Rebuild cron jobs +sync_cron_jobs + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart crond +if [ "$restart" != 'no' ]; then + $BIN/v-restart-cron "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-rebuild-databases b/bin/v-rebuild-databases index 2052fa5c4..f34f27dcd 100755 --- a/bin/v-rebuild-databases +++ b/bin/v-rebuild-databases @@ -1,53 +1,53 @@ -#!/bin/bash -# info: rebuild databases -# options: user -# -# The function for rebuilding of all databases of a single user. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/db.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user' -validate_format 'user' -is_system_enabled "$DB_SYSTEM" -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting rebuild loop -for database in $(search_objects 'db' 'SUSPENDED' "no" 'DB'); do - get_database_values - # Switching on db type - case $TYPE in - mysql) rebuild_mysql_database ;; - pgsql) rebuild_pgsql_database ;; - esac -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: rebuild databases +# options: USER +# +# The function for rebuilding of all databases of a single user. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/db.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_system_enabled "$DB_SYSTEM" +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting rebuild loop +for database in $(search_objects 'db' 'SUSPENDED' "no" 'DB'); do + get_database_values + # Switching on db type + case $TYPE in + mysql) rebuild_mysql_database ;; + pgsql) rebuild_pgsql_database ;; + esac +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-rebuild-dns-domains b/bin/v-rebuild-dns-domains index 1f4892167..b15200c9f 100755 --- a/bin/v-rebuild-dns-domains +++ b/bin/v-rebuild-dns-domains @@ -1,128 +1,128 @@ -#!/bin/bash -# info: rebuild dns domains -# options: user [restart] -# -# The function rebuilds BIND configuration files for all dns domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -restart=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user [restart]' -validate_format 'user' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -user_domains=0 -user_records=0 -suspended_dns=0 - -# Checking dns folder -if [ ! -d "$USER_DATA/dns" ]; then - rm -f $USER_DATA/dns - mkdir $USER_DATA/dns -fi - -# Defining config and fie -conf="$USER_DATA/dns.conf" - - -# Defining user name servers -ns=$(get_user_value '$NS') -i=1 -for nameserver in ${ns//,/ };do - eval ns$i="$nameserver" - i=$((i + 1)) -done - -# Starting loop -for domain in $(search_objects 'dns' 'DOMAIN' "*" 'DOMAIN'); do - # Defining variables - get_domain_values 'dns' - domain_idn=$(idn -t --quiet -a "$domain") - - # Checking zone file - if [ ! -e "$USER_DATA/dns/$domain.conf" ]; then - cat $DNSTPL/$TPL.tpl |\ - sed -e "s/%ip%/$IP/g" \ - -e "s/%domain_idn%/$domain_idn/g" \ - -e "s/%domain%/$domain/g" \ - -e "s/%ns1%/$ns1/g" \ - -e "s/%ns2%/$ns2/g" \ - -e "s/%ns3%/$ns3/g" \ - -e "s/%ns4%/$ns4/g" \ - -e "s/%time%/$TIME/g" \ - -e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain.conf - fi - - # Sorting records - sort_dns_records - - # Updating zone - update_domain_zone - - # Set file permissions - chmod 640 $HOMEDIR/$user/conf/dns/$domain.db - chown root:named $HOMEDIR/$user/conf/dns/$domain.db - - # Bind config check - nconf='/etc/named.conf' - if [ "$SUSPENDED" = 'yes' ]; then - rm_string=$(grep -n /etc/namedb/$domain.db $nconf | cut -d : -f 1) - if [ ! -z "$rm_string" ]; then - sed -i "$rm_string d" $nconf - fi - suspended_dns=$((suspended_dns + 1)) - else - if [ -z "$(grep /$domain.db $nconf)" ]; then - named="zone \"$domain_idn\" {type master; file" - named="$named \"$HOMEDIR/$user/conf/dns/$domain.db\";};" - echo "$named" >> /etc/named.conf - fi - fi - user_domains=$((user_domains + 1)) - records=$(wc -l $USER_DATA/dns/$domain.conf | cut -f 1 -d ' ') - user_records=$((user_records + records)) - update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating counters -update_user_value "$user" '$U_DNS_DOMAINS' "$user_domains" -update_user_value "$user" '$U_DNS_RECORDS' "$user_records" -update_user_value "$user" '$SUSPENDED_DNS' "$suspended_dns" - -# Restart named -if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: rebuild dns domains +# options: USER [RESTART] +# +# The function rebuilds BIND configuration files for all dns domains. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +restart=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [RESTART]' +validate_format 'user' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +user_domains=0 +user_records=0 +suspended_dns=0 + +# Checking dns folder +if [ ! -d "$USER_DATA/dns" ]; then + rm -f $USER_DATA/dns + mkdir $USER_DATA/dns +fi + +# Defining config and fie +conf="$USER_DATA/dns.conf" + + +# Defining user name servers +ns=$(get_user_value '$NS') +i=1 +for nameserver in ${ns//,/ };do + eval ns$i="$nameserver" + i=$((i + 1)) +done + +# Starting loop +for domain in $(search_objects 'dns' 'DOMAIN' "*" 'DOMAIN'); do + # Defining variables + get_domain_values 'dns' + domain_idn=$(idn -t --quiet -a "$domain") + + # Checking zone file + if [ ! -e "$USER_DATA/dns/$domain.conf" ]; then + cat $DNSTPL/$TPL.tpl |\ + sed -e "s/%ip%/$IP/g" \ + -e "s/%domain_idn%/$domain_idn/g" \ + -e "s/%domain%/$domain/g" \ + -e "s/%ns1%/$ns1/g" \ + -e "s/%ns2%/$ns2/g" \ + -e "s/%ns3%/$ns3/g" \ + -e "s/%ns4%/$ns4/g" \ + -e "s/%time%/$TIME/g" \ + -e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain.conf + fi + + # Sorting records + sort_dns_records + + # Updating zone + update_domain_zone + + # Set file permissions + chmod 640 $HOMEDIR/$user/conf/dns/$domain.db + chown root:named $HOMEDIR/$user/conf/dns/$domain.db + + # Bind config check + nconf='/etc/named.conf' + if [ "$SUSPENDED" = 'yes' ]; then + rm_string=$(grep -n /etc/namedb/$domain.db $nconf | cut -d : -f 1) + if [ ! -z "$rm_string" ]; then + sed -i "$rm_string d" $nconf + fi + suspended_dns=$((suspended_dns + 1)) + else + if [ -z "$(grep /$domain.db $nconf)" ]; then + named="zone \"$domain_idn\" {type master; file" + named="$named \"$HOMEDIR/$user/conf/dns/$domain.db\";};" + echo "$named" >> /etc/named.conf + fi + fi + user_domains=$((user_domains + 1)) + records=$(wc -l $USER_DATA/dns/$domain.conf | cut -f 1 -d ' ') + user_records=$((user_records + records)) + update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records" +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Updating counters +update_user_value "$user" '$U_DNS_DOMAINS' "$user_domains" +update_user_value "$user" '$U_DNS_RECORDS' "$user_records" +update_user_value "$user" '$SUSPENDED_DNS' "$suspended_dns" + +# Restart named +if [ "$restart" != 'no' ]; then + $BIN/v-restart-dns "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-rebuild-mail-domains b/bin/v-rebuild-mail-domains index 2771f097c..8855bd800 100755 --- a/bin/v-rebuild-mail-domains +++ b/bin/v-rebuild-mail-domains @@ -1,184 +1,184 @@ -#!/bin/bash -# info: rebuild mail domains -# options: user -# -# The function rebuilds EXIM configuration files for all mail domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user' -validate_format 'user' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Reset counters -U_MAIL_DOMAINS=0 -U_MAIL_DKMI=0 -U_MAIL_ACCOUNTS=0 -SUSPENDED_MAIL=0 -U_DISK_MAIL=0 - -# Checking mail folder -if [ ! -d "$USER_DATA/mail" ]; then - rm -f $USER_DATA/mail - mkdir $USER_DATA/mail -fi - -# Starting loop -for domain in $(search_objects 'mail' 'SUSPENDED' "*" 'DOMAIN'); do - # Defining variables - get_domain_values 'mail' - - # Rebuilding config structure - rm -f /etc/exim/domains/$domain - mkdir -p $HOMEDIR/$user/conf/mail/$domain - ln -s $HOMEDIR/$user/conf/mail/$domain /etc/exim/domains/ - rm -f $HOMEDIR/$user/conf/mail/$domain/aliases - rm -f $HOMEDIR/$user/conf/mail/$domain/protection - rm -f $HOMEDIR/$user/conf/mail/$domain/passwd - touch $HOMEDIR/$user/conf/mail/$domain/aliases - touch $HOMEDIR/$user/conf/mail/$domain/protection - touch $HOMEDIR/$user/conf/mail/$domain/passwd - chown -R dovecot:mail $HOMEDIR/$user/conf/mail/$domain - chown -R dovecot:mail /etc/exim/domains/$domain - chmod 770 $HOMEDIR/$user/conf/mail/$domain - chmod 660 $HOMEDIR/$user/conf/mail/$domain* - chmod 660 /etc/exim/domains/$domain - - # Adding antispam protection - if [ "$ANTISPAM" = 'yes' ]; then - echo 'antispam' >> $HOMEDIR/$user/conf/mail/$domain/protection - fi - - # Adding antivirus protection - if [ "$ANTIVIRUS" = 'yes' ]; then - echo 'antivirus' >> $HOMEDIR/$user/conf/mail/$domain/protection - fi - - # Adding dkim - if [ "$DKIM" = 'yes' ]; then - U_MAIL_DKMI=$((U_MAIL_DKMI + 1)) - pem="$USER_DATA/mail/$domain.pem" - pub="$USER_DATA/mail/$domain.pub" - openssl genrsa -out $pem 512 &>/dev/null - openssl rsa -pubout -in $pem -out $pub &>/dev/null - chmod 660 $USER_DATA/mail/$domain.* - - cp $pem $HOMEDIR/$user/conf/mail/$domain/dkim.pem - chown root:mail $HOMEDIR/$user/conf/mail/$domain/dkim.pem - chmod 660 $HOMEDIR/$user/conf/mail/$domain/dkim.pem - - # Deleting old dkim records - records=$($BIN/v-list-dns-domain-records $user $domain plain) - dkim_records=$(echo "$records" |grep -w '_domainkey'|cut -f 1 -d ' ') - for id in $dkim_records; do - $BIN/v-delete-dns-domain-record $user $domain $id - done - - # Adding dkim dns records - check_dns_domain=$(is_object_valid 'dns' 'DOMAIN' "$domain") - if [ "$?" -eq 0 ]; then - p=$(cat $pub|grep -v ' KEY---'|tr -d '\n') - record='_domainkey' - policy="\"t=y; o=~;\"" - $BIN/v-add-dns-domain-record $user $domain $record TXT "$policy" - - record='mail._domainkey' - slct="\"k=rsa\; p=$p\"" - $BIN/v-add-dns-domain-record $user $domain $record TXT "$slct" - fi - fi - - # Removing symbolic link - if [ "$SUSPENDED" = 'yes' ]; then - SUSPENDED_MAIL=$((SUSPENDED_MAIL +1)) - rm -f /etc/exim/domains/$domain - fi - - if [ ! -e $HOMEDIR/$user/mail/$domain ]; then - mkdir $HOMEDIR/$user/mail/$domain - fi - chown $user:mail $HOMEDIR/$user/mail/$domain - chmod 770 $HOMEDIR/$user/mail/$domain - - dom_aliases=$HOMEDIR/$user/conf/mail/$domain/aliases - if [ ! -z "$CATCHALL" ]; then - echo "*@$domain:$CATCHALL" >> $dom_aliases - fi - - # Rebuild domain accounts - accs=0 - dom_diks=0 - if [ -e "$USER_DATA/mail/$domain.conf" ]; then - accounts=$(search_objects "mail/$domain" 'SUSPENDED' "no" 'ACCOUNT') - else - accounts='' - fi - - for account in $accounts; do - (( ++accs)) - dom_diks=$((dom_diks + U_DISK)) - object=$(grep "ACCOUNT='$account'" $USER_DATA/mail/$domain.conf) - eval "$object" - if [ "$SUSPENDED" = 'yes' ]; then - MD5='SUSPENDED' - fi - - str="$account:$MD5:$user:mail::$HOMEDIR/$user:$QUOTA" - echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd - - for malias in ${ALIAS//,/ }; do - echo "$malias@$domain:$account@$domain" >> $dom_aliases - done - if [ ! -z "$FWD" ]; then - echo "$account@$domain:$FWD" >> $dom_aliases - fi - - done - update_object_value 'mail' 'DOMAIN' "$domain" '$ACCOUNTS' "$accs" - update_object_value 'mail' 'DOMAIN' "$domain" '$U_DISK' "$dom_diks" - U_MAIL_ACCOUNTS=$((U_MAIL_ACCOUNTS + accs)) - U_DISK_MAIL=$((U_DISK_MAIL + dom_diks)) - U_MAIL_DOMAINS=$((U_MAIL_DOMAINS + 1)) -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating counters -update_user_value "$user" '$U_MAIL_DOMAINS' "$U_MAIL_DOMAINS" -update_user_value "$user" '$U_MAIL_DKMI' "$U_MAIL_DKMI" -update_user_value "$user" '$U_MAIL_ACCOUNTS' "$U_MAIL_ACCOUNTS" -update_user_value "$user" '$SUSPENDED_MAIL' "$SUSPENDED_MAIL" -update_user_value "$user" '$U_DISK_MAIL' "$U_DISK_MAIL" - -recalc_user_disk_usage - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: rebuild mail domains +# options: USER +# +# The function rebuilds EXIM configuration files for all mail domains. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Reset counters +U_MAIL_DOMAINS=0 +U_MAIL_DKMI=0 +U_MAIL_ACCOUNTS=0 +SUSPENDED_MAIL=0 +U_DISK_MAIL=0 + +# Checking mail folder +if [ ! -d "$USER_DATA/mail" ]; then + rm -f $USER_DATA/mail + mkdir $USER_DATA/mail +fi + +# Starting loop +for domain in $(search_objects 'mail' 'SUSPENDED' "*" 'DOMAIN'); do + # Defining variables + get_domain_values 'mail' + + # Rebuilding config structure + rm -f /etc/exim/domains/$domain + mkdir -p $HOMEDIR/$user/conf/mail/$domain + ln -s $HOMEDIR/$user/conf/mail/$domain /etc/exim/domains/ + rm -f $HOMEDIR/$user/conf/mail/$domain/aliases + rm -f $HOMEDIR/$user/conf/mail/$domain/protection + rm -f $HOMEDIR/$user/conf/mail/$domain/passwd + touch $HOMEDIR/$user/conf/mail/$domain/aliases + touch $HOMEDIR/$user/conf/mail/$domain/protection + touch $HOMEDIR/$user/conf/mail/$domain/passwd + chown -R dovecot:mail $HOMEDIR/$user/conf/mail/$domain + chown -R dovecot:mail /etc/exim/domains/$domain + chmod 770 $HOMEDIR/$user/conf/mail/$domain + chmod 660 $HOMEDIR/$user/conf/mail/$domain* + chmod 660 /etc/exim/domains/$domain + + # Adding antispam protection + if [ "$ANTISPAM" = 'yes' ]; then + echo 'antispam' >> $HOMEDIR/$user/conf/mail/$domain/protection + fi + + # Adding antivirus protection + if [ "$ANTIVIRUS" = 'yes' ]; then + echo 'antivirus' >> $HOMEDIR/$user/conf/mail/$domain/protection + fi + + # Adding dkim + if [ "$DKIM" = 'yes' ]; then + U_MAIL_DKMI=$((U_MAIL_DKMI + 1)) + pem="$USER_DATA/mail/$domain.pem" + pub="$USER_DATA/mail/$domain.pub" + openssl genrsa -out $pem 512 &>/dev/null + openssl rsa -pubout -in $pem -out $pub &>/dev/null + chmod 660 $USER_DATA/mail/$domain.* + + cp $pem $HOMEDIR/$user/conf/mail/$domain/dkim.pem + chown root:mail $HOMEDIR/$user/conf/mail/$domain/dkim.pem + chmod 660 $HOMEDIR/$user/conf/mail/$domain/dkim.pem + + # Deleting old dkim records + records=$($BIN/v-list-dns-domain-records $user $domain plain) + dkim_records=$(echo "$records" |grep -w '_domainkey'|cut -f 1 -d ' ') + for id in $dkim_records; do + $BIN/v-delete-dns-domain-record $user $domain $id + done + + # Adding dkim dns records + check_dns_domain=$(is_object_valid 'dns' 'DOMAIN' "$domain") + if [ "$?" -eq 0 ]; then + p=$(cat $pub|grep -v ' KEY---'|tr -d '\n') + record='_domainkey' + policy="\"t=y; o=~;\"" + $BIN/v-add-dns-domain-record $user $domain $record TXT "$policy" + + record='mail._domainkey' + slct="\"k=rsa\; p=$p\"" + $BIN/v-add-dns-domain-record $user $domain $record TXT "$slct" + fi + fi + + # Removing symbolic link + if [ "$SUSPENDED" = 'yes' ]; then + SUSPENDED_MAIL=$((SUSPENDED_MAIL +1)) + rm -f /etc/exim/domains/$domain + fi + + if [ ! -e $HOMEDIR/$user/mail/$domain ]; then + mkdir $HOMEDIR/$user/mail/$domain + fi + chown $user:mail $HOMEDIR/$user/mail/$domain + chmod 770 $HOMEDIR/$user/mail/$domain + + dom_aliases=$HOMEDIR/$user/conf/mail/$domain/aliases + if [ ! -z "$CATCHALL" ]; then + echo "*@$domain:$CATCHALL" >> $dom_aliases + fi + + # Rebuild domain accounts + accs=0 + dom_diks=0 + if [ -e "$USER_DATA/mail/$domain.conf" ]; then + accounts=$(search_objects "mail/$domain" 'SUSPENDED' "no" 'ACCOUNT') + else + accounts='' + fi + + for account in $accounts; do + (( ++accs)) + dom_diks=$((dom_diks + U_DISK)) + object=$(grep "ACCOUNT='$account'" $USER_DATA/mail/$domain.conf) + eval "$object" + if [ "$SUSPENDED" = 'yes' ]; then + MD5='SUSPENDED' + fi + + str="$account:$MD5:$user:mail::$HOMEDIR/$user:$QUOTA" + echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd + + for malias in ${ALIAS//,/ }; do + echo "$malias@$domain:$account@$domain" >> $dom_aliases + done + if [ ! -z "$FWD" ]; then + echo "$account@$domain:$FWD" >> $dom_aliases + fi + + done + update_object_value 'mail' 'DOMAIN' "$domain" '$ACCOUNTS' "$accs" + update_object_value 'mail' 'DOMAIN' "$domain" '$U_DISK' "$dom_diks" + U_MAIL_ACCOUNTS=$((U_MAIL_ACCOUNTS + accs)) + U_DISK_MAIL=$((U_DISK_MAIL + dom_diks)) + U_MAIL_DOMAINS=$((U_MAIL_DOMAINS + 1)) +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Updating counters +update_user_value "$user" '$U_MAIL_DOMAINS' "$U_MAIL_DOMAINS" +update_user_value "$user" '$U_MAIL_DKMI' "$U_MAIL_DKMI" +update_user_value "$user" '$U_MAIL_ACCOUNTS' "$U_MAIL_ACCOUNTS" +update_user_value "$user" '$SUSPENDED_MAIL' "$SUSPENDED_MAIL" +update_user_value "$user" '$U_DISK_MAIL' "$U_DISK_MAIL" + +recalc_user_disk_usage + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-rebuild-user b/bin/v-rebuild-user index 356c9dadf..3635fd702 100755 --- a/bin/v-rebuild-user +++ b/bin/v-rebuild-user @@ -1,157 +1,157 @@ -#!/bin/bash -# info: rebuild system user -# options: user [restart] -# -# The function rebuilds system user account. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -restart=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user [restart]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# -export PATH=$PATH:/usr/sbin - -# Get user variables -source $USER_DATA/user.conf - -# Rebuild user -shell=$(chsh --list-shells | grep -w "$SHELL" |head -n1) -adduser "$user" -s "$shell" -c "$CONTACT" -m -d "$HOMEDIR/$user" &>/dev/null - -# Update password -shadow='/etc/shadow' -shdw=$(grep ^$user: $shadow) -shdw3=$(echo "$shdw" | cut -f3 -d :) -shdw4=$(echo "$shdw" | cut -f4 -d :) -shdw5=$(echo "$shdw" | cut -f5 -d :) -shdw6=$(echo "$shdw" | cut -f6 -d :) -shdw7=$(echo "$shdw" | cut -f7 -d :) -shdw8=$(echo "$shdw" | cut -f8 -d :) -shdw9=$(echo "$shdw" | cut -f9 -d :) -chmod u+w $shadow -sed -i "/^$user:*/d" $shadow -echo "$user:$MD5:$shdw3:$shdw4:$shdw5:$shdw6:$shdw7:$shdw8:$shdw9" >> $shadow -chmod u-w $shadow - -# Building directory tree -mkdir -p $HOMEDIR/$user/conf -chmod a+x $HOMEDIR/$user -chmod a+x $HOMEDIR/$user/conf -chown $user:$user $HOMEDIR/$user -chown $user:$user $HOMEDIR/$user/conf - -if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then - mkdir -p $HOMEDIR/$user/conf/web - mkdir -p $HOMEDIR/$user/web - mkdir -p $HOMEDIR/$user/tmp - chmod 751 $HOMEDIR/$user/conf/web - chmod 751 $HOMEDIR/$user/web - chmod 771 $HOMEDIR/$user/tmp - chown $user:$user $HOMEDIR/$user/web - $BIN/v-rebuild-web-domains $user $restart -fi - -if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then - mkdir -p $HOMEDIR/$user/conf/dns - chmod 751 $HOMEDIR/$user/conf/dns - $BIN/v-rebuild-dns-domains $user $restart -fi - -if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then - mkdir -p $HOMEDIR/$user/conf/mail - mkdir -p $HOMEDIR/$user/mail - chmod 751 $HOMEDIR/$user/mail - chmod 751 $HOMEDIR/$user/conf/mail - $BIN/v-rebuild-mail-domains $user -fi - - -if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then - $BIN/v-rebuild-databases $user -fi - -if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then - $BIN/v-rebuild-cron-jobs $user $restart -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Creating configuration files and pipes -chmod 770 $USER_DATA -touch $USER_DATA/backup.conf -chmod 660 $USER_DATA/backup.conf -touch $USER_DATA/history.log -chmod 660 $USER_DATA/history.log -touch $USER_DATA/stats.log -chmod 660 $USER_DATA/stats.log - -sed -i "/ $user$/d" $VESTA/data/queue/disk.pipe -echo "v-update-user-disk $user" >> $VESTA/data/queue/disk.pipe - -if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then - mkdir -p $USER_DATA/ssl - chmod 770 $USER_DATA/ssl - touch $USER_DATA/web.conf - chmod 660 $USER_DATA/web.conf - if [ "$(grep -w $user $VESTA/data/queue/traffic.pipe)" ]; then - echo "$BIN/v-update-web-domains-traff $user" \ - >> $VESTA/data/queue/traffic.pipe - fi - echo "v-update-web-domains-disk $user" >> $VESTA/data/queue/disk.pipe -fi - -if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then - mkdir -p $USER_DATA/dns - chmod 770 $USER_DATA/dns - touch $USER_DATA/dns.conf - chmod 660 $USER_DATA/dns.conf -fi - -if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then - mkdir -p $USER_DATA/mail - chmod 770 $USER_DATA/mail - touch $USER_DATA/mail.conf - chmod 660 $USER_DATA/mail.conf - echo "v-update-mail-domains-disk $user" >> $VESTA/data/queue/disk.pipe -fi - -if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then - touch $USER_DATA/db.conf - chmod 660 $USER_DATA/db.conf - echo "v_update_datbases_disk $user" >> $VESTA/data/queue/disk.pipe -fi - -if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then - touch $USER_DATA/cron.conf - chmod 660 $USER_DATA/cron.conf -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: rebuild system user +# options: USER [RESTART] +# +# The function rebuilds system user account. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +restart=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [RESTART]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# +export PATH=$PATH:/usr/sbin + +# Get user variables +source $USER_DATA/user.conf + +# Rebuild user +shell=$(chsh --list-shells | grep -w "$SHELL" |head -n1) +adduser "$user" -s "$shell" -c "$CONTACT" -m -d "$HOMEDIR/$user" &>/dev/null + +# Update password +shadow='/etc/shadow' +shdw=$(grep ^$user: $shadow) +shdw3=$(echo "$shdw" | cut -f3 -d :) +shdw4=$(echo "$shdw" | cut -f4 -d :) +shdw5=$(echo "$shdw" | cut -f5 -d :) +shdw6=$(echo "$shdw" | cut -f6 -d :) +shdw7=$(echo "$shdw" | cut -f7 -d :) +shdw8=$(echo "$shdw" | cut -f8 -d :) +shdw9=$(echo "$shdw" | cut -f9 -d :) +chmod u+w $shadow +sed -i "/^$user:*/d" $shadow +echo "$user:$MD5:$shdw3:$shdw4:$shdw5:$shdw6:$shdw7:$shdw8:$shdw9" >> $shadow +chmod u-w $shadow + +# Building directory tree +mkdir -p $HOMEDIR/$user/conf +chmod a+x $HOMEDIR/$user +chmod a+x $HOMEDIR/$user/conf +chown $user:$user $HOMEDIR/$user +chown $user:$user $HOMEDIR/$user/conf + +if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then + mkdir -p $HOMEDIR/$user/conf/web + mkdir -p $HOMEDIR/$user/web + mkdir -p $HOMEDIR/$user/tmp + chmod 751 $HOMEDIR/$user/conf/web + chmod 751 $HOMEDIR/$user/web + chmod 771 $HOMEDIR/$user/tmp + chown $user:$user $HOMEDIR/$user/web + $BIN/v-rebuild-web-domains $user $restart +fi + +if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then + mkdir -p $HOMEDIR/$user/conf/dns + chmod 751 $HOMEDIR/$user/conf/dns + $BIN/v-rebuild-dns-domains $user $restart +fi + +if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then + mkdir -p $HOMEDIR/$user/conf/mail + mkdir -p $HOMEDIR/$user/mail + chmod 751 $HOMEDIR/$user/mail + chmod 751 $HOMEDIR/$user/conf/mail + $BIN/v-rebuild-mail-domains $user +fi + + +if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then + $BIN/v-rebuild-databases $user +fi + +if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then + $BIN/v-rebuild-cron-jobs $user $restart +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Creating configuration files and pipes +chmod 770 $USER_DATA +touch $USER_DATA/backup.conf +chmod 660 $USER_DATA/backup.conf +touch $USER_DATA/history.log +chmod 660 $USER_DATA/history.log +touch $USER_DATA/stats.log +chmod 660 $USER_DATA/stats.log + +sed -i "/ $user$/d" $VESTA/data/queue/disk.pipe +echo "v-update-user-disk $user" >> $VESTA/data/queue/disk.pipe + +if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then + mkdir -p $USER_DATA/ssl + chmod 770 $USER_DATA/ssl + touch $USER_DATA/web.conf + chmod 660 $USER_DATA/web.conf + if [ "$(grep -w $user $VESTA/data/queue/traffic.pipe)" ]; then + echo "$BIN/v-update-web-domains-traff $user" \ + >> $VESTA/data/queue/traffic.pipe + fi + echo "v-update-web-domains-disk $user" >> $VESTA/data/queue/disk.pipe +fi + +if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then + mkdir -p $USER_DATA/dns + chmod 770 $USER_DATA/dns + touch $USER_DATA/dns.conf + chmod 660 $USER_DATA/dns.conf +fi + +if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then + mkdir -p $USER_DATA/mail + chmod 770 $USER_DATA/mail + touch $USER_DATA/mail.conf + chmod 660 $USER_DATA/mail.conf + echo "v-update-mail-domains-disk $user" >> $VESTA/data/queue/disk.pipe +fi + +if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then + touch $USER_DATA/db.conf + chmod 660 $USER_DATA/db.conf + echo "v_update_datbases_disk $user" >> $VESTA/data/queue/disk.pipe +fi + +if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then + touch $USER_DATA/cron.conf + chmod 660 $USER_DATA/cron.conf +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-rebuild-web-domains b/bin/v-rebuild-web-domains index 107c2621e..1571305ce 100755 --- a/bin/v-rebuild-web-domains +++ b/bin/v-rebuild-web-domains @@ -1,312 +1,312 @@ -#!/bin/bash -# info: rebuild dns domains -# options: user [restart] -# -# The function rebuilds BIND configuration files for all dns domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -restart=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/ip.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user [restart]' -validate_format 'user' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -user_domains=0 -user_ssl=0 -user_aliases=0 -suspended_web=0 - -# Clean up old config -rm -f $HOMEDIR/$user/conf/tmp_*.conf - -# Defining config -conf=$USER_DATA/web.conf -fields='$DOMAIN' -nohead=1 - -# Starting loop -for domain in $(shell_list) ; do - - # Rebuilding directories - mkdir -p $HOMEDIR/$user/web/$domain \ - $HOMEDIR/$user/web/$domain/public_html \ - $HOMEDIR/$user/web/$domain/public_shtml \ - $HOMEDIR/$user/web/$domain/document_errors \ - $HOMEDIR/$user/web/$domain/cgi-bin \ - $HOMEDIR/$user/web/$domain/private \ - $HOMEDIR/$user/web/$domain/stats \ - $HOMEDIR/$user/web/$domain/logs - if [ ! -e "$HOMEDIR/$user/web/$domain/logs/$domain.log" ]; then - ln -s /var/log/httpd/domains/$domain.error.log \ - $HOMEDIR/$user/web/$domain/logs/$domain.log - fi - if [ ! -e "$HOMEDIR/$user/web/$domain/logs/$domain.error.log" ]; then - ln -s /var/log/httpd/domains/$domain.error.log \ - $HOMEDIR/$user/web/$domain/logs/$domain.error.log - fi - if [ -e "$WEBTPL/skel/document_errors/" ]; then - cp -r $WEBTPL/skel/document_errors/ $HOMEDIR/$user/web/$domain/ - fi - - touch /var/log/httpd/domains/$domain.bytes \ - /var/log/httpd/domains/$domain.log \ - /var/log/httpd/domains/$domain.error.log - - chmod 551 $HOMEDIR/$user/web/$domain - chmod 771 $HOMEDIR/$user/web/$domain/private - chmod 771 $HOMEDIR/$user/web/$domain/cgi-bin - chmod 771 $HOMEDIR/$user/web/$domain/public_html - chmod 771 $HOMEDIR/$user/web/$domain/public_shtml - chmod 771 $HOMEDIR/$user/web/$domain/document_errors - chmod 551 $HOMEDIR/$user/web/$domain/stats - chmod 551 $HOMEDIR/$user/web/$domain/logs - chmod 640 /var/log/httpd/domains/$domain.* - - chown $user:$user $HOMEDIR/$user/web/$domain - chown $user:$user $HOMEDIR/$user/web/$domain/private - chown $user:$user $HOMEDIR/$user/web/$domain/cgi-bin - chown $user:$user $HOMEDIR/$user/web/$domain/public_html - chown $user:$user $HOMEDIR/$user/web/$domain/public_shtml - chown -R $user:$user $HOMEDIR/$user/web/$domain/document_errors - chown root:$user /var/log/httpd/domains/$domain.* - chown root:apache $conf - - # Parsing domain values - domain_idn=$(idn -t --quiet -a "$domain") - get_domain_values 'web' - - # Preparing domain values for the template substitution - upd_web_domain_values - - # Adding domain to the tmp_httpd.conf - tpl_file="$WEBTPL/apache_$TPL.tpl" - conf="$HOMEDIR/$user/conf/web/tmp_httpd.conf" - add_web_config - chown root:apache $conf - chmod 640 $conf - - # Running template trigger - if [ -x $WEBTPL/apache_$TPL.sh ]; then - $WEBTPL/apache_$TPL.sh $user $domain $ip $HOMEDIR $docroot - fi - - # Checking aliases - if [ ! -z "$ALIAS" ]; then - aliases=$(echo "$ALIAS"|tr ',' '\n'| wc -l) - user_aliases=$((user_aliases + aliases)) - fi - - # Checking stats - if [ ! -z "$STATS" ]; then - cat $WEBTPL/$STATS.tpl |\ - sed -e "s/%ip%/$ip/g" \ - -e "s/%web_port%/$WEB_PORT/g" \ - -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \ - -e "s/%proxy_port%/$PROXY_PORT/g" \ - -e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \ - -e "s/%domain_idn%/$domain_idn/g" \ - -e "s/%domain%/$domain/g" \ - -e "s/%user%/$user/g" \ - -e "s/%home%/${HOMEDIR////\/}/g" \ - -e "s/%alias%/${aliases//,/ }/g" \ - -e "s/%alias_idn%/${aliases_idn//,/ }/g" \ - > $HOMEDIR/$user/conf/web/$STATS.$domain.conf - - if [ "$STATS" == 'awstats' ]; then - if [ ! -e "/etc/awstats/$STATS.$domain.conf" ]; then - ln -s $HOMEDIR/$user/conf/web/$STATS.$domain.conf /etc/awstats/ - fi - fi - - webstats="$BIN/v-update-web-domain-stat $user $domain" - check_webstats=$(grep "$webstats" $VESTA/data/queue/webstats.pipe) - if [ -z "$check_webstats" ]; then - echo "$webstats" >> $VESTA/data/queue/webstats.pipe - fi - - if [ ! -z "$STATS_USER" ]; then - # Definining statistic dir - stats_dir="$HOMEDIR/$user/web/$domain/stats" - - # Adding htaccess file - echo "AuthUserFile $stats_dir/.htpasswd" > $stats_dir/.htaccess - echo "AuthName \"Web Statistics\"" >> $stats_dir/.htaccess - echo "AuthType Basic" >> $stats_dir/.htaccess - echo "Require valid-user" >> $stats_dir/.htaccess - - # Generating htaccess user and password - echo "$STATS_USER:$STATS_CRYPT" > $stats_dir/.htpasswd - fi - fi - - # Checking ssl - if [ "$SSL" = 'yes' ]; then - # Adding domain to the shttpd.conf - conf="$HOMEDIR/$user/conf/web/tmp_shttpd.conf" - tpl_file="$WEBTPL/apache_$TPL.stpl" - add_web_config - chown root:apache $conf - chmod 640 $conf - - cp -f $USER_DATA/ssl/$domain.crt \ - $HOMEDIR/$user/conf/web/ssl.$domain.crt - cp -f $USER_DATA/ssl/$domain.key \ - $HOMEDIR/$user/conf/web/ssl.$domain.key - cp -f $USER_DATA/ssl/$domain.pem \ - $HOMEDIR/$user/conf/web/ssl.$domain.pem - if [ -e "$USER_DATA/ssl/$domain.ca" ]; then - cp -f $USER_DATA/ssl/$domain.ca \ - $HOMEDIR/$user/conf/web/ssl.$domain.ca - fi - - # Running template trigger - if [ -x $WEBTPL/apache_$TPL.sh ]; then - $WEBTPL/apache_$TPL.sh $user $domain $ip $HOMEDIR $sdocroot - fi - - user_ssl=$((user_ssl + 1)) - ssl_change='yes' - fi - - # Checking nginx - if [ ! -z "$NGINX" ]; then - tpl_file="$WEBTPL/nginx_$NGINX.tpl" - conf="$HOMEDIR/$user/conf/web/tmp_nginx.conf" - add_web_config - chown root:nginx $conf - chmod 640 $conf - - if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web/tmp_snginx.conf" - add_web_config - chown root:nginx $conf - chmod 640 $conf - fi - ngix_change='yes' - fi - if [ "$SUSPENDED" = 'yes' ]; then - suspended_web=$((suspended_web + 1)) - fi - user_domains=$((user_domains + 1)) - - # Checking ftp - if [ ! -z "$FTP_USER" ]; then - if [ -z "$(grep ^$FTP_USER: /etc/passwd)" ]; then - /usr/sbin/adduser $FTP_USER -g $user -s /sbin/nologin -M \ - -d "$HOMEDIR/$user/web/$domain" > /dev/null 2>&1 - - shadow='/etc/shadow' - shdw=$(grep "^$FTP_USER:" $shadow) - shdw3=$(echo "$shdw" | cut -f3 -d :) - shdw4=$(echo "$shdw" | cut -f4 -d :) - shdw5=$(echo "$shdw" | cut -f5 -d :) - shdw6=$(echo "$shdw" | cut -f6 -d :) - shdw7=$(echo "$shdw" | cut -f7 -d :) - shdw8=$(echo "$shdw" | cut -f8 -d :) - shdw9=$(echo "$shdw" | cut -f9 -d :) - chmod u+w $shadow - sed -i "/^$FTP_USER:*/d" $shadow - shdw_str="$FTP_USER:$FTP_MD5:$shdw3:$shdw4:$shdw5:$shdw6" - shdw_str="$shdw_str:$shdw7:$shdw8:$shdw9" - echo "$shdw_str" >> $shadow - chmod u-w $shadow - fi - fi - -done - -# Renaming tmp config -tmp_conf="$HOMEDIR/$user/conf/web/tmp_httpd.conf" -conf="$HOMEDIR/$user/conf/web/httpd.conf" -if [ -e "$tmp_conf" ]; then - mv $tmp_conf $conf -fi - -# Checking include in main httpd.conf -main_conf='/etc/httpd/conf.d/vesta.conf' -main_conf_check=$(grep "$conf" $main_conf ) -if [ ! -z "$domain" ] && [ -z "$main_conf_check" ]; then - echo "Include $conf" >>$main_conf -fi - -# Checking ssl -if [ "$ssl_change" = 'yes' ]; then - tmp_conf="$HOMEDIR/$user/conf/web/tmp_shttpd.conf" - conf="$HOMEDIR/$user/conf/web/shttpd.conf" - mv $tmp_conf $conf - - # Checking include in main httpd.conf - main_conf_check=$(grep "$conf" $main_conf ) - if [ -z "$main_conf_check" ]; then - echo "Include $conf" >>$main_conf - fi -fi - -# Checking nginx -if [ "$ngix_change" = 'yes' ]; then - nginx_conf='/etc/nginx/conf.d/vesta_users.conf' - tmp_conf="$HOMEDIR/$user/conf/web/tmp_nginx.conf" - conf="$HOMEDIR/$user/conf/web/nginx.conf" - mv $tmp_conf $conf - - nginx_conf_check=$(grep "$conf" $nginx_conf ) - if [ -z "$nginx_conf_check" ]; then - echo "include $conf;" >>$nginx_conf - fi - - # Checking ssl for nginx - if [ "$ssl_change" = 'yes' ]; then - tmp_conf="$HOMEDIR/$user/conf/web/tmp_snginx.conf" - conf="$HOMEDIR/$user/conf/web/snginx.conf" - mv $tmp_conf $conf - nginx_conf_check=$(grep "$conf" $nginx_conf ) - if [ -z "$nginx_conf_check" ]; then - echo "include $conf;" >>$nginx_conf - fi - fi -fi - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating counters -update_user_value "$user" '$SUSPENDED_WEB' "$suspended_web" -update_user_value "$user" '$U_WEB_DOMAINS' "$user_domains" -update_user_value "$user" '$U_WEB_SSL' "$user_ssl" -update_user_value "$user" '$U_WEB_ALIASES' "$user_aliases" - -# Restart web server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: rebuild dns domains +# options: USER [RESTART] +# +# The function rebuilds BIND configuration files for all dns domains. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +restart=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh +source $VESTA/func/ip.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [RESTART]' +validate_format 'user' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +user_domains=0 +user_ssl=0 +user_aliases=0 +suspended_web=0 + +# Clean up old config +rm -f $HOMEDIR/$user/conf/tmp_*.conf + +# Defining config +conf=$USER_DATA/web.conf +fields='$DOMAIN' +nohead=1 + +# Starting loop +for domain in $(shell_list) ; do + + # Rebuilding directories + mkdir -p $HOMEDIR/$user/web/$domain \ + $HOMEDIR/$user/web/$domain/public_html \ + $HOMEDIR/$user/web/$domain/public_shtml \ + $HOMEDIR/$user/web/$domain/document_errors \ + $HOMEDIR/$user/web/$domain/cgi-bin \ + $HOMEDIR/$user/web/$domain/private \ + $HOMEDIR/$user/web/$domain/stats \ + $HOMEDIR/$user/web/$domain/logs + if [ ! -e "$HOMEDIR/$user/web/$domain/logs/$domain.log" ]; then + ln -s /var/log/httpd/domains/$domain.error.log \ + $HOMEDIR/$user/web/$domain/logs/$domain.log + fi + if [ ! -e "$HOMEDIR/$user/web/$domain/logs/$domain.error.log" ]; then + ln -s /var/log/httpd/domains/$domain.error.log \ + $HOMEDIR/$user/web/$domain/logs/$domain.error.log + fi + if [ -e "$WEBTPL/skel/document_errors/" ]; then + cp -r $WEBTPL/skel/document_errors/ $HOMEDIR/$user/web/$domain/ + fi + + touch /var/log/httpd/domains/$domain.bytes \ + /var/log/httpd/domains/$domain.log \ + /var/log/httpd/domains/$domain.error.log + + chmod 551 $HOMEDIR/$user/web/$domain + chmod 771 $HOMEDIR/$user/web/$domain/private + chmod 771 $HOMEDIR/$user/web/$domain/cgi-bin + chmod 771 $HOMEDIR/$user/web/$domain/public_html + chmod 771 $HOMEDIR/$user/web/$domain/public_shtml + chmod 771 $HOMEDIR/$user/web/$domain/document_errors + chmod 551 $HOMEDIR/$user/web/$domain/stats + chmod 551 $HOMEDIR/$user/web/$domain/logs + chmod 640 /var/log/httpd/domains/$domain.* + + chown $user:$user $HOMEDIR/$user/web/$domain + chown $user:$user $HOMEDIR/$user/web/$domain/private + chown $user:$user $HOMEDIR/$user/web/$domain/cgi-bin + chown $user:$user $HOMEDIR/$user/web/$domain/public_html + chown $user:$user $HOMEDIR/$user/web/$domain/public_shtml + chown -R $user:$user $HOMEDIR/$user/web/$domain/document_errors + chown root:$user /var/log/httpd/domains/$domain.* + chown root:apache $conf + + # Parsing domain values + domain_idn=$(idn -t --quiet -a "$domain") + get_domain_values 'web' + + # Preparing domain values for the template substitution + upd_web_domain_values + + # Adding domain to the tmp_httpd.conf + tpl_file="$WEBTPL/apache_$TPL.tpl" + conf="$HOMEDIR/$user/conf/web/tmp_httpd.conf" + add_web_config + chown root:apache $conf + chmod 640 $conf + + # Running template trigger + if [ -x $WEBTPL/apache_$TPL.sh ]; then + $WEBTPL/apache_$TPL.sh $user $domain $ip $HOMEDIR $docroot + fi + + # Checking aliases + if [ ! -z "$ALIAS" ]; then + aliases=$(echo "$ALIAS"|tr ',' '\n'| wc -l) + user_aliases=$((user_aliases + aliases)) + fi + + # Checking stats + if [ ! -z "$STATS" ]; then + cat $WEBTPL/$STATS.tpl |\ + sed -e "s/%ip%/$ip/g" \ + -e "s/%web_port%/$WEB_PORT/g" \ + -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \ + -e "s/%proxy_port%/$PROXY_PORT/g" \ + -e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \ + -e "s/%domain_idn%/$domain_idn/g" \ + -e "s/%domain%/$domain/g" \ + -e "s/%user%/$user/g" \ + -e "s/%home%/${HOMEDIR////\/}/g" \ + -e "s/%alias%/${aliases//,/ }/g" \ + -e "s/%alias_idn%/${aliases_idn//,/ }/g" \ + > $HOMEDIR/$user/conf/web/$STATS.$domain.conf + + if [ "$STATS" == 'awstats' ]; then + if [ ! -e "/etc/awstats/$STATS.$domain.conf" ]; then + ln -s $HOMEDIR/$user/conf/web/$STATS.$domain.conf /etc/awstats/ + fi + fi + + webstats="$BIN/v-update-web-domain-stat $user $domain" + check_webstats=$(grep "$webstats" $VESTA/data/queue/webstats.pipe) + if [ -z "$check_webstats" ]; then + echo "$webstats" >> $VESTA/data/queue/webstats.pipe + fi + + if [ ! -z "$STATS_USER" ]; then + # Definining statistic dir + stats_dir="$HOMEDIR/$user/web/$domain/stats" + + # Adding htaccess file + echo "AuthUserFile $stats_dir/.htpasswd" > $stats_dir/.htaccess + echo "AuthName \"Web Statistics\"" >> $stats_dir/.htaccess + echo "AuthType Basic" >> $stats_dir/.htaccess + echo "Require valid-user" >> $stats_dir/.htaccess + + # Generating htaccess user and password + echo "$STATS_USER:$STATS_CRYPT" > $stats_dir/.htpasswd + fi + fi + + # Checking ssl + if [ "$SSL" = 'yes' ]; then + # Adding domain to the shttpd.conf + conf="$HOMEDIR/$user/conf/web/tmp_shttpd.conf" + tpl_file="$WEBTPL/apache_$TPL.stpl" + add_web_config + chown root:apache $conf + chmod 640 $conf + + cp -f $USER_DATA/ssl/$domain.crt \ + $HOMEDIR/$user/conf/web/ssl.$domain.crt + cp -f $USER_DATA/ssl/$domain.key \ + $HOMEDIR/$user/conf/web/ssl.$domain.key + cp -f $USER_DATA/ssl/$domain.pem \ + $HOMEDIR/$user/conf/web/ssl.$domain.pem + if [ -e "$USER_DATA/ssl/$domain.ca" ]; then + cp -f $USER_DATA/ssl/$domain.ca \ + $HOMEDIR/$user/conf/web/ssl.$domain.ca + fi + + # Running template trigger + if [ -x $WEBTPL/apache_$TPL.sh ]; then + $WEBTPL/apache_$TPL.sh $user $domain $ip $HOMEDIR $sdocroot + fi + + user_ssl=$((user_ssl + 1)) + ssl_change='yes' + fi + + # Checking nginx + if [ ! -z "$NGINX" ]; then + tpl_file="$WEBTPL/nginx_$NGINX.tpl" + conf="$HOMEDIR/$user/conf/web/tmp_nginx.conf" + add_web_config + chown root:nginx $conf + chmod 640 $conf + + if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/tmp_snginx.conf" + add_web_config + chown root:nginx $conf + chmod 640 $conf + fi + ngix_change='yes' + fi + if [ "$SUSPENDED" = 'yes' ]; then + suspended_web=$((suspended_web + 1)) + fi + user_domains=$((user_domains + 1)) + + # Checking ftp + if [ ! -z "$FTP_USER" ]; then + if [ -z "$(grep ^$FTP_USER: /etc/passwd)" ]; then + /usr/sbin/adduser $FTP_USER -g $user -s /sbin/nologin -M \ + -d "$HOMEDIR/$user/web/$domain" > /dev/null 2>&1 + + shadow='/etc/shadow' + shdw=$(grep "^$FTP_USER:" $shadow) + shdw3=$(echo "$shdw" | cut -f3 -d :) + shdw4=$(echo "$shdw" | cut -f4 -d :) + shdw5=$(echo "$shdw" | cut -f5 -d :) + shdw6=$(echo "$shdw" | cut -f6 -d :) + shdw7=$(echo "$shdw" | cut -f7 -d :) + shdw8=$(echo "$shdw" | cut -f8 -d :) + shdw9=$(echo "$shdw" | cut -f9 -d :) + chmod u+w $shadow + sed -i "/^$FTP_USER:*/d" $shadow + shdw_str="$FTP_USER:$FTP_MD5:$shdw3:$shdw4:$shdw5:$shdw6" + shdw_str="$shdw_str:$shdw7:$shdw8:$shdw9" + echo "$shdw_str" >> $shadow + chmod u-w $shadow + fi + fi + +done + +# Renaming tmp config +tmp_conf="$HOMEDIR/$user/conf/web/tmp_httpd.conf" +conf="$HOMEDIR/$user/conf/web/httpd.conf" +if [ -e "$tmp_conf" ]; then + mv $tmp_conf $conf +fi + +# Checking include in main httpd.conf +main_conf='/etc/httpd/conf.d/vesta.conf' +main_conf_check=$(grep "$conf" $main_conf ) +if [ ! -z "$domain" ] && [ -z "$main_conf_check" ]; then + echo "Include $conf" >>$main_conf +fi + +# Checking ssl +if [ "$ssl_change" = 'yes' ]; then + tmp_conf="$HOMEDIR/$user/conf/web/tmp_shttpd.conf" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" + mv $tmp_conf $conf + + # Checking include in main httpd.conf + main_conf_check=$(grep "$conf" $main_conf ) + if [ -z "$main_conf_check" ]; then + echo "Include $conf" >>$main_conf + fi +fi + +# Checking nginx +if [ "$ngix_change" = 'yes' ]; then + nginx_conf='/etc/nginx/conf.d/vesta_users.conf' + tmp_conf="$HOMEDIR/$user/conf/web/tmp_nginx.conf" + conf="$HOMEDIR/$user/conf/web/nginx.conf" + mv $tmp_conf $conf + + nginx_conf_check=$(grep "$conf" $nginx_conf ) + if [ -z "$nginx_conf_check" ]; then + echo "include $conf;" >>$nginx_conf + fi + + # Checking ssl for nginx + if [ "$ssl_change" = 'yes' ]; then + tmp_conf="$HOMEDIR/$user/conf/web/tmp_snginx.conf" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + mv $tmp_conf $conf + nginx_conf_check=$(grep "$conf" $nginx_conf ) + if [ -z "$nginx_conf_check" ]; then + echo "include $conf;" >>$nginx_conf + fi + fi +fi + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Updating counters +update_user_value "$user" '$SUSPENDED_WEB' "$suspended_web" +update_user_value "$user" '$U_WEB_DOMAINS' "$user_domains" +update_user_value "$user" '$U_WEB_SSL' "$user_ssl" +update_user_value "$user" '$U_WEB_ALIASES' "$user_aliases" + +# Restart web server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-restart-cron b/bin/v-restart-cron index 3499a3f2a..6e0b02f0f 100755 --- a/bin/v-restart-cron +++ b/bin/v-restart-cron @@ -1,39 +1,39 @@ -#!/bin/bash -# info: restart cron service -# options: none -# -# The function tells crond service to reread its configuration files. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -EVENT=${1-$EVENT} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing config / or just source config -if [ "$CRON_SYSTEM" = 'crond' ]; then - /etc/init.d/crond 'reload' &>/dev/null - if [ $? -ne 0 ]; then - /etc/init.d/crond 'restart' &>/dev/null - if [ $? -ne 0 ]; then - log_event "$E_RESTART" "$EVENT" - exit $E_RESTART - fi - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: restart cron service +# options: NONE +# +# The function tells crond service to reread its configuration files. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +EVENT=${1-$EVENT} + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Parsing config / or just source config +if [ "$CRON_SYSTEM" = 'crond' ]; then + /etc/init.d/crond 'reload' &>/dev/null + if [ $? -ne 0 ]; then + /etc/init.d/crond 'restart' &>/dev/null + if [ $? -ne 0 ]; then + log_event "$E_RESTART" "$EVENT" + exit $E_RESTART + fi + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-restart-dns b/bin/v-restart-dns index b99373732..a780d29d4 100755 --- a/bin/v-restart-dns +++ b/bin/v-restart-dns @@ -1,37 +1,37 @@ -#!/bin/bash -# info: restart dns service -# options: none -# -# The function tells BIND service to reload dns zone files. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -EVENT=${1-$EVENT} - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -if [ "$DNS_SYSTEM" = 'bind' ]; then - /etc/init.d/named reload &>/dev/null - if [ $? -ne 0 ]; then - /etc/init.d/named restart &>/dev/null - if [ $? -ne 0 ]; then - log_event "$E_RESTART" "$EVENT" - exit $E_RESTART - fi - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: restart dns service +# options: NONE +# +# The function tells BIND service to reload dns zone files. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +EVENT=${1-$EVENT} + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +if [ "$DNS_SYSTEM" = 'bind' ]; then + /etc/init.d/named reload &>/dev/null + if [ $? -ne 0 ]; then + /etc/init.d/named restart &>/dev/null + if [ $? -ne 0 ]; then + log_event "$E_RESTART" "$EVENT" + exit $E_RESTART + fi + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-restart-mail b/bin/v-restart-mail index 6c3021791..f66085c95 100755 --- a/bin/v-restart-mail +++ b/bin/v-restart-mail @@ -1,37 +1,37 @@ -#!/bin/bash -# info: restart mail service -# options: none -# -# The function tells Exim service to reload configuration files. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -EVENT=${1-$EVENT} - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -if [ "$MAIL_SYSTEM" = 'exim' ]; then - /etc/init.d/exim reload &>/dev/null - if [ $? -ne 0 ]; then - /etc/init.d/exim restart &>/dev/null - if [ $? -ne 0 ]; then - log_event "$E_RESTART" "$EVENT" - exit $E_RESTART - fi - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: restart mail service +# options: NONE +# +# The function tells Exim service to reload configuration files. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +EVENT=${1-$EVENT} + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +if [ "$MAIL_SYSTEM" = 'exim' ]; then + /etc/init.d/exim reload &>/dev/null + if [ $? -ne 0 ]; then + /etc/init.d/exim restart &>/dev/null + if [ $? -ne 0 ]; then + log_event "$E_RESTART" "$EVENT" + exit $E_RESTART + fi + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-restart-web b/bin/v-restart-web index 64d00d71d..128cd00ae 100755 --- a/bin/v-restart-web +++ b/bin/v-restart-web @@ -1,61 +1,61 @@ -#!/bin/bash -# info: restart dns service -# options: none -# -# The function tells BIND service to reload dns zone files. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -EVENT=${1-$EVENT} - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -if [ "$WEB_SYSTEM" = 'apache' ]; then - /etc/init.d/httpd status &>/dev/null - if [ $? -eq 0 ]; then - /etc/init.d/httpd graceful &>/dev/null - if [ $? -ne 0 ]; then - log_event "$E_RESTART" "$EVENT" - exit $E_RESTART - fi - else - /etc/init.d/httpd start &>/dev/null - if [ $? -ne 0 ]; then - log_event "$E_RESTART" "$EVENT" - exit $E_RESTART - fi - fi -fi - -if [ "$PROXY_SYSTEM" = 'nginx' ]; then - /etc/init.d/nginx status &>/dev/null - if [ $? -eq 0 ]; then - /etc/init.d/nginx reload &>/dev/null - if [ $? -ne 0 ]; then - log_event "$E_RESTART" "$EVENT" - exit $E_RESTART - fi - else - /etc/init.d/nginx start &>/dev/null - if [ $? -ne 0 ]; then - log_event "$E_RESTART" "$EVENT" - exit $E_RESTART - fi - fi - -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: restart dns service +# options: NONE +# +# The function tells BIND service to reload dns zone files. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +EVENT=${1-$EVENT} + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +if [ "$WEB_SYSTEM" = 'apache' ]; then + /etc/init.d/httpd status &>/dev/null + if [ $? -eq 0 ]; then + /etc/init.d/httpd graceful &>/dev/null + if [ $? -ne 0 ]; then + log_event "$E_RESTART" "$EVENT" + exit $E_RESTART + fi + else + /etc/init.d/httpd start &>/dev/null + if [ $? -ne 0 ]; then + log_event "$E_RESTART" "$EVENT" + exit $E_RESTART + fi + fi +fi + +if [ "$PROXY_SYSTEM" = 'nginx' ]; then + /etc/init.d/nginx status &>/dev/null + if [ $? -eq 0 ]; then + /etc/init.d/nginx reload &>/dev/null + if [ $? -ne 0 ]; then + log_event "$E_RESTART" "$EVENT" + exit $E_RESTART + fi + else + /etc/init.d/nginx start &>/dev/null + if [ $? -ne 0 ]; then + log_event "$E_RESTART" "$EVENT" + exit $E_RESTART + fi + fi + +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-restore-user b/bin/v-restore-user index 235689724..3a90a3002 100755 --- a/bin/v-restore-user +++ b/bin/v-restore-user @@ -1,40 +1,40 @@ -#!/bin/bash -# info: restore user -# options: user backup -# -# The function for resotring user from backup. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -backup=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/db.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: restore user +# options: USER BACKUP +# +# The function for resotring user from backup. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +backup=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh +source $VESTA/func/db.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-search-domain-owner b/bin/v-search-domain-owner new file mode 100755 index 000000000..c334888f5 --- /dev/null +++ b/bin/v-search-domain-owner @@ -0,0 +1,55 @@ +#!/bin/bash +# info: search domain owner +# options: DOMAIN [TYPE] +# +# The function that allows to find user objects. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +domain=$(idn -t --quiet -u "$1" ) +type=${2-any} + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'DOMAIN [TYPE]' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Define conf +case $type in + web) conf="$VESTA/data/users/*/web.conf" ;; + dns) conf="$VESTA/data/users/*/dns.conf" ;; + mail) conf="$VESTA/data/users/*/mail.conf" ;; + *) conf="$VESTA/data/users/*/*.conf" +esac + + +owner=$(grep "DOMAIN='$domain'" $conf | head -n 1 | cut -f7 -d '/') +if [ -z "$owner" ]; then + exit $E_NOTEXIST +fi + +echo $owner + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +#log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-search-object b/bin/v-search-object index 0cc2e47bd..618090811 100755 --- a/bin/v-search-object +++ b/bin/v-search-object @@ -1,258 +1,258 @@ -#!/bin/bash -# info: search objects -# options: object [format] -# -# The function that allows to find system objects. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -object=$1 -format=${2-shell} - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - -# Json list function -json_list_search() { - echo '{' - fileds_count=$(echo $fields| wc -w ) - while read line; do - eval $line - if [ -n "$list_data" ]; then - echo -e ' },' - fi - i=1 - IFS=' ' - for field in $fields; do - eval value=\"$field\" - value=$(echo "$value"|sed -e 's/"/\\"/g' -e "s/%quote%/'/g") - if [ $i -eq 1 ]; then - (( ++i)) - echo -e "\t\"$value\": {" - else - if [ $i -lt $fileds_count ]; then - (( ++i)) - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," - else - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" - list_data=1 - fi - fi - done - done < $conf - if [ -n "$list_data" ]; then - echo -e ' }' - fi - echo -e '}' -} - -# Shell list function -shell_list_search() { - if [ -z "$nohead" ] ; then - echo "${fields//$/}" - for a in $fields; do - echo -e "------ \c" - done - echo - fi - while read line ; do - eval $line - eval echo "$fields" | sed -e "s/%quote%/'/g" - done < $conf -} - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'object [format]' -validate_format 'object' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -conf=$(mktemp) -i=0 -OLD_IFS=$IFS -IFS=$'\n' - -# User loop -for user in $(ls $VESTA/data/users/); do - # Search query - search=$(grep "$object" \ - $VESTA/data/users/$user/web.conf \ - $VESTA/data/users/$user/dns.conf \ - $VESTA/data/users/$user/dns/*.conf \ - $VESTA/data/users/$user/mail.conf \ - $VESTA/data/users/$user/mail/*.conf \ - $VESTA/data/users/$user/db.conf \ - $VESTA/data/users/$user/cron.conf 2> /dev/null) - - for row in $search; do - # Initialise variable - key='' - result='' - dom_alias='' - suspended='' - object_link='' - object_parent='' - object_time='' - object_date='' - - # Parsing result - type=$(echo $row |cut -f 1 -d : |cut -f 8 -d /) - data=$(echo $row |cut -f 2,3,4,5 -d :) - eval "$data" - - # Check WEB domain - if [ "$type" = 'web.conf' ]; then - if [ -n "$(echo $DOMAIN |grep $object)" ]; then - # Check domain alias - check_alias="$(echo $ALIAS| tr ',' '\n' |grep $object)" - if [ ! -z "$check_alias" ];then - dom_alias=$(echo $check_alias | tr ' ' ',') - fi - key="DOMAIN" - result="$DOMAIN" - suspended=$SUSPENDED - object_time=$TIME - object_date=$DATE - ((i ++)) - else - check_alias="$(echo $ALIAS| tr ',' '\n' |grep $object)" - if [ ! -z "$check_alias" ];then - key="DOMAIN" - result="$DOMAIN" - object_parent="$DOMAIN" - dom_alias=$(echo $check_alias | tr ' ' ',') - suspended=$SUSPENDED - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - fi - - # DNS - if [ "$type" = 'dns.conf' ]; then - if [ -n "$(echo $DOMAIN |grep $object)" ]; then - key="DOMAIN" - result="$DOMAIN" - suspended=$SUSPENDED - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - # DNS Records - if [ "$type" = 'dns' ]; then - if [ -n "$(echo $RECORD |grep $object)" ]; then - key="RECORD" - result="$RECORD.$DOMAIN" - suspended=$SUSPENDED - object_link=$ID - object_parent=$DOMAIN - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - # MAIL - if [ "$type" = 'mail.conf' ]; then - if [ -n "$(echo $DOMAIN |grep $object)" ]; then - key="DOMAIN" - result="$DOMAIN" - suspended=$SUSPENDED - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - # Mail Accounts - if [ "$type" = 'mail' ]; then - type='mail' - if [ -n "$(echo $ACCOUNT |grep $object)" ]; then - key="ACCOUNT" - dom="$(echo $row|cut -f 1 -d :|cut -f 9 -d /|sed -e "s/.conf//")" - result="$ACCOUNT@$dom" - suspended=$SUSPENDED - object_link=$ACCOUNT - object_parent=$dom - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - # DB - if [ "$type" = 'db.conf' ]; then - if [ -n "$(echo $DB |grep $object)" ]; then - key="DATABASE" - result="$DB" - suspended=$SUSPENDED - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - # Cron Jobs - if [ "$type" = 'cron.conf' ]; then - if [ -n "$(echo $CMD |grep $object)" ]; then - key="JOB" - result="$CMD" - suspended=$SUSPENDED - object_link=$JOB - object_parent=$JOB - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - if [ ! -z "$result" ]; then - type=$(echo $type|cut -f1 -d \.) - str="ID='$i' USER='$user' TYPE='$type' KEY='$key'" - str="$str RESULT='$result' ALIAS='$dom_alias'" - str="$str LINK='$object_link' PARENT='$object_parent'" - str="$str SUSPENDED='$suspended' TIME='$object_time'" - str="$str DATE='$object_date'" - echo $str >> $conf - fi - done -done -IFS=$OLD_IFS - -# Defining fileds to select -fields='$ID $USER $TYPE $KEY $RESULT $ALIAS $LINK $PARENT $SUSPENDED $TIME' -fields="$fields \$DATE" - -# Listing domains -case $format in - json) json_list_search ;; - plain) nohead=1; shell_list_search ;; - shell) fields='$USER~$TYPE~$KEY~$RESULT~$ALIAS'; - shell_list |column -t -s '~' ;; - *) check_args '1' '0' 'object [format]' -esac - -rm $conf - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -#log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: search objects +# options: OBJECT [FORMAT] +# +# The function that allows to find system objects. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +object=$1 +format=${2-shell} + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + +# Json list function +json_list_search() { + echo '{' + fileds_count=$(echo $fields| wc -w ) + while read line; do + eval $line + if [ -n "$list_data" ]; then + echo -e ' },' + fi + i=1 + IFS=' ' + for field in $fields; do + eval value=\"$field\" + value=$(echo "$value"|sed -e 's/"/\\"/g' -e "s/%quote%/'/g") + if [ $i -eq 1 ]; then + (( ++i)) + echo -e "\t\"$value\": {" + else + if [ $i -lt $fileds_count ]; then + (( ++i)) + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," + else + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" + list_data=1 + fi + fi + done + done < $conf + if [ -n "$list_data" ]; then + echo -e ' }' + fi + echo -e '}' +} + +# Shell list function +shell_list_search() { + if [ -z "$nohead" ] ; then + echo "${fields//$/}" + for a in $fields; do + echo -e "------ \c" + done + echo + fi + while read line ; do + eval $line + eval echo "$fields" | sed -e "s/%quote%/'/g" + done < $conf +} + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'OBJECT [FORMAT]' +validate_format 'object' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +conf=$(mktemp) +i=0 +OLD_IFS=$IFS +IFS=$'\n' + +# User loop +for user in $(ls $VESTA/data/users/); do + # Search query + search=$(grep "$object" \ + $VESTA/data/users/$user/web.conf \ + $VESTA/data/users/$user/dns.conf \ + $VESTA/data/users/$user/dns/*.conf \ + $VESTA/data/users/$user/mail.conf \ + $VESTA/data/users/$user/mail/*.conf \ + $VESTA/data/users/$user/db.conf \ + $VESTA/data/users/$user/cron.conf 2> /dev/null) + + for row in $search; do + # Initialise variable + key='' + result='' + dom_alias='' + suspended='' + object_link='' + object_parent='' + object_time='' + object_date='' + + # Parsing result + type=$(echo $row |cut -f 1 -d : |cut -f 8 -d /) + data=$(echo $row |cut -f 2,3,4,5 -d :) + eval "$data" + + # Check WEB domain + if [ "$type" = 'web.conf' ]; then + if [ -n "$(echo $DOMAIN |grep $object)" ]; then + # Check domain alias + check_alias="$(echo $ALIAS| tr ',' '\n' |grep $object)" + if [ ! -z "$check_alias" ];then + dom_alias=$(echo $check_alias | tr ' ' ',') + fi + key="DOMAIN" + result="$DOMAIN" + suspended=$SUSPENDED + object_time=$TIME + object_date=$DATE + ((i ++)) + else + check_alias="$(echo $ALIAS| tr ',' '\n' |grep $object)" + if [ ! -z "$check_alias" ];then + key="DOMAIN" + result="$DOMAIN" + object_parent="$DOMAIN" + dom_alias=$(echo $check_alias | tr ' ' ',') + suspended=$SUSPENDED + object_time=$TIME + object_date=$DATE + ((i ++)) + fi + fi + fi + + # DNS + if [ "$type" = 'dns.conf' ]; then + if [ -n "$(echo $DOMAIN |grep $object)" ]; then + key="DOMAIN" + result="$DOMAIN" + suspended=$SUSPENDED + object_time=$TIME + object_date=$DATE + ((i ++)) + fi + fi + + # DNS Records + if [ "$type" = 'dns' ]; then + if [ -n "$(echo $RECORD |grep $object)" ]; then + key="RECORD" + result="$RECORD.$DOMAIN" + suspended=$SUSPENDED + object_link=$ID + object_parent=$DOMAIN + object_time=$TIME + object_date=$DATE + ((i ++)) + fi + fi + + # MAIL + if [ "$type" = 'mail.conf' ]; then + if [ -n "$(echo $DOMAIN |grep $object)" ]; then + key="DOMAIN" + result="$DOMAIN" + suspended=$SUSPENDED + object_time=$TIME + object_date=$DATE + ((i ++)) + fi + fi + + # Mail Accounts + if [ "$type" = 'mail' ]; then + type='mail' + if [ -n "$(echo $ACCOUNT |grep $object)" ]; then + key="ACCOUNT" + dom="$(echo $row|cut -f 1 -d :|cut -f 9 -d /|sed -e "s/.conf//")" + result="$ACCOUNT@$dom" + suspended=$SUSPENDED + object_link=$ACCOUNT + object_parent=$dom + object_time=$TIME + object_date=$DATE + ((i ++)) + fi + fi + + # DB + if [ "$type" = 'db.conf' ]; then + if [ -n "$(echo $DB |grep $object)" ]; then + key="DATABASE" + result="$DB" + suspended=$SUSPENDED + object_time=$TIME + object_date=$DATE + ((i ++)) + fi + fi + + # Cron Jobs + if [ "$type" = 'cron.conf' ]; then + if [ -n "$(echo $CMD |grep $object)" ]; then + key="JOB" + result="$CMD" + suspended=$SUSPENDED + object_link=$JOB + object_parent=$JOB + object_time=$TIME + object_date=$DATE + ((i ++)) + fi + fi + + if [ ! -z "$result" ]; then + type=$(echo $type|cut -f1 -d \.) + str="ID='$i' USER='$user' TYPE='$type' KEY='$key'" + str="$str RESULT='$result' ALIAS='$dom_alias'" + str="$str LINK='$object_link' PARENT='$object_parent'" + str="$str SUSPENDED='$suspended' TIME='$object_time'" + str="$str DATE='$object_date'" + echo $str >> $conf + fi + done +done +IFS=$OLD_IFS + +# Defining fileds to select +fields='$ID $USER $TYPE $KEY $RESULT $ALIAS $LINK $PARENT $SUSPENDED $TIME' +fields="$fields \$DATE" + +# Listing domains +case $format in + json) json_list_search ;; + plain) nohead=1; shell_list_search ;; + shell) fields='$USER~$TYPE~$KEY~$RESULT~$ALIAS'; + shell_list |column -t -s '~' ;; + *) check_args '1' '0' 'OBJECT [FORMAT]' +esac + +rm $conf + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +#log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-search-user-object b/bin/v-search-user-object index 9d956c70e..ec95264da 100755 --- a/bin/v-search-user-object +++ b/bin/v-search-user-object @@ -1,258 +1,258 @@ -#!/bin/bash -# info: search objects -# options: user object [format] -# -# The function that allows to find user objects. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -object=$2 -format=${3-shell} - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - -# Json list function -json_list_search() { - echo '{' - fileds_count=$(echo $fields| wc -w ) - while read line; do - eval $line - if [ -n "$list_data" ]; then - echo -e ' },' - fi - i=1 - IFS=' ' - for field in $fields; do - eval value=\"$field\" - value=$(echo "$value"|sed -e 's/"/\\"/g' -e "s/%quote%/'/g") - if [ $i -eq 1 ]; then - (( ++i)) - echo -e "\t\"$value\": {" - else - if [ $i -lt $fileds_count ]; then - (( ++i)) - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," - else - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" - list_data=1 - fi - fi - done - done < $conf - if [ -n "$list_data" ]; then - echo -e ' }' - fi - echo -e '}' -} - -# Shell list function -shell_list_search() { - if [ -z "$nohead" ] ; then - echo "${fields//$/}" - for a in $fields; do - echo -e "------ \c" - done - echo - fi - while read line ; do - eval $line - eval echo "$fields" | sed -e "s/%quote%/'/g" - done < $conf -} - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user object [format]' -validate_format 'user' 'object' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -conf=$(mktemp) -i=0 -OLD_IFS=$IFS -IFS=$'\n' - -# Search query -search=$(grep "$object" \ - $VESTA/data/users/$user/web.conf \ - $VESTA/data/users/$user/dns.conf \ - $VESTA/data/users/$user/dns/*.conf \ - $VESTA/data/users/$user/mail.conf \ - $VESTA/data/users/$user/mail/*.conf \ - $VESTA/data/users/$user/db.conf \ - $VESTA/data/users/$user/cron.conf 2> /dev/null) - -for row in $search; do - # Initialise variable - key='' - result='' - dom_alias='' - suspended='' - object_link='' - object_parent='' - object_time='' - object_date='' - - # Parsing result - type=$(echo $row |cut -f 1 -d : |cut -f 8 -d /) - data=$(echo $row |cut -f 2,3,4,5 -d :) - eval "$data" - - # Check WEB domain - if [ "$type" = 'web.conf' ]; then - if [ -n "$(echo $DOMAIN |grep $object)" ]; then - # Check domain alias - check_alias="$(echo $ALIAS| tr ',' '\n' |grep $object)" - if [ ! -z "$check_alias" ];then - dom_alias=$(echo $check_alias | tr ' ' ',') - fi - key="DOMAIN" - result="$DOMAIN" - suspended=$SUSPENDED - object_time=$TIME - object_date=$DATE - ((i ++)) - else - check_alias="$(echo $ALIAS| tr ',' '\n' |grep $object)" - if [ ! -z "$check_alias" ];then - key="DOMAIN" - result="$DOMAIN" - object_parent="$DOMAIN" - dom_alias=$(echo $check_alias | tr ' ' ',') - suspended=$SUSPENDED - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - fi - - # DNS - if [ "$type" = 'dns.conf' ]; then - if [ -n "$(echo $DOMAIN |grep $object)" ]; then - key="DOMAIN" - result="$DOMAIN" - suspended=$SUSPENDED - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - # DNS Records - if [ "$type" = 'dns' ]; then - if [ -n "$(echo $RECORD |grep $object)" ]; then - key="RECORD" - result="$RECORD.$DOMAIN" - suspended=$SUSPENDED - object_link=$ID - object_parent=$DOMAIN - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - # MAIL - if [ "$type" = 'mail.conf' ]; then - if [ -n "$(echo $DOMAIN |grep $object)" ]; then - key="DOMAIN" - result="$DOMAIN" - suspended=$SUSPENDED - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - # Mail Accounts - if [ "$type" = 'mail' ]; then - type='mail' - if [ -n "$(echo $ACCOUNT |grep $object)" ]; then - key="ACCOUNT" - dom="$(echo $row|cut -f 1 -d :|cut -f 9 -d /|sed -e "s/.conf//")" - result="$ACCOUNT@$dom" - suspended=$SUSPENDED - object_link=$ACCOUNT - object_parent=$dom - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - # DB - if [ "$type" = 'db.conf' ]; then - if [ -n "$(echo $DB |grep $object)" ]; then - key="DATABASE" - result="$DB" - suspended=$SUSPENDED - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - # Cron Jobs - if [ "$type" = 'cron.conf' ]; then - if [ -n "$(echo $CMD |grep $object)" ]; then - key="JOB" - result="$CMD" - suspended=$SUSPENDED - object_link=$JOB - object_parent=$JOB - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - if [ ! -z "$result" ]; then - type=$(echo $type|cut -f1 -d \.) - str="ID='$i' USER='$user' TYPE='$type' KEY='$key'" - str="$str RESULT='$result' ALIAS='$dom_alias'" - str="$str LINK='$object_link' PARENT='$object_parent'" - str="$str SUSPENDED='$suspended' TIME='$object_time'" - str="$str DATE='$object_date'" - echo $str >> $conf - fi -done - -IFS=$OLD_IFS - -# Defining fileds to select -fields='$ID $USER $TYPE $KEY $RESULT $ALIAS $LINK $PARENT $SUSPENDED $TIME' -fields="$fields \$DATE" - -# Listing domains -case $format in - json) json_list_search ;; - plain) nohead=1; shell_list_search ;; - shell) fields='$USER~$TYPE~$KEY~$RESULT~$ALIAS'; - shell_list |column -t -s '~' ;; - *) check_args '2' '0' 'user object [format]' -esac - -rm $conf - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -#log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: search objects +# options: USER OBJECT [FORMAT] +# +# The function that allows to find user objects. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +object=$2 +format=${3-shell} + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + +# Json list function +json_list_search() { + echo '{' + fileds_count=$(echo $fields| wc -w ) + while read line; do + eval $line + if [ -n "$list_data" ]; then + echo -e ' },' + fi + i=1 + IFS=' ' + for field in $fields; do + eval value=\"$field\" + value=$(echo "$value"|sed -e 's/"/\\"/g' -e "s/%quote%/'/g") + if [ $i -eq 1 ]; then + (( ++i)) + echo -e "\t\"$value\": {" + else + if [ $i -lt $fileds_count ]; then + (( ++i)) + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," + else + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" + list_data=1 + fi + fi + done + done < $conf + if [ -n "$list_data" ]; then + echo -e ' }' + fi + echo -e '}' +} + +# Shell list function +shell_list_search() { + if [ -z "$nohead" ] ; then + echo "${fields//$/}" + for a in $fields; do + echo -e "------ \c" + done + echo + fi + while read line ; do + eval $line + eval echo "$fields" | sed -e "s/%quote%/'/g" + done < $conf +} + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER OBJECT [FORMAT]' +validate_format 'user' 'object' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +conf=$(mktemp) +i=0 +OLD_IFS=$IFS +IFS=$'\n' + +# Search query +search=$(grep "$object" \ + $VESTA/data/users/$user/web.conf \ + $VESTA/data/users/$user/dns.conf \ + $VESTA/data/users/$user/dns/*.conf \ + $VESTA/data/users/$user/mail.conf \ + $VESTA/data/users/$user/mail/*.conf \ + $VESTA/data/users/$user/db.conf \ + $VESTA/data/users/$user/cron.conf 2> /dev/null) + +for row in $search; do + # Initialise variable + key='' + result='' + dom_alias='' + suspended='' + object_link='' + object_parent='' + object_time='' + object_date='' + + # Parsing result + type=$(echo $row |cut -f 1 -d : |cut -f 8 -d /) + data=$(echo $row |cut -f 2,3,4,5 -d :) + eval "$data" + + # Check WEB domain + if [ "$type" = 'web.conf' ]; then + if [ -n "$(echo $DOMAIN |grep $object)" ]; then + # Check domain alias + check_alias="$(echo $ALIAS| tr ',' '\n' |grep $object)" + if [ ! -z "$check_alias" ];then + dom_alias=$(echo $check_alias | tr ' ' ',') + fi + key="DOMAIN" + result="$DOMAIN" + suspended=$SUSPENDED + object_time=$TIME + object_date=$DATE + ((i ++)) + else + check_alias="$(echo $ALIAS| tr ',' '\n' |grep $object)" + if [ ! -z "$check_alias" ];then + key="DOMAIN" + result="$DOMAIN" + object_parent="$DOMAIN" + dom_alias=$(echo $check_alias | tr ' ' ',') + suspended=$SUSPENDED + object_time=$TIME + object_date=$DATE + ((i ++)) + fi + fi + fi + + # DNS + if [ "$type" = 'dns.conf' ]; then + if [ -n "$(echo $DOMAIN |grep $object)" ]; then + key="DOMAIN" + result="$DOMAIN" + suspended=$SUSPENDED + object_time=$TIME + object_date=$DATE + ((i ++)) + fi + fi + + # DNS Records + if [ "$type" = 'dns' ]; then + if [ -n "$(echo $RECORD |grep $object)" ]; then + key="RECORD" + result="$RECORD.$DOMAIN" + suspended=$SUSPENDED + object_link=$ID + object_parent=$DOMAIN + object_time=$TIME + object_date=$DATE + ((i ++)) + fi + fi + + # MAIL + if [ "$type" = 'mail.conf' ]; then + if [ -n "$(echo $DOMAIN |grep $object)" ]; then + key="DOMAIN" + result="$DOMAIN" + suspended=$SUSPENDED + object_time=$TIME + object_date=$DATE + ((i ++)) + fi + fi + + # Mail Accounts + if [ "$type" = 'mail' ]; then + type='mail' + if [ -n "$(echo $ACCOUNT |grep $object)" ]; then + key="ACCOUNT" + dom="$(echo $row|cut -f 1 -d :|cut -f 9 -d /|sed -e "s/.conf//")" + result="$ACCOUNT@$dom" + suspended=$SUSPENDED + object_link=$ACCOUNT + object_parent=$dom + object_time=$TIME + object_date=$DATE + ((i ++)) + fi + fi + + # DB + if [ "$type" = 'db.conf' ]; then + if [ -n "$(echo $DB |grep $object)" ]; then + key="DATABASE" + result="$DB" + suspended=$SUSPENDED + object_time=$TIME + object_date=$DATE + ((i ++)) + fi + fi + + # Cron Jobs + if [ "$type" = 'cron.conf' ]; then + if [ -n "$(echo $CMD |grep $object)" ]; then + key="JOB" + result="$CMD" + suspended=$SUSPENDED + object_link=$JOB + object_parent=$JOB + object_time=$TIME + object_date=$DATE + ((i ++)) + fi + fi + + if [ ! -z "$result" ]; then + type=$(echo $type|cut -f1 -d \.) + str="ID='$i' USER='$user' TYPE='$type' KEY='$key'" + str="$str RESULT='$result' ALIAS='$dom_alias'" + str="$str LINK='$object_link' PARENT='$object_parent'" + str="$str SUSPENDED='$suspended' TIME='$object_time'" + str="$str DATE='$object_date'" + echo $str >> $conf + fi +done + +IFS=$OLD_IFS + +# Defining fileds to select +fields='$ID $USER $TYPE $KEY $RESULT $ALIAS $LINK $PARENT $SUSPENDED $TIME' +fields="$fields \$DATE" + +# Listing domains +case $format in + json) json_list_search ;; + plain) nohead=1; shell_list_search ;; + shell) fields='$USER~$TYPE~$KEY~$RESULT~$ALIAS'; + shell_list |column -t -s '~' ;; + *) check_args '2' '0' 'USER OBJECT [FORMAT]' +esac + +rm $conf + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +#log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-suspend-cron-job b/bin/v-suspend-cron-job index 43d118c80..400f095cf 100755 --- a/bin/v-suspend-cron-job +++ b/bin/v-suspend-cron-job @@ -1,57 +1,57 @@ -#!/bin/bash -# info: suspend cron job -# options: user job [restart] -# -# The function suspends a certain job of the cron scheduler. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -job=$2 -restart=$3 - -# Inlcudes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user job [restart]' -validate_format 'user' 'job' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'cron' 'JOB' "$job" -is_object_unsuspended 'cron' 'JOB' "$job" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Suspending job -update_object_value 'cron' 'JOB' "$job" '$SUSPENDED' 'yes' -increase_user_value "$user" '$SUSPENDED_CRON' - -# Sync system cron with user -sync_cron_jobs - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart crond -if [ "$restart" != 'no' ]; then - $BIN/v-restart-cron "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: suspend cron job +# options: USER JOB [RESTART] +# +# The function suspends a certain job of the cron scheduler. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +job=$2 +restart=$3 + +# Inlcudes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER JOB [RESTART]' +validate_format 'user' 'job' +is_object_valid 'user' 'USER' "$user" +is_object_valid 'cron' 'JOB' "$job" +is_object_unsuspended 'cron' 'JOB' "$job" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Suspending job +update_object_value 'cron' 'JOB' "$job" '$SUSPENDED' 'yes' +increase_user_value "$user" '$SUSPENDED_CRON' + +# Sync system cron with user +sync_cron_jobs + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart crond +if [ "$restart" != 'no' ]; then + $BIN/v-restart-cron "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-suspend-cron-jobs b/bin/v-suspend-cron-jobs index 6d4505550..cf31c6e9c 100755 --- a/bin/v-suspend-cron-jobs +++ b/bin/v-suspend-cron-jobs @@ -1,52 +1,52 @@ -#!/bin/bash -# info: Suspending sys cron jobs -# options: user [restart] -# -# The function suspends all user cron jobs. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -restart=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Suspendn all jobs -for job in $(search_objects 'cron' 'SUSPENDED' 'no' 'JOB'); do - $BIN/v-suspend-cron-job $user $job 'no' -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart crond -if [ "$restart" != 'no' ]; then - $BIN/v-restart-cron "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: Suspending sys cron jobs +# options: USER [RESTART] +# +# The function suspends all user cron jobs. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +restart=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Suspendn all jobs +for job in $(search_objects 'cron' 'SUSPENDED' 'no' 'JOB'); do + $BIN/v-suspend-cron-job $user $job 'no' +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart crond +if [ "$restart" != 'no' ]; then + $BIN/v-restart-cron "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-suspend-database b/bin/v-suspend-database index 84b943db9..5145a9c06 100755 --- a/bin/v-suspend-database +++ b/bin/v-suspend-database @@ -1,60 +1,60 @@ -#!/bin/bash -# info: suspend database -# options: user database -# -# The function for suspending a certain user database. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -database=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/db.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user database' -validate_format 'user' 'database' -is_system_enabled "$DB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'db' 'DB' "$database" -is_object_unsuspended 'db' 'DB' "$database" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get database values -get_database_values - -# Switching on db type -case $TYPE in - mysql) suspend_mysql_database ;; - pgsql) suspend_pgsql_database ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating db value -update_object_value 'db' 'DB' "$database" '$SUSPENDED' 'yes' -increase_user_value "$user" '$SUSPENDED_DB' - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: suspend database +# options: USER DATABASE +# +# The function for suspending a certain user database. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +database=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/db.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DATABASE' +validate_format 'user' 'database' +is_system_enabled "$DB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'db' 'DB' "$database" +is_object_unsuspended 'db' 'DB' "$database" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Get database values +get_database_values + +# Switching on db type +case $TYPE in + mysql) suspend_mysql_database ;; + pgsql) suspend_pgsql_database ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Updating db value +update_object_value 'db' 'DB' "$database" '$SUSPENDED' 'yes' +increase_user_value "$user" '$SUSPENDED_DB' + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-suspend-database-server b/bin/v-suspend-database-server index 2854dae62..c9c8f3b6c 100755 --- a/bin/v-suspend-database-server +++ b/bin/v-suspend-database-server @@ -1,47 +1,47 @@ -#!/bin/bash -# info: suspend database server -# options: type host -# -# The function for suspending a database server. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -type=$1 -host=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'type host' -validate_format 'type' 'host' -is_system_enabled "$DB_SYSTEM" -is_object_valid "../../conf/$type" 'HOST' "$host" -is_object_unsuspended "../../conf/$type" 'HOST' "$host" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Suspend database creation on a server -update_object_value "../../conf/$type" 'HOST' "$host" '$SUSPENDED' 'yes' - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: suspend database server +# options: TYPE HOST +# +# The function for suspending a database server. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +type=$1 +host=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'TYPE HOST' +validate_format 'type' 'host' +is_system_enabled "$DB_SYSTEM" +is_object_valid "../../conf/$type" 'HOST' "$host" +is_object_unsuspended "../../conf/$type" 'HOST' "$host" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Suspend database creation on a server +update_object_value "../../conf/$type" 'HOST' "$host" '$SUSPENDED' 'yes' + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-suspend-databases b/bin/v-suspend-databases index 8ff792e96..ef6260b33 100755 --- a/bin/v-suspend-databases +++ b/bin/v-suspend-databases @@ -1,47 +1,47 @@ -#!/bin/bash -# info: suspend databases -# options: user -# -# The function for suspending of all databases of a single user. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user' -validate_format 'user' -is_system_enabled "$DB_SYSTEM" -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting suspend loop -for database in $(search_objects 'db' 'SUSPENDED' "no" 'DB'); do - $BIN/v-suspend-database "$user" "$database" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: suspend databases +# options: USER +# +# The function for suspending of all databases of a single user. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_system_enabled "$DB_SYSTEM" +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting suspend loop +for database in $(search_objects 'db' 'SUSPENDED' "no" 'DB'); do + $BIN/v-suspend-database "$user" "$database" +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-suspend-dns-domain b/bin/v-suspend-dns-domain index 7ce528d88..29df20050 100755 --- a/bin/v-suspend-dns-domain +++ b/bin/v-suspend-dns-domain @@ -1,60 +1,60 @@ -#!/bin/bash -# info: suspend dns domain -# options: user domain [restart] -# -# The function suspends a certain user's domain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -restart="$3" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain [restart]' -validate_format 'user' 'domain' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting domain from named.conf -sed -i "/\/$domain.db\"/d" /etc/named.conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding suspend in config -update_object_value 'dns' 'DOMAIN' "$domain" '$SUSPENDED' 'yes' -sed -i "s/SUSPENDED='no'/SUSPENDED='yes'/g" $USER_DATA/dns/$domain.conf -increase_user_value "$user" '$SUSPENDED_DNS' - -# Restart named -if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: suspend dns domain +# options: USER DOMAIN [RESTART] +# +# The function suspends a certain user's domain. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +restart="$3" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [RESTART]' +validate_format 'user' 'domain' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" +is_object_unsuspended 'dns' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Deleting domain from named.conf +sed -i "/\/$domain.db\"/d" /etc/named.conf + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Adding suspend in config +update_object_value 'dns' 'DOMAIN' "$domain" '$SUSPENDED' 'yes' +sed -i "s/SUSPENDED='no'/SUSPENDED='yes'/g" $USER_DATA/dns/$domain.conf +increase_user_value "$user" '$SUSPENDED_DNS' + +# Restart named +if [ "$restart" != 'no' ]; then + $BIN/v-restart-dns "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-suspend-dns-domain-record b/bin/v-suspend-dns-domain-record index d7f1b5170..7d683cf92 100755 --- a/bin/v-suspend-dns-domain-record +++ b/bin/v-suspend-dns-domain-record @@ -1,71 +1,71 @@ -#!/bin/bash -# info: suspend dns domain record -# options: user domain id [restart] -# -# The function suspends a certain domain record. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -id=$3 -restart="$4" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user domain id [restart]' -validate_format 'user' 'domain' 'id' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" -is_object_valid "dns/$domain" 'ID' "$id" -is_object_unsuspended "dns/$domain" 'ID' "$id" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -line=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf) -eval $line -sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf - -# Adding record -dns_rec="ID='$id' RECORD='$RECORD' TYPE='$TYPE' PRIORITY='$PRIORITY'" -dns_rec="$dns_rec VALUE='$VALUE' SUSPENDED='yes' TIME='$TIME' DATE='$DATE'" -echo "$dns_rec" >> $USER_DATA/dns/$domain.conf - -# Sorting records -sort_dns_records - -# Updating zone -update_domain_zone - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart named -if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: suspend dns domain record +# options: USER DOMAIN ID [RESTART] +# +# The function suspends a certain domain record. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +id=$3 +restart="$4" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN ID [RESTART]' +validate_format 'user' 'domain' 'id' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" +is_object_unsuspended 'dns' 'DOMAIN' "$domain" +is_object_valid "dns/$domain" 'ID' "$id" +is_object_unsuspended "dns/$domain" 'ID' "$id" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +line=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf) +eval $line +sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf + +# Adding record +dns_rec="ID='$id' RECORD='$RECORD' TYPE='$TYPE' PRIORITY='$PRIORITY'" +dns_rec="$dns_rec VALUE='$VALUE' SUSPENDED='yes' TIME='$TIME' DATE='$DATE'" +echo "$dns_rec" >> $USER_DATA/dns/$domain.conf + +# Sorting records +sort_dns_records + +# Updating zone +update_domain_zone + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart named +if [ "$restart" != 'no' ]; then + $BIN/v-restart-dns "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-suspend-dns-domains b/bin/v-suspend-dns-domains index 7bb2e8c1f..332f89b51 100755 --- a/bin/v-suspend-dns-domains +++ b/bin/v-suspend-dns-domains @@ -1,53 +1,53 @@ -#!/bin/bash -# info: suspend dns domains -# options: user [restart] -# -# The function suspends all user's DNS domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -restart=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user [restart]' -validate_format 'user' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting suspend loop -for domain in $(search_objects 'dns' 'SUSPENDED' "no" 'DOMAIN'); do - $BIN/v-suspend-dns-domain "$user" "$domain" 'no' -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart dns server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: suspend dns domains +# options: USER [RESTART] +# +# The function suspends all user's DNS domains. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +restart=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [RESTART]' +validate_format 'user' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting suspend loop +for domain in $(search_objects 'dns' 'SUSPENDED' "no" 'DOMAIN'); do + $BIN/v-suspend-dns-domain "$user" "$domain" 'no' +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart dns server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-dns "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-suspend-mail-account b/bin/v-suspend-mail-account index 1944612f3..ee3cb279b 100755 --- a/bin/v-suspend-mail-account +++ b/bin/v-suspend-mail-account @@ -1,60 +1,60 @@ -#!/bin/bash -# info: suspend mail account -# options: user domain account -# -# The function suspends mail account. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -account=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user domain account' -validate_format 'user' 'domain' 'account' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -quota=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$QUOTA') -sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd -str="$account:SUSPENDED:$user:mail::$HOMEDIR/$user:$quota" -echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$SUSPENDED' 'yes' - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: suspend mail account +# options: USER DOMAIN ACCOUNT +# +# The function suspends mail account. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +account=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN ACCOUNT' +validate_format 'user' 'domain' 'account' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_valid "mail/$domain" 'ACCOUNT' "$account" +is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +quota=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$QUOTA') +sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd +str="$account:SUSPENDED:$user:mail::$HOMEDIR/$user:$quota" +echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value "mail/$domain" 'ACCOUNT' "$account" '$SUSPENDED' 'yes' + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-suspend-mail-accounts b/bin/v-suspend-mail-accounts index 789c34921..15656a5d3 100755 --- a/bin/v-suspend-mail-accounts +++ b/bin/v-suspend-mail-accounts @@ -1,53 +1,53 @@ -#!/bin/bash -# info: suspend all mail domain accounts -# options: user domain -# -# The function suspends all mail domain accounts. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain' -validate_format 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting suspend loop -for account in $(search_objects "mail/$domain" 'SUSPENDED' "no" 'ACCOUNT'); do - $BIN/v-suspend-mail-account "$user" "$domain" "$account" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# No Logging -#log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: suspend all mail domain accounts +# options: USER DOMAIN +# +# The function suspends all mail domain accounts. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting suspend loop +for account in $(search_objects "mail/$domain" 'SUSPENDED' "no" 'ACCOUNT'); do + $BIN/v-suspend-mail-account "$user" "$domain" "$account" +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# No Logging +#log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-suspend-mail-domain b/bin/v-suspend-mail-domain index ef60bc22b..2128609e4 100755 --- a/bin/v-suspend-mail-domain +++ b/bin/v-suspend-mail-domain @@ -1,58 +1,58 @@ -#!/bin/bash -# info: suspend mail domain -# options: user domain -# -# The function suspends mail domain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain' -validate_format 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting symbolic link -rm -f /etc/exim/domains/$domain - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating config -update_object_value 'mail' 'DOMAIN' "$domain" '$SUSPENDED' 'yes' -sed -i "s/SUSPENDED='no'/SUSPENDED='yes'/g" $USER_DATA/mail/$domain.conf -increase_user_value "$user" '$SUSPENDED_MAIL' - - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: suspend mail domain +# options: USER DOMAIN +# +# The function suspends mail domain. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Deleting symbolic link +rm -f /etc/exim/domains/$domain + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Updating config +update_object_value 'mail' 'DOMAIN' "$domain" '$SUSPENDED' 'yes' +sed -i "s/SUSPENDED='no'/SUSPENDED='yes'/g" $USER_DATA/mail/$domain.conf +increase_user_value "$user" '$SUSPENDED_MAIL' + + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-suspend-mail-domains b/bin/v-suspend-mail-domains index 99ee8e468..244c9d5e0 100755 --- a/bin/v-suspend-mail-domains +++ b/bin/v-suspend-mail-domains @@ -1,48 +1,48 @@ -#!/bin/bash -# info: suspend mail domains -# options: user -# -# The function suspends all user's MAIL domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user' -validate_format 'user' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting suspend loop -for domain in $(search_objects 'mail' 'SUSPENDED' "no" 'DOMAIN'); do - $BIN/v-suspend-mail-domain "$user" "$domain" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: suspend mail domains +# options: USER +# +# The function suspends all user's MAIL domains. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting suspend loop +for domain in $(search_objects 'mail' 'SUSPENDED' "no" 'DOMAIN'); do + $BIN/v-suspend-mail-domain "$user" "$domain" +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-suspend-user b/bin/v-suspend-user index f159b7832..69317c176 100755 --- a/bin/v-suspend-user +++ b/bin/v-suspend-user @@ -1,85 +1,85 @@ -#!/bin/bash -# info: suspend user -# options: user [restart] -# -# The function suspends a certain user and all his objects. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -restart=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user [restart]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -if [ "$user" = 'admin' ]; then - exit -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding '!' in front of the password -/usr/sbin/usermod --lock $user - -# Suspending web domains -if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then - $BIN/v-suspend-web-domains $user $restart -fi - -# Suspending dns domains -if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then - $BIN/v-suspend-dns-domains $user $restart -fi - -# Suspending mail domains -if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then - $BIN/v-suspend-mail-domains $user -fi - -# Suspending datbabases -if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then - $BIN/v-suspend-databases $user -fi - -# Suspending cron jobs -if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then - $BIN/v-suspend-cron-jobs $user $restart -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart web server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" - $BIN/v-restart-dns "$EVENT" - $BIN/v-restart-cron "$EVENT" -fi - -# Changing suspend value -update_user_value "$user" '$SUSPENDED' 'yes' -increase_user_value 'admin' '$SUSPENDED_USERS' - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: suspend user +# options: USER [RESTART] +# +# The function suspends a certain user and all his objects. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +restart=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [RESTART]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +if [ "$user" = 'admin' ]; then + exit +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Adding '!' in front of the password +/usr/sbin/usermod --lock $user + +# Suspending web domains +if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then + $BIN/v-suspend-web-domains $user $restart +fi + +# Suspending dns domains +if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then + $BIN/v-suspend-dns-domains $user $restart +fi + +# Suspending mail domains +if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then + $BIN/v-suspend-mail-domains $user +fi + +# Suspending datbabases +if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then + $BIN/v-suspend-databases $user +fi + +# Suspending cron jobs +if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then + $BIN/v-suspend-cron-jobs $user $restart +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart web server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" + $BIN/v-restart-dns "$EVENT" + $BIN/v-restart-cron "$EVENT" +fi + +# Changing suspend value +update_user_value "$user" '$SUSPENDED' 'yes' +increase_user_value 'admin' '$SUSPENDED_USERS' + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-suspend-web-domain b/bin/v-suspend-web-domain index 349be3e04..3e951f05a 100755 --- a/bin/v-suspend-web-domain +++ b/bin/v-suspend-web-domain @@ -1,96 +1,96 @@ -#!/bin/bash -# info: suspend web domain -# options: user domain -# -# The function for suspending the site's operation. After blocking it all -# visitors will be redirected to a web page explaining the reason of suspend. -# By blocking the site the content of all its directories remains untouched. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -restart=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain [restart]' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain values -get_domain_values 'web' -tpl_file="$WEBTPL/apache_$TPL.tpl" -conf="$HOMEDIR/$user/conf/web/httpd.conf" -SUSPENDED='yes' - -# Preparing domain values for the template substitution -upd_web_domain_values - -# Recreating vhost -del_web_config -add_web_config - -# Check ssl -if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/apache_$TPL.stpl" - conf="$HOMEDIR/$user/conf/web/shttpd.conf" - del_web_config - add_web_config -fi - -# Checking nginx -if [ ! -z "$NGINX" ]; then - tpl_file="$WEBTPL/nginx_$NGINX.tpl" - conf="$HOMEDIR/$user/conf/web/nginx.conf" - del_web_config - add_web_config - - if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web/snginx.conf" - del_web_config - add_web_config - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$SUSPENDED' 'yes' -increase_user_value "$user" '$SUSPENDED_WEB' - -# Restart web server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: suspend web domain +# options: USER DOMAIN +# +# The function for suspending the site's operation. After blocking it all +# visitors will be redirected to a web page explaining the reason of suspend. +# By blocking the site the content of all its directories remains untouched. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +restart=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [RESTART]' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Parsing domain values +get_domain_values 'web' +tpl_file="$WEBTPL/apache_$TPL.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" +SUSPENDED='yes' + +# Preparing domain values for the template substitution +upd_web_domain_values + +# Recreating vhost +del_web_config +add_web_config + +# Check ssl +if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" + del_web_config + add_web_config +fi + +# Checking nginx +if [ ! -z "$NGINX" ]; then + tpl_file="$WEBTPL/nginx_$NGINX.tpl" + conf="$HOMEDIR/$user/conf/web/nginx.conf" + del_web_config + add_web_config + + if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + del_web_config + add_web_config + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$SUSPENDED' 'yes' +increase_user_value "$user" '$SUSPENDED_WEB' + +# Restart web server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-suspend-web-domains b/bin/v-suspend-web-domains index 90a85f8e5..027adf5d0 100755 --- a/bin/v-suspend-web-domains +++ b/bin/v-suspend-web-domains @@ -1,53 +1,53 @@ -#!/bin/bash -# info: suspend web domains -# options: user [restart] -# -# The function of suspending all user's sites. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -restart=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user [restart]' -validate_format 'user' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting suspend loop -for domain in $(search_objects 'web' 'SUSPENDED' "no" 'DOMAIN'); do - $BIN/v-suspend-web-domain "$user" "$domain" 'no' -done - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart web server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: suspend web domains +# options: USER [RESTART] +# +# The function of suspending all user's sites. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +restart=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [RESTART]' +validate_format 'user' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting suspend loop +for domain in $(search_objects 'web' 'SUSPENDED' "no" 'DOMAIN'); do + $BIN/v-suspend-web-domain "$user" "$domain" 'no' +done + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart web server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-unsuspend-cron-job b/bin/v-unsuspend-cron-job index 64e6d62b4..5bca05191 100755 --- a/bin/v-unsuspend-cron-job +++ b/bin/v-unsuspend-cron-job @@ -1,57 +1,57 @@ -#!/bin/bash -# info: unuspend cron job -# options: user job [restart] -# -# The function unsuspen certain cron job. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -job=$2 -restart="${3-yes}" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user job [restart]' -validate_format 'user' 'job' 'restart' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'cron' 'JOB' "$job" -is_object_suspended 'cron' 'JOB' "$job" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Unsuspending job -update_object_value 'cron' 'JOB' "$job" '$SUSPENDED' 'no' -decrease_user_value "$user" '$SUSPENDED_CRON' - -# Sync system cron with user -sync_cron_jobs - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart crond -if [ "$restart" != 'no' ]; then - $BIN/v-restart-cron "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: unuspend cron job +# options: USER JOB [RESTART] +# +# The function unsuspen certain cron job. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +job=$2 +restart="${3-yes}" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER JOB [RESTART]' +validate_format 'user' 'job' 'restart' +is_object_valid 'user' 'USER' "$user" +is_object_valid 'cron' 'JOB' "$job" +is_object_suspended 'cron' 'JOB' "$job" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Unsuspending job +update_object_value 'cron' 'JOB' "$job" '$SUSPENDED' 'no' +decrease_user_value "$user" '$SUSPENDED_CRON' + +# Sync system cron with user +sync_cron_jobs + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart crond +if [ "$restart" != 'no' ]; then + $BIN/v-restart-cron "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-unsuspend-cron-jobs b/bin/v-unsuspend-cron-jobs index b05d00951..05868c19d 100755 --- a/bin/v-unsuspend-cron-jobs +++ b/bin/v-unsuspend-cron-jobs @@ -1,52 +1,52 @@ -#!/bin/bash -# info: unuspend sys cron -# options: user [restart] -# -# The function unsuspends all suspended cron jobs. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -restart=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user [restart]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Unsuspendning jobs -for job in $(search_objects 'cron' 'SUSPENDED' 'yes' 'JOB'); do - $BIN/v-unsuspend-cron-job $user $job 'no' -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart crond -if [ "$restart" != 'no' ]; then - $BIN/v-restart-cron "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: unuspend sys cron +# options: USER [RESTART] +# +# The function unsuspends all suspended cron jobs. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +restart=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [RESTART]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Unsuspendning jobs +for job in $(search_objects 'cron' 'SUSPENDED' 'yes' 'JOB'); do + $BIN/v-unsuspend-cron-job $user $job 'no' +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart crond +if [ "$restart" != 'no' ]; then + $BIN/v-restart-cron "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-unsuspend-database b/bin/v-unsuspend-database index d700dd0a9..513925bb5 100755 --- a/bin/v-unsuspend-database +++ b/bin/v-unsuspend-database @@ -1,59 +1,59 @@ -#!/bin/bash -# info: unsuspend database -# options: user database -# -# The function for unsuspending database. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -database=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/db.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user database' -validate_format 'user' 'database' -is_system_enabled "$DB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_valid 'db' 'DB' "$database" -is_object_suspended 'db' 'DB' "$database" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get database values -get_database_values - -# Switching on db type -case $TYPE in - mysql) unsuspend_mysql_database ;; - pgsql) unsuspend_pgsql_database ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating db value -update_object_value 'db' 'DB' "$database" '$SUSPENDED' 'no' -decrease_user_value "$user" '$SUSPENDED_DB' - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: unsuspend database +# options: USER DATABASE +# +# The function for unsuspending database. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +database=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/db.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DATABASE' +validate_format 'user' 'database' +is_system_enabled "$DB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_valid 'db' 'DB' "$database" +is_object_suspended 'db' 'DB' "$database" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Get database values +get_database_values + +# Switching on db type +case $TYPE in + mysql) unsuspend_mysql_database ;; + pgsql) unsuspend_pgsql_database ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Updating db value +update_object_value 'db' 'DB' "$database" '$SUSPENDED' 'no' +decrease_user_value "$user" '$SUSPENDED_DB' + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-unsuspend-database-server b/bin/v-unsuspend-database-server index 387e1cf16..47a3b6ffb 100755 --- a/bin/v-unsuspend-database-server +++ b/bin/v-unsuspend-database-server @@ -1,47 +1,47 @@ -#!/bin/bash -# info: unsuspend database server -# options: type host -# -# The function for unsuspending a database server. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -type=$1 -host=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'type host' -validate_format 'type' 'host' -is_system_enabled "$DB_SYSTEM" -is_object_valid "../../conf/$type" 'HOST' "$host" -is_object_suspended "../../conf/$type" 'HOST' "$host" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Unsuspend database creation on a server -update_object_value "../../conf/$type" 'HOST' "$host" '$SUSPENDED' 'no' - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: unsuspend database server +# options: TYPE HOST +# +# The function for unsuspending a database server. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +type=$1 +host=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'TYPE HOST' +validate_format 'type' 'host' +is_system_enabled "$DB_SYSTEM" +is_object_valid "../../conf/$type" 'HOST' "$host" +is_object_suspended "../../conf/$type" 'HOST' "$host" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Unsuspend database creation on a server +update_object_value "../../conf/$type" 'HOST' "$host" '$SUSPENDED' 'no' + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-unsuspend-databases b/bin/v-unsuspend-databases index 5d48a209b..2219b5d79 100755 --- a/bin/v-unsuspend-databases +++ b/bin/v-unsuspend-databases @@ -1,48 +1,48 @@ -#!/bin/bash -# info: unsuspend databases -# options: user -# -# The function for unsuspending all user's databases. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/db.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user' -validate_format 'user' -is_system_enabled "$DB_SYSTEM" -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting unsuspend loop -for database in $(search_objects 'db' 'SUSPENDED' "yes" 'DB'); do - $BIN/v-unsuspend-database "$user" "$database" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: unsuspend databases +# options: USER +# +# The function for unsuspending all user's databases. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/db.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_system_enabled "$DB_SYSTEM" +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting unsuspend loop +for database in $(search_objects 'db' 'SUSPENDED' "yes" 'DB'); do + $BIN/v-unsuspend-database "$user" "$database" +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-unsuspend-dns-domain b/bin/v-unsuspend-dns-domain index 9cfdf2120..1795da41a 100755 --- a/bin/v-unsuspend-dns-domain +++ b/bin/v-unsuspend-dns-domain @@ -1,62 +1,62 @@ -#!/bin/bash -# info: unsuspend dns domain -# options: user domain -# -# The function unsuspends a certain user's domain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -restart="$3" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain' -validate_format 'user' 'domain' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_suspended 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding zone in named.conf -named="zone \"$domain_idn\" {type master; file" -named="$named \"$HOMEDIR/$user/conf/dns/$domain.db\";};" -echo "$named" >> /etc/named.conf - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Unsuspending domain in config -update_object_value 'dns' 'DOMAIN' "$domain" '$SUSPENDED' 'no' -decrease_user_value "$user" '$SUSPENDED_DNS' -sed -i "s/SUSPENDED='yes'/SUSPENDED='no'/g" $USER_DATA/dns/$domain.conf - - -# Restart named -if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: unsuspend dns domain +# options: USER DOMAIN +# +# The function unsuspends a certain user's domain. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +restart="$3" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" +is_object_suspended 'dns' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Adding zone in named.conf +named="zone \"$domain_idn\" {type master; file" +named="$named \"$HOMEDIR/$user/conf/dns/$domain.db\";};" +echo "$named" >> /etc/named.conf + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Unsuspending domain in config +update_object_value 'dns' 'DOMAIN' "$domain" '$SUSPENDED' 'no' +decrease_user_value "$user" '$SUSPENDED_DNS' +sed -i "s/SUSPENDED='yes'/SUSPENDED='no'/g" $USER_DATA/dns/$domain.conf + + +# Restart named +if [ "$restart" != 'no' ]; then + $BIN/v-restart-dns "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-unsuspend-dns-domain-record b/bin/v-unsuspend-dns-domain-record index a95a75d90..8b4a9ab41 100755 --- a/bin/v-unsuspend-dns-domain-record +++ b/bin/v-unsuspend-dns-domain-record @@ -1,70 +1,70 @@ -#!/bin/bash -# info: unsuspend dns domain record -# options: user domain id [restart] -# -# The function unsuspends a certain domain record. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -id=$3 -restart="$4" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user domain id [restart]' -validate_format 'user' 'domain' 'id' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" -is_object_valid "dns/$domain" 'ID' "$id" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -line=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf) -eval $line -sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf - -# Adding record -dns_rec="ID='$id' RECORD='$RECORD' TYPE='$TYPE' PRIORITY='$PRIORITY'" -dns_rec="$dns_rec VALUE='$VALUE' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" -echo "$dns_rec" >> $USER_DATA/dns/$domain.conf - -# Sorting records -sort_dns_records - -# Updating zone -update_domain_zone - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart named -if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: unsuspend dns domain record +# options: USER DOMAIN ID [RESTART] +# +# The function unsuspends a certain domain record. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +id=$3 +restart="$4" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN ID [RESTART]' +validate_format 'user' 'domain' 'id' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" +is_object_unsuspended 'dns' 'DOMAIN' "$domain" +is_object_valid "dns/$domain" 'ID' "$id" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +line=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf) +eval $line +sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf + +# Adding record +dns_rec="ID='$id' RECORD='$RECORD' TYPE='$TYPE' PRIORITY='$PRIORITY'" +dns_rec="$dns_rec VALUE='$VALUE' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" +echo "$dns_rec" >> $USER_DATA/dns/$domain.conf + +# Sorting records +sort_dns_records + +# Updating zone +update_domain_zone + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart named +if [ "$restart" != 'no' ]; then + $BIN/v-restart-dns "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-unsuspend-dns-domains b/bin/v-unsuspend-dns-domains index 468b41a00..ae72bc8ec 100755 --- a/bin/v-unsuspend-dns-domains +++ b/bin/v-unsuspend-dns-domains @@ -1,53 +1,53 @@ -#!/bin/bash -# info: unsuspend dns domains -# options: user [restart] -# -# The function unsuspends all user's DNS domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -restart=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user [restart]' -validate_format 'user' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting unsuspend loop -for domain in $(search_objects 'dns' 'SUSPENDED' "yes" 'DOMAIN'); do - $BIN/v-unsuspend-dns-domain "$user" "$domain" 'no' -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart dns server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: unsuspend dns domains +# options: USER [RESTART] +# +# The function unsuspends all user's DNS domains. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +restart=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [RESTART]' +validate_format 'user' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting unsuspend loop +for domain in $(search_objects 'dns' 'SUSPENDED' "yes" 'DOMAIN'); do + $BIN/v-unsuspend-dns-domain "$user" "$domain" 'no' +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart dns server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-dns "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-unsuspend-mail-account b/bin/v-unsuspend-mail-account index 2cf7216aa..0d6e84df4 100755 --- a/bin/v-unsuspend-mail-account +++ b/bin/v-unsuspend-mail-account @@ -1,61 +1,61 @@ -#!/bin/bash -# info: unsuspend mail account -# options: user domain account -# -# The function unsuspends mail account. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -account=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'user domain account' -validate_format 'user' 'domain' 'account' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_suspended "mail/$domain" 'ACCOUNT' "$account" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -md5=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$MD5') -quota=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$QUOTA') -sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd -str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota" -echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$SUSPENDED' 'no' - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: unsuspend mail account +# options: USER DOMAIN ACCOUNT +# +# The function unsuspends mail account. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +account=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN ACCOUNT' +validate_format 'user' 'domain' 'account' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_valid "mail/$domain" 'ACCOUNT' "$account" +is_object_suspended "mail/$domain" 'ACCOUNT' "$account" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +md5=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$MD5') +quota=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$QUOTA') +sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd +str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota" +echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value "mail/$domain" 'ACCOUNT' "$account" '$SUSPENDED' 'no' + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-unsuspend-mail-accounts b/bin/v-unsuspend-mail-accounts index e71f57901..2793235bb 100755 --- a/bin/v-unsuspend-mail-accounts +++ b/bin/v-unsuspend-mail-accounts @@ -1,53 +1,53 @@ -#!/bin/bash -# info: unsuspend all mail domain accounts -# options: user domain -# -# The function unsuspends all mail domain accounts. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain' -validate_format 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting unsuspend loop -for account in $(search_objects "mail/$domain" 'SUSPENDED' 'yes' 'ACCOUNT'); do - $BIN/v-unsuspend-mail-account "$user" "$domain" "$account" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# No Logging -#log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: unsuspend all mail domain accounts +# options: USER DOMAIN +# +# The function unsuspends all mail domain accounts. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting unsuspend loop +for account in $(search_objects "mail/$domain" 'SUSPENDED' 'yes' 'ACCOUNT'); do + $BIN/v-unsuspend-mail-account "$user" "$domain" "$account" +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# No Logging +#log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-unsuspend-mail-domain b/bin/v-unsuspend-mail-domain index 7f2504d5e..42d3f619f 100755 --- a/bin/v-unsuspend-mail-domain +++ b/bin/v-unsuspend-mail-domain @@ -1,57 +1,57 @@ -#!/bin/bash -# info: unsuspend mail domain -# options: user domain -# -# The function unsuspends mail domain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain' -validate_format 'user' 'domain' -is_system_enabled 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_suspended 'mail' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Add symbolic link -ln -s $HOMEDIR/$user/conf/mail/$domain /etc/exim/domains/ - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating config -update_object_value 'mail' 'DOMAIN' "$domain" '$SUSPENDED' 'no' -sed -i "s/SUSPENDED='yes'/SUSPENDED='no'/g" $USER_DATA/mail/$domain.conf -decrease_user_value "$user" '$SUSPENDED_MAIL' - - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: unsuspend mail domain +# options: USER DOMAIN +# +# The function unsuspends mail domain. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled 'MAIL_SYSTEM' +is_object_valid 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_suspended 'mail' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Add symbolic link +ln -s $HOMEDIR/$user/conf/mail/$domain /etc/exim/domains/ + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Updating config +update_object_value 'mail' 'DOMAIN' "$domain" '$SUSPENDED' 'no' +sed -i "s/SUSPENDED='yes'/SUSPENDED='no'/g" $USER_DATA/mail/$domain.conf +decrease_user_value "$user" '$SUSPENDED_MAIL' + + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-unsuspend-mail-domains b/bin/v-unsuspend-mail-domains index a1c37bc68..538f427fb 100755 --- a/bin/v-unsuspend-mail-domains +++ b/bin/v-unsuspend-mail-domains @@ -1,48 +1,48 @@ -#!/bin/bash -# info: unsuspend mail domains -# options: user -# -# The function unsuspends all user's MAIL domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user' -validate_format 'user' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting unsuspend loop -for domain in $(search_objects 'mail' 'SUSPENDED' "yes" 'DOMAIN'); do - $BIN/v-unsuspend-mail-domain "$user" "$domain" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: unsuspend mail domains +# options: USER +# +# The function unsuspends all user's MAIL domains. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting unsuspend loop +for domain in $(search_objects 'mail' 'SUSPENDED' "yes" 'DOMAIN'); do + $BIN/v-unsuspend-mail-domain "$user" "$domain" +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-unsuspend-user b/bin/v-unsuspend-user index 10ecbc23e..445ee2222 100755 --- a/bin/v-unsuspend-user +++ b/bin/v-unsuspend-user @@ -1,83 +1,83 @@ -#!/bin/bash -# info: unsuspend user -# options: user [restart] -# -# The function unsuspends user and all his objects. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -restart=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" -if [ "$user" = 'admin' ]; then - exit -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting '!' in front of the password -/usr/sbin/usermod --unlock $user - -# Unsuspending web domains -if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then - $BIN/v-unsuspend-web-domains $user $restart -fi - -# Unsuspending dns domains -if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then - $BIN/v-unsuspend-dns-domains $user $restart -fi - -# Unsuspending mail domains -if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then - $BIN/v-unsuspend-mail-domains $user -fi - -# Unsuspending datbabases -if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then - $BIN/v-unsuspend-databases $user -fi - -# Unsuspending cron jobs -if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then - $BIN/v-unsuspend-cron-jobs $user $restart -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Changing suspend value -update_user_value "$user" '$SUSPENDED' 'no' -decrease_user_value 'admin' '$SUSPENDED_USERS' - -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" - $BIN/v-restart-dns "$EVENT" - $BIN/v-restart-cron "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: unsuspend user +# options: USER [RESTART] +# +# The function unsuspends user and all his objects. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +restart=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" +if [ "$user" = 'admin' ]; then + exit +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Deleting '!' in front of the password +/usr/sbin/usermod --unlock $user + +# Unsuspending web domains +if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then + $BIN/v-unsuspend-web-domains $user $restart +fi + +# Unsuspending dns domains +if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then + $BIN/v-unsuspend-dns-domains $user $restart +fi + +# Unsuspending mail domains +if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then + $BIN/v-unsuspend-mail-domains $user +fi + +# Unsuspending datbabases +if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then + $BIN/v-unsuspend-databases $user +fi + +# Unsuspending cron jobs +if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then + $BIN/v-unsuspend-cron-jobs $user $restart +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Changing suspend value +update_user_value "$user" '$SUSPENDED' 'no' +decrease_user_value 'admin' '$SUSPENDED_USERS' + +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" + $BIN/v-restart-dns "$EVENT" + $BIN/v-restart-cron "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-unsuspend-web-domain b/bin/v-unsuspend-web-domain index 85d1dbcd3..857d99d02 100755 --- a/bin/v-unsuspend-web-domain +++ b/bin/v-unsuspend-web-domain @@ -1,93 +1,93 @@ -#!/bin/bash -# info: unsuspend web domain -# options: user domain -# -# The function of unsuspending the domain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -restart="$3" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain [restart]' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_suspended 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain values -get_domain_values 'web' -tpl_file="$WEBTPL/apache_$TPL.tpl" -conf="$HOMEDIR/$user/conf/web/httpd.conf" -SUSPENDED='no' - -# Preparing domain values for the template substitution -upd_web_domain_values - -# Recreating vhost -del_web_config -add_web_config - -# Check ssl -if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/apache_$TPL.stpl" - conf="$HOMEDIR/$user/conf/web/shttpd.conf" - del_web_config - add_web_config -fi - -# Checking nginx -if [ ! -z "$NGINX" ]; then - tpl_file="$WEBTPL/nginx_$NGINX.tpl" - conf="$HOMEDIR/$user/conf/web/nginx.conf" - del_web_config - add_web_config - - if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web/snginx.conf" - del_web_config - add_web_config - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$SUSPENDED' 'no' -decrease_user_value "$user" '$SUSPENDED_WEB' - -# Restart web erver -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: unsuspend web domain +# options: USER DOMAIN +# +# The function of unsuspending the domain. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +restart="$3" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [RESTART]' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_suspended 'web' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Parsing domain values +get_domain_values 'web' +tpl_file="$WEBTPL/apache_$TPL.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" +SUSPENDED='no' + +# Preparing domain values for the template substitution +upd_web_domain_values + +# Recreating vhost +del_web_config +add_web_config + +# Check ssl +if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" + del_web_config + add_web_config +fi + +# Checking nginx +if [ ! -z "$NGINX" ]; then + tpl_file="$WEBTPL/nginx_$NGINX.tpl" + conf="$HOMEDIR/$user/conf/web/nginx.conf" + del_web_config + add_web_config + + if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + del_web_config + add_web_config + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$SUSPENDED' 'no' +decrease_user_value "$user" '$SUSPENDED_WEB' + +# Restart web erver +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-unsuspend-web-domains b/bin/v-unsuspend-web-domains index 474766fac..c899ed7c4 100755 --- a/bin/v-unsuspend-web-domains +++ b/bin/v-unsuspend-web-domains @@ -1,54 +1,54 @@ -#!/bin/bash -# info: unsuspend web domains -# options: user [restart] -# -# The function of unsuspending all user's sites. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -restart=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user [restart]' -validate_format 'user' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting unsuspend loop -for domain in $(search_objects 'web' 'SUSPENDED' "yes" 'DOMAIN'); do - $BIN/v-unsuspend-web-domain "$user" "$domain" 'no' -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart web server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: unsuspend web domains +# options: USER [RESTART] +# +# The function of unsuspending all user's sites. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +restart=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [RESTART]' +validate_format 'user' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting unsuspend loop +for domain in $(search_objects 'web' 'SUSPENDED' "yes" 'DOMAIN'); do + $BIN/v-unsuspend-web-domain "$user" "$domain" 'no' +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart web server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-update-database-disk b/bin/v-update-database-disk index 528a031c9..30bd5d2bd 100755 --- a/bin/v-update-database-disk +++ b/bin/v-update-database-disk @@ -1,60 +1,60 @@ -#!/bin/bash -# info: update database disk usage -# options: user database -# -# The function recalculates disk usage for speciefic database. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -database=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/db.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user database' -validate_format 'user' 'database' -is_system_enabled "$DB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'db' 'DB' "$database" -is_object_unsuspended 'db' 'DB' "$database" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get database values -get_database_values - -# Switching on db type -case $TYPE in - mysql) get_mysql_disk_usage ;; - pgsql) get_pgsql_disk_usage ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating disk usage -update_object_value 'db' 'DB' "$database" '$U_DISK' "$usage" -recalc_user_disk_usage - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: update database disk usage +# options: USER DATABASE +# +# The function recalculates disk usage for speciefic database. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +database=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/db.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DATABASE' +validate_format 'user' 'database' +is_system_enabled "$DB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'db' 'DB' "$database" +is_object_unsuspended 'db' 'DB' "$database" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Get database values +get_database_values + +# Switching on db type +case $TYPE in + mysql) get_mysql_disk_usage ;; + pgsql) get_pgsql_disk_usage ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Updating disk usage +update_object_value 'db' 'DB' "$database" '$U_DISK' "$usage" +recalc_user_disk_usage + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-update-databases-disk b/bin/v-update-databases-disk index 1031a1b0b..86fe6aba4 100755 --- a/bin/v-update-databases-disk +++ b/bin/v-update-databases-disk @@ -1,47 +1,47 @@ -#!/bin/bash -# info: update databases disk usage -# options: user -# -# The function recalculates disk usage for all user databases. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user' -validate_format 'user' -is_system_enabled "$DB_SYSTEM" -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting update loop -for database in $(search_objects 'db' 'SUSPENDED' "no" 'DB'); do - $BIN/v-update-database-disk "$user" "$database" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: update databases disk usage +# options: USER +# +# The function recalculates disk usage for all user databases. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_system_enabled "$DB_SYSTEM" +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting update loop +for database in $(search_objects 'db' 'SUSPENDED' "no" 'DB'); do + $BIN/v-update-database-disk "$user" "$database" +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-update-mail-domain-disk b/bin/v-update-mail-domain-disk index 8919afed0..1bac15ad0 100755 --- a/bin/v-update-mail-domain-disk +++ b/bin/v-update-mail-domain-disk @@ -1,64 +1,64 @@ -#!/bin/bash -# info: update mail domain disk usage -# options: user domain -# -# The function updates domain disk usage. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain' -validate_format 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting loop -dom_diks=0 -for account in $(search_objects "mail/$domain" 'SUSPENDED' "no" 'ACCOUNT'); do - home_dir=$HOMEDIR/$user/mail/$domain/$account - if [ -e "$home_dir" ]; then - udisk=$(nice -n 19 du -shm $home_dir | cut -f 1 ) - else - udisk=0 - fi - update_object_value "mail/$domain" 'ACCOUNT' "$account" '$U_DISK' "$udisk" - dom_diks=$((dom_diks + udisk)) -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -update_object_value 'mail' 'DOMAIN' "$domain" '$U_DISK' "$dom_diks" -recalc_user_disk_usage - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: update mail domain disk usage +# options: USER DOMAIN +# +# The function updates domain disk usage. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting loop +dom_diks=0 +for account in $(search_objects "mail/$domain" 'SUSPENDED' "no" 'ACCOUNT'); do + home_dir=$HOMEDIR/$user/mail/$domain/$account + if [ -e "$home_dir" ]; then + udisk=$(nice -n 19 du -shm $home_dir | cut -f 1 ) + else + udisk=0 + fi + update_object_value "mail/$domain" 'ACCOUNT' "$account" '$U_DISK' "$udisk" + dom_diks=$((dom_diks + udisk)) +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +update_object_value 'mail' 'DOMAIN' "$domain" '$U_DISK' "$dom_diks" +recalc_user_disk_usage + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-update-mail-domains-disk b/bin/v-update-mail-domains-disk index d2c835c73..1090fc588 100755 --- a/bin/v-update-mail-domains-disk +++ b/bin/v-update-mail-domains-disk @@ -1,63 +1,63 @@ -#!/bin/bash -# info: calculate disk usage for all mail domains -# options: user -# -# The function calculates disk usage for all mail domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user' -validate_format 'user' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting loop -for domain in $(search_objects 'mail' 'SUSPENDED' "no" 'DOMAIN'); do - dom_diks=0 - accounts=$(search_objects "mail/$domain" 'SUSPENDED' "no" 'ACCOUNT') - for account in $accounts; do - home_dir=$HOMEDIR/$user/mail/$domain/$account - if [ -e "$home_dir" ]; then - udisk=$(nice -n 19 du -shm $home_dir | cut -f 1 ) - else - udisk=0 - fi - update_object_value "mail/$domain" 'ACCOUNT' "$account" '$U_DISK' "$udisk" - dom_diks=$((dom_diks + udisk)) - done - update_object_value 'mail' 'DOMAIN' "$domain" '$U_DISK' "$dom_diks" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - - -recalc_user_disk_usage - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: calculate disk usage for all mail domains +# options: USER +# +# The function calculates disk usage for all mail domains. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting loop +for domain in $(search_objects 'mail' 'SUSPENDED' "no" 'DOMAIN'); do + dom_diks=0 + accounts=$(search_objects "mail/$domain" 'SUSPENDED' "no" 'ACCOUNT') + for account in $accounts; do + home_dir=$HOMEDIR/$user/mail/$domain/$account + if [ -e "$home_dir" ]; then + udisk=$(nice -n 19 du -shm $home_dir | cut -f 1 ) + else + udisk=0 + fi + update_object_value "mail/$domain" 'ACCOUNT' "$account" '$U_DISK' "$udisk" + dom_diks=$((dom_diks + udisk)) + done + update_object_value 'mail' 'DOMAIN' "$domain" '$U_DISK' "$dom_diks" +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + + +recalc_user_disk_usage + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-update-sys-ip b/bin/v-update-sys-ip index c34387e37..9ced5b1f7 100755 --- a/bin/v-update-sys-ip +++ b/bin/v-update-sys-ip @@ -1,93 +1,93 @@ -#!/bin/bash -# info: update system ip -# options: [user] [ip_status] -# -# The function scans configured ip in the system and register them with vesta -# internal database. This call is intended for use on vps servers, where ip is -# set by hypervizor. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=${1-admin} -ip_status=${2-shared} - -# Includes -source $VESTA/conf/vesta.conf # include for internal func -source $VESTA/func/main.sh -source $VESTA/func/ip.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '0' "$#" '[user] [ip_status]' -validate_format 'user' 'ip_status' -is_object_valid 'user' 'USER' "$user" "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get ip list -ip_list=$(/sbin/ifconfig | grep 'inet addr:' | cut -f 2 -d : | \ - cut -f 1 -d ' '| grep -v 127.0.0.1) - -# Get vesta registered ip list -vesta_ip_list=$(ls $VESTA/data/ips/) - -# Defining config paths -conf='/etc/httpd/conf.d/vesta.conf' -nconf='/etc/nginx/conf.d/vesta_ip.conf' -iconf='/etc/sysconfig/network-scripts/ifcfg' -rconf='/etc/httpd/conf.d/mod_extract_forwarded.conf' - -# Comparing each ip -for ip in $ip_list; do - check_ip=$(echo $vesta_ip_list | grep -w "$ip") - - # Checking ip registered - if [ -z "$check_ip" ]; then - # Parsing additional params - iface=$(/sbin/ifconfig |grep -B1 -w $ip |head -n 1 |cut -f 1 -d ' ') - interface=$(echo "$iface" | cut -f 1 -d :) - mask=$(/sbin/ifconfig |grep -w $ip |awk -F "Mask:" '{print $2}') - - # Adding vesta ip - create_vesta_ip - - # Adding namehosting support - namehost_ip_support - - # Creating startup script - if [ ! -e "$iconf-$iface" ]; then - create_vesta_ip - fi - fi - - # TBD: revers comparation -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating user conf -increase_user_value "$user" '$IP_OWNED' - -# Restart web server -if [ "$web_restart" = 'yes' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: update system ip +# options: [USER] [IP_STATUS] +# +# The function scans configured ip in the system and register them with vesta +# internal database. This call is intended for use on vps servers, where ip is +# set by hypervizor. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=${1-admin} +ip_status=${2-shared} + +# Includes +source $VESTA/conf/vesta.conf # include for internal func +source $VESTA/func/main.sh +source $VESTA/func/ip.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '0' "$#" '[USER] [IP_STATUS]' +validate_format 'user' 'ip_status' +is_object_valid 'user' 'USER' "$user" "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Get ip list +ip_list=$(/sbin/ifconfig | grep 'inet addr:' | cut -f 2 -d : | \ + cut -f 1 -d ' '| grep -v 127.0.0.1) + +# Get vesta registered ip list +vesta_ip_list=$(ls $VESTA/data/ips/) + +# Defining config paths +conf='/etc/httpd/conf.d/vesta.conf' +nconf='/etc/nginx/conf.d/vesta_ip.conf' +iconf='/etc/sysconfig/network-scripts/ifcfg' +rconf='/etc/httpd/conf.d/mod_extract_forwarded.conf' + +# Comparing each ip +for ip in $ip_list; do + check_ip=$(echo $vesta_ip_list | grep -w "$ip") + + # Checking ip registered + if [ -z "$check_ip" ]; then + # Parsing additional params + iface=$(/sbin/ifconfig |grep -B1 -w $ip |head -n 1 |cut -f 1 -d ' ') + interface=$(echo "$iface" | cut -f 1 -d :) + mask=$(/sbin/ifconfig |grep -w $ip |awk -F "Mask:" '{print $2}') + + # Adding vesta ip + create_vesta_ip + + # Adding namehosting support + namehost_ip_support + + # Creating startup script + if [ ! -e "$iconf-$iface" ]; then + create_vesta_ip + fi + fi + + # TBD: revers comparation +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Updating user conf +increase_user_value "$user" '$IP_OWNED' + +# Restart web server +if [ "$web_restart" = 'yes' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-update-sys-queue b/bin/v-update-sys-queue index 54b4d1963..0cb530c21 100755 --- a/bin/v-update-sys-queue +++ b/bin/v-update-sys-queue @@ -1,61 +1,61 @@ -#!/bin/bash -# info: update system queue -# options: pipe -# -# This function is responsible queue processing. Restarts of services, -# scheduled backups, web log parsing and other heavy resource consuming -# operations are handled by this script. It helps to optimize system behaviour. -# In a nutshell Apache will be restarted only once even if 10 domains are -# added or deleted. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# -# Argument defenition -queue=$1 - -# Importing system enviroment as we run this script -# mostly by cron wich not read it by itself -source /etc/profile - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - -# Export PATH for cron -PATH=$PATH:$BIN - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'queue' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining pipe functions -case $queue in - restart) bash $VESTA/data/queue/restart.pipe; - rm $VESTA/data/queue/restart.pipe; - touch $VESTA/data/queue/restart.pipe;; - webstats) bash $VESTA/data/queue/webstats.pipe > /dev/null 2>&1 ;; - backup) bash $VESTA/data/queue/backup.pipe;; - disk) bash $VESTA/data/queue/disk.pipe;; - traffic) bash $VESTA/data/queue/traffic.pipe;; - *) check_args '1' '0' 'queue' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# No Logging -#log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: update system queue +# options: PIPE +# +# This function is responsible queue processing. Restarts of services, +# scheduled backups, web log parsing and other heavy resource consuming +# operations are handled by this script. It helps to optimize system behaviour. +# In a nutshell Apache will be restarted only once even if 10 domains are +# added or deleted. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# +# Argument defenition +queue=$1 + +# Importing system enviroment as we run this script +# mostly by cron wich not read it by itself +source /etc/profile + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + +# Export PATH for cron +PATH=$PATH:$BIN + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'QUEUE' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining pipe functions +case $queue in + restart) bash $VESTA/data/queue/restart.pipe; + rm $VESTA/data/queue/restart.pipe; + touch $VESTA/data/queue/restart.pipe;; + webstats) bash $VESTA/data/queue/webstats.pipe > /dev/null 2>&1 ;; + backup) bash $VESTA/data/queue/backup.pipe;; + disk) bash $VESTA/data/queue/disk.pipe;; + traffic) bash $VESTA/data/queue/traffic.pipe;; + *) check_args '1' '0' 'QUEUE' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# No Logging +#log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-update-sys-rrd b/bin/v-update-sys-rrd index e264d4fc6..263409fcc 100755 --- a/bin/v-update-sys-rrd +++ b/bin/v-update-sys-rrd @@ -1,137 +1,137 @@ -#!/bin/bash -# info: update system rrd charts -# options: none -# -# The script is wrapper for all rrd functions. It updates all -# v-update-sys-rrd_* at once. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Importing system enviroment as we run this script -# mostly by cron wich do not read it by itself -source /etc/profile - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - -# Another workaround for cron enviroment -PATH="$PATH:$BIN" -export PATH - -# Checking rrddir -if [ ! -d "$RRD" ]; then - mkdir -p $RRD -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Checking daily period -if [ -e "$RRD/daily.rrd" ]; then - mtime=$(stat -c "%Y" $RRD/daily.rrd) - ctime=$(date +%s) - dtime=$((ctime - mtime)) - # Update every 5 minute - if [ "$dtime" -gt '290' ]; then - touch $RRD/daily.rrd - periods="$periods daily" - fi -else - touch $RRD/daily.rrd - periods="$periods daily" -fi - -# Checking weekly period -if [ -e "$RRD/weekly.rrd" ]; then - mtime=$(stat -c "%Y" $RRD/weekly.rrd) - ctime=$(date +%s) - dtime=$((ctime - mtime)) - # Update every hour - if [ "$dtime" -gt '3590' ]; then - touch $RRD/weekly.rrd - periods="$periods weekly" - fi -else - touch $RRD/weekly.rrd - periods="$periods weekly" -fi - -# Checking monthly period -if [ -e "$RRD/monthly.rrd" ]; then - mtime=$(stat -c "%Y" $RRD/monthly.rrd) - ctime=$(date +%s) - dtime=$((ctime - mtime)) - # Update every 6 hours - if [ "$dtime" -gt '21590' ]; then - touch $RRD/monthly.rrd - periods="$periods monthly" - fi -else - touch $RRD/monthly.rrd - periods="$periods monthly" -fi - -# Checking yearly period -if [ -e "$RRD/yearly.rrd" ]; then - mtime=$(stat -c "%Y" $RRD/yearly.rrd) - ctime=$(date +%s) - dtime=$((ctime - mtime)) - # Update every 12 hours - if [ "$dtime" -gt '43190' ]; then - touch $RRD/yearly.rrd - periods="$periods yearly" - fi -else - touch $RRD/yearly.rrd - periods="$periods yearly" -fi - - -# Updateing system stats -for period in $periods; do - - $BIN/v-update-sys-rrd-la $period - $BIN/v-update-sys-rrd-net $period - $BIN/v-update-sys-rrd-mem $period - $BIN/v-update-sys-rrd-ssh $period - - # Updating web stats - if [ "$WEB_SYSTEM" = 'apache' ]; then - $BIN/v-update-sys-rrd-httpd $period - fi - - if [ "$PROXY_SYSTEM" = 'nginx' ]; then - $BIN/v-update-sys-rrd-nginx $period - fi - - # Updating ftp stats - if [ ! -z "$FTP_SYSTEM" ] && [ "$FTP_SYSTEM" != 'no' ]; then - $BIN/v-update-sys-rrd-ftp $period - fi - - # Updating db stats - if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then - for type in ${DB_SYSTEM//,/ }; do - # Switching on db type - case $type in - mysql) $BIN/v-update-sys-rrd-mysql $period ;; - pgsql) $BIN/v-update-sys-rrd-pgsql $period ;; - esac - done - fi -done - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# No Logging -#log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: update system rrd charts +# options: NONE +# +# The script is wrapper for all rrd functions. It updates all +# v-update-sys-rrd_* at once. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Importing system enviroment as we run this script +# mostly by cron wich do not read it by itself +source /etc/profile + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + +# Another workaround for cron enviroment +PATH="$PATH:$BIN" +export PATH + +# Checking rrddir +if [ ! -d "$RRD" ]; then + mkdir -p $RRD +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Checking daily period +if [ -e "$RRD/daily.rrd" ]; then + mtime=$(stat -c "%Y" $RRD/daily.rrd) + ctime=$(date +%s) + dtime=$((ctime - mtime)) + # Update every 5 minute + if [ "$dtime" -gt '290' ]; then + touch $RRD/daily.rrd + periods="$periods daily" + fi +else + touch $RRD/daily.rrd + periods="$periods daily" +fi + +# Checking weekly period +if [ -e "$RRD/weekly.rrd" ]; then + mtime=$(stat -c "%Y" $RRD/weekly.rrd) + ctime=$(date +%s) + dtime=$((ctime - mtime)) + # Update every hour + if [ "$dtime" -gt '3590' ]; then + touch $RRD/weekly.rrd + periods="$periods weekly" + fi +else + touch $RRD/weekly.rrd + periods="$periods weekly" +fi + +# Checking monthly period +if [ -e "$RRD/monthly.rrd" ]; then + mtime=$(stat -c "%Y" $RRD/monthly.rrd) + ctime=$(date +%s) + dtime=$((ctime - mtime)) + # Update every 6 hours + if [ "$dtime" -gt '21590' ]; then + touch $RRD/monthly.rrd + periods="$periods monthly" + fi +else + touch $RRD/monthly.rrd + periods="$periods monthly" +fi + +# Checking yearly period +if [ -e "$RRD/yearly.rrd" ]; then + mtime=$(stat -c "%Y" $RRD/yearly.rrd) + ctime=$(date +%s) + dtime=$((ctime - mtime)) + # Update every 12 hours + if [ "$dtime" -gt '43190' ]; then + touch $RRD/yearly.rrd + periods="$periods yearly" + fi +else + touch $RRD/yearly.rrd + periods="$periods yearly" +fi + + +# Updateing system stats +for period in $periods; do + + $BIN/v-update-sys-rrd-la $period + $BIN/v-update-sys-rrd-net $period + $BIN/v-update-sys-rrd-mem $period + $BIN/v-update-sys-rrd-ssh $period + + # Updating web stats + if [ "$WEB_SYSTEM" = 'apache' ]; then + $BIN/v-update-sys-rrd-httpd $period + fi + + if [ "$PROXY_SYSTEM" = 'nginx' ]; then + $BIN/v-update-sys-rrd-nginx $period + fi + + # Updating ftp stats + if [ ! -z "$FTP_SYSTEM" ] && [ "$FTP_SYSTEM" != 'no' ]; then + $BIN/v-update-sys-rrd-ftp $period + fi + + # Updating db stats + if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then + for type in ${DB_SYSTEM//,/ }; do + # Switching on db type + case $type in + mysql) $BIN/v-update-sys-rrd-mysql $period ;; + pgsql) $BIN/v-update-sys-rrd-pgsql $period ;; + esac + done + fi +done + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# No Logging +#log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-update-sys-rrd-ftp b/bin/v-update-sys-rrd-ftp index e79623bcf..270f39752 100755 --- a/bin/v-update-sys-rrd-ftp +++ b/bin/v-update-sys-rrd-ftp @@ -1,97 +1,97 @@ -#!/bin/bash -# info: update ftp rrd -# options: period -# -# The function is for updating ftpd rrd database and graphic. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -period=${1-daily} - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on time period -case $period in - daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; - weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; - monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; - yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; - *) exit $E_RRD ;; -esac - -# Checking directory -if [ ! -d "$RRD/ftp" ]; then - mkdir $RRD/ftp -fi - -# Checking database -if [ ! -e "$RRD/ftp/ftp.rrd" ]; then - # Adding database - rrdtool create $RRD/ftp/ftp.rrd --step $RRD_STEP \ - DS:A:GAUGE:600:U:U \ - RRA:AVERAGE:0.5:1:600 \ - RRA:AVERAGE:0.5:6:700 \ - RRA:AVERAGE:0.5:24:775 \ - RRA:AVERAGE:0.5:288:797 \ - RRA:MAX:0.5:1:600 \ - RRA:MAX:0.5:6:700 \ - RRA:MAX:0.5:24:775 \ - RRA:MAX:0.5:288:797 -fi - -# Parsing data -if [ "$period" = 'daily' ]; then - a=0 - a=$(ps aux |grep $FTP_SYSTEM |grep -v grep| grep -v nobody|\ - grep -v root|wc -l) - - # Updating rrd database - rrdtool update $RRD/ftp/ftp.rrd N:$a -fi - -# Updating rrd graph -rrdtool graph $RRD/ftp/$period-ftp.png \ - --imgformat PNG \ - --height="120" \ - --width="440" \ - --start "$start" \ - --end "$end" \ - --vertical-label "Connections" \ - --x-grid "$grid" \ - -c "BACK#7a766d" \ - -c "SHADEA#7a766d" \ - -c "SHADEB#7a766d" \ - -c "FONT#FFFFFF" \ - -c "CANVAS#302c2d" \ - -c "GRID#666666" \ - -c "MGRID#AAAAAA" \ - -c "FRAME#302c2d" \ - -c "ARROW#FFFFFF" \ - DEF:a=$RRD/ftp/ftp.rrd:A:AVERAGE \ - COMMENT:'\r' \ - LINE1:a#fefda0:"Users " \ - GPRINT:a:'LAST:Current\:''%8.0lf' \ - GPRINT:a:'MIN:Min\:''%8.0lf' \ - GPRINT:a:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -if [ "$result" -ne 0 ]; then - exit $E_RRD -fi - -exit +#!/bin/bash +# info: update ftp rrd +# options: PERIOD +# +# The function is for updating ftpd rrd database and graphic. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +period=${1-daily} + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Switching on time period +case $period in + daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; + weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; + monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; + yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; + *) exit $E_RRD ;; +esac + +# Checking directory +if [ ! -d "$RRD/ftp" ]; then + mkdir $RRD/ftp +fi + +# Checking database +if [ ! -e "$RRD/ftp/ftp.rrd" ]; then + # Adding database + rrdtool create $RRD/ftp/ftp.rrd --step $RRD_STEP \ + DS:A:GAUGE:600:U:U \ + RRA:AVERAGE:0.5:1:600 \ + RRA:AVERAGE:0.5:6:700 \ + RRA:AVERAGE:0.5:24:775 \ + RRA:AVERAGE:0.5:288:797 \ + RRA:MAX:0.5:1:600 \ + RRA:MAX:0.5:6:700 \ + RRA:MAX:0.5:24:775 \ + RRA:MAX:0.5:288:797 +fi + +# Parsing data +if [ "$period" = 'daily' ]; then + a=0 + a=$(ps aux |grep $FTP_SYSTEM |grep -v grep| grep -v nobody|\ + grep -v root|wc -l) + + # Updating rrd database + rrdtool update $RRD/ftp/ftp.rrd N:$a +fi + +# Updating rrd graph +rrdtool graph $RRD/ftp/$period-ftp.png \ + --imgformat PNG \ + --height="120" \ + --width="440" \ + --start "$start" \ + --end "$end" \ + --vertical-label "Connections" \ + --x-grid "$grid" \ + -c "BACK#7a766d" \ + -c "SHADEA#7a766d" \ + -c "SHADEB#7a766d" \ + -c "FONT#FFFFFF" \ + -c "CANVAS#302c2d" \ + -c "GRID#666666" \ + -c "MGRID#AAAAAA" \ + -c "FRAME#302c2d" \ + -c "ARROW#FFFFFF" \ + DEF:a=$RRD/ftp/ftp.rrd:A:AVERAGE \ + COMMENT:'\r' \ + LINE1:a#fefda0:"Users " \ + GPRINT:a:'LAST:Current\:''%8.0lf' \ + GPRINT:a:'MIN:Min\:''%8.0lf' \ + GPRINT:a:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +if [ "$result" -ne 0 ]; then + exit $E_RRD +fi + +exit diff --git a/bin/v-update-sys-rrd-httpd b/bin/v-update-sys-rrd-httpd index 297d1028a..bc490bf5c 100755 --- a/bin/v-update-sys-rrd-httpd +++ b/bin/v-update-sys-rrd-httpd @@ -1,103 +1,103 @@ -#!/bin/bash -# info: update httpd rrd -# options: period -# -# The function is for updating apache rrd database and graphic. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -period=${1-daily} - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on time period -case $period in - daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; - weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; - monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; - yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; - *) exit $E_RRD ;; -esac - - -# Checking directory -if [ ! -d "$RRD/web" ]; then - mkdir $RRD/web -fi - -# Checking database -if [ ! -e "$RRD/web/httpd.rrd" ]; then - # Adding database - rrdtool create $RRD/web/httpd.rrd --step $RRD_STEP \ - DS:A:GAUGE:600:U:U \ - RRA:AVERAGE:0.5:1:600 \ - RRA:AVERAGE:0.5:6:700 \ - RRA:AVERAGE:0.5:24:775 \ - RRA:AVERAGE:0.5:288:797 \ - RRA:MAX:0.5:1:600 \ - RRA:MAX:0.5:6:700 \ - RRA:MAX:0.5:24:775 \ - RRA:MAX:0.5:288:797 -fi - -# Parsing data -if [ "$period" = 'daily' ]; then - server_status=$(wget -qO- http://localhost:8081/server-status |\ - grep 'currently being processed'| \ - cut -f 2 -d '>' |\ - sed 's/requests currently being processed, //' | \ - cut -f 1,2 -d ' ') - active=$(echo "$server_status"|cut -f 1 -d ' ') - idle=$(echo "$server_status"|cut -f 1 -d ' ') - a=$((active + idle)) - - # Updating rrd database - rrdtool update $RRD/web/httpd.rrd N:$a -fi - -# Updating rrd graph -rrdtool graph $RRD/web/$period-httpd.png \ - --imgformat PNG \ - --height="120" \ - --width="440" \ - --start "$start" \ - --end "$end" \ - --vertical-label "Connections" \ - --x-grid "$grid" \ - -c "BACK#7a766d" \ - -c "SHADEA#7a766d" \ - -c "SHADEB#7a766d" \ - -c "FONT#FFFFFF" \ - -c "CANVAS#302c2d" \ - -c "GRID#666666" \ - -c "MGRID#AAAAAA" \ - -c "FRAME#302c2d" \ - -c "ARROW#FFFFFF" \ - DEF:a=$RRD/web/httpd.rrd:A:AVERAGE \ - COMMENT:'\r' \ - LINE1:a#fefda0:"Connections " \ - GPRINT:a:'LAST:Current\:''%8.0lf' \ - GPRINT:a:'MIN:Min\:''%8.0lf' \ - GPRINT:a:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -if [ "$result" -ne 0 ]; then - exit $E_RRD -fi - -exit +#!/bin/bash +# info: update httpd rrd +# options: PERIOD +# +# The function is for updating apache rrd database and graphic. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +period=${1-daily} + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Switching on time period +case $period in + daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; + weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; + monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; + yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; + *) exit $E_RRD ;; +esac + + +# Checking directory +if [ ! -d "$RRD/web" ]; then + mkdir $RRD/web +fi + +# Checking database +if [ ! -e "$RRD/web/httpd.rrd" ]; then + # Adding database + rrdtool create $RRD/web/httpd.rrd --step $RRD_STEP \ + DS:A:GAUGE:600:U:U \ + RRA:AVERAGE:0.5:1:600 \ + RRA:AVERAGE:0.5:6:700 \ + RRA:AVERAGE:0.5:24:775 \ + RRA:AVERAGE:0.5:288:797 \ + RRA:MAX:0.5:1:600 \ + RRA:MAX:0.5:6:700 \ + RRA:MAX:0.5:24:775 \ + RRA:MAX:0.5:288:797 +fi + +# Parsing data +if [ "$period" = 'daily' ]; then + server_status=$(wget -qO- http://localhost:8081/server-status |\ + grep 'currently being processed'| \ + cut -f 2 -d '>' |\ + sed 's/requests currently being processed, //' | \ + cut -f 1,2 -d ' ') + active=$(echo "$server_status"|cut -f 1 -d ' ') + idle=$(echo "$server_status"|cut -f 1 -d ' ') + a=$((active + idle)) + + # Updating rrd database + rrdtool update $RRD/web/httpd.rrd N:$a +fi + +# Updating rrd graph +rrdtool graph $RRD/web/$period-httpd.png \ + --imgformat PNG \ + --height="120" \ + --width="440" \ + --start "$start" \ + --end "$end" \ + --vertical-label "Connections" \ + --x-grid "$grid" \ + -c "BACK#7a766d" \ + -c "SHADEA#7a766d" \ + -c "SHADEB#7a766d" \ + -c "FONT#FFFFFF" \ + -c "CANVAS#302c2d" \ + -c "GRID#666666" \ + -c "MGRID#AAAAAA" \ + -c "FRAME#302c2d" \ + -c "ARROW#FFFFFF" \ + DEF:a=$RRD/web/httpd.rrd:A:AVERAGE \ + COMMENT:'\r' \ + LINE1:a#fefda0:"Connections " \ + GPRINT:a:'LAST:Current\:''%8.0lf' \ + GPRINT:a:'MIN:Min\:''%8.0lf' \ + GPRINT:a:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +if [ "$result" -ne 0 ]; then + exit $E_RRD +fi + +exit diff --git a/bin/v-update-sys-rrd-la b/bin/v-update-sys-rrd-la index 8879446b9..371fbeb41 100755 --- a/bin/v-update-sys-rrd-la +++ b/bin/v-update-sys-rrd-la @@ -1,103 +1,103 @@ -#!/bin/bash -# info: update load average rrd -# options: period -# -# The function is for updating load average rrd database and graphic. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -period=${1-daily} - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on time period -case $period in - daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; - weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; - monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; - yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; - *) exit $E_RRD ;; -esac - -# Checking directory -if [ ! -d "$RRD/la" ]; then - mkdir $RRD/la -fi - -# Checking database -if [ ! -e "$RRD/la/la.rrd" ]; then - # Adding database - rrdtool create $RRD/la/la.rrd --step $RRD_STEP \ - DS:LA:GAUGE:600:U:U \ - DS:PR:GAUGE:600:U:U \ - RRA:AVERAGE:0.5:1:600 \ - RRA:AVERAGE:0.5:6:700 \ - RRA:AVERAGE:0.5:24:775 \ - RRA:AVERAGE:0.5:288:797 \ - RRA:MAX:0.5:1:600 \ - RRA:MAX:0.5:6:700 \ - RRA:MAX:0.5:24:775 \ - RRA:MAX:0.5:288:797 -fi - -# Parsing data -if [ "$period" = 'daily' ]; then - loadavg=$(cat /proc/loadavg ) - la=$(echo "$loadavg"|cut -f 2 -d ' ') - pr=$(ps auxh |wc -l) - - # Updating rrd database - rrdtool update $RRD/la/la.rrd N:${la//./}:$pr -fi - -# Updating graph -rrdtool graph $RRD/la/$period-la.png \ - --imgformat PNG \ - --height="120" \ - --width="440" \ - --start "$start" \ - --end "$end" \ - --vertical-label "Points" \ - --x-grid "$grid" \ - -c "BACK#7a766d" \ - -c "SHADEA#7a766d" \ - -c "SHADEB#7a766d" \ - -c "FONT#FFFFFF" \ - -c "CANVAS#302c2d" \ - -c "GRID#666666" \ - -c "MGRID#AAAAAA" \ - -c "FRAME#484243" \ - -c "ARROW#FFFFFF" \ - DEF:la=$RRD/la/la.rrd:LA:AVERAGE \ - DEF:pr=$RRD/la/la.rrd:PR:AVERAGE \ - COMMENT:'\r' \ - AREA:la#C8EA2E:"LA * 100"\ - GPRINT:la:'LAST: Current\:''%8.0lf' \ - GPRINT:la:'MIN: Min\:''%8.0lf' \ - GPRINT:la:'MAX: Max\:''%8.0lf\j' \ - LINE1:pr#1c74cd:"Procs # " \ - GPRINT:pr:'LAST:Current\:''%8.0lf' \ - GPRINT:pr:'MIN:Min\:''%8.0lf' \ - GPRINT:pr:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -if [ "$result" -ne 0 ]; then - exit $E_RRD -fi - -exit +#!/bin/bash +# info: update load average rrd +# options: PERIOD +# +# The function is for updating load average rrd database and graphic. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +period=${1-daily} + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Switching on time period +case $period in + daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; + weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; + monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; + yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; + *) exit $E_RRD ;; +esac + +# Checking directory +if [ ! -d "$RRD/la" ]; then + mkdir $RRD/la +fi + +# Checking database +if [ ! -e "$RRD/la/la.rrd" ]; then + # Adding database + rrdtool create $RRD/la/la.rrd --step $RRD_STEP \ + DS:LA:GAUGE:600:U:U \ + DS:PR:GAUGE:600:U:U \ + RRA:AVERAGE:0.5:1:600 \ + RRA:AVERAGE:0.5:6:700 \ + RRA:AVERAGE:0.5:24:775 \ + RRA:AVERAGE:0.5:288:797 \ + RRA:MAX:0.5:1:600 \ + RRA:MAX:0.5:6:700 \ + RRA:MAX:0.5:24:775 \ + RRA:MAX:0.5:288:797 +fi + +# Parsing data +if [ "$period" = 'daily' ]; then + loadavg=$(cat /proc/loadavg ) + la=$(echo "$loadavg"|cut -f 2 -d ' ') + pr=$(ps auxh |wc -l) + + # Updating rrd database + rrdtool update $RRD/la/la.rrd N:${la//./}:$pr +fi + +# Updating graph +rrdtool graph $RRD/la/$period-la.png \ + --imgformat PNG \ + --height="120" \ + --width="440" \ + --start "$start" \ + --end "$end" \ + --vertical-label "Points" \ + --x-grid "$grid" \ + -c "BACK#7a766d" \ + -c "SHADEA#7a766d" \ + -c "SHADEB#7a766d" \ + -c "FONT#FFFFFF" \ + -c "CANVAS#302c2d" \ + -c "GRID#666666" \ + -c "MGRID#AAAAAA" \ + -c "FRAME#484243" \ + -c "ARROW#FFFFFF" \ + DEF:la=$RRD/la/la.rrd:LA:AVERAGE \ + DEF:pr=$RRD/la/la.rrd:PR:AVERAGE \ + COMMENT:'\r' \ + AREA:la#C8EA2E:"LA * 100"\ + GPRINT:la:'LAST: Current\:''%8.0lf' \ + GPRINT:la:'MIN: Min\:''%8.0lf' \ + GPRINT:la:'MAX: Max\:''%8.0lf\j' \ + LINE1:pr#1c74cd:"Procs # " \ + GPRINT:pr:'LAST:Current\:''%8.0lf' \ + GPRINT:pr:'MIN:Min\:''%8.0lf' \ + GPRINT:pr:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +if [ "$result" -ne 0 ]; then + exit $E_RRD +fi + +exit diff --git a/bin/v-update-sys-rrd-mem b/bin/v-update-sys-rrd-mem index 639db83b5..0ad3bf1b3 100755 --- a/bin/v-update-sys-rrd-mem +++ b/bin/v-update-sys-rrd-mem @@ -1,103 +1,103 @@ -#!/bin/bash -# info: update memory rrd -# options: period -# -# The function is for updating memory rrd database and graphic. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -period=${1-daily} - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on time period -case $period in - daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; - weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; - monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; - yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; - *) exit $E_RRD ;; -esac - -# Checking directory -if [ ! -d "$RRD/mem" ]; then - mkdir $RRD/mem -fi - -# Checking database -if [ ! -e "$RRD/mem/mem.rrd" ]; then - # Adding database - rrdtool create $RRD/mem/mem.rrd --step $RRD_STEP \ - DS:RAM:GAUGE:600:U:U \ - DS:SWAP:GAUGE:600:U:U \ - RRA:AVERAGE:0.5:1:600 \ - RRA:AVERAGE:0.5:6:700 \ - RRA:AVERAGE:0.5:24:775 \ - RRA:AVERAGE:0.5:288:797 \ - RRA:MAX:0.5:1:600 \ - RRA:MAX:0.5:6:700 \ - RRA:MAX:0.5:24:775 \ - RRA:MAX:0.5:288:797 -fi - -# Parsing data -if [ "$period" = 'daily' ]; then - mem=$(free -m) - ram=$(echo "$mem" |awk '{print $3}'|head -n2 |tail -n1) - swap=$(echo "$mem" |awk '{print $3}'|tail -n1) - - # Updating rrd - rrdtool update $RRD/mem/mem.rrd N:$ram:$swap -fi - -# Updating rrd graph -rrdtool graph $RRD/mem/$period-mem.png \ - --imgformat PNG \ - --height="120" \ - --width="440" \ - --start "$start" \ - --end "$end" \ - --vertical-label "Mbytes" \ - --x-grid "$grid" \ - -c "BACK#7a766d" \ - -c "SHADEA#7a766d" \ - -c "SHADEB#7a766d" \ - -c "FONT#FFFFFF" \ - -c "CANVAS#302c2d" \ - -c "GRID#666666" \ - -c "MGRID#AAAAAA" \ - -c "FRAME#302c2d" \ - -c "ARROW#FFFFFF" \ - DEF:ram=$RRD/mem/mem.rrd:RAM:AVERAGE \ - DEF:swap=$RRD/mem/mem.rrd:SWAP:AVERAGE \ - COMMENT:'\r' \ - AREA:ram#867995:"RAM "\ - GPRINT:ram:'LAST: Current\:''%8.0lf' \ - GPRINT:ram:'MIN: Min\:''%8.0lf' \ - GPRINT:ram:'MAX: Max\:''%8.0lf\j' \ - LINE1:swap#f57900:"SWAP" \ - GPRINT:swap:'LAST:Current\:''%8.0lf' \ - GPRINT:swap:'MIN:Min\:''%8.0lf' \ - GPRINT:swap:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -if [ "$result" -ne 0 ]; then - exit $E_RRD -fi - -exit +#!/bin/bash +# info: update memory rrd +# options: PERIOD +# +# The function is for updating memory rrd database and graphic. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +period=${1-daily} + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Switching on time period +case $period in + daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; + weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; + monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; + yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; + *) exit $E_RRD ;; +esac + +# Checking directory +if [ ! -d "$RRD/mem" ]; then + mkdir $RRD/mem +fi + +# Checking database +if [ ! -e "$RRD/mem/mem.rrd" ]; then + # Adding database + rrdtool create $RRD/mem/mem.rrd --step $RRD_STEP \ + DS:RAM:GAUGE:600:U:U \ + DS:SWAP:GAUGE:600:U:U \ + RRA:AVERAGE:0.5:1:600 \ + RRA:AVERAGE:0.5:6:700 \ + RRA:AVERAGE:0.5:24:775 \ + RRA:AVERAGE:0.5:288:797 \ + RRA:MAX:0.5:1:600 \ + RRA:MAX:0.5:6:700 \ + RRA:MAX:0.5:24:775 \ + RRA:MAX:0.5:288:797 +fi + +# Parsing data +if [ "$period" = 'daily' ]; then + mem=$(free -m) + ram=$(echo "$mem" |awk '{print $3}'|head -n2 |tail -n1) + swap=$(echo "$mem" |awk '{print $3}'|tail -n1) + + # Updating rrd + rrdtool update $RRD/mem/mem.rrd N:$ram:$swap +fi + +# Updating rrd graph +rrdtool graph $RRD/mem/$period-mem.png \ + --imgformat PNG \ + --height="120" \ + --width="440" \ + --start "$start" \ + --end "$end" \ + --vertical-label "Mbytes" \ + --x-grid "$grid" \ + -c "BACK#7a766d" \ + -c "SHADEA#7a766d" \ + -c "SHADEB#7a766d" \ + -c "FONT#FFFFFF" \ + -c "CANVAS#302c2d" \ + -c "GRID#666666" \ + -c "MGRID#AAAAAA" \ + -c "FRAME#302c2d" \ + -c "ARROW#FFFFFF" \ + DEF:ram=$RRD/mem/mem.rrd:RAM:AVERAGE \ + DEF:swap=$RRD/mem/mem.rrd:SWAP:AVERAGE \ + COMMENT:'\r' \ + AREA:ram#867995:"RAM "\ + GPRINT:ram:'LAST: Current\:''%8.0lf' \ + GPRINT:ram:'MIN: Min\:''%8.0lf' \ + GPRINT:ram:'MAX: Max\:''%8.0lf\j' \ + LINE1:swap#f57900:"SWAP" \ + GPRINT:swap:'LAST:Current\:''%8.0lf' \ + GPRINT:swap:'MIN:Min\:''%8.0lf' \ + GPRINT:swap:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +if [ "$result" -ne 0 ]; then + exit $E_RRD +fi + +exit diff --git a/bin/v-update-sys-rrd-mysql b/bin/v-update-sys-rrd-mysql index 95baf5eee..02a5e5d33 100755 --- a/bin/v-update-sys-rrd-mysql +++ b/bin/v-update-sys-rrd-mysql @@ -1,141 +1,141 @@ -#!/bin/bash -# info: update MySQL rrd -# options: period -# -# The function is for updating mysql rrd database and graphic. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -period=${1-daily} - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on time period -case $period in - daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; - weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; - monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; - yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; - *) exit $E_RRD ;; -esac - -# Checking directory -if [ ! -d "$RRD/db" ]; then - mkdir $RRD/db -fi - -# Parsing db hosts -conf="$VESTA/conf/mysql.conf" -fields='$HOST' -nohead=1 -hosts=$(shell_list) -check_row=$(echo "$hosts" |wc -l) -if [ 0 -eq "$check_row" ]; then - exit -fi - -# Parsing excludes -for exclude in $(echo ${RRD_MYSQL_EXCLUDE//,/ }); do - hosts=$(echo "$hosts" |grep -vw "$exclude" ) -done - -for host in $hosts; do - # Checking database - if [ ! -e "$RRD/db/mysql_$host.rrd" ]; then - # Adding database - rrdtool create $RRD/db/mysql_$host.rrd --step $RRD_STEP \ - DS:A:COUNTER:600:U:U \ - DS:S:COUNTER:600:U:U \ - RRA:AVERAGE:0.5:1:600 \ - RRA:AVERAGE:0.5:6:700 \ - RRA:AVERAGE:0.5:24:775 \ - RRA:AVERAGE:0.5:288:797 \ - RRA:MAX:0.5:1:600 \ - RRA:MAX:0.5:6:700 \ - RRA:MAX:0.5:24:775 \ - RRA:MAX:0.5:288:797 - fi - - if [ "$period" = 'daily' ]; then - # Defining host credentials - host_str=$(grep "HOST='$host'" $conf) - for key in $host_str; do - eval ${key%%=*}=${key#*=} - done - sql="mysql -h $HOST -u $USER -p$PASSWORD -P$PORT -e" - - # Checking empty vars - if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $PORT ] - then - echo "Error: config is broken" - log_event "$E_PARSING" "$EVENT" - exit $E_PARSING - fi - - # Parsing data - status=$($sql "SHOW GLOBAL STATUS" 2>/dev/null); code="$?" - if [ '0' -ne "$code" ]; then - active=0 - slow=0 - else - active=$(echo "$status"|grep 'Queries'|cut -f 2) - slow=$(echo "$status"|grep 'Slow_queries'|cut -f 2) - fi - - # Updating rrd - rrdtool update $RRD/db/mysql_$host.rrd N:$active:$slow - fi - - # Updating daily graph - rrdtool graph $RRD/db/$period-mysql_$host.png \ - --imgformat PNG \ - --height="120" \ - --width="440" \ - --start "$start" \ - --end "$end" \ - --vertical-label "Queries" \ - --x-grid "$grid" \ - -c "BACK#7a766d" \ - -c "SHADEA#7a766d" \ - -c "SHADEB#7a766d" \ - -c "FONT#FFFFFF" \ - -c "CANVAS#302c2d" \ - -c "GRID#666666" \ - -c "MGRID#AAAAAA" \ - -c "FRAME#302c2d" \ - -c "ARROW#FFFFFF" \ - DEF:a=$RRD/db/mysql_$host.rrd:A:AVERAGE \ - DEF:s=$RRD/db/mysql_$host.rrd:S:AVERAGE \ - COMMENT:'\r' \ - LINE1:a#fefda0:"Queries"\ - GPRINT:a:'LAST: Current\:''%8.0lf' \ - GPRINT:a:'MIN: Min\:''%8.0lf' \ - GPRINT:a:'MAX: Max\:''%8.0lf\j' \ - AREA:s#f57900:"Slow " \ - GPRINT:s:'LAST:Current\:''%8.0lf' \ - GPRINT:s:'MIN:Min\:''%8.0lf' \ - GPRINT:s:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? - - if [ "$result" -ne 0 ]; then - exit $E_RRD - fi - -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: update MySQL rrd +# options: PERIOD +# +# The function is for updating mysql rrd database and graphic. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +period=${1-daily} + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Switching on time period +case $period in + daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; + weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; + monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; + yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; + *) exit $E_RRD ;; +esac + +# Checking directory +if [ ! -d "$RRD/db" ]; then + mkdir $RRD/db +fi + +# Parsing db hosts +conf="$VESTA/conf/mysql.conf" +fields='$HOST' +nohead=1 +hosts=$(shell_list) +check_row=$(echo "$hosts" |wc -l) +if [ 0 -eq "$check_row" ]; then + exit +fi + +# Parsing excludes +for exclude in $(echo ${RRD_MYSQL_EXCLUDE//,/ }); do + hosts=$(echo "$hosts" |grep -vw "$exclude" ) +done + +for host in $hosts; do + # Checking database + if [ ! -e "$RRD/db/mysql_$host.rrd" ]; then + # Adding database + rrdtool create $RRD/db/mysql_$host.rrd --step $RRD_STEP \ + DS:A:COUNTER:600:U:U \ + DS:S:COUNTER:600:U:U \ + RRA:AVERAGE:0.5:1:600 \ + RRA:AVERAGE:0.5:6:700 \ + RRA:AVERAGE:0.5:24:775 \ + RRA:AVERAGE:0.5:288:797 \ + RRA:MAX:0.5:1:600 \ + RRA:MAX:0.5:6:700 \ + RRA:MAX:0.5:24:775 \ + RRA:MAX:0.5:288:797 + fi + + if [ "$period" = 'daily' ]; then + # Defining host credentials + host_str=$(grep "HOST='$host'" $conf) + for key in $host_str; do + eval ${key%%=*}=${key#*=} + done + sql="mysql -h $HOST -u $USER -p$PASSWORD -P$PORT -e" + + # Checking empty vars + if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $PORT ] + then + echo "Error: config is broken" + log_event "$E_PARSING" "$EVENT" + exit $E_PARSING + fi + + # Parsing data + status=$($sql "SHOW GLOBAL STATUS" 2>/dev/null); code="$?" + if [ '0' -ne "$code" ]; then + active=0 + slow=0 + else + active=$(echo "$status"|grep 'Queries'|cut -f 2) + slow=$(echo "$status"|grep 'Slow_queries'|cut -f 2) + fi + + # Updating rrd + rrdtool update $RRD/db/mysql_$host.rrd N:$active:$slow + fi + + # Updating daily graph + rrdtool graph $RRD/db/$period-mysql_$host.png \ + --imgformat PNG \ + --height="120" \ + --width="440" \ + --start "$start" \ + --end "$end" \ + --vertical-label "Queries" \ + --x-grid "$grid" \ + -c "BACK#7a766d" \ + -c "SHADEA#7a766d" \ + -c "SHADEB#7a766d" \ + -c "FONT#FFFFFF" \ + -c "CANVAS#302c2d" \ + -c "GRID#666666" \ + -c "MGRID#AAAAAA" \ + -c "FRAME#302c2d" \ + -c "ARROW#FFFFFF" \ + DEF:a=$RRD/db/mysql_$host.rrd:A:AVERAGE \ + DEF:s=$RRD/db/mysql_$host.rrd:S:AVERAGE \ + COMMENT:'\r' \ + LINE1:a#fefda0:"Queries"\ + GPRINT:a:'LAST: Current\:''%8.0lf' \ + GPRINT:a:'MIN: Min\:''%8.0lf' \ + GPRINT:a:'MAX: Max\:''%8.0lf\j' \ + AREA:s#f57900:"Slow " \ + GPRINT:s:'LAST:Current\:''%8.0lf' \ + GPRINT:s:'MIN:Min\:''%8.0lf' \ + GPRINT:s:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? + + if [ "$result" -ne 0 ]; then + exit $E_RRD + fi + +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-update-sys-rrd-net b/bin/v-update-sys-rrd-net index b66397846..83cffa2e9 100755 --- a/bin/v-update-sys-rrd-net +++ b/bin/v-update-sys-rrd-net @@ -1,116 +1,116 @@ -#!/bin/bash -# info: update network rrd -# options: period -# -# The function is for updating network usage rrd database and graphic. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -period=${1-daily} - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on time period -case $period in - daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; - weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; - monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; - yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; - *) exit $E_RRD ;; -esac - -# Checking directory -if [ ! -d "$RRD/net" ]; then - mkdir $RRD/net -fi - -# Parsing network interfaces -ifaces=$(cat /proc/net/dev |grep : |cut -f 1 -d : |sed -e "s/ //g") - -# Parsing excludes -for exclude in $(echo ${RRD_IFACE_EXCLUDE//,/ }); do - ifaces=$(echo "$ifaces" |grep -vw "$exclude" ) -done - -for iface in $ifaces; do - # Checking database - if [ ! -e "$RRD/net/$iface.rrd" ]; then - # Adding database - rrdtool create $RRD/net/$iface.rrd --step $RRD_STEP \ - DS:RX:COUNTER:600:U:U \ - DS:TX:COUNTER:600:U:U \ - RRA:AVERAGE:0.5:1:600 \ - RRA:AVERAGE:0.5:6:700 \ - RRA:AVERAGE:0.5:24:775 \ - RRA:AVERAGE:0.5:288:797 \ - RRA:MAX:0.5:1:600 \ - RRA:MAX:0.5:6:700 \ - RRA:MAX:0.5:24:775 \ - RRA:MAX:0.5:288:797 - fi - - # Parsing device stats - if [ "$period" = 'daily' ]; then - raw_iface=$(grep "$iface:" /proc/net/dev |sed -e "s/:/ /") - rx=$(echo "$raw_iface" |awk '{print $2}') - tx=$(echo "$raw_iface" |awk '{print $10}') - - # Updating rrd database - rrdtool update $RRD/net/$iface.rrd N:$rx:$tx - fi - - # Updating rrd graph - rrdtool graph $RRD/net/$period-$iface.png \ - --imgformat PNG \ - --height="120" \ - --width="440" \ - --start "$start" \ - --end "$end" \ - --vertical-label "KBytes" \ - --x-grid "$grid" \ - -c "BACK#7a766d" \ - -c "SHADEA#7a766d" \ - -c "SHADEB#7a766d" \ - -c "FONT#FFFFFF" \ - -c "CANVAS#302c2d" \ - -c "GRID#666666" \ - -c "MGRID#AAAAAA" \ - -c "FRAME#302c2d" \ - -c "ARROW#FFFFFF" \ - DEF:inoctets=$RRD/net/$iface.rrd:RX:AVERAGE \ - DEF:outoctets=$RRD/net/$iface.rrd:TX:AVERAGE \ - "CDEF:in=inoctets,8,*" \ - "CDEF:out=outoctets,8,*" \ - COMMENT:'\r' \ - AREA:in#C8EA2E:"Input (rx) "\ - GPRINT:in:'LAST: Current\:''%8.0lf' \ - GPRINT:in:'MIN: Min\:''%8.0lf' \ - GPRINT:in:'MAX: Max\:''%8.0lf\j' \ - LINE1:out#1c74cd:"Output (tx)" \ - GPRINT:out:'LAST:Current\:''%8.0lf' \ - GPRINT:out:'MIN:Min\:''%8.0lf' \ - GPRINT:out:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? - - if [ "$result" -ne 0 ]; then - exit $E_RRD - fi - -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: update network rrd +# options: PERIOD +# +# The function is for updating network usage rrd database and graphic. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +period=${1-daily} + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Switching on time period +case $period in + daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; + weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; + monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; + yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; + *) exit $E_RRD ;; +esac + +# Checking directory +if [ ! -d "$RRD/net" ]; then + mkdir $RRD/net +fi + +# Parsing network interfaces +ifaces=$(cat /proc/net/dev |grep : |cut -f 1 -d : |sed -e "s/ //g") + +# Parsing excludes +for exclude in $(echo ${RRD_IFACE_EXCLUDE//,/ }); do + ifaces=$(echo "$ifaces" |grep -vw "$exclude" ) +done + +for iface in $ifaces; do + # Checking database + if [ ! -e "$RRD/net/$iface.rrd" ]; then + # Adding database + rrdtool create $RRD/net/$iface.rrd --step $RRD_STEP \ + DS:RX:COUNTER:600:U:U \ + DS:TX:COUNTER:600:U:U \ + RRA:AVERAGE:0.5:1:600 \ + RRA:AVERAGE:0.5:6:700 \ + RRA:AVERAGE:0.5:24:775 \ + RRA:AVERAGE:0.5:288:797 \ + RRA:MAX:0.5:1:600 \ + RRA:MAX:0.5:6:700 \ + RRA:MAX:0.5:24:775 \ + RRA:MAX:0.5:288:797 + fi + + # Parsing device stats + if [ "$period" = 'daily' ]; then + raw_iface=$(grep "$iface:" /proc/net/dev |sed -e "s/:/ /") + rx=$(echo "$raw_iface" |awk '{print $2}') + tx=$(echo "$raw_iface" |awk '{print $10}') + + # Updating rrd database + rrdtool update $RRD/net/$iface.rrd N:$rx:$tx + fi + + # Updating rrd graph + rrdtool graph $RRD/net/$period-$iface.png \ + --imgformat PNG \ + --height="120" \ + --width="440" \ + --start "$start" \ + --end "$end" \ + --vertical-label "KBytes" \ + --x-grid "$grid" \ + -c "BACK#7a766d" \ + -c "SHADEA#7a766d" \ + -c "SHADEB#7a766d" \ + -c "FONT#FFFFFF" \ + -c "CANVAS#302c2d" \ + -c "GRID#666666" \ + -c "MGRID#AAAAAA" \ + -c "FRAME#302c2d" \ + -c "ARROW#FFFFFF" \ + DEF:inoctets=$RRD/net/$iface.rrd:RX:AVERAGE \ + DEF:outoctets=$RRD/net/$iface.rrd:TX:AVERAGE \ + "CDEF:in=inoctets,8,*" \ + "CDEF:out=outoctets,8,*" \ + COMMENT:'\r' \ + AREA:in#C8EA2E:"Input (rx) "\ + GPRINT:in:'LAST: Current\:''%8.0lf' \ + GPRINT:in:'MIN: Min\:''%8.0lf' \ + GPRINT:in:'MAX: Max\:''%8.0lf\j' \ + LINE1:out#1c74cd:"Output (tx)" \ + GPRINT:out:'LAST:Current\:''%8.0lf' \ + GPRINT:out:'MIN:Min\:''%8.0lf' \ + GPRINT:out:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? + + if [ "$result" -ne 0 ]; then + exit $E_RRD + fi + +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-update-sys-rrd-nginx b/bin/v-update-sys-rrd-nginx index 6acd6433e..aeef948db 100755 --- a/bin/v-update-sys-rrd-nginx +++ b/bin/v-update-sys-rrd-nginx @@ -1,95 +1,95 @@ -#!/bin/bash -# info: update nginx rrd -# options: period -# -# The function is for updating nginx rrd database and graphic. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -period=${1-daily} - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on time period -case $period in - daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; - weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; - monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; - yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; - *) exit $E_RRD ;; -esac - -# Checking directory -if [ ! -d "$RRD/web" ]; then - mkdir $RRD/web -fi - -# Checking database -if [ ! -e "$RRD/web/nginx.rrd" ]; then - # Adding database - rrdtool create $RRD/web/nginx.rrd --step $RRD_STEP \ - DS:A:GAUGE:600:U:U \ - RRA:AVERAGE:0.5:1:600 \ - RRA:AVERAGE:0.5:6:700 \ - RRA:AVERAGE:0.5:24:775 \ - RRA:AVERAGE:0.5:288:797 \ - RRA:MAX:0.5:1:600 \ - RRA:MAX:0.5:6:700 \ - RRA:MAX:0.5:24:775 \ - RRA:MAX:0.5:288:797 -fi - -# Parsing data -if [ "$period" = 'daily' ]; then - a=$(wget -qO- http://localhost:8084/|head -n1|cut -f 3 -d ' ') - - # Updating rrd database - rrdtool update $RRD/web/nginx.rrd N:$a -fi - -# Updating rrd graph -rrdtool graph $RRD/web/$period-nginx.png \ - --imgformat PNG \ - --height="120" \ - --width="440" \ - --start "$start" \ - --end "$end" \ - --vertical-label "Connections" \ - --x-grid "$grid" \ - -c "BACK#7a766d" \ - -c "SHADEA#7a766d" \ - -c "SHADEB#7a766d" \ - -c "FONT#FFFFFF" \ - -c "CANVAS#302c2d" \ - -c "GRID#666666" \ - -c "MGRID#AAAAAA" \ - -c "FRAME#302c2d" \ - -c "ARROW#FFFFFF" \ - DEF:a=$RRD/web/nginx.rrd:A:AVERAGE \ - COMMENT:'\r' \ - LINE1:a#fefda0:"Connections " \ - GPRINT:a:'LAST:Current\:''%8.0lf' \ - GPRINT:a:'MIN:Min\:''%8.0lf' \ - GPRINT:a:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -if [ "$result" -ne 0 ]; then - exit $E_RRD -fi - -exit +#!/bin/bash +# info: update nginx rrd +# options: PERIOD +# +# The function is for updating nginx rrd database and graphic. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +period=${1-daily} + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Switching on time period +case $period in + daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; + weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; + monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; + yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; + *) exit $E_RRD ;; +esac + +# Checking directory +if [ ! -d "$RRD/web" ]; then + mkdir $RRD/web +fi + +# Checking database +if [ ! -e "$RRD/web/nginx.rrd" ]; then + # Adding database + rrdtool create $RRD/web/nginx.rrd --step $RRD_STEP \ + DS:A:GAUGE:600:U:U \ + RRA:AVERAGE:0.5:1:600 \ + RRA:AVERAGE:0.5:6:700 \ + RRA:AVERAGE:0.5:24:775 \ + RRA:AVERAGE:0.5:288:797 \ + RRA:MAX:0.5:1:600 \ + RRA:MAX:0.5:6:700 \ + RRA:MAX:0.5:24:775 \ + RRA:MAX:0.5:288:797 +fi + +# Parsing data +if [ "$period" = 'daily' ]; then + a=$(wget -qO- http://localhost:8084/|head -n1|cut -f 3 -d ' ') + + # Updating rrd database + rrdtool update $RRD/web/nginx.rrd N:$a +fi + +# Updating rrd graph +rrdtool graph $RRD/web/$period-nginx.png \ + --imgformat PNG \ + --height="120" \ + --width="440" \ + --start "$start" \ + --end "$end" \ + --vertical-label "Connections" \ + --x-grid "$grid" \ + -c "BACK#7a766d" \ + -c "SHADEA#7a766d" \ + -c "SHADEB#7a766d" \ + -c "FONT#FFFFFF" \ + -c "CANVAS#302c2d" \ + -c "GRID#666666" \ + -c "MGRID#AAAAAA" \ + -c "FRAME#302c2d" \ + -c "ARROW#FFFFFF" \ + DEF:a=$RRD/web/nginx.rrd:A:AVERAGE \ + COMMENT:'\r' \ + LINE1:a#fefda0:"Connections " \ + GPRINT:a:'LAST:Current\:''%8.0lf' \ + GPRINT:a:'MIN:Min\:''%8.0lf' \ + GPRINT:a:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +if [ "$result" -ne 0 ]; then + exit $E_RRD +fi + +exit diff --git a/bin/v-update-sys-rrd-pgsql b/bin/v-update-sys-rrd-pgsql index 5a4e9f38b..e5b946325 100755 --- a/bin/v-update-sys-rrd-pgsql +++ b/bin/v-update-sys-rrd-pgsql @@ -1,146 +1,146 @@ -#!/bin/bash -# info: update PostgreSQL rrd -# options: period -# -# The function is for updating postgresql rrd database and graphic. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -period=${1-daily} - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on time period -case $period in - daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; - weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; - monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; - yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; - *) exit $E_RRD ;; -esac - -# Checking directory -if [ ! -d "$RRD/db" ]; then - mkdir $RRD/db -fi - -# Parsing db hosts -conf="$VESTA/conf/pgsql.conf" -fields='$HOST' -nohead=1 -hosts=$(shell_list) -check_row=$(echo "$hosts" |wc -l) -if [ 0 -eq "$check_row" ]; then - exit -fi - -# Parsing excludes -for exclude in $(echo ${RRD_PGSQL_EXCLUDE//,/ }); do - hosts=$(echo "$hosts" |grep -vw "$exclude" ) -done - -for host in $hosts; do - # Checking database - if [ ! -e "$RRD/db/pgsql_$host.rrd" ]; then - # Adding database - rrdtool create $RRD/db/pgsql_$host.rrd --step $RRD_STEP \ - DS:A:GAUGE:600:U:U \ - DS:T:COUNTER:600:U:U \ - RRA:AVERAGE:0.5:1:600 \ - RRA:AVERAGE:0.5:6:700 \ - RRA:AVERAGE:0.5:24:775 \ - RRA:AVERAGE:0.5:288:797 \ - RRA:MAX:0.5:1:600 \ - RRA:MAX:0.5:6:700 \ - RRA:MAX:0.5:24:775 \ - RRA:MAX:0.5:288:797 - fi - - if [ "$period" = 'daily' ]; then - # Defining host credentials - host_str=$(grep "HOST='$host'" $conf) - for key in $host_str; do - eval ${key%%=*}=${key#*=} - done - - export PGPASSWORD="$PASSWORD" - sql="psql -h $HOST -U $USER -p $PORT -c" - - # Checking empty vars - if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $TPL ] - then - echo "Error: config is broken" - log_event "$E_PARSING" "$EVENT" - exit $E_PARSING - fi - - # Parsing data - q='SELECT SUM(xact_commit + xact_rollback), SUM(numbackends) - FROM pg_stat_database;' - status=$($sql plsql -d postgres -c "$q" 2>/dev/null); code="$?" - if [ '0' -ne "$code" ]; then - active=0 - slow=0 - else - active=$(echo "$status"|head -n 3|tail -n 1|awk '{print $3}') - trans=$(echo "$status"|head -n 3 |tail -n 1|awk '{print $1}') - fi - - # Updating rrd - export PGPASSWORD='pgsql' - rrdtool update $RRD/db/pgsql_$host.rrd N:$active:$trans - fi - - # Updating rrd graph - rrdtool graph $RRD/db/$period-pgsql_$host.png \ - --imgformat PNG \ - --height="120" \ - --width="440" \ - --start "$start" \ - --end "$end" \ - --vertical-label "Queries" \ - --x-grid "$grid" \ - -c "BACK#7a766d" \ - -c "SHADEA#7a766d" \ - -c "SHADEB#7a766d" \ - -c "FONT#FFFFFF" \ - -c "CANVAS#302c2d" \ - -c "GRID#666666" \ - -c "MGRID#AAAAAA" \ - -c "FRAME#302c2d" \ - -c "ARROW#FFFFFF" \ - DEF:a=$RRD/db/pgsql_$host.rrd:A:AVERAGE \ - DEF:t=$RRD/db/pgsql_$host.rrd:T:AVERAGE \ - COMMENT:'\r' \ - LINE1:a#fefda0:"Queries "\ - GPRINT:a:'LAST: Current\:''%8.0lf' \ - GPRINT:a:'MIN: Min\:''%8.0lf' \ - GPRINT:a:'MAX: Max\:''%8.0lf\j' \ - LINE2:t#f57900:"Transactions" \ - GPRINT:t:'LAST:Current\:''%8.0lf' \ - GPRINT:t:'MIN:Min\:''%8.0lf' \ - GPRINT:t:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? - - if [ "$result" -ne 0 ]; then - exit $E_RRD - fi - -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: update PostgreSQL rrd +# options: PERIOD +# +# The function is for updating postgresql rrd database and graphic. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +period=${1-daily} + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Switching on time period +case $period in + daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; + weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; + monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; + yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; + *) exit $E_RRD ;; +esac + +# Checking directory +if [ ! -d "$RRD/db" ]; then + mkdir $RRD/db +fi + +# Parsing db hosts +conf="$VESTA/conf/pgsql.conf" +fields='$HOST' +nohead=1 +hosts=$(shell_list) +check_row=$(echo "$hosts" |wc -l) +if [ 0 -eq "$check_row" ]; then + exit +fi + +# Parsing excludes +for exclude in $(echo ${RRD_PGSQL_EXCLUDE//,/ }); do + hosts=$(echo "$hosts" |grep -vw "$exclude" ) +done + +for host in $hosts; do + # Checking database + if [ ! -e "$RRD/db/pgsql_$host.rrd" ]; then + # Adding database + rrdtool create $RRD/db/pgsql_$host.rrd --step $RRD_STEP \ + DS:A:GAUGE:600:U:U \ + DS:T:COUNTER:600:U:U \ + RRA:AVERAGE:0.5:1:600 \ + RRA:AVERAGE:0.5:6:700 \ + RRA:AVERAGE:0.5:24:775 \ + RRA:AVERAGE:0.5:288:797 \ + RRA:MAX:0.5:1:600 \ + RRA:MAX:0.5:6:700 \ + RRA:MAX:0.5:24:775 \ + RRA:MAX:0.5:288:797 + fi + + if [ "$period" = 'daily' ]; then + # Defining host credentials + host_str=$(grep "HOST='$host'" $conf) + for key in $host_str; do + eval ${key%%=*}=${key#*=} + done + + export PGPASSWORD="$PASSWORD" + sql="psql -h $HOST -U $USER -p $PORT -c" + + # Checking empty vars + if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $TPL ] + then + echo "Error: config is broken" + log_event "$E_PARSING" "$EVENT" + exit $E_PARSING + fi + + # Parsing data + q='SELECT SUM(xact_commit + xact_rollback), SUM(numbackends) + FROM pg_stat_database;' + status=$($sql plsql -d postgres -c "$q" 2>/dev/null); code="$?" + if [ '0' -ne "$code" ]; then + active=0 + slow=0 + else + active=$(echo "$status"|head -n 3|tail -n 1|awk '{print $3}') + trans=$(echo "$status"|head -n 3 |tail -n 1|awk '{print $1}') + fi + + # Updating rrd + export PGPASSWORD='pgsql' + rrdtool update $RRD/db/pgsql_$host.rrd N:$active:$trans + fi + + # Updating rrd graph + rrdtool graph $RRD/db/$period-pgsql_$host.png \ + --imgformat PNG \ + --height="120" \ + --width="440" \ + --start "$start" \ + --end "$end" \ + --vertical-label "Queries" \ + --x-grid "$grid" \ + -c "BACK#7a766d" \ + -c "SHADEA#7a766d" \ + -c "SHADEB#7a766d" \ + -c "FONT#FFFFFF" \ + -c "CANVAS#302c2d" \ + -c "GRID#666666" \ + -c "MGRID#AAAAAA" \ + -c "FRAME#302c2d" \ + -c "ARROW#FFFFFF" \ + DEF:a=$RRD/db/pgsql_$host.rrd:A:AVERAGE \ + DEF:t=$RRD/db/pgsql_$host.rrd:T:AVERAGE \ + COMMENT:'\r' \ + LINE1:a#fefda0:"Queries "\ + GPRINT:a:'LAST: Current\:''%8.0lf' \ + GPRINT:a:'MIN: Min\:''%8.0lf' \ + GPRINT:a:'MAX: Max\:''%8.0lf\j' \ + LINE2:t#f57900:"Transactions" \ + GPRINT:t:'LAST:Current\:''%8.0lf' \ + GPRINT:t:'MIN:Min\:''%8.0lf' \ + GPRINT:t:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? + + if [ "$result" -ne 0 ]; then + exit $E_RRD + fi + +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-update-sys-rrd-ssh b/bin/v-update-sys-rrd-ssh index 5fcb7e273..12e67904f 100755 --- a/bin/v-update-sys-rrd-ssh +++ b/bin/v-update-sys-rrd-ssh @@ -1,96 +1,96 @@ -#!/bin/bash -# info: update ssh rrd -# options: period -# -# The function is for updating ssh rrd database and graphic. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -period=${1-daily} - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on time period -case $period in - daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; - weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; - monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; - yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; - *) exit $E_RRD ;; -esac - -# Checking directory -if [ ! -d "$RRD/ssh" ]; then - mkdir $RRD/ssh -fi - -# Checking database -if [ ! -e "$RRD/ssh/ssh.rrd" ]; then - # Adding database - rrdtool create $RRD/ssh/ssh.rrd --step $RRD_STEP \ - DS:A:GAUGE:600:U:U \ - RRA:AVERAGE:0.5:1:600 \ - RRA:AVERAGE:0.5:6:700 \ - RRA:AVERAGE:0.5:24:775 \ - RRA:AVERAGE:0.5:288:797 \ - RRA:MAX:0.5:1:600 \ - RRA:MAX:0.5:6:700 \ - RRA:MAX:0.5:24:775 \ - RRA:MAX:0.5:288:797 -fi - -# Parsing data -if [ "$period" = 'daily' ]; then - a=0 - a=$(ps auxf|grep sshd |grep -v grep |grep -v '/usr/sbin/'| wc -l) - - # Updating rrd database - rrdtool update $RRD/ssh/ssh.rrd N:$a -fi - -# Updating daily graph -rrdtool graph $RRD/ssh/$period-ssh.png \ - --imgformat PNG \ - --height="120" \ - --width="440" \ - --start "$start" \ - --end "$end" \ - --vertical-label "Connections" \ - --x-grid "$grid" \ - -c "BACK#7a766d" \ - -c "SHADEA#7a766d" \ - -c "SHADEB#7a766d" \ - -c "FONT#FFFFFF" \ - -c "CANVAS#302c2d" \ - -c "GRID#666666" \ - -c "MGRID#AAAAAA" \ - -c "FRAME#302c2d" \ - -c "ARROW#FFFFFF" \ - DEF:a=$RRD/ssh/ssh.rrd:A:AVERAGE \ - COMMENT:'\r' \ - LINE1:a#fefda0:"Users " \ - GPRINT:a:'LAST:Current\:''%8.0lf' \ - GPRINT:a:'MIN:Min\:''%8.0lf' \ - GPRINT:a:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -if [ "$result" -ne 0 ]; then - exit $E_RRD -fi - -exit +#!/bin/bash +# info: update ssh rrd +# options: PERIOD +# +# The function is for updating ssh rrd database and graphic. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +period=${1-daily} + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Switching on time period +case $period in + daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; + weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; + monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; + yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; + *) exit $E_RRD ;; +esac + +# Checking directory +if [ ! -d "$RRD/ssh" ]; then + mkdir $RRD/ssh +fi + +# Checking database +if [ ! -e "$RRD/ssh/ssh.rrd" ]; then + # Adding database + rrdtool create $RRD/ssh/ssh.rrd --step $RRD_STEP \ + DS:A:GAUGE:600:U:U \ + RRA:AVERAGE:0.5:1:600 \ + RRA:AVERAGE:0.5:6:700 \ + RRA:AVERAGE:0.5:24:775 \ + RRA:AVERAGE:0.5:288:797 \ + RRA:MAX:0.5:1:600 \ + RRA:MAX:0.5:6:700 \ + RRA:MAX:0.5:24:775 \ + RRA:MAX:0.5:288:797 +fi + +# Parsing data +if [ "$period" = 'daily' ]; then + a=0 + a=$(ps auxf|grep sshd |grep -v grep |grep -v '/usr/sbin/'| wc -l) + + # Updating rrd database + rrdtool update $RRD/ssh/ssh.rrd N:$a +fi + +# Updating daily graph +rrdtool graph $RRD/ssh/$period-ssh.png \ + --imgformat PNG \ + --height="120" \ + --width="440" \ + --start "$start" \ + --end "$end" \ + --vertical-label "Connections" \ + --x-grid "$grid" \ + -c "BACK#7a766d" \ + -c "SHADEA#7a766d" \ + -c "SHADEB#7a766d" \ + -c "FONT#FFFFFF" \ + -c "CANVAS#302c2d" \ + -c "GRID#666666" \ + -c "MGRID#AAAAAA" \ + -c "FRAME#302c2d" \ + -c "ARROW#FFFFFF" \ + DEF:a=$RRD/ssh/ssh.rrd:A:AVERAGE \ + COMMENT:'\r' \ + LINE1:a#fefda0:"Users " \ + GPRINT:a:'LAST:Current\:''%8.0lf' \ + GPRINT:a:'MIN:Min\:''%8.0lf' \ + GPRINT:a:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +if [ "$result" -ne 0 ]; then + exit $E_RRD +fi + +exit diff --git a/bin/v-update-sys-vesta b/bin/v-update-sys-vesta index 6e31b0ed4..1d047d4d5 100755 --- a/bin/v-update-sys-vesta +++ b/bin/v-update-sys-vesta @@ -1,113 +1,113 @@ -#!/bin/bash -# info: update vesta after rpm update -# options: version -# -# The function is runs as rpm update trigger. It pulls shell script from vesta -# server and runs it. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -version=$1 -updates='' - -# Importing system enviroment -source /etc/profile - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -# Checking arg number -check_args '1' "$#" 'version' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Compare versions -if [ "$version" != "$VERSION" ]; then - # Downloading version tree - upd_host="yum.vestacp.com" - wget -O "/tmp/versions" http://$V_UPD_HOST/upd_scripts/version_tree.txt \ - &>/dev/null - - # Checking download result - if [ "$?" -ne "0" ]; then - echo "Error: version tree update failed" - log_event "$E_UPDATE" "$EVENT" - exit $E_UPDATE - fi - - # Deviding version - v1=$(echo "$version" |cut -f 1 -d '.') - v2=$(echo "$version" |cut -f 2 -d '.') - v3=$(echo "$version" |cut -f 3 -d '.') - V1=$(echo "$VERSION" |cut -f 1 -d '.') - V2=$(echo "$VERSION" |cut -f 2 -d '.') - V3=$(echo "$VERSION" |cut -f 3 -d '.') - - - # Checking difference between versions - # Too nested tests, sory about complexity - if [ "$V1" -lt "$v1" ]; then - for ver in $(seq $V1 $v1); do - updates="$updates $(grep "^$ver." /tmp/versions|grep ":1$"|\ - cut -f 1 -d :)" - done - else - if [ "$V2" -lt "$v2" ]; then - for ver in $(seq $V2 $v2); do - updates="$updates $(grep "^$v1.$ver." /tmp/versions |\ - grep ":1$"|cut -f 1 -d :)" - done - else - V4=$((V3 + 1)) - for ver in $(seq $V4 $v3); do - updates="$updates $(grep "^$v1.$v2.$ver" /tmp/versions |\ - grep ":1$"|cut -f 1 -d :)" - done - fi - fi - - # Executing update scripts - if [ ! -z "$updates" ]; then - mkdir $BIN/updates &>/dev/null - - for update in $updates; do - wget -O $BIN/updates/$update.sh \ - http://$V_UPD_HOST/upd_scripts/$update.sh &>/dev/null - - # Checking download result - if [ "$?" -ne "0" ]; then - echo "Error: version tree update failed" - log_event "$E_UPDATE" "$EVENT" - exit $E_UPDATE - fi - bash $BIN/updates/$update.sh - done - rm -rf $BIN/updates - fi - - # Updating config version - sed -i "s/VERSION='$VERSION'/VERSION='$version'/g" $VESTA/conf/vesta.conf -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: update vesta after rpm update +# options: VERSION +# +# The function is runs as rpm update trigger. It pulls shell script from vesta +# server and runs it. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +version=$1 +updates='' + +# Importing system enviroment +source /etc/profile + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +# Checking arg number +check_args '1' "$#" 'VERSION' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Compare versions +if [ "$version" != "$VERSION" ]; then + # Downloading version tree + upd_host="yum.vestacp.com" + wget -O "/tmp/versions" http://$V_UPD_HOST/upd_scripts/version_tree.txt \ + &>/dev/null + + # Checking download result + if [ "$?" -ne "0" ]; then + echo "Error: version tree update failed" + log_event "$E_UPDATE" "$EVENT" + exit $E_UPDATE + fi + + # Deviding version + v1=$(echo "$version" |cut -f 1 -d '.') + v2=$(echo "$version" |cut -f 2 -d '.') + v3=$(echo "$version" |cut -f 3 -d '.') + V1=$(echo "$VERSION" |cut -f 1 -d '.') + V2=$(echo "$VERSION" |cut -f 2 -d '.') + V3=$(echo "$VERSION" |cut -f 3 -d '.') + + + # Checking difference between versions + # Too nested tests, sory about complexity + if [ "$V1" -lt "$v1" ]; then + for ver in $(seq $V1 $v1); do + updates="$updates $(grep "^$ver." /tmp/versions|grep ":1$"|\ + cut -f 1 -d :)" + done + else + if [ "$V2" -lt "$v2" ]; then + for ver in $(seq $V2 $v2); do + updates="$updates $(grep "^$v1.$ver." /tmp/versions |\ + grep ":1$"|cut -f 1 -d :)" + done + else + V4=$((V3 + 1)) + for ver in $(seq $V4 $v3); do + updates="$updates $(grep "^$v1.$v2.$ver" /tmp/versions |\ + grep ":1$"|cut -f 1 -d :)" + done + fi + fi + + # Executing update scripts + if [ ! -z "$updates" ]; then + mkdir $BIN/updates &>/dev/null + + for update in $updates; do + wget -O $BIN/updates/$update.sh \ + http://$V_UPD_HOST/upd_scripts/$update.sh &>/dev/null + + # Checking download result + if [ "$?" -ne "0" ]; then + echo "Error: version tree update failed" + log_event "$E_UPDATE" "$EVENT" + exit $E_UPDATE + fi + bash $BIN/updates/$update.sh + done + rm -rf $BIN/updates + fi + + # Updating config version + sed -i "s/VERSION='$VERSION'/VERSION='$version'/g" $VESTA/conf/vesta.conf +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-update-user-backups b/bin/v-update-user-backups index 628ea3c06..9aad7140e 100755 --- a/bin/v-update-user-backups +++ b/bin/v-update-user-backups @@ -1,278 +1,278 @@ -#!/bin/bash -# info: update user backups -# options: user -# -# The function rescan backup directory and updates backup database. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - -# Argument defenition -user=$1 -type="${2-$BACKUP_SYSTEM}" - -# Defining tar parser function -get_backup_info() { - backup=$1 - backup_type="$2" - - backup_name=$(basename $backup ) - backup_date=$(echo $backup_name |cut -f 2 -d '.' ) - backup_time=$(stat --printf=%y $backup |cut -f 2 -d ' ' |cut -f 1 -d '.') - backup_size=$(du -sm $backup |cut -f 1 ) - backup_data=$(tar -tf $backup) - - vst_data=$(echo "$backup_data" |grep "^./vesta/" |grep -v "^./vesta/$") - if [ -z "$vst_data" ]; then - vst='' - else - vst='yes' - fi - - pam_data=$(echo "$backup_data" |grep "^./pam/" |grep -v "^./pam/$") - if [ -z "$pam_data" ]; then - pam='' - else - pam='yes' - fi - - web_data=$(echo "$backup_data" |grep "^./web/" |grep -v "^./web/$" |sort) - if [ -z "$web_data" ]; then - web='' - else - i=1 - for domain in $web_data; do - domain="$(basename $domain|sed -e 's/.tar.gz$//')" - if [ "$i" -eq 1 ]; then - web="$domain" - i=2 - else - web="$web,$domain" - fi - done - fi - - dns_data=$(echo "$backup_data" |grep "^./dns/" |grep ".db$" |sort) - if [ -z "$dns_data" ]; then - dns='' - else - i=1 - for domain in $dns_data; do - domain="$(basename $domain|sed -e 's/.db$//')" - if [ "$i" -eq 1 ]; then - dns="$domain" - i=2 - else - dns="$dns,$domain" - fi - done - fi - - mail_data=$(echo "$backup_data"|grep "^./mail/"|grep -v "^./mail/$"|sort) - if [ -z "$mail_data" ]; then - ml='' - else - i=1 - for domain in $mail_data; do - domain="$(basename $domain|sed -e 's/.tar.gz$//')" - if [ "$i" -eq 1 ]; then - ml="$domain" - i=2 - else - ml="$ml,$domain" - fi - done - fi - - db_data=$(echo "$backup_data"|grep "^./db/"|grep ".sql.gz$"|sort) - if [ -z "$db_data" ]; then - db='' - else - i=1 - for dbase in $db_data; do - dbase=$(basename $dbase|sed -e "s/.\(my\|pg\)sql.sql.gz$//") - if [ "$i" -eq 1 ]; then - db="$dbase" - i=2 - else - db="$db,$dbase" - fi - done - fi - - ssl_data=$(echo "$backup_data"|grep "^./ssl/"|grep ".crt$"|sort) - if [ -z "$ssl_data" ]; then - ssl='' - else - i=1 - for certificate in $ssl_data; do - certificate="$(basename $certificate|sed -e "s/.crt$//")" - if [ "$i" -eq 1 ]; then - ssl="$certificate" - i=2 - else - ssl="$ssl,$certificate" - fi - done - fi - - cron_data=$(echo "$backup_data" |grep "^./cron/" |grep -v "^./cron/$") - if [ -z "$cron_data" ]; then - cron='' - else - cron='yes' - fi - - echo -n "DATE='$backup_date' TIME='$backup_time' RUNTIME='0'" - echo -n " SIZE='$backup_size' TYPE='$backup_type' VESTA='$vst' PAM='$pam'" - echo " WEB='$web' DNS='$dns' MAIL='$ml' DB='$db' SSL='$ssl' CRON='$cron'" -} - -# Defining ftp command function -ftpc() { - ftp -n $HOST $PORT <> $tmp_file - done -fi - -# Checking ftp -if [ "$type" = 'ftp' ]; then - tmpdir=$(mktemp -p $BACKUP -d) - ftmpdir=$(basename $tmpdir) - init_ftp_variables - check_ftp_connection - backups=$(ftpc ls|awk '{print $9}'|grep "^$user.") - - for backup in $backups; do - cd $tmpdir - if [ ! -z "$(ftpc "get $backup")" ]; then - echo "Error: FTP transfer error" - log_event "$E_FTP" "$EVENT" - exit $E_FTP - fi - get_backup_info $tmpdir/$backup $type >> $tmp_file - rm -f $tmpdir/$backup - done - rm -rf $tmpdir -fi - -# Checking both local and ftp -if [ "$type" = 'ftp,local' ] || [ "$type" = 'local,ftp' ]; then - - tmpdir=$(mktemp -p $BACKUP -d) - ftmpdir=$(basename $tmpdir) - init_ftp_variables - check_ftp_connection - ftp_backups=$(ftpc ls|awk '{print $9}'|grep "^$user.") - local_backups=$(ls $BACKUP/ |grep "^$user." |sort) - backups=$(echo -e "$local_backups\n$ftp_backups" |\ - sort |uniq -c | awk '{print $1" "$2}') - - for backup in $(echo "$backups"|grep "^1 "|cut -f 2 -d ' '); do - check_ftp=$(echo $ftp_backups|grep -w $backup) - if [ ! -z "$check_ftp" ]; then - cd $tmpdir - if [ ! -z "$(ftpc "get $backup")" ]; then - echo "Error: FTP transfer error" - log_event "$E_FTP" "$EVENT" - exit $E_FTP - fi - get_backup_info $tmpdir/$backup ftp >> $tmp_file - rm -f $tmpdir/$backup - else - get_backup_info $BACKUP/$backup local >> $tmp_file - fi - done - - for backup in $(echo "$backups"|grep "^2 "|cut -f 2 -d ' '); do - get_backup_info $BACKUP/$backup $type >> $tmp_file - done - rm -rf $tmpdir -fi - -# Checking if there was any output -if [ -e "$tmp_file" ]; then - cat $tmp_file | sort > $USER_DATA/backup.conf - rm $tmp_file -else - rm $USER_DATA/backup.conf - touch $USER_DATA/backup.conf -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: update user backups +# options: USER +# +# The function rescan backup directory and updates backup database. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + +# Argument defenition +user=$1 +type="${2-$BACKUP_SYSTEM}" + +# Defining tar parser function +get_backup_info() { + backup=$1 + backup_type="$2" + + backup_name=$(basename $backup ) + backup_date=$(echo $backup_name |cut -f 2 -d '.' ) + backup_time=$(stat --printf=%y $backup |cut -f 2 -d ' ' |cut -f 1 -d '.') + backup_size=$(du -sm $backup |cut -f 1 ) + backup_data=$(tar -tf $backup) + + vst_data=$(echo "$backup_data" |grep "^./vesta/" |grep -v "^./vesta/$") + if [ -z "$vst_data" ]; then + vst='' + else + vst='yes' + fi + + pam_data=$(echo "$backup_data" |grep "^./pam/" |grep -v "^./pam/$") + if [ -z "$pam_data" ]; then + pam='' + else + pam='yes' + fi + + web_data=$(echo "$backup_data" |grep "^./web/" |grep -v "^./web/$" |sort) + if [ -z "$web_data" ]; then + web='' + else + i=1 + for domain in $web_data; do + domain="$(basename $domain|sed -e 's/.tar.gz$//')" + if [ "$i" -eq 1 ]; then + web="$domain" + i=2 + else + web="$web,$domain" + fi + done + fi + + dns_data=$(echo "$backup_data" |grep "^./dns/" |grep ".db$" |sort) + if [ -z "$dns_data" ]; then + dns='' + else + i=1 + for domain in $dns_data; do + domain="$(basename $domain|sed -e 's/.db$//')" + if [ "$i" -eq 1 ]; then + dns="$domain" + i=2 + else + dns="$dns,$domain" + fi + done + fi + + mail_data=$(echo "$backup_data"|grep "^./mail/"|grep -v "^./mail/$"|sort) + if [ -z "$mail_data" ]; then + ml='' + else + i=1 + for domain in $mail_data; do + domain="$(basename $domain|sed -e 's/.tar.gz$//')" + if [ "$i" -eq 1 ]; then + ml="$domain" + i=2 + else + ml="$ml,$domain" + fi + done + fi + + db_data=$(echo "$backup_data"|grep "^./db/"|grep ".sql.gz$"|sort) + if [ -z "$db_data" ]; then + db='' + else + i=1 + for dbase in $db_data; do + dbase=$(basename $dbase|sed -e "s/.\(my\|pg\)sql.sql.gz$//") + if [ "$i" -eq 1 ]; then + db="$dbase" + i=2 + else + db="$db,$dbase" + fi + done + fi + + ssl_data=$(echo "$backup_data"|grep "^./ssl/"|grep ".crt$"|sort) + if [ -z "$ssl_data" ]; then + ssl='' + else + i=1 + for certificate in $ssl_data; do + certificate="$(basename $certificate|sed -e "s/.crt$//")" + if [ "$i" -eq 1 ]; then + ssl="$certificate" + i=2 + else + ssl="$ssl,$certificate" + fi + done + fi + + cron_data=$(echo "$backup_data" |grep "^./cron/" |grep -v "^./cron/$") + if [ -z "$cron_data" ]; then + cron='' + else + cron='yes' + fi + + echo -n "DATE='$backup_date' TIME='$backup_time' RUNTIME='0'" + echo -n " SIZE='$backup_size' TYPE='$backup_type' VESTA='$vst' PAM='$pam'" + echo " WEB='$web' DNS='$dns' MAIL='$ml' DB='$db' SSL='$ssl' CRON='$cron'" +} + +# Defining ftp command function +ftpc() { + ftp -n $HOST $PORT <> $tmp_file + done +fi + +# Checking ftp +if [ "$type" = 'ftp' ]; then + tmpdir=$(mktemp -p $BACKUP -d) + ftmpdir=$(basename $tmpdir) + init_ftp_variables + check_ftp_connection + backups=$(ftpc ls|awk '{print $9}'|grep "^$user.") + + for backup in $backups; do + cd $tmpdir + if [ ! -z "$(ftpc "get $backup")" ]; then + echo "Error: FTP transfer error" + log_event "$E_FTP" "$EVENT" + exit $E_FTP + fi + get_backup_info $tmpdir/$backup $type >> $tmp_file + rm -f $tmpdir/$backup + done + rm -rf $tmpdir +fi + +# Checking both local and ftp +if [ "$type" = 'ftp,local' ] || [ "$type" = 'local,ftp' ]; then + + tmpdir=$(mktemp -p $BACKUP -d) + ftmpdir=$(basename $tmpdir) + init_ftp_variables + check_ftp_connection + ftp_backups=$(ftpc ls|awk '{print $9}'|grep "^$user.") + local_backups=$(ls $BACKUP/ |grep "^$user." |sort) + backups=$(echo -e "$local_backups\n$ftp_backups" |\ + sort |uniq -c | awk '{print $1" "$2}') + + for backup in $(echo "$backups"|grep "^1 "|cut -f 2 -d ' '); do + check_ftp=$(echo $ftp_backups|grep -w $backup) + if [ ! -z "$check_ftp" ]; then + cd $tmpdir + if [ ! -z "$(ftpc "get $backup")" ]; then + echo "Error: FTP transfer error" + log_event "$E_FTP" "$EVENT" + exit $E_FTP + fi + get_backup_info $tmpdir/$backup ftp >> $tmp_file + rm -f $tmpdir/$backup + else + get_backup_info $BACKUP/$backup local >> $tmp_file + fi + done + + for backup in $(echo "$backups"|grep "^2 "|cut -f 2 -d ' '); do + get_backup_info $BACKUP/$backup $type >> $tmp_file + done + rm -rf $tmpdir +fi + +# Checking if there was any output +if [ -e "$tmp_file" ]; then + cat $tmp_file | sort > $USER_DATA/backup.conf + rm $tmp_file +else + rm $USER_DATA/backup.conf + touch $USER_DATA/backup.conf +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-update-user-counters b/bin/v-update-user-counters index a90debbb7..4dde41a1a 100755 --- a/bin/v-update-user-counters +++ b/bin/v-update-user-counters @@ -1,214 +1,214 @@ -#!/bin/bash -# info: update user usage counters -# options: user -# -# Function updates usage counters like U_WEB_DOMAINS, U_MAIL_ACCOUNTS, etc. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '0' "$#" 'user' -if [ ! -z "$user" ]; then - validate_format 'user' - is_object_valid 'user' 'USER' "$user" -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Creating user_list -if [ -z "$user" ]; then - user_list=$(ls $VESTA/data/users) -else - user_list="$user" -fi - -# Updating user stats -for user in $user_list; do - USER_DATA=$VESTA/data/users/$user - # Cleaning counters - SUSPENDED_USERS=0 - SUSPENDED_WEB=0 - SUSPENDED_DNS=0 - SUSPENDED_MAIL=0 - SUSPENDED_DB=0 - SUSPENDED_CRON=0 - IP_AVAIL=0 - IP_OWNED=0 - U_USERS=0 - U_DISK=0 - U_DISK_DIRS=$(get_user_value '$U_DISK_DIRS') - if [ -z "$U_DISK_DIRS" ]; then - U_DISK_DIRS=0 - fi - DISK=$((DISK + U_DISK_DIRS)) - U_DISK_WEB=0 - U_DISK_MAIL=0 - U_DISK_DB=0 - BANDWIDTH=0 - U_BANDWIDTH=0 - U_WEB_DOMAINS=0 - U_WEB_SSL=0 - U_WEB_ALIASES=0 - U_DNS_DOMAINS=0 - U_DNS_RECORDS=0 - U_MAIL_DOMAINS=0 - U_MAIL_DKIM=0 - U_MAIL_ACCOUNTS=0 - U_DATABASES=0 - U_CRON_JOBS=0 - U_BACKUPS=0 - - # New IFS - IFS=$'\n' - - # Checking users - if [ "$user" = 'admin' ]; then - SUSPENDED_USERS=$(grep "SUSPENDED='yes'" $VESTA/data/users/*/user.conf) - SUSPENDED_USERS=$(echo "$SUSPENDED_USERS" |wc -l) - U_USERS=$(ls $VESTA/data/users/|wc -l) - fi - - # Checking ip - for ip in $(ls $VESTA/data/ips) ;do - source $VESTA/data/ips/$ip - if [ "$OWNER" = "$user" ]; then - IP_OWNED=$((IP_OWNED + 1)) - IP_AVAIL=$((IP_AVAIL + 1)) - fi - if [ "$OWNER" = 'admin' ] && [ "$STATUS" = 'shared' ]; then - IP_AVAIL=$((IP_AVAIL + 1)) - fi - done - if [ "$user" = 'admin' ]; then - IP_AVAIL=$(ls $VESTA/data/ips | wc -l) - fi - - # Checking web system - U_WEB_DOMAINS=0 - for domain_str in $(cat $USER_DATA/web.conf) ;do - eval $domain_str - U_DISK_WEB=$((U_DISK_WEB + U_DISK)) - U_WEB_DOMAINS=$((U_WEB_DOMAINS + 1)) - - if [ "$SSL" = 'yes' ]; then - U_WEB_SSL=$((U_WEB_SSL + 1)) - fi - if [ "$SUSPENDED" = 'yes' ]; then - SUSPENDED_WEB=$((SUSPENDED_WEB + 1)) - fi - if [ ! -z "$ALIAS" ]; then - aliases=$(echo "$ALIAS"|tr ',' '\n'| wc -l) - U_WEB_ALIASES=$((U_WEB_ALIASES + aliases)) - fi - BANDWIDTH=$((BANDWIDTH + U_BANDWIDTH)) - done - DISK=$((DISK + U_DISK_WEB)) - - # Checking dns system - for domain_str in $(cat $USER_DATA/dns.conf); do - eval $domain_str - U_DNS_DOMAINS=$((U_DNS_DOMAINS + 1)) - records=$(wc -l $USER_DATA/dns/$DOMAIN.conf| cut -f 1 -d ' ') - U_DNS_RECORDS=$((U_DNS_RECORDS + records)) - if [ "$SUSPENDED" = 'yes' ]; then - SUSPENDED_DNS=$((SUSPENDED_DNS + 1)) - fi - done - - # Checking mail system - for domain_str in $(cat $USER_DATA/mail.conf); do - eval $domain_str - U_DISK_MAIL=$((U_DISK_MAIL + U_DISK)) - U_MAIL_DOMAINS=$((U_MAIL_DOMAINS + 1)) - accounts=$(wc -l $USER_DATA/mail/$DOMAIN.conf| cut -f 1 -d ' ') - U_MAIL_ACCOUNTS=$((U_MAIL_ACCOUNTS + accounts)) - if [ "$DKIM" = 'yes' ]; then - U_MAIL_DKIM=$((U_MAIL_DKIM + 1)) - fi - if [ "$SUSPENDED" = 'yes' ]; then - SUSPENDED_MAIL=$((SUSPENDED_MAIL + 1)) - fi - done - DISK=$((DISK + U_DISK_MAIL)) - - # Checking db system - for db_str in $(cat $USER_DATA/db.conf); do - eval $db_str - U_DISK_DB=$((U_DISK_DB + U_DISK)) - U_DATABASES=$((U_DATABASES + 1)) - if [ "$SUSPENDED" = 'yes' ]; then - SUSPENDED_DB=$((SUSPENDED_DB + 1)) - fi - done - DISK=$((DISK + U_DISK_DB)) - - # Checking cron system - for cron_str in $(cat $USER_DATA/cron.conf);do - eval $cron_str - U_CRON_JOBS=$((U_CRON_JOBS + 1)) - if [ "$SUSPENDED" = 'yes' ]; then - SUSPENDED_CRON=$((SUSPENDED_CRON + 1)) - fi - done - - # Checking backup - for backup_str in $(cat $USER_DATA/backup.conf); do - U_BACKUPS=$((U_BACKUPS +1)) - done - - U_DISK=$DISK - U_BANDWIDTH=$BANDWIDTH - update_user_value "$user" '$SUSPENDED_USERS' "$SUSPENDED_USERS" - update_user_value "$user" '$SUSPENDED_WEB' "$SUSPENDED_WEB" - update_user_value "$user" '$SUSPENDED_DNS' "$SUSPENDED_DNS" - update_user_value "$user" '$SUSPENDED_MAIL' "$SUSPENDED_MAIL" - update_user_value "$user" '$SUSPENDED_DB' "$SUSPENDED_DB" - update_user_value "$user" '$SUSPENDED_CRON' "$SUSPENDED_CRON" - update_user_value "$user" '$IP_AVAIL' "$IP_AVAIL" - update_user_value "$user" '$IP_OWNED' "$IP_OWNED" - update_user_value "$user" '$U_USERS' "$U_USERS" - update_user_value "$user" '$U_DISK' "$U_DISK" - update_user_value "$user" '$U_DISK_DIRS' "$U_DISK_DIRS" - update_user_value "$user" '$U_DISK_WEB' "$U_DISK_WEB" - update_user_value "$user" '$U_DISK_MAIL' "$U_DISK_MAIL" - update_user_value "$user" '$U_DISK_DB' "$U_DISK_DB" - update_user_value "$user" '$U_BANDWIDTH' "$U_BANDWIDTH" - update_user_value "$user" '$U_WEB_DOMAINS' "$U_WEB_DOMAINS" - update_user_value "$user" '$U_WEB_SSL' "$U_WEB_SSL" - update_user_value "$user" '$U_WEB_ALIASES' "$U_WEB_ALIASES" - update_user_value "$user" '$U_DNS_DOMAINS' "$U_DNS_DOMAINS" - update_user_value "$user" '$U_DNS_RECORDS' "$U_DNS_RECORDS" - update_user_value "$user" '$U_MAIL_DOMAINS' "$U_MAIL_DOMAINS" - update_user_value "$user" '$U_MAIL_DKIM' "$U_MAIL_DKIM" - update_user_value "$user" '$U_MAIL_ACCOUNTS' "$U_MAIL_ACCOUNTS" - update_user_value "$user" '$U_DATABASES' "$U_DATABASES" - update_user_value "$user" '$U_CRON_JOBS' "$U_CRON_JOBS" - update_user_value "$user" '$U_BACKUPS' "$U_BACKUPS" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: update user usage counters +# options: USER +# +# Function updates usage counters like U_WEB_DOMAINS, U_MAIL_ACCOUNTS, etc. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '0' "$#" 'USER' +if [ ! -z "$user" ]; then + validate_format 'user' + is_object_valid 'user' 'USER' "$user" +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Creating user_list +if [ -z "$user" ]; then + user_list=$(ls $VESTA/data/users) +else + user_list="$user" +fi + +# Updating user stats +for user in $user_list; do + USER_DATA=$VESTA/data/users/$user + # Cleaning counters + SUSPENDED_USERS=0 + SUSPENDED_WEB=0 + SUSPENDED_DNS=0 + SUSPENDED_MAIL=0 + SUSPENDED_DB=0 + SUSPENDED_CRON=0 + IP_AVAIL=0 + IP_OWNED=0 + U_USERS=0 + U_DISK=0 + U_DISK_DIRS=$(get_user_value '$U_DISK_DIRS') + if [ -z "$U_DISK_DIRS" ]; then + U_DISK_DIRS=0 + fi + DISK=$((DISK + U_DISK_DIRS)) + U_DISK_WEB=0 + U_DISK_MAIL=0 + U_DISK_DB=0 + BANDWIDTH=0 + U_BANDWIDTH=0 + U_WEB_DOMAINS=0 + U_WEB_SSL=0 + U_WEB_ALIASES=0 + U_DNS_DOMAINS=0 + U_DNS_RECORDS=0 + U_MAIL_DOMAINS=0 + U_MAIL_DKIM=0 + U_MAIL_ACCOUNTS=0 + U_DATABASES=0 + U_CRON_JOBS=0 + U_BACKUPS=0 + + # New IFS + IFS=$'\n' + + # Checking users + if [ "$user" = 'admin' ]; then + SUSPENDED_USERS=$(grep "SUSPENDED='yes'" $VESTA/data/users/*/user.conf) + SUSPENDED_USERS=$(echo "$SUSPENDED_USERS" |wc -l) + U_USERS=$(ls $VESTA/data/users/|wc -l) + fi + + # Checking ip + for ip in $(ls $VESTA/data/ips) ;do + source $VESTA/data/ips/$ip + if [ "$OWNER" = "$user" ]; then + IP_OWNED=$((IP_OWNED + 1)) + IP_AVAIL=$((IP_AVAIL + 1)) + fi + if [ "$OWNER" = 'admin' ] && [ "$STATUS" = 'shared' ]; then + IP_AVAIL=$((IP_AVAIL + 1)) + fi + done + if [ "$user" = 'admin' ]; then + IP_AVAIL=$(ls $VESTA/data/ips | wc -l) + fi + + # Checking web system + U_WEB_DOMAINS=0 + for domain_str in $(cat $USER_DATA/web.conf) ;do + eval $domain_str + U_DISK_WEB=$((U_DISK_WEB + U_DISK)) + U_WEB_DOMAINS=$((U_WEB_DOMAINS + 1)) + + if [ "$SSL" = 'yes' ]; then + U_WEB_SSL=$((U_WEB_SSL + 1)) + fi + if [ "$SUSPENDED" = 'yes' ]; then + SUSPENDED_WEB=$((SUSPENDED_WEB + 1)) + fi + if [ ! -z "$ALIAS" ]; then + aliases=$(echo "$ALIAS"|tr ',' '\n'| wc -l) + U_WEB_ALIASES=$((U_WEB_ALIASES + aliases)) + fi + BANDWIDTH=$((BANDWIDTH + U_BANDWIDTH)) + done + DISK=$((DISK + U_DISK_WEB)) + + # Checking dns system + for domain_str in $(cat $USER_DATA/dns.conf); do + eval $domain_str + U_DNS_DOMAINS=$((U_DNS_DOMAINS + 1)) + records=$(wc -l $USER_DATA/dns/$DOMAIN.conf| cut -f 1 -d ' ') + U_DNS_RECORDS=$((U_DNS_RECORDS + records)) + if [ "$SUSPENDED" = 'yes' ]; then + SUSPENDED_DNS=$((SUSPENDED_DNS + 1)) + fi + done + + # Checking mail system + for domain_str in $(cat $USER_DATA/mail.conf); do + eval $domain_str + U_DISK_MAIL=$((U_DISK_MAIL + U_DISK)) + U_MAIL_DOMAINS=$((U_MAIL_DOMAINS + 1)) + accounts=$(wc -l $USER_DATA/mail/$DOMAIN.conf| cut -f 1 -d ' ') + U_MAIL_ACCOUNTS=$((U_MAIL_ACCOUNTS + accounts)) + if [ "$DKIM" = 'yes' ]; then + U_MAIL_DKIM=$((U_MAIL_DKIM + 1)) + fi + if [ "$SUSPENDED" = 'yes' ]; then + SUSPENDED_MAIL=$((SUSPENDED_MAIL + 1)) + fi + done + DISK=$((DISK + U_DISK_MAIL)) + + # Checking db system + for db_str in $(cat $USER_DATA/db.conf); do + eval $db_str + U_DISK_DB=$((U_DISK_DB + U_DISK)) + U_DATABASES=$((U_DATABASES + 1)) + if [ "$SUSPENDED" = 'yes' ]; then + SUSPENDED_DB=$((SUSPENDED_DB + 1)) + fi + done + DISK=$((DISK + U_DISK_DB)) + + # Checking cron system + for cron_str in $(cat $USER_DATA/cron.conf);do + eval $cron_str + U_CRON_JOBS=$((U_CRON_JOBS + 1)) + if [ "$SUSPENDED" = 'yes' ]; then + SUSPENDED_CRON=$((SUSPENDED_CRON + 1)) + fi + done + + # Checking backup + for backup_str in $(cat $USER_DATA/backup.conf); do + U_BACKUPS=$((U_BACKUPS +1)) + done + + U_DISK=$DISK + U_BANDWIDTH=$BANDWIDTH + update_user_value "$user" '$SUSPENDED_USERS' "$SUSPENDED_USERS" + update_user_value "$user" '$SUSPENDED_WEB' "$SUSPENDED_WEB" + update_user_value "$user" '$SUSPENDED_DNS' "$SUSPENDED_DNS" + update_user_value "$user" '$SUSPENDED_MAIL' "$SUSPENDED_MAIL" + update_user_value "$user" '$SUSPENDED_DB' "$SUSPENDED_DB" + update_user_value "$user" '$SUSPENDED_CRON' "$SUSPENDED_CRON" + update_user_value "$user" '$IP_AVAIL' "$IP_AVAIL" + update_user_value "$user" '$IP_OWNED' "$IP_OWNED" + update_user_value "$user" '$U_USERS' "$U_USERS" + update_user_value "$user" '$U_DISK' "$U_DISK" + update_user_value "$user" '$U_DISK_DIRS' "$U_DISK_DIRS" + update_user_value "$user" '$U_DISK_WEB' "$U_DISK_WEB" + update_user_value "$user" '$U_DISK_MAIL' "$U_DISK_MAIL" + update_user_value "$user" '$U_DISK_DB' "$U_DISK_DB" + update_user_value "$user" '$U_BANDWIDTH' "$U_BANDWIDTH" + update_user_value "$user" '$U_WEB_DOMAINS' "$U_WEB_DOMAINS" + update_user_value "$user" '$U_WEB_SSL' "$U_WEB_SSL" + update_user_value "$user" '$U_WEB_ALIASES' "$U_WEB_ALIASES" + update_user_value "$user" '$U_DNS_DOMAINS' "$U_DNS_DOMAINS" + update_user_value "$user" '$U_DNS_RECORDS' "$U_DNS_RECORDS" + update_user_value "$user" '$U_MAIL_DOMAINS' "$U_MAIL_DOMAINS" + update_user_value "$user" '$U_MAIL_DKIM' "$U_MAIL_DKIM" + update_user_value "$user" '$U_MAIL_ACCOUNTS' "$U_MAIL_ACCOUNTS" + update_user_value "$user" '$U_DATABASES' "$U_DATABASES" + update_user_value "$user" '$U_CRON_JOBS' "$U_CRON_JOBS" + update_user_value "$user" '$U_BACKUPS' "$U_BACKUPS" +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-update-user-disk b/bin/v-update-user-disk index 19d4812b5..4a8f32f8b 100755 --- a/bin/v-update-user-disk +++ b/bin/v-update-user-disk @@ -1,65 +1,65 @@ -#!/bin/bash -# info: update user disk usage -# options: user -# -# The functions recalculates disk usage and updates database. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'user' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Saving old IFS -OLDIFS=$IFS -IFS=$(echo -en "\n\b") - -# Defining directory list -dir_list=$(ls $HOMEDIR/$user/ |grep -v '^web$' | grep -v '^mail$' |\ - grep -v '^conf$') - -# Starting update disk loop -disk_usage='0' -for dir in $dir_list; do - dir_disk=$(du -shm "$HOMEDIR/$user/$dir"|cut -f 1 ) - disk_usage=$((disk_usage + dir_disk)) -done - -# Restoring old IFS -IFS=$OLDIFS - -# Updating disk value in config -update_user_value "$user" '$U_DIR_DISK' "$disk_usage" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Recalculating user disk space -recalc_user_disk_usage - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: update user disk usage +# options: USER +# +# The functions recalculates disk usage and updates database. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Saving old IFS +OLDIFS=$IFS +IFS=$(echo -en "\n\b") + +# Defining directory list +dir_list=$(ls $HOMEDIR/$user/ |grep -v '^web$' | grep -v '^mail$' |\ + grep -v '^conf$') + +# Starting update disk loop +disk_usage='0' +for dir in $dir_list; do + dir_disk=$(du -shm "$HOMEDIR/$user/$dir"|cut -f 1 ) + disk_usage=$((disk_usage + dir_disk)) +done + +# Restoring old IFS +IFS=$OLDIFS + +# Updating disk value in config +update_user_value "$user" '$U_DIR_DISK' "$disk_usage" + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Recalculating user disk space +recalc_user_disk_usage + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-update-user-package b/bin/v-update-user-package index 933a333ad..803188a79 100755 --- a/bin/v-update-user-package +++ b/bin/v-update-user-package @@ -1,47 +1,47 @@ -#!/bin/bash -# info: update user package -# options: pacakge -# -# The function propogates package to connected users. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -package=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'package' -validate_format 'package' -is_package_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -for user in $(ls $VESTA/data/users); do - check_package=$(grep "PACKAGE='$package'" $USER_DATA/$user/user.conf) - if [ ! -z "$check_package" ]; then - $BIN/v-change-user-package $user $package 'yes' - fi -done - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: update user package +# options: PACAKGE +# +# The function propogates package to connected users. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +package=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'PACKAGE' +validate_format 'package' +is_package_valid + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +for user in $(ls $VESTA/data/users); do + check_package=$(grep "PACKAGE='$package'" $USER_DATA/$user/user.conf) + if [ ! -z "$check_package" ]; then + $BIN/v-change-user-package $user $package 'yes' + fi +done + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-update-user-stats b/bin/v-update-user-stats index b62945274..066042850 100755 --- a/bin/v-update-user-stats +++ b/bin/v-update-user-stats @@ -1,169 +1,169 @@ -#!/bin/bash -# info: update user statistics -# options: user -# -# Function logs user parameters into statistics database. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Importing system enviroment as we run this script -# mostly by cron wich not read it by itself -source /etc/profile - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '0' "$#" 'user' -if [ ! -z "$user" ]; then - validate_format 'user' - is_object_valid 'user' 'USER' "$user" -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Creating user_list -if [ -z "$user" ]; then - user_list=$(ls $VESTA/data/users) -else - user_list="$user" -fi - -# Reset overal statistics -TOTAL_IP_OWNED=0 -TOTAL_U_DISK=0 -TOTAL_U_DISK_DIRS=0 -TOTAL_U_DISK_WEB=0 -TOTAL_U_DISK_MAIL=0 -TOTAL_U_DISK_DB=0 -TOTAL_U_BANDWIDTH=0 -TOTAL_U_WEB_DOMAINS=0 -TOTAL_U_WEB_SSL=0 -TOTAL_U_WEB_ALIASES=0 -TOTAL_U_DNS_DOMAINS=0 -TOTAL_U_DNS_RECORDS=0 -TOTAL_U_MAIL_DOMAINS=0 -TOTAL_U_MAIL_DKIM=0 -TOTAL_U_MAIL_ACCOUNTS=0 -TOTAL_U_DATABASES=0 -TOTAL_U_CRON_JOBS=0 -TOTAL_U_BACKUPS=0 - -# Updating user stats -for user in $user_list; do - USER_DATA=$VESTA/data/users/$user - source $USER_DATA/user.conf - next_month=$(date +'%m/01' -d '+ 1 month') - DATE=$(date -d "$next_month -1day" +%F) - - # Compiling report string - s="DATE='$DATE' TIME='$TIME' PACKAGE='$PACKAGE' IP_OWNED='$IP_OWNED'" - s="$s DISK_QUOTA='$DISK_QUOTA' U_DISK='$U_DISK' U_DISK_DIRS='$U_DISK_DIRS'" - s="$s U_DISK_WEB='$U_DISK_WEB' U_DISK_MAIL='$U_DISK_MAIL'" - s="$s U_DISK_DB='$U_DISK_DB' BANDWIDTH='$BANDWIDTH'" - s="$s U_BANDWIDTH='$U_BANDWIDTH' U_WEB_DOMAINS='$U_WEB_DOMAINS'" - s="$s U_WEB_SSL='$U_WEB_SSL' U_WEB_ALIASES='$U_WEB_ALIASES'" - s="$s U_DNS_DOMAINS='$U_DNS_DOMAINS' U_DNS_RECORDS='$U_DNS_RECORDS'" - s="$s U_MAIL_DOMAINS='$U_MAIL_DOMAINS' U_MAIL_DKIM='$U_MAIL_DKIM'" - s="$s U_MAIL_ACCOUNTS='$U_MAIL_ACCOUNTS' U_DATABASES='$U_DATABASES'" - s="$s U_CRON_JOBS='$U_CRON_JOBS' U_BACKUPS='$U_BACKUPS'" - - # Updating user stats log - stats="$USER_DATA/stats.log" - if [ -e "$stats" ]; then - # Checking dublicates - check_month=$(grep -n "DATE='$DATE'" $stats|cut -f 1 -d :) - if [ -z "$check_month" ]; then - # Updating as there no dublicates - echo "$s" >> $stats - chmod 660 $stats - else - # Replacing string with new data - sed -i "$check_month s/.*/$s/" $stats - fi - else - # Creating stats log - echo "$s" >$stats - chmod 660 $stats - fi - - # Increase overall counters - TOTAL_IP_OWNED=$((TOTAL_IP_OWNED + IP_OWNED)) - TOTAL_U_DISK=$((TOTAL_U_DISK + U_DISK)) - TOTAL_U_DISK_DIRS=$((TOTAL_U_DISK_DIRS + U_DISK_DIRS)) - TOTAL_U_DISK_WEB=$((TOTAL_U_DISK_WEB + U_DISK_WEB)) - TOTAL_U_DISK_MAIL=$((TOTAL_U_DISK_MAIL + U_DISK_MAIL)) - TOTAL_U_DISK_DB=$((TOTAL_U_DISK_DB + U_DISK_DB)) - TOTAL_U_BANDWIDTH=$((TOTAL_U_BANDWIDTH + U_BANDWIDTH)) - TOTAL_U_WEB_DOMAINS=$((TOTAL_U_WEB_DOMAINS + U_WEB_DOMAINS)) - TOTAL_U_WEB_SSL=$((TOTAL_U_WEB_SSL + U_WEB_SSL)) - TOTAL_U_WEB_ALIASES=$((TOTAL_U_WEB_ALIASES + U_WEB_ALIASES)) - TOTAL_U_DNS_DOMAINS=$((TOTAL_U_DNS_DOMAINS + U_DNS_DOMAINS)) - TOTAL_U_DNS_RECORDS=$((TOTAL_U_DNS_RECORDS + U_DNS_RECORDS)) - TOTAL_U_MAIL_DOMAINS=$((TOTAL_U_MAIL_DOMAINS + U_MAIL_DOMAINS)) - TOTAL_U_MAIL_DKIM=$((TOTAL_U_MAIL_DKIM + U_MAIL_DKIM)) - TOTAL_U_MAIL_ACCOUNTS=$((TOTAL_U_MAIL_ACCOUNTS + U_MAIL_ACCOUNTS)) - TOTAL_U_DATABASES=$((TOTAL_U_DATABASES + U_DATABASES)) - TOTAL_U_CRON_JOBS=$((TOTAL_U_CRON_JOBS + U_CRON_JOBS)) - TOTAL_U_BACKUPS=$((TOTAL_U_BACKUPS + U_BACKUPS)) - -done - -# Updating overall stats -stats="$VESTA/data/users/admin/overall_stats.log" - -s="DATE='$DATE' TIME='$TIME' PACKAGE='default' IP_OWNED='$TOTAL_IP_OWNED'" -s="$s DISK_QUOTA='0' U_DISK='$TOTAL_U_DISK' U_DISK_DIRS='$TOTAL_U_DISK_DIRS'" -s="$s U_DISK_WEB='$TOTAL_U_DISK_WEB' U_DISK_MAIL='$TOTAL_U_DISK_MAIL'" -s="$s U_DISK_DB='$TOTAL_U_DISK_DB' BANDWIDTH='0'" -s="$s U_BANDWIDTH='$TOTAL_U_BANDWIDTH' U_WEB_DOMAINS='$TOTAL_U_WEB_DOMAINS'" -s="$s U_WEB_SSL='$TOTAL_U_WEB_SSL' U_WEB_ALIASES='$TOTAL_U_WEB_ALIASES'" -s="$s U_DNS_DOMAINS='$TOTAL_U_DNS_DOMAINS'" -s="$s U_DNS_RECORDS='$TOTAL_U_DNS_RECORDS'" -s="$s U_MAIL_DOMAINS='$TOTAL_U_MAIL_DOMAINS' U_MAIL_DKIM='$TOTAL_U_MAIL_DKIM'" -s="$s U_MAIL_ACCOUNTS='$TOTAL_U_MAIL_ACCOUNTS'" -s="$s U_DATABASES='$TOTAL_U_DATABASES'" -s="$s U_CRON_JOBS='$TOTAL_U_CRON_JOBS' U_BACKUPS='$TOTAL_U_BACKUPS'" - -if [ -e "$stats" ]; then - # Checking dublicates - check_month=$(grep -n "DATE='$DATE'" $stats|cut -f 1 -d :) - if [ -z "$check_month" ]; then - # Updating as there no dublicates - echo "$s" >> $stats - chmod 660 $stats - else - # Replacing string with new data - sed -i "$check_month s/.*/$s/" $stats - fi -else - # Creating stats log - echo "$s" >$stats - chmod 660 $stats -fi - - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: update user statistics +# options: USER +# +# Function logs user parameters into statistics database. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Importing system enviroment as we run this script +# mostly by cron wich not read it by itself +source /etc/profile + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '0' "$#" 'USER' +if [ ! -z "$user" ]; then + validate_format 'user' + is_object_valid 'user' 'USER' "$user" +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Creating user_list +if [ -z "$user" ]; then + user_list=$(ls $VESTA/data/users) +else + user_list="$user" +fi + +# Reset overal statistics +TOTAL_IP_OWNED=0 +TOTAL_U_DISK=0 +TOTAL_U_DISK_DIRS=0 +TOTAL_U_DISK_WEB=0 +TOTAL_U_DISK_MAIL=0 +TOTAL_U_DISK_DB=0 +TOTAL_U_BANDWIDTH=0 +TOTAL_U_WEB_DOMAINS=0 +TOTAL_U_WEB_SSL=0 +TOTAL_U_WEB_ALIASES=0 +TOTAL_U_DNS_DOMAINS=0 +TOTAL_U_DNS_RECORDS=0 +TOTAL_U_MAIL_DOMAINS=0 +TOTAL_U_MAIL_DKIM=0 +TOTAL_U_MAIL_ACCOUNTS=0 +TOTAL_U_DATABASES=0 +TOTAL_U_CRON_JOBS=0 +TOTAL_U_BACKUPS=0 + +# Updating user stats +for user in $user_list; do + USER_DATA=$VESTA/data/users/$user + source $USER_DATA/user.conf + next_month=$(date +'%m/01' -d '+ 1 month') + DATE=$(date -d "$next_month -1day" +%F) + + # Compiling report string + s="DATE='$DATE' TIME='$TIME' PACKAGE='$PACKAGE' IP_OWNED='$IP_OWNED'" + s="$s DISK_QUOTA='$DISK_QUOTA' U_DISK='$U_DISK' U_DISK_DIRS='$U_DISK_DIRS'" + s="$s U_DISK_WEB='$U_DISK_WEB' U_DISK_MAIL='$U_DISK_MAIL'" + s="$s U_DISK_DB='$U_DISK_DB' BANDWIDTH='$BANDWIDTH'" + s="$s U_BANDWIDTH='$U_BANDWIDTH' U_WEB_DOMAINS='$U_WEB_DOMAINS'" + s="$s U_WEB_SSL='$U_WEB_SSL' U_WEB_ALIASES='$U_WEB_ALIASES'" + s="$s U_DNS_DOMAINS='$U_DNS_DOMAINS' U_DNS_RECORDS='$U_DNS_RECORDS'" + s="$s U_MAIL_DOMAINS='$U_MAIL_DOMAINS' U_MAIL_DKIM='$U_MAIL_DKIM'" + s="$s U_MAIL_ACCOUNTS='$U_MAIL_ACCOUNTS' U_DATABASES='$U_DATABASES'" + s="$s U_CRON_JOBS='$U_CRON_JOBS' U_BACKUPS='$U_BACKUPS'" + + # Updating user stats log + stats="$USER_DATA/stats.log" + if [ -e "$stats" ]; then + # Checking dublicates + check_month=$(grep -n "DATE='$DATE'" $stats|cut -f 1 -d :) + if [ -z "$check_month" ]; then + # Updating as there no dublicates + echo "$s" >> $stats + chmod 660 $stats + else + # Replacing string with new data + sed -i "$check_month s/.*/$s/" $stats + fi + else + # Creating stats log + echo "$s" >$stats + chmod 660 $stats + fi + + # Increase overall counters + TOTAL_IP_OWNED=$((TOTAL_IP_OWNED + IP_OWNED)) + TOTAL_U_DISK=$((TOTAL_U_DISK + U_DISK)) + TOTAL_U_DISK_DIRS=$((TOTAL_U_DISK_DIRS + U_DISK_DIRS)) + TOTAL_U_DISK_WEB=$((TOTAL_U_DISK_WEB + U_DISK_WEB)) + TOTAL_U_DISK_MAIL=$((TOTAL_U_DISK_MAIL + U_DISK_MAIL)) + TOTAL_U_DISK_DB=$((TOTAL_U_DISK_DB + U_DISK_DB)) + TOTAL_U_BANDWIDTH=$((TOTAL_U_BANDWIDTH + U_BANDWIDTH)) + TOTAL_U_WEB_DOMAINS=$((TOTAL_U_WEB_DOMAINS + U_WEB_DOMAINS)) + TOTAL_U_WEB_SSL=$((TOTAL_U_WEB_SSL + U_WEB_SSL)) + TOTAL_U_WEB_ALIASES=$((TOTAL_U_WEB_ALIASES + U_WEB_ALIASES)) + TOTAL_U_DNS_DOMAINS=$((TOTAL_U_DNS_DOMAINS + U_DNS_DOMAINS)) + TOTAL_U_DNS_RECORDS=$((TOTAL_U_DNS_RECORDS + U_DNS_RECORDS)) + TOTAL_U_MAIL_DOMAINS=$((TOTAL_U_MAIL_DOMAINS + U_MAIL_DOMAINS)) + TOTAL_U_MAIL_DKIM=$((TOTAL_U_MAIL_DKIM + U_MAIL_DKIM)) + TOTAL_U_MAIL_ACCOUNTS=$((TOTAL_U_MAIL_ACCOUNTS + U_MAIL_ACCOUNTS)) + TOTAL_U_DATABASES=$((TOTAL_U_DATABASES + U_DATABASES)) + TOTAL_U_CRON_JOBS=$((TOTAL_U_CRON_JOBS + U_CRON_JOBS)) + TOTAL_U_BACKUPS=$((TOTAL_U_BACKUPS + U_BACKUPS)) + +done + +# Updating overall stats +stats="$VESTA/data/users/admin/overall_stats.log" + +s="DATE='$DATE' TIME='$TIME' PACKAGE='default' IP_OWNED='$TOTAL_IP_OWNED'" +s="$s DISK_QUOTA='0' U_DISK='$TOTAL_U_DISK' U_DISK_DIRS='$TOTAL_U_DISK_DIRS'" +s="$s U_DISK_WEB='$TOTAL_U_DISK_WEB' U_DISK_MAIL='$TOTAL_U_DISK_MAIL'" +s="$s U_DISK_DB='$TOTAL_U_DISK_DB' BANDWIDTH='0'" +s="$s U_BANDWIDTH='$TOTAL_U_BANDWIDTH' U_WEB_DOMAINS='$TOTAL_U_WEB_DOMAINS'" +s="$s U_WEB_SSL='$TOTAL_U_WEB_SSL' U_WEB_ALIASES='$TOTAL_U_WEB_ALIASES'" +s="$s U_DNS_DOMAINS='$TOTAL_U_DNS_DOMAINS'" +s="$s U_DNS_RECORDS='$TOTAL_U_DNS_RECORDS'" +s="$s U_MAIL_DOMAINS='$TOTAL_U_MAIL_DOMAINS' U_MAIL_DKIM='$TOTAL_U_MAIL_DKIM'" +s="$s U_MAIL_ACCOUNTS='$TOTAL_U_MAIL_ACCOUNTS'" +s="$s U_DATABASES='$TOTAL_U_DATABASES'" +s="$s U_CRON_JOBS='$TOTAL_U_CRON_JOBS' U_BACKUPS='$TOTAL_U_BACKUPS'" + +if [ -e "$stats" ]; then + # Checking dublicates + check_month=$(grep -n "DATE='$DATE'" $stats|cut -f 1 -d :) + if [ -z "$check_month" ]; then + # Updating as there no dublicates + echo "$s" >> $stats + chmod 660 $stats + else + # Replacing string with new data + sed -i "$check_month s/.*/$s/" $stats + fi +else + # Creating stats log + echo "$s" >$stats + chmod 660 $stats +fi + + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-update-web-domain-disk b/bin/v-update-web-domain-disk index 5e838a062..52617853f 100755 --- a/bin/v-update-web-domain-disk +++ b/bin/v-update-web-domain-disk @@ -1,60 +1,60 @@ -#!/bin/bash -# info: update disk usage for domain -# options: user domain -# -# The function recalculates disk usage for speciefic webdomain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining home directory -home_dir="$HOMEDIR/$user/web/$domain/" - -# Checking home directory exist -if [ -e "$home_dir" ]; then - disk_usage=$(nice -n 19 du -shm $home_dir | cut -f 1 ) -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating disk value in config -update_object_value 'web' 'DOMAIN' "$domain" '$U_DISK' "$disk_usage" -recalc_user_disk_usage - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: update disk usage for domain +# options: USER DOMAIN +# +# The function recalculates disk usage for speciefic webdomain. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining home directory +home_dir="$HOMEDIR/$user/web/$domain/" + +# Checking home directory exist +if [ -e "$home_dir" ]; then + disk_usage=$(nice -n 19 du -shm $home_dir | cut -f 1 ) +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Updating disk value in config +update_object_value 'web' 'DOMAIN' "$domain" '$U_DISK' "$disk_usage" +recalc_user_disk_usage + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-update-web-domain-stat b/bin/v-update-web-domain-stat index 58093590e..4692002e9 100755 --- a/bin/v-update-web-domain-stat +++ b/bin/v-update-web-domain-stat @@ -1,144 +1,144 @@ -#!/bin/bash -# info: update domain statistics -# options: user domain -# -# The function runs log analyzer for speciefic webdomain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'user domain' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -get_domain_values 'web' - -# Checking config -config="$HOMEDIR/$user/conf/web/$STATS.$domain.conf" -if [ ! -e "$config" ]; then - echo "Error: Parsing error" - log_event "$E_PARSING" "$EVENT" - exit $E_PARSING -fi - -# Checking statistics directory -dir="$HOMEDIR/$user/web/$domain/stats" -if [ ! -e "$dir" ]; then - mkdir -p $dir -fi - -# Defining functions -build_webalizer() { - /usr/bin/webalizer -c $config -} - -build_awstats() { - awstats="/usr/share/awstats/wwwroot/cgi-bin/awstats.pl" - wwwroot="/usr/share/awstats/wwwroot" - opts="-config=$domain -staticlinks -update -output" - month=$(date "+%Y-%m") - output='alldomains allhosts lasthosts unknownip allrobots lastrobots - urldetail urlentry urlexit osdetail browserdetail unknownbrowser - unknownos refererse refererpages keyphrases keywords errors404' - - # Checking statistics directory - if [ ! -e "$dir/$month" ]; then - mkdir -p $dir/$month - fi - - # Logo check - if [ ! -e "$dir/logo.png" ]; then - cp -r $VESTA/web/images/logo.png $dir/ - fi - - # Icon directory check - if [ ! -e "$dir/icon" ]; then - cp -r $wwwroot/icon $dir/ - fi - - # Creating main awstats page - $awstats $opts | sed -e "s%awstats.$domain.%%g" > $dir/$month/index.html - - # Creating suplemental awstats pages - for format in $output; do - $awstats $opts=$format |\ - sed -e "s%awstats.$domain.%%g" > $dir/$month/$format.html - done - - # Creating index page - cat $WEBTPL/awstats_index.tpl | sed -e "s/%month%/$month/g" >\ - $dir/index.html - - # Creating navigation page - months=$(find $dir -type d | sed -e "s%$dir/%%g" -e "s%$dir%%g" |\ - grep -v icon | sort -r ) - for link in $months; do - year=$(echo $link |cut -f 1 -d \-) - month=$(echo $link |cut -f 2 -d \-) - case "$month" in - 1) month='January';; - 2) month='February';; - 3) month='March';; - 4) month='April';; - 5) month='May';; - 6) month='June';; - 7) month='July';; - 8) month='August';; - 9) month='September';; - 10) month='October';; - 11) month='November';; - 12) month='December';; - esac - echo $month - - select_m="$select_m
- -
- - - - - -
- - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Package Name -
- - Default Template -
- -
- System Shell -
- -
- Web Domains -
- - Web Aliases (per domain) -
- - DNS Domains -
- - DNS Records (per domain) -
- - Mail Domains -
- - Mail Accounts (per domain) -
- - Databases -
- - Cron Jobs -
- - Backups -
- - Disk Quota (in Mb) -
- - Bandwidth (in Mb) -
- - Name Servers -
- - - -
-
-
+ + + + + + + + +
+ +
+ + + + + +
+ + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Package Name +
+ + Default Template +
+ +
+ System Shell +
+ +
+ Web Domains +
+ + Web Aliases (per domain) +
+ + DNS Domains +
+ + DNS Records (per domain) +
+ + Mail Domains +
+ + Mail Accounts (per domain) +
+ + Databases +
+ + Cron Jobs +
+ + Backups +
+ + Disk Quota (in Mb) +
+ + Bandwidth (in Mb) +
+ + Name Servers +
+ + + +
+
+
diff --git a/web/templates/admin/edit_mail_acc.html b/web/templates/admin/edit_mail_acc.html index bd87ada4b..ed909bc89 100644 --- a/web/templates/admin/edit_mail_acc.html +++ b/web/templates/admin/edit_mail_acc.html @@ -1,163 +1,155 @@ - - - - - - - -
- -
- - - - - - - -
- - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Domain -
- - Account -
- - Password generate -
- - Quota (in megabytes) -
- > -
- Aliases (use local-part) -
- -
- Forward to (email address or addresses) -
- -
- Autoreply -
- onclick="javascript:elementHideShow('autoreplytable');"> -
- - - - - - - -
- Autoreply Message -
- -
-
- - -
-
-
+ + + + + + + +
+ +
+ + + + + + + +
+ + + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Account +
+ disabled > + + Password generate +
+ + Quota (in megabytes) +
+ > +
+ Aliases (use local-part) +
+ +
+ Forward to (email address or addresses) +
+ +
+ Autoreply +
+ onclick="javascript:elementHideShow('autoreplytable');"> +
+ + + + + + + +
+ Autoreply Message +
+ +
+
+ + +
+
+
diff --git a/web/templates/admin/list_backup.html b/web/templates/admin/list_backup.html index cdb4fa5a7..8a6899931 100644 --- a/web/templates/admin/list_backup.html +++ b/web/templates/admin/list_backup.html @@ -1,193 +1,193 @@ - - - - - - -
- -
- - - $value) { - ++$i; - $web = 'no'; - $dns = 'no'; - $mail = 'no'; - $db = 'no'; - - if (!empty($data[$key]['WEB'])) $web = 'yes ¨'; - if (!empty($data[$key]['DNS'])) $dns = 'yes ¨'; - if (!empty($data[$key]['MAIL'])) $mail = 'yes ¨'; - if (!empty($data[$key]['DB'])) $db = 'yes ¨'; - ?> - - - - - - - - -
- - - - -
">
active
-
- - - - - - - -
download"> restore - - delete - " /> - -
- - - - - - - - - - -
- -
- - - - - - - - - - -
- -
- Run Time: -
- Backup Size: -
-
- - - - - - - - - - - - - -
- SYS: - - - - -
- WEB: - - - - -
- DNS: - - - - -
-
- - - - - - - - - - - - - -
- MAIL: - - - - -
- DB: - - - - -
- CRON: - - - - -
-
-
- - - - - - - -
- -
-
- + + + + + + +
+ +
+ + + $value) { + ++$i; + $web = 'no'; + $dns = 'no'; + $mail = 'no'; + $db = 'no'; + + if (!empty($data[$key]['WEB'])) $web = 'yes ¨'; + if (!empty($data[$key]['DNS'])) $dns = 'yes ¨'; + if (!empty($data[$key]['MAIL'])) $mail = 'yes ¨'; + if (!empty($data[$key]['DB'])) $db = 'yes ¨'; + ?> + + + + + + + + +
+ + + + +
">
active
+
+ + + + + + + +
download"> restore + + delete + " /> + +
+ + + + + + + + + + +
+ +
+ + + + + + + + + + +
+ +
+ Run Time: +
+ Backup Size: +
+
+ + + + + + + + + + + + + +
+ SYS: + + + + +
+ WEB: + + + + +
+ DNS: + + + + +
+
+ + + + + + + + + + + + + +
+ MAIL: + + + + +
+ DB: + + + + +
+ CRON: + + + + +
+
+
+ + + + + + + +
+ +
+
+ diff --git a/web/templates/admin/list_cron.html b/web/templates/admin/list_cron.html index 519dc28f3..c511735c1 100644 --- a/web/templates/admin/list_cron.html +++ b/web/templates/admin/list_cron.html @@ -1,181 +1,181 @@ - - - - - -
- -
- - - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend'; - } - ?> - - - - - - - -
- - - - -
">
-
- - - - - - - -
edit - - - - - - - delete - - -
- - - - - - - - - - - - -
- -
- - - - - - - -
- Min -
- -
-
- - - - - - - -
- Hour -
- -
-
- - - - - - - -
- Day -
- -
-
- - - - - - - -
- Month -
- -
-
- - - - - - - -
- Day of Week -
- -
-
-
- - - - - - - -
- -
-
- + + + + + + + + + +
+ + + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend'; + } + ?> + + + + + + + +
+ + + + +
">
+
+ + + + + + + +
edit + + + + + + + delete + + +
+ + + + + + + + + + + + +
+ +
+ + + + + + + +
+ Min +
+ +
+
+ + + + + + + +
+ Hour +
+ +
+
+ + + + + + + +
+ Day +
+ +
+
+ + + + + + + +
+ Month +
+ +
+
+ + + + + + + +
+ Day of Week +
+ +
+
+
+ + + + + + + +
+ +
+
+ diff --git a/web/templates/admin/list_db.html b/web/templates/admin/list_db.html index ba4875dab..30a265166 100644 --- a/web/templates/admin/list_db.html +++ b/web/templates/admin/list_db.html @@ -1,161 +1,161 @@ - - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - if ($data[$key]['TYPE'] == 'mysql') $db_admin = "phpMyAdmin"; - if ($data[$key]['TYPE'] == 'mysql') $db_admin_link = "http://".$http_host."/phpMyAdmin/"; - if ($data[$key]['TYPE'] == 'pgsql') $db_admin = "phpPgAdmin"; - if ($data[$key]['TYPE'] == 'pgsql') $db_admin_link = "http://".$http_host."/phpPgAdmin/"; - ?> - - - - - -
- - - - -
">
-
- - - - - - - - -
open edit - - - " /> - - - - delete - " /> - -
- - - - - - - - - -
- -
- - - - - - - -
- [] database -
Disk: -
-
-
-
-
- - - - - - - - - -
- User: - - -
- Host: - - -
-
- - - - - -
- Charset: - - -
-
-
- - - - - - - -
- -
-
+ + + + + + + + + + +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + if ($data[$key]['TYPE'] == 'mysql') $db_admin = "phpMyAdmin"; + if ($data[$key]['TYPE'] == 'mysql') $db_admin_link = "http://".$http_host."/phpMyAdmin/"; + if ($data[$key]['TYPE'] == 'pgsql') $db_admin = "phpPgAdmin"; + if ($data[$key]['TYPE'] == 'pgsql') $db_admin_link = "http://".$http_host."/phpPgAdmin/"; + ?> + + + + + +
+ + + + +
">
+
+ + + + + + + + +
open edit + + + " /> + + + + delete + " /> + +
+ + + + + + + + + +
+ +
+ + + + + + + +
+ [] database +
Disk: +
+
+
+
+
+ + + + + + + + + +
+ User: + + +
+ Host: + + +
+
+ + + + + +
+ Charset: + + +
+
+
+ + + + + + + +
+ +
+
diff --git a/web/templates/admin/list_dns.html b/web/templates/admin/list_dns.html index 29bf75e53..a11e63213 100644 --- a/web/templates/admin/list_dns.html +++ b/web/templates/admin/list_dns.html @@ -1,147 +1,147 @@ - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - ?> - - - - - - -
- - - - -
" >
">
-
- - - - - - - - - -
list records add record edit - - - - - - - delete - - -
- - - - - - - - - -
- -
- - - - - - -
- -
- [] template -
-
- - - - - - - - - -
SOA:
TTL:
-
- - - - - - - - - -
Expire:
Records:
-
-
- - - - - - - -
- -
-
- + + + + + + + + + +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + ?> + + + + + + +
+ + + + +
" >
">
+
+ + + + + + + + + +
list records add record edit + + + + + + + delete + + +
+ + + + + + + + + +
+ +
+ + + + + + +
+ +
+ [] template +
+
+ + + + + + + + + +
SOA:
TTL:
+
+ + + + + + + + + +
Expire:
Records:
+
+
+ + + + + + + +
+ +
+
+ diff --git a/web/templates/admin/list_dns_rec.html b/web/templates/admin/list_dns_rec.html index 12a975486..2489aea76 100644 --- a/web/templates/admin/list_dns_rec.html +++ b/web/templates/admin/list_dns_rec.html @@ -1,107 +1,107 @@ - - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - ?> - - - - - - -
- - - - -
">
-
- - - - - - - -
edit - - - - - - - delete - - -
- - - - - - - -
-
- - - - - - -
- - -
-
+ + + + + + + + + + +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + ?> + + + + + + +
+ + + + +
">
+
+ + + + + + + +
edit + + + + + + + delete + + +
+ + + + + + + +
+
+ + + + + + +
+ + +
+
diff --git a/web/templates/admin/list_ip.html b/web/templates/admin/list_ip.html index 3831fa4d3..3e4a80712 100644 --- a/web/templates/admin/list_ip.html +++ b/web/templates/admin/list_ip.html @@ -1,137 +1,137 @@ - - - - - - - - - - -
- - - $value) { - ++$i; - ?> - - - - - - - -
- - - - -
">
active
-
- - - - - - -
edit - - delete - " /> - -
- - - - - - - - - - -
- -
- - - - - - - -
- -
- -
-
- - - - - - - - - -
- Web Domains: - - -
- Status: - - -
-
- - - - -
- Sys Users: -
-
-
- - - - - - - -
- -
-
+ + + + + + + + + + +
+ + + $value) { + ++$i; + ?> + + + + + + + +
+ + + + +
">
active
+
+ + + + + + +
edit + + delete + " /> + +
+ + + + + + + + + + +
+ +
+ + + + + + + +
+ +
+ +
+
+ + + + + + + + + +
+ Web Domains: + + +
+ Status: + + +
+
+ + + + +
+ Sys Users: +
+
+
+ + + + + + + +
+ +
+
diff --git a/web/templates/admin/list_log.html b/web/templates/admin/list_log.html index aafabd6eb..b1f2dab35 100644 --- a/web/templates/admin/list_log.html +++ b/web/templates/admin/list_log.html @@ -1,71 +1,71 @@ - - - - - - - - - - -
- - - $value) { - ++$i; - ?> - - - - - - - - -
- - - -
">
">
-
- - - - -
- - - - -
- -
-
- - - - - - -
- -
-
+ + + + + + + + + + +
+ + + $value) { + ++$i; + ?> + + + + + + + + +
+ + + +
">
">
+
+ + + + +
+ + + + +
+ +
+
+ + + + + + +
+ +
+
diff --git a/web/templates/admin/list_mail.html b/web/templates/admin/list_mail.html index 0824e8059..e5a1844ca 100644 --- a/web/templates/admin/list_mail.html +++ b/web/templates/admin/list_mail.html @@ -1,173 +1,173 @@ - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - if (empty($data[$key]['CATCHALL'])) { - $data[$key]['CATCHALL'] = '/dev/null'; - } - ?> - - - - - - - -
- - - - -
" >
">
-
- - - - - - - - - - -
list accounts add account" target="_blank"> open webmail edit - - - - - - - delete - - -
- - - - - - - - - - -
- -
- - - - - - - -
- catchall > -
- Disk: -
-
-
-
-
- - - - - - - - - -
- Antivirus: - - -
- Antispam: - - -
-
- - - - - - - - - -
- DKIM: - - -
- Accounts: - - -
-
-
- - - - - - - -
- -
-
+ + + + + + + + + +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + if (empty($data[$key]['CATCHALL'])) { + $data[$key]['CATCHALL'] = '/dev/null'; + } + ?> + + + + + + + +
+ + + + +
" >
">
+
+ + + + + + + + + + +
list accounts add account" target="_blank"> open webmail edit + + + + + + + delete + + +
+ + + + + + + + + + +
+ +
+ + + + + + + +
+ catchall > +
+ Disk: +
+
+
+
+
+ + + + + + + + + +
+ Antivirus: + + +
+ Antispam: + + +
+
+ + + + + + + + + +
+ DKIM: + + +
+ Accounts: + + +
+
+
+ + + + + + + +
+ +
+
diff --git a/web/templates/admin/list_mail_acc.html b/web/templates/admin/list_mail_acc.html index ada142a19..2137383d6 100644 --- a/web/templates/admin/list_mail_acc.html +++ b/web/templates/admin/list_mail_acc.html @@ -1,155 +1,155 @@ - - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend'; - } - ?> - - - - - - - -
- - - - -
">
-
- - - - - - - -
edit - - - - - - - delete - - -
- - - - - - - - -
- - - - - - -
- -
- Disk: -
-
-
-
-
- - - - - - - - - -
- Quota: - - -
- Autoreply: - - -
-
- - - - - -
- Forward: - - -
-
-
- - - - - - - -
- -
-
- + + + + + + + + + + +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend'; + } + ?> + + + + + + + +
+ + + + +
">
+
+ + + + + + + +
edit + + + + + + + delete + + +
+ + + + + + + + +
+ + + + + + +
+ +
+ Disk: +
+
+
+
+
+ + + + + + + + + +
+ Quota: + + +
+ Autoreply: + + +
+
+ + + + + +
+ Forward: + + +
+
+
+ + + + + + + +
+ +
+
+ diff --git a/web/templates/admin/list_packages.html b/web/templates/admin/list_packages.html index a13395dd9..853164e6c 100644 --- a/web/templates/admin/list_packages.html +++ b/web/templates/admin/list_packages.html @@ -1,217 +1,217 @@ - - - - - - - - - - -
- - - $value) { - ++$i; - ?> - - - - - - - -
- - - - -
">
active
-
- - - - - - -
edit - - delete - " /> - -
- - - - - - - - - -
- -
- - - - - - - - - - - - - - - -
- Defaul Template: - - -
- System Shell: - - -
- Bandwidth: -
-
-
-
- Disk: -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - -
- Web Domains: - - -
- Web Aliases: - - per domain -
- Dns Domains: - - -
- Dns Records: - - per domain -
- Name Servers: - - -
-
- - - - - - - - - - - - - - - - - - - - - -
- Mail Domains: - - -
- Mail Accounts: - - per domain -
- Databases: - - -
- Cron Jobs: - - -
- Backups: - - -
-
-
- - - - - - - -
- -
-
+ + + + + + + + + + +
+ + + $value) { + ++$i; + ?> + + + + + + + +
+ + + + +
">
active
+
+ + + + + + +
edit + + delete + " /> + +
+ + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + +
+ Defaul Template: + + +
+ System Shell: + + +
+ Bandwidth: +
+
+
+
+ Disk: +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + +
+ Web Domains: + + +
+ Web Aliases: + + per domain +
+ Dns Domains: + + +
+ Dns Records: + + per domain +
+ Name Servers: + + +
+
+ + + + + + + + + + + + + + + + + + + + + +
+ Mail Domains: + + +
+ Mail Accounts: + + per domain +
+ Databases: + + +
+ Cron Jobs: + + +
+ Backups: + + +
+
+
+ + + + + + + +
+ +
+
diff --git a/web/templates/admin/list_rrd.html b/web/templates/admin/list_rrd.html index 0d3697ccc..fc9f1220d 100644 --- a/web/templates/admin/list_rrd.html +++ b/web/templates/admin/list_rrd.html @@ -1,72 +1,72 @@ - - - - - - - - - - -
- - $value) { - ?> - - - - - - - -
- - - -
">
">
-
- - - - - -
" target="_blank"> download
- - - - - - -
- - - - -
- "> -
-
-
-
-
+ + + + + + + + + + +
+ + $value) { + ?> + + + + + + + +
+ + + +
">
">
+
+ + + + + +
" target="_blank"> download
+ + + + + + +
+ + + + +
+ "> +
+
+
+
+
diff --git a/web/templates/admin/list_search.html b/web/templates/admin/list_search.html index a3ab75ab4..3f04096eb 100644 --- a/web/templates/admin/list_search.html +++ b/web/templates/admin/list_search.html @@ -1,218 +1,218 @@ - - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend'; - } - if ($data[$key]['TYPE'] == 'db') { - $object = 'database'; - } else { - $object = strtolower($data[$key]['TYPE']." ".$data[$key]['KEY']); - } - ?> - - - - - - - -
- - - -
">
-
- - - - - - - - - - -
- - login as - - '; - } - - if ($data[$key]['KEY'] == 'ACCOUNT') { - echo ''; - } - - if ($data[$key]['KEY'] == 'JOB') { - echo ''; - } - - if (($data[$key]['KEY'] != 'RECORD') && ($data[$key]['KEY'] != 'ACCOUNT') && ($data[$key]['KEY'] != 'JOB')) { - echo ''; - } - ?> - edit - - - - '; - } - - if ($data[$key]['KEY'] == 'ACCOUNT') { - echo ''; - } - - if ($data[$key]['KEY'] == 'JOB') { - echo ''; - } - - if (($data[$key]['KEY'] != 'RECORD') && ($data[$key]['KEY'] != 'ACCOUNT') && ($data[$key]['KEY'] != 'JOB')) { - echo ''; - } - ?> - - - - delete - '; - } - - if ($data[$key]['KEY'] == 'ACCOUNT') { - echo ''; - } - - if ($data[$key]['KEY'] == 'JOB') { - echo ''; - } - - if (($data[$key]['KEY'] != 'RECORD') && ($data[$key]['KEY'] != 'ACCOUNT') && ($data[$key]['KEY'] != 'JOB')) { - echo ''; - } - ?> - -
- - - - - - - - -
- - - - - -
- Object: - - -
-
- - - - - -
- Owner: - - -
-
- - - - - -
- Status: - - -
-
-
- - - - - - - -
- -
-
- + + + + + + + + + + +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend'; + } + if ($data[$key]['TYPE'] == 'db') { + $object = 'database'; + } else { + $object = strtolower($data[$key]['TYPE']." ".$data[$key]['KEY']); + } + ?> + + + + + + + +
+ + + +
">
+
+ + + + + + + + + + +
+ + login as + + '; + } + + if ($data[$key]['KEY'] == 'ACCOUNT') { + echo ''; + } + + if ($data[$key]['KEY'] == 'JOB') { + echo ''; + } + + if (($data[$key]['KEY'] != 'RECORD') && ($data[$key]['KEY'] != 'ACCOUNT') && ($data[$key]['KEY'] != 'JOB')) { + echo ''; + } + ?> + edit + + + + '; + } + + if ($data[$key]['KEY'] == 'ACCOUNT') { + echo ''; + } + + if ($data[$key]['KEY'] == 'JOB') { + echo ''; + } + + if (($data[$key]['KEY'] != 'RECORD') && ($data[$key]['KEY'] != 'ACCOUNT') && ($data[$key]['KEY'] != 'JOB')) { + echo ''; + } + ?> + + + + delete + '; + } + + if ($data[$key]['KEY'] == 'ACCOUNT') { + echo ''; + } + + if ($data[$key]['KEY'] == 'JOB') { + echo ''; + } + + if (($data[$key]['KEY'] != 'RECORD') && ($data[$key]['KEY'] != 'ACCOUNT') && ($data[$key]['KEY'] != 'JOB')) { + echo ''; + } + ?> + +
+ + + + + + + + +
+ + + + + +
+ Object: + + +
+
+ + + + + +
+ Owner: + + +
+
+ + + + + +
+ Status: + + +
+
+
+ + + + + + + +
+ +
+
+ diff --git a/web/templates/admin/list_stats.html b/web/templates/admin/list_stats.html index 35eb13093..aeae10115 100644 --- a/web/templates/admin/list_stats.html +++ b/web/templates/admin/list_stats.html @@ -1,221 +1,221 @@ - - - - - - - - - - -
- - - $value) { - ++$i; - ?> - - - - - - - - -
- - -
">
-
- - - - -
- - - - - - - - - - -
- -
- - - - - - - - - - - - - -
- [] package -
- Bandwidth: % () -
-
-
-
- Disk: % () -
-
-
-
- - - - - -
- Web:
- Mail:
-
- Databases:
- User Dirs:
-
-
-
- - - - - - - - - - - - - - - - - - - - - -
- Web Domains: - - -
- Web SSL: - - -
- Web Aliases: - - -
- Dns Domains: - - -
- Dns Records: - - -
-
- - - - - - - - - - - - - - - - - - - - - -
- Mail Domains: - - -
- Mail Accounts: - - -
- Databases: - - -
- Cron Jobs: - - -
- Dedicated IP: - - -
-
-
- - - - - - -
- -
-
- + + + + + + + + + + +
+ + + $value) { + ++$i; + ?> + + + + + + + + +
+ + +
">
+
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + + + + + + + + + + +
+ [] package +
+ Bandwidth: % () +
+
+
+
+ Disk: % () +
+
+
+
+ + + + + +
+ Web:
+ Mail:
+
+ Databases:
+ User Dirs:
+
+
+
+ + + + + + + + + + + + + + + + + + + + + +
+ Web Domains: + + +
+ Web SSL: + + +
+ Web Aliases: + + +
+ Dns Domains: + + +
+ Dns Records: + + +
+
+ + + + + + + + + + + + + + + + + + + + + +
+ Mail Domains: + + +
+ Mail Accounts: + + +
+ Databases: + + +
+ Cron Jobs: + + +
+ Dedicated IP: + + +
+
+
+ + + + + + +
+ +
+
+ diff --git a/web/templates/admin/list_user.html b/web/templates/admin/list_user.html index 1c59f5a23..165981710 100644 --- a/web/templates/admin/list_user.html +++ b/web/templates/admin/list_user.html @@ -1,250 +1,250 @@ - - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - ?> - - - - - - -
- - - - -
">
-
- - - - - - - - -
- logout"; - if (!empty($_SESSION['look_alert'])) { - ?> - -
-

You have logged in as user .

-
- login as"; - } - ?> -
"> edit - - - - - - - delete - - -
- - - - - - - - - - -
- - - - - - - - - - - - -
[] package
Bandwidth: % () -
-
-
-
Disk: % () -
-
-
-
- - - - - -
- Web:
- Mail:
-
- Databases:
- User Dirs:
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Template:
Web Domains: /
Web SSL:
Web Aliases: per domain
Dns Domains: /
Dns Records: per domain
Name Servers:
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Mail Domains: /
Mail Accounts: per domain
Databases: /
Cron Jobs: /
Shell:
Dedicated IP:
Backups: /
-
-
- - - - - - - -
- -
-
+ + + + + + + + + + +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + ?> + + + + + + +
+ + + + +
">
+
+ + + + + + + + +
+ logout"; + if (!empty($_SESSION['look_alert'])) { + ?> + +
+

You have logged in as user .

+
+ login as"; + } + ?> +
"> edit + + + + + + + delete + + +
+ + + + + + + + + + +
+ + + + + + + + + + + + +
[] package
Bandwidth: % () +
+
+
+
Disk: % () +
+
+
+
+ + + + + +
+ Web:
+ Mail:
+
+ Databases:
+ User Dirs:
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Template:
Web Domains: /
Web SSL:
Web Aliases: per domain
Dns Domains: /
Dns Records: per domain
Name Servers:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Mail Domains: /
Mail Accounts: per domain
Databases: /
Cron Jobs: /
Shell:
Dedicated IP:
Backups: /
+
+
+ + + + + + + +
+ +
+
diff --git a/web/templates/admin/list_web.html b/web/templates/admin/list_web.html index 2e299c26f..c970a04fe 100644 --- a/web/templates/admin/list_web.html +++ b/web/templates/admin/list_web.html @@ -1,207 +1,207 @@ - - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - if (!empty($data[$key]['SSL_HOME'])) { - if ($data[$key]['SSL_HOME'] == 'same') { - $ssl_home = 'public_html'; - } else { - $ssl_home = 'public_shtml'; - } - } else { - $ssl_home = ''; - } - $web_stats='no'; - if (!empty($data[$key]['STATS'])) { - $web_stats=$data[$key]['STATS']; - } - $ftp_user='no'; - if (!empty($data[$key]['FTP_USER'])) { - $ftp_user=$data[$key]['FTP_USER']; - } - $nginx_support='no'; - if (!empty($data[$key]['NGINX'])) { - $nginx_support='yes'; - } - if (strlen($data[$key]['NGINX_EXT']) > 16 ) { - $nginx_ext_title = str_replace(',', ', ', $data[$key]['NGINX_EXT']); - $nginx_ext = substr($data[$key]['NGINX_EXT'], 0, 16); - $nginx_ext = trim($nginx_ext, ","); - $nginx_ext = str_replace(',', ', ', $nginx_ext); - $nginx_ext = $nginx_ext.", ..."; - } else { - $nginx_ext_title = ''; - $nginx_ext = str_replace(',', ', ', $data[$key]['NGINX_EXT']); - } - ?> - - - - - - -
- - - - -
" >
">
-
- - - - '; - echo ""; - echo ' open webstats '; - } - ?> - - - - -
"> edit - - - - - - - delete - - -
- - - - - - - - - - -
- -
- - - - - - - - - - - - -
- -
- [] template -
- Bandwidth: -
-
-
-
Disk: -
-
-
-
-
- - - - - - - - - - - - - - - - - -
SSL Support:
SSL Home:
Nginx Support:
Nginx Extentions:>
-
- - - - - - - - - -
Web Statistics:
Additional FTP:
-
-
- - - - - - -
- - -
-
+ + + + + + + + + + +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + if (!empty($data[$key]['SSL_HOME'])) { + if ($data[$key]['SSL_HOME'] == 'same') { + $ssl_home = 'public_html'; + } else { + $ssl_home = 'public_shtml'; + } + } else { + $ssl_home = ''; + } + $web_stats='no'; + if (!empty($data[$key]['STATS'])) { + $web_stats=$data[$key]['STATS']; + } + $ftp_user='no'; + if (!empty($data[$key]['FTP_USER'])) { + $ftp_user=$data[$key]['FTP_USER']; + } + $nginx_support='no'; + if (!empty($data[$key]['NGINX'])) { + $nginx_support='yes'; + } + if (strlen($data[$key]['NGINX_EXT']) > 16 ) { + $nginx_ext_title = str_replace(',', ', ', $data[$key]['NGINX_EXT']); + $nginx_ext = substr($data[$key]['NGINX_EXT'], 0, 16); + $nginx_ext = trim($nginx_ext, ","); + $nginx_ext = str_replace(',', ', ', $nginx_ext); + $nginx_ext = $nginx_ext.", ..."; + } else { + $nginx_ext_title = ''; + $nginx_ext = str_replace(',', ', ', $data[$key]['NGINX_EXT']); + } + ?> + + + + + + +
+ + + + +
" >
">
+
+ + + + '; + echo ""; + echo ' open webstats '; + } + ?> + + + + +
"> edit + + + + + + + delete + + +
+ + + + + + + + + + +
+ +
+ + + + + + + + + + + + +
+ +
+ [] template +
+ Bandwidth: +
+
+
+
Disk: +
+
+
+
+
+ + + + + + + + + + + + + + + + + +
SSL Support:
SSL Home:
Nginx Support:
Nginx Extentions:>
+
+ + + + + + + + + +
Web Statistics:
Additional FTP:
+
+
+ + + + + + +
+ + +
+
diff --git a/web/templates/admin/panel.html b/web/templates/admin/panel.html index 4049b1001..b81fd01da 100644 --- a/web/templates/admin/panel.html +++ b/web/templates/admin/panel.html @@ -1,76 +1,112 @@ -
- - - + +
- - - - -
- - - - - - - - - - -
- - - - - - - - - - - - +
+ + + + +
+ + + - -
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/web/templates/header.html b/web/templates/header.html index 4ba8c35f4..4ae4b1aa0 100644 --- a/web/templates/header.html +++ b/web/templates/header.html @@ -1,784 +1,721 @@ - - - - Vesta - <?php echo "$TAB"; ?> - - - - - - - - - + + + + Vesta - <?php echo "$TAB"; ?> + + + + + + + + + diff --git a/web/templates/user/list_cron.html b/web/templates/user/list_cron.html index 8f7dc93b6..e186b96d5 100644 --- a/web/templates/user/list_cron.html +++ b/web/templates/user/list_cron.html @@ -1,171 +1,171 @@ - - - - - -
- -
- - - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend'; - } - ?> - - - - - - - -
- - - - -
">
-
- - - - - - -
edit - - delete - - -
- - - - - - - - - - - - -
- -
- - - - - - - -
- Min -
- -
-
- - - - - - - -
- Hour -
- -
-
- - - - - - - -
- Day -
- -
-
- - - - - - - -
- Month -
- -
-
- - - - - - - -
- Day of Week -
- -
-
-
- - - - - - - -
- -
-
- + + + + + +
+ +
+ + + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend'; + } + ?> + + + + + + + +
+ + + + +
">
+
+ + + + + + +
edit + + delete + + +
+ + + + + + + + + + + + +
+ +
+ + + + + + + +
+ Min +
+ +
+
+ + + + + + + +
+ Hour +
+ +
+
+ + + + + + + +
+ Day +
+ +
+
+ + + + + + + +
+ Month +
+ +
+
+ + + + + + + +
+ Day of Week +
+ +
+
+
+ + + + + + + +
+ +
+
+ diff --git a/web/templates/user/list_db.html b/web/templates/user/list_db.html index 7d91b1bbb..79071d515 100644 --- a/web/templates/user/list_db.html +++ b/web/templates/user/list_db.html @@ -1,151 +1,151 @@ - - - - - - -
- -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - if ($data[$key]['TYPE'] == 'mysql') $db_admin = "phpMyAdmin"; - if ($data[$key]['TYPE'] == 'mysql') $db_admin_link = "http://".$http_host."/phpMyAdmin/"; - if ($data[$key]['TYPE'] == 'pgsql') $db_admin = "phpPgAdmin"; - if ($data[$key]['TYPE'] == 'pgsql') $db_admin_link = "http://".$http_host."/phpPgAdmin/"; - ?> - - - - - -
- - - - -
">
-
- - - - - - - -
open edit - - delete - " /> - -
- - - - - - - - - -
- -
- - - - - - - -
- [] database -
Disk: -
-
-
-
-
- - - - - - - - - -
- User: - - -
- Host: - - -
-
- - - - - -
- Charset: - - -
-
-
- - - - - - - -
- -
-
+ + + + + + +
+ +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + if ($data[$key]['TYPE'] == 'mysql') $db_admin = "phpMyAdmin"; + if ($data[$key]['TYPE'] == 'mysql') $db_admin_link = "http://".$http_host."/phpMyAdmin/"; + if ($data[$key]['TYPE'] == 'pgsql') $db_admin = "phpPgAdmin"; + if ($data[$key]['TYPE'] == 'pgsql') $db_admin_link = "http://".$http_host."/phpPgAdmin/"; + ?> + + + + + +
+ + + + +
">
+
+ + + + + + + +
open edit + + delete + " /> + +
+ + + + + + + + + +
+ +
+ + + + + + + +
+ [] database +
Disk: +
+
+
+
+
+ + + + + + + + + +
+ User: + + +
+ Host: + + +
+
+ + + + + +
+ Charset: + + +
+
+
+ + + + + + + +
+ +
+
diff --git a/web/templates/user/list_dns.html b/web/templates/user/list_dns.html index efdd9e40d..070e78998 100644 --- a/web/templates/user/list_dns.html +++ b/web/templates/user/list_dns.html @@ -1,137 +1,137 @@ - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - ?> - - - - - - -
- - - - -
" >
">
-
- - - - - - - - -
list records add record edit - - delete - - -
- - - - - - - - - -
- -
- - - - - - -
- -
- [] template -
-
- - - - - - - - - -
SOA:
TTL:
-
- - - - - - - - - -
Expire:
Records:
-
-
- - - - - - - -
- -
-
- + + + + + + + + + +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + ?> + + + + + + +
+ + + + +
" >
">
+
+ + + + + + + + +
list records add record edit + + delete + + +
+ + + + + + + + + +
+ +
+ + + + + + +
+ +
+ [] template +
+
+ + + + + + + + + +
SOA:
TTL:
+
+ + + + + + + + + +
Expire:
Records:
+
+
+ + + + + + + +
+ +
+
+ diff --git a/web/templates/user/list_dns_rec.html b/web/templates/user/list_dns_rec.html index d8d46a9a6..2cec75fa3 100644 --- a/web/templates/user/list_dns_rec.html +++ b/web/templates/user/list_dns_rec.html @@ -1,98 +1,98 @@ - - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - ?> - - - - - - -
- - - - -
">
-
- - - - - - -
edit - - delete - - -
- - - - - - - -
-
- - - - - - -
- - -
-
- + + + + + + + + + + +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + ?> + + + + + + +
+ + + + +
">
+
+ + + + + + +
edit + + delete + + +
+ + + + + + + +
+
+ + + + + + +
+ + +
+
+ diff --git a/web/templates/user/list_mail.html b/web/templates/user/list_mail.html index a4b79d5e1..3d15bc714 100644 --- a/web/templates/user/list_mail.html +++ b/web/templates/user/list_mail.html @@ -1,164 +1,164 @@ - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - if (empty($data[$key]['CATCHALL'])) { - $data[$key]['CATCHALL'] = '/dev/null'; - } - ?> - - - - - - - -
- - - - -
" >
">
-
- - - - - - - - - -
list accounts add account" target="_blank"> open webmail edit - - delete - - -
- - - - - - - - - - -
- -
- - - - - - - -
- catchall > -
- Disk: -
-
-
-
-
- - - - - - - - - -
- Antivirus: - - -
- Antispam: - - -
-
- - - - - - - - - -
- DKIM: - - -
- Accounts: - - -
-
-
- - - - - - - -
- -
-
- + + + + + + + + + +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + if (empty($data[$key]['CATCHALL'])) { + $data[$key]['CATCHALL'] = '/dev/null'; + } + ?> + + + + + + + +
+ + + + +
" >
">
+
+ + + + + + + + + +
list accounts add account" target="_blank"> open webmail edit + + delete + + +
+ + + + + + + + + + +
+ +
+ + + + + + + +
+ catchall > +
+ Disk: +
+
+
+
+
+ + + + + + + + + +
+ Antivirus: + + +
+ Antispam: + + +
+
+ + + + + + + + + +
+ DKIM: + + +
+ Accounts: + + +
+
+
+ + + + + + + +
+ +
+
+ diff --git a/web/templates/user/list_mail_acc.html b/web/templates/user/list_mail_acc.html index d59367bc0..cfa9c9e02 100644 --- a/web/templates/user/list_mail_acc.html +++ b/web/templates/user/list_mail_acc.html @@ -1,145 +1,145 @@ - - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend'; - } - ?> - - - - - - - -
- - - - -
">
-
- - - - - - -
edit - - delete - - -
- - - - - - - - -
- - - - - - -
- -
- Disk: -
-
-
-
-
- - - - - - - - - -
- Quota: - - -
- Autoreply: - - -
-
- - - - - -
- Forward: - - -
-
-
- - - - - - - -
- -
-
- + + + + + + + + + + +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend'; + } + ?> + + + + + + + +
+ + + + +
">
+
+ + + + + + +
edit + + delete + + +
+ + + + + + + + +
+ + + + + + +
+ +
+ Disk: +
+
+
+
+
+ + + + + + + + + +
+ Quota: + + +
+ Autoreply: + + +
+
+ + + + + +
+ Forward: + + +
+
+
+ + + + + + + +
+ +
+
+ diff --git a/web/templates/user/list_search.html b/web/templates/user/list_search.html index e4192bd10..60d22bdf2 100644 --- a/web/templates/user/list_search.html +++ b/web/templates/user/list_search.html @@ -1,171 +1,171 @@ - - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend'; - } - if ($data[$key]['TYPE'] == 'db') { - $object = 'database'; - } else { - $object = strtolower($data[$key]['TYPE']." ".$data[$key]['KEY']); - } - ?> - - - - - - - -
- - - -
">
-
- - - - - - -
- '; - } - - if ($data[$key]['KEY'] == 'ACCOUNT') { - echo ''; - } - - if ($data[$key]['KEY'] == 'JOB') { - echo ''; - } - - if (($data[$key]['KEY'] != 'RECORD') && ($data[$key]['KEY'] != 'ACCOUNT') && ($data[$key]['KEY'] != 'JOB')) { - echo ''; - } - ?> - edit - - - delete - '; - } - - if ($data[$key]['KEY'] == 'ACCOUNT') { - echo ''; - } - - if ($data[$key]['KEY'] == 'JOB') { - echo ''; - } - - if (($data[$key]['KEY'] != 'RECORD') && ($data[$key]['KEY'] != 'ACCOUNT') && ($data[$key]['KEY'] != 'JOB')) { - echo ''; - } - ?> - -
- - - - - - - - -
- - - - - -
- Object: - - -
-
- - - - - -
- Owner: - - -
-
- - - - - -
- Status: - - -
-
-
- - - - - - - -
- -
-
- + + + + + + + + + + +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend'; + } + if ($data[$key]['TYPE'] == 'db') { + $object = 'database'; + } else { + $object = strtolower($data[$key]['TYPE']." ".$data[$key]['KEY']); + } + ?> + + + + + + + +
+ + + +
">
+
+ + + + + + +
+ '; + } + + if ($data[$key]['KEY'] == 'ACCOUNT') { + echo ''; + } + + if ($data[$key]['KEY'] == 'JOB') { + echo ''; + } + + if (($data[$key]['KEY'] != 'RECORD') && ($data[$key]['KEY'] != 'ACCOUNT') && ($data[$key]['KEY'] != 'JOB')) { + echo ''; + } + ?> + edit + + + delete + '; + } + + if ($data[$key]['KEY'] == 'ACCOUNT') { + echo ''; + } + + if ($data[$key]['KEY'] == 'JOB') { + echo ''; + } + + if (($data[$key]['KEY'] != 'RECORD') && ($data[$key]['KEY'] != 'ACCOUNT') && ($data[$key]['KEY'] != 'JOB')) { + echo ''; + } + ?> + +
+ + + + + + + + +
+ + + + + +
+ Object: + + +
+
+ + + + + +
+ Owner: + + +
+
+ + + + + +
+ Status: + + +
+
+
+ + + + + + + +
+ +
+
+ diff --git a/web/templates/user/list_stats.html b/web/templates/user/list_stats.html index 0bb657702..e707ce028 100644 --- a/web/templates/user/list_stats.html +++ b/web/templates/user/list_stats.html @@ -1,203 +1,203 @@ - - - - - - - - - - -
- - - $value) { - ++$i; - ?> - - - - - - - - -
- - -
">
-
- - - - -
- - - - - - - - - - -
- -
- - - - - - - - - - - - - -
- [] package -
- Bandwidth: % () -
-
-
-
- Disk: % () -
-
-
-
- - - - - -
- Web:
- Mail:
-
- Databases:
- User Dirs:
-
-
-
- - - - - - - - - - - - - - - - - - - - - -
- Web Domains: - - -
- Web SSL: - - -
- Web Aliases: - - -
- Dns Domains: - - -
- Dns Records: - - -
-
- - - - - - - - - - - - - - - - - - - - - -
- Mail Domains: - - -
- Mail Accounts: - - -
- Databases: - - -
- Cron Jobs: - - -
- Dedicated IP: - - -
-
-
- - - - - - -
- -
-
- + + + + + + + + + + +
+ + + $value) { + ++$i; + ?> + + + + + + + + +
+ + +
">
+
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + + + + + + + + + + +
+ [] package +
+ Bandwidth: % () +
+
+
+
+ Disk: % () +
+
+
+
+ + + + + +
+ Web:
+ Mail:
+
+ Databases:
+ User Dirs:
+
+
+
+ + + + + + + + + + + + + + + + + + + + + +
+ Web Domains: + + +
+ Web SSL: + + +
+ Web Aliases: + + +
+ Dns Domains: + + +
+ Dns Records: + + +
+
+ + + + + + + + + + + + + + + + + + + + + +
+ Mail Domains: + + +
+ Mail Accounts: + + +
+ Databases: + + +
+ Cron Jobs: + + +
+ Dedicated IP: + + +
+
+
+ + + + + + +
+ +
+
+ diff --git a/web/templates/user/list_user.html b/web/templates/user/list_user.html index 00b3bd31f..df83fc29b 100644 --- a/web/templates/user/list_user.html +++ b/web/templates/user/list_user.html @@ -1,196 +1,196 @@ - - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - ?> - - - - - - -
- - - - -
">
-
- - - - - -
"> edit
- - - - - - - - - - -
- - - - - - - - - - - - -
[] package
Bandwidth: % () -
-
-
-
Disk: % () -
-
-
-
- - - - - -
- Web:
- Mail:
-
- Databases:
- User Dirs:
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Template:
Web Domains: /
Web SSL:
Web Aliases: per domain
Dns Domains: /
Dns Records: per domain
Name Servers:
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Mail Domains: /
Mail Accounts: per domain
Databases: /
Cron Jobs: /
Shell:
Dedicated IP:
Backups: /
-
-
- - - - - - - -
- -
-
- + + + + + + + + + + +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + ?> + + + + + + +
+ + + + +
">
+
+ + + + + +
"> edit
+ + + + + + + + + + +
+ + + + + + + + + + + + +
[] package
Bandwidth: % () +
+
+
+
Disk: % () +
+
+
+
+ + + + + +
+ Web:
+ Mail:
+
+ Databases:
+ User Dirs:
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Template:
Web Domains: /
Web SSL:
Web Aliases: per domain
Dns Domains: /
Dns Records: per domain
Name Servers:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Mail Domains: /
Mail Accounts: per domain
Databases: /
Cron Jobs: /
Shell:
Dedicated IP:
Backups: /
+
+
+ + + + + + + +
+ +
+
+ diff --git a/web/templates/user/list_web.html b/web/templates/user/list_web.html index 1772ff2dd..94ce93c06 100644 --- a/web/templates/user/list_web.html +++ b/web/templates/user/list_web.html @@ -1,194 +1,194 @@ - - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - if (!empty($data[$key]['SSL_HOME'])) { - if ($data[$key]['SSL_HOME'] == 'same') { - $ssl_home = 'public_html'; - } else { - $ssl_home = 'public_shtml'; - } - } else { - $ssl_home = ''; - } - if (strlen($data[$key]['NGINX_EXT']) > 16 ) { - $nginx_ext_title = str_replace(',', ', ', $data[$key]['NGINX_EXT']); - $nginx_ext = substr($data[$key]['NGINX_EXT'], 0, 16); - $nginx_ext = trim($nginx_ext, ","); - $nginx_ext = str_replace(',', ', ', $nginx_ext); - $nginx_ext = $nginx_ext.", ..."; - } else { - $nginx_ext_title = ''; - $nginx_ext = str_replace(',', ', ', $data[$key]['NGINX_EXT']); - } - ?> - - - - - - -
- - - - -
" >
">
-
- - - - '; - echo ""; - echo ' open webstats '; - } - ?> - - - -
"> edit - - delete - - -
- - - - - - - - - - -
- -
- - - - - - - - - - - - -
- -
- [] template -
- Bandwidth: -
-
-
-
Disk: -
-
-
-
-
- - - - - - - - - - - - - - - - - -
CGI Support:
Error Log:
Web Statistics:
Statistics Auth:
-
- - - - - - - - - - - - - - - - - -
SSL Support:
SSL Home:
Nginx Template:
Nginx Extentions:>
-
-
- - - - - - -
- - -
-
- + + + + + + + + + + +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + if (!empty($data[$key]['SSL_HOME'])) { + if ($data[$key]['SSL_HOME'] == 'same') { + $ssl_home = 'public_html'; + } else { + $ssl_home = 'public_shtml'; + } + } else { + $ssl_home = ''; + } + if (strlen($data[$key]['NGINX_EXT']) > 16 ) { + $nginx_ext_title = str_replace(',', ', ', $data[$key]['NGINX_EXT']); + $nginx_ext = substr($data[$key]['NGINX_EXT'], 0, 16); + $nginx_ext = trim($nginx_ext, ","); + $nginx_ext = str_replace(',', ', ', $nginx_ext); + $nginx_ext = $nginx_ext.", ..."; + } else { + $nginx_ext_title = ''; + $nginx_ext = str_replace(',', ', ', $data[$key]['NGINX_EXT']); + } + ?> + + + + + + +
+ + + + +
" >
">
+
+ + + + '; + echo ""; + echo ' open webstats '; + } + ?> + + + +
"> edit + + delete + + +
+ + + + + + + + + + +
+ +
+ + + + + + + + + + + + +
+ +
+ [] template +
+ Bandwidth: +
+
+
+
Disk: +
+
+
+
+
+ + + + + + + + + + + + + + + + + +
CGI Support:
Error Log:
Web Statistics:
Statistics Auth:
+
+ + + + + + + + + + + + + + + + + +
SSL Support:
SSL Home:
Nginx Template:
Nginx Extentions:>
+
+
+ + + + + + +
+ + +
+
+ diff --git a/web/templates/user/panel.html b/web/templates/user/panel.html index 689d6097e..3d3d6ed6d 100644 --- a/web/templates/user/panel.html +++ b/web/templates/user/panel.html @@ -1,75 +1,113 @@ -
- - - + +
- - - - -
- - - - - - - - - - -
- - - - - - - - - - - +
+ + + + +
+ + + - -
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file From a2ac36b6769aa386f78a7ad1bb519bbebf1fcf50 Mon Sep 17 00:00:00 2001 From: ZonD Eighty Date: Thu, 10 Jan 2013 22:14:34 +0400 Subject: [PATCH 04/11] Merge changes from upstream & more --- bin/v-add-dns-on-web-alias | 90 ++ bin/v-add-web-domain-ftp | 80 ++ bin/v-rebuild-web-domains | 315 +++++ bin/v-update-user-stats | 172 +++ func/domain.sh | 1004 ++++++++------- func/main.sh | 1544 +++++++++++------------ install/0.9.7/rhel/exim.conf | 680 +++++----- install/0.9.7/rhel/roundcube-driver.php | 63 + install/vst-install.sh | 650 ++++++++++ web/add/db/index.php | 169 +-- web/edit/web/index.php | 1174 ++++++++--------- web/inc/i18n/ru.php | 3 + web/templates/admin/add_db.html | 360 +++--- web/templates/admin/list_dns.html | 293 +++-- web/templates/admin/list_dns_rec.html | 222 ++-- web/templates/admin/list_mail.html | 346 ++--- web/templates/admin/list_mail_acc.html | 317 ++--- web/templates/header.html | 1439 +++++++++++---------- web/templates/user/list_dns.html | 273 ++-- web/templates/user/list_dns_rec.html | 203 +-- web/templates/user/list_mail.html | 327 +++-- web/templates/user/list_mail_acc.html | 297 ++--- 22 files changed, 5760 insertions(+), 4261 deletions(-) diff --git a/bin/v-add-dns-on-web-alias b/bin/v-add-dns-on-web-alias index a3383ee32..f4889da67 100755 --- a/bin/v-add-dns-on-web-alias +++ b/bin/v-add-dns-on-web-alias @@ -1,3 +1,4 @@ +<<<<<<< HEAD #!/bin/bash # info: add dns domain or dns record based on web domain alias restart # options: USER DOMAIN @@ -78,3 +79,92 @@ fi # No Logging exit +======= +#!/bin/bash +# info: add dns domain or dns record based on web domain alias restart +# options: USER DOMAIN +# +# The function adds dns domain or dns record based on web domain alias. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g') +domain_idn=$(idn -t --quiet -a "$domain") +dom_alias=$(idn -t --quiet -u "$3" ) +dom_alias=$(echo $dom_alias | sed -e 's/\.*$//g' -e 's/^\.*//g') +dom_alias=$(echo $dom_alias | tr '[:upper:]' '[:lower:]') +dom_alias_idn=$(idn -t --quiet -a "$dom_alias" ) +restart="$4" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN ALIAS' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Parsing domain values +get_domain_values 'web' + +# Check if it a simple domain +if [ $(echo -e "${dom_alias//\./\n}" | wc -l) -le 2 ]; then + if [ ! -e "$USER_DATA/dns/$dom_alias.conf" ]; then + $BIN/v-add-dns-domain \ + $user $dom_alias $IP '' '' '' '' '' $restart > /dev/null + fi +else + # Check subdomain + sub=$(echo "$dom_alias" | cut -f1 -d . -s) + dom=$(echo "$dom_alias" | sed -e "s/^$sub.//" ) + if [ ! -e "$USER_DATA/dns/$dom.conf" ]; then + $BIN/v-add-dns-domain \ + $user $dom $IP '' '' '' '' '' $restart > /dev/null + + if [ $? -eq 0 ]; then + $BIN/v-add-dns-domain-record \ + $user $dom "$sub" A $IP '' '' $restart + fi + else + if [ "$sub" == '*' ]; then + rec=$(grep -w "RECORD='\*'" $USER_DATA/dns/$dom.conf) + else + rec=$(grep -w "RECORD='$sub'" $USER_DATA/dns/$dom.conf) + fi + if [ -z "$rec" ]; then + $BIN/v-add-dns-domain-record \ + $user $dom "$sub" A $IP '' '' $restart > /dev/null + fi + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# No Logging + +exit +>>>>>>> 994c40901078e48fe939536f7b366e29c2e44a1d diff --git a/bin/v-add-web-domain-ftp b/bin/v-add-web-domain-ftp index e2d566a8f..69c58673d 100755 --- a/bin/v-add-web-domain-ftp +++ b/bin/v-add-web-domain-ftp @@ -1,3 +1,4 @@ +<<<<<<< HEAD #!/bin/bash # info: add ftp account for web domain. # options: USER DOMAIN FTP_USER FTP_PASSWORD @@ -69,3 +70,82 @@ log_history "added ftp account $ftp_user for $domain" log_event "$OK" "$EVENT" exit +======= +#!/bin/bash +# info: add ftp account for web domain. +# options: USER DOMAIN FTP_USER FTP_PASSWORD +# +# The function creates addutional ftp account for web domain. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +ftp_user=${1}_${3} +ftp_password=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + +# Hiding password +A4='******' +EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'" +EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'" + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '4' "$#" 'USER DOMAIN FTP_USER FTP_PASSWORD' +validate_format 'user' 'domain' 'ftp_user' 'ftp_password' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +get_domain_values 'web' +check_ftp_user=$(grep "^$ftp_user:" /etc/passwd) +if [ ! -z "$check_ftp_user" ] && [ "$FTP_USER" != "$ftp_user" ]; then + echo "Error: ftp user $ftp_user already exists" + log_event "$E_EXISTS $EVENT" + exit $E_EXISTS +fi + +if [ ! -z "$FTP_USER" ]; then + /usr/sbin/userdel $FTP_USER +fi + +# Adding user +/usr/sbin/adduser $ftp_user -g $user -s /sbin/nologin -M \ + -d "$HOMEDIR/$user/web/$domain" > /dev/null 2>&1 +echo "$ftp_password" | /usr/bin/passwd "$ftp_user" --stdin &>/dev/null +ftp_md5="$(awk -v user=$ftp_user -F : 'user == $1 {print $2}' /etc/shadow)" + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$FTP_USER' "$ftp_user" +update_object_value 'web' 'DOMAIN' "$domain" '$FTP_MD5' "$ftp_md5" + +# Logging +log_history "added ftp account $ftp_user for $domain" +log_event "$OK" "$EVENT" + +exit +>>>>>>> 994c40901078e48fe939536f7b366e29c2e44a1d diff --git a/bin/v-rebuild-web-domains b/bin/v-rebuild-web-domains index 1571305ce..cb1a66307 100755 --- a/bin/v-rebuild-web-domains +++ b/bin/v-rebuild-web-domains @@ -1,3 +1,4 @@ +<<<<<<< HEAD #!/bin/bash # info: rebuild dns domains # options: USER [RESTART] @@ -310,3 +311,317 @@ fi log_event "$OK" "$EVENT" exit +======= +#!/bin/bash +# info: rebuild dns domains +# options: USER [RESTART] +# +# The function rebuilds BIND configuration files for all dns domains. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +restart=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh +source $VESTA/func/ip.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [RESTART]' +validate_format 'user' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +user_domains=0 +user_ssl=0 +user_aliases=0 +suspended_web=0 + +# Clean up old config +rm -f $HOMEDIR/$user/conf/tmp_*.conf + +# Defining config +conf=$USER_DATA/web.conf +fields='$DOMAIN' +nohead=1 + +# Starting loop +for domain in $(shell_list) ; do + + # Rebuilding directories + mkdir -p $HOMEDIR/$user/web/$domain \ + $HOMEDIR/$user/web/$domain/public_html \ + $HOMEDIR/$user/web/$domain/public_shtml \ + $HOMEDIR/$user/web/$domain/document_errors \ + $HOMEDIR/$user/web/$domain/cgi-bin \ + $HOMEDIR/$user/web/$domain/private \ + $HOMEDIR/$user/web/$domain/stats \ + $HOMEDIR/$user/web/$domain/logs + if [ ! -e "$HOMEDIR/$user/web/$domain/logs/$domain.log" ]; then + ln -s /var/log/httpd/domains/$domain.error.log \ + $HOMEDIR/$user/web/$domain/logs/$domain.log + fi + if [ ! -e "$HOMEDIR/$user/web/$domain/logs/$domain.error.log" ]; then + ln -s /var/log/httpd/domains/$domain.error.log \ + $HOMEDIR/$user/web/$domain/logs/$domain.error.log + fi + if [ -e "$WEBTPL/skel/document_errors/" ]; then + cp -r $WEBTPL/skel/document_errors/ $HOMEDIR/$user/web/$domain/ + fi + + touch /var/log/httpd/domains/$domain.bytes \ + /var/log/httpd/domains/$domain.log \ + /var/log/httpd/domains/$domain.error.log + + chmod 551 $HOMEDIR/$user/web/$domain + chmod 771 $HOMEDIR/$user/web/$domain/private + chmod 751 $HOMEDIR/$user/web/$domain/cgi-bin + chmod 771 $HOMEDIR/$user/web/$domain/public_html + chmod 771 $HOMEDIR/$user/web/$domain/public_shtml + chmod 771 $HOMEDIR/$user/web/$domain/document_errors + chmod 551 $HOMEDIR/$user/web/$domain/stats + chmod 551 $HOMEDIR/$user/web/$domain/logs + chmod 640 /var/log/httpd/domains/$domain.* + + chown $user:$user $HOMEDIR/$user/web/$domain + chown $user:$user $HOMEDIR/$user/web/$domain/private + chown $user:$user $HOMEDIR/$user/web/$domain/cgi-bin + chown $user:$user $HOMEDIR/$user/web/$domain/public_html + chown $user:$user $HOMEDIR/$user/web/$domain/public_shtml + chown -R $user:$user $HOMEDIR/$user/web/$domain/document_errors + chown root:$user /var/log/httpd/domains/$domain.* + chown root:apache $conf + + # Parsing domain values + domain_idn=$(idn -t --quiet -a "$domain") + get_domain_values 'web' + + # Preparing domain values for the template substitution + upd_web_domain_values + + # Adding domain to the tmp_httpd.conf + tpl_file="$WEBTPL/apache_$TPL.tpl" + conf="$HOMEDIR/$user/conf/web/tmp_httpd.conf" + add_web_config + chown root:apache $conf + chmod 640 $conf + + # Running template trigger + if [ -x $WEBTPL/apache_$TPL.sh ]; then + $WEBTPL/apache_$TPL.sh $user $domain $ip $HOMEDIR $docroot + fi + + # Checking aliases + if [ ! -z "$ALIAS" ]; then + aliases=$(echo "$ALIAS"|tr ',' '\n'| wc -l) + user_aliases=$((user_aliases + aliases)) + fi + + # Checking stats + if [ ! -z "$STATS" ]; then + cat $WEBTPL/$STATS.tpl |\ + sed -e "s/%ip%/$ip/g" \ + -e "s/%web_port%/$WEB_PORT/g" \ + -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \ + -e "s/%proxy_port%/$PROXY_PORT/g" \ + -e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \ + -e "s/%domain_idn%/$domain_idn/g" \ + -e "s/%domain%/$domain/g" \ + -e "s/%user%/$user/g" \ + -e "s/%home%/${HOMEDIR////\/}/g" \ + -e "s/%alias%/${aliases//,/ }/g" \ + -e "s/%alias_idn%/${aliases_idn//,/ }/g" \ + > $HOMEDIR/$user/conf/web/$STATS.$domain.conf + + if [ "$STATS" == 'awstats' ]; then + if [ ! -e "/etc/awstats/$STATS.$domain.conf" ]; then + ln -s $HOMEDIR/$user/conf/web/$STATS.$domain.conf /etc/awstats/ + fi + fi + + webstats="$BIN/v-update-web-domain-stat $user $domain" + check_webstats=$(grep "$webstats" $VESTA/data/queue/webstats.pipe) + if [ -z "$check_webstats" ]; then + echo "$webstats" >> $VESTA/data/queue/webstats.pipe + fi + + if [ ! -z "$STATS_USER" ]; then + # Definining statistic dir + stats_dir="$HOMEDIR/$user/web/$domain/stats" + + # Adding htaccess file + echo "AuthUserFile $stats_dir/.htpasswd" > $stats_dir/.htaccess + echo "AuthName \"Web Statistics\"" >> $stats_dir/.htaccess + echo "AuthType Basic" >> $stats_dir/.htaccess + echo "Require valid-user" >> $stats_dir/.htaccess + + # Generating htaccess user and password + echo "$STATS_USER:$STATS_CRYPT" > $stats_dir/.htpasswd + fi + fi + + # Checking ssl + if [ "$SSL" = 'yes' ]; then + # Adding domain to the shttpd.conf + conf="$HOMEDIR/$user/conf/web/tmp_shttpd.conf" + tpl_file="$WEBTPL/apache_$TPL.stpl" + add_web_config + chown root:apache $conf + chmod 640 $conf + + cp -f $USER_DATA/ssl/$domain.crt \ + $HOMEDIR/$user/conf/web/ssl.$domain.crt + cp -f $USER_DATA/ssl/$domain.key \ + $HOMEDIR/$user/conf/web/ssl.$domain.key + cp -f $USER_DATA/ssl/$domain.pem \ + $HOMEDIR/$user/conf/web/ssl.$domain.pem + if [ -e "$USER_DATA/ssl/$domain.ca" ]; then + cp -f $USER_DATA/ssl/$domain.ca \ + $HOMEDIR/$user/conf/web/ssl.$domain.ca + fi + + # Running template trigger + if [ -x $WEBTPL/apache_$TPL.sh ]; then + $WEBTPL/apache_$TPL.sh $user $domain $ip $HOMEDIR $sdocroot + fi + + user_ssl=$((user_ssl + 1)) + ssl_change='yes' + fi + + # Checking nginx + if [ ! -z "$NGINX" ]; then + tpl_file="$WEBTPL/nginx_$NGINX.tpl" + conf="$HOMEDIR/$user/conf/web/tmp_nginx.conf" + add_web_config + chown root:nginx $conf + chmod 640 $conf + + if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/tmp_snginx.conf" + add_web_config + chown root:nginx $conf + chmod 640 $conf + fi + ngix_change='yes' + fi + if [ "$SUSPENDED" = 'yes' ]; then + suspended_web=$((suspended_web + 1)) + fi + user_domains=$((user_domains + 1)) + + # Checking ftp + if [ ! -z "$FTP_USER" ]; then + if [ -z "$(grep ^$FTP_USER: /etc/passwd)" ]; then + /usr/sbin/adduser $FTP_USER -g $user -s /sbin/nologin -M \ + -d "$HOMEDIR/$user/web/$domain" > /dev/null 2>&1 + + shadow='/etc/shadow' + shdw=$(grep "^$FTP_USER:" $shadow) + shdw3=$(echo "$shdw" | cut -f3 -d :) + shdw4=$(echo "$shdw" | cut -f4 -d :) + shdw5=$(echo "$shdw" | cut -f5 -d :) + shdw6=$(echo "$shdw" | cut -f6 -d :) + shdw7=$(echo "$shdw" | cut -f7 -d :) + shdw8=$(echo "$shdw" | cut -f8 -d :) + shdw9=$(echo "$shdw" | cut -f9 -d :) + chmod u+w $shadow + sed -i "/^$FTP_USER:*/d" $shadow + shdw_str="$FTP_USER:$FTP_MD5:$shdw3:$shdw4:$shdw5:$shdw6" + shdw_str="$shdw_str:$shdw7:$shdw8:$shdw9" + echo "$shdw_str" >> $shadow + chmod u-w $shadow + fi + fi + +done + +# Renaming tmp config +tmp_conf="$HOMEDIR/$user/conf/web/tmp_httpd.conf" +conf="$HOMEDIR/$user/conf/web/httpd.conf" +if [ -e "$tmp_conf" ]; then + mv $tmp_conf $conf +fi + +# Checking include in main httpd.conf +main_conf='/etc/httpd/conf.d/vesta.conf' +main_conf_check=$(grep "$conf" $main_conf ) +if [ ! -z "$domain" ] && [ -z "$main_conf_check" ]; then + echo "Include $conf" >>$main_conf +fi + +# Checking ssl +if [ "$ssl_change" = 'yes' ]; then + tmp_conf="$HOMEDIR/$user/conf/web/tmp_shttpd.conf" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" + mv $tmp_conf $conf + + # Checking include in main httpd.conf + main_conf_check=$(grep "$conf" $main_conf ) + if [ -z "$main_conf_check" ]; then + echo "Include $conf" >>$main_conf + fi +fi + +# Checking nginx +if [ "$ngix_change" = 'yes' ]; then + nginx_conf='/etc/nginx/conf.d/vesta_users.conf' + tmp_conf="$HOMEDIR/$user/conf/web/tmp_nginx.conf" + conf="$HOMEDIR/$user/conf/web/nginx.conf" + mv $tmp_conf $conf + + nginx_conf_check=$(grep "$conf" $nginx_conf ) + if [ -z "$nginx_conf_check" ]; then + echo "include $conf;" >>$nginx_conf + fi + + # Checking ssl for nginx + if [ "$ssl_change" = 'yes' ]; then + tmp_conf="$HOMEDIR/$user/conf/web/tmp_snginx.conf" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + mv $tmp_conf $conf + nginx_conf_check=$(grep "$conf" $nginx_conf ) + if [ -z "$nginx_conf_check" ]; then + echo "include $conf;" >>$nginx_conf + fi + fi +fi + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Updating counters +update_user_value "$user" '$SUSPENDED_WEB' "$suspended_web" +update_user_value "$user" '$U_WEB_DOMAINS' "$user_domains" +update_user_value "$user" '$U_WEB_SSL' "$user_ssl" +update_user_value "$user" '$U_WEB_ALIASES' "$user_aliases" + +# Restart web server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit +>>>>>>> 994c40901078e48fe939536f7b366e29c2e44a1d diff --git a/bin/v-update-user-stats b/bin/v-update-user-stats index 066042850..3410d8583 100755 --- a/bin/v-update-user-stats +++ b/bin/v-update-user-stats @@ -1,3 +1,4 @@ +<<<<<<< HEAD #!/bin/bash # info: update user statistics # options: USER @@ -167,3 +168,174 @@ fi log_event "$OK" "$EVENT" exit +======= +#!/bin/bash +# info: update user statistics +# options: USER +# +# Function logs user parameters into statistics database. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Importing system enviroment as we run this script +# mostly by cron wich not read it by itself +source /etc/profile + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '0' "$#" 'USER' +if [ ! -z "$user" ]; then + validate_format 'user' + is_object_valid 'user' 'USER' "$user" +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Creating user_list +if [ -z "$user" ]; then + user_list=$(ls $VESTA/data/users) +else + user_list="$user" +fi + +# Reset overal statistics +TOTAL_IP_OWNED=0 +TOTAL_U_DISK=0 +TOTAL_U_DISK_DIRS=0 +TOTAL_U_DISK_WEB=0 +TOTAL_U_DISK_MAIL=0 +TOTAL_U_DISK_DB=0 +TOTAL_U_BANDWIDTH=0 +TOTAL_U_WEB_DOMAINS=0 +TOTAL_U_WEB_SSL=0 +TOTAL_U_WEB_ALIASES=0 +TOTAL_U_DNS_DOMAINS=0 +TOTAL_U_DNS_RECORDS=0 +TOTAL_U_MAIL_DOMAINS=0 +TOTAL_U_MAIL_DKIM=0 +TOTAL_U_MAIL_ACCOUNTS=0 +TOTAL_U_DATABASES=0 +TOTAL_U_CRON_JOBS=0 +TOTAL_U_BACKUPS=0 + +# Updating user stats +for user in $user_list; do + USER_DATA=$VESTA/data/users/$user + source $USER_DATA/user.conf + next_month=$(date +'%m/01/%y' -d '+ 1 month') + DATE=$(date -d "$next_month -1day" +%F) + + # Compiling report string + s="DATE='$DATE' TIME='$TIME' PACKAGE='$PACKAGE' IP_OWNED='$IP_OWNED'" + s="$s DISK_QUOTA='$DISK_QUOTA' U_DISK='$U_DISK' U_DISK_DIRS='$U_DISK_DIRS'" + s="$s U_DISK_WEB='$U_DISK_WEB' U_DISK_MAIL='$U_DISK_MAIL'" + s="$s U_DISK_DB='$U_DISK_DB' BANDWIDTH='$BANDWIDTH'" + s="$s U_BANDWIDTH='$U_BANDWIDTH' U_WEB_DOMAINS='$U_WEB_DOMAINS'" + s="$s U_WEB_SSL='$U_WEB_SSL' U_WEB_ALIASES='$U_WEB_ALIASES'" + s="$s U_DNS_DOMAINS='$U_DNS_DOMAINS' U_DNS_RECORDS='$U_DNS_RECORDS'" + s="$s U_MAIL_DOMAINS='$U_MAIL_DOMAINS' U_MAIL_DKIM='$U_MAIL_DKIM'" + s="$s U_MAIL_ACCOUNTS='$U_MAIL_ACCOUNTS' U_DATABASES='$U_DATABASES'" + s="$s U_CRON_JOBS='$U_CRON_JOBS' U_BACKUPS='$U_BACKUPS'" + + # Updating user stats log + stats="$USER_DATA/stats.log" + if [ -e "$stats" ]; then + # Checking dublicates + check_month=$(grep -n "DATE='$DATE'" $stats|cut -f 1 -d :) + if [ -z "$check_month" ]; then + # Updating as there no dublicates + echo "$s" >> $stats + chmod 660 $stats + else + # Replacing string with new data + sed -i "$check_month s/.*/$s/" $stats + fi + else + # Creating stats log + echo "$s" >$stats + chmod 660 $stats + fi + + # Increase overall counters + TOTAL_IP_OWNED=$((TOTAL_IP_OWNED + IP_OWNED)) + TOTAL_U_DISK=$((TOTAL_U_DISK + U_DISK)) + TOTAL_U_DISK_DIRS=$((TOTAL_U_DISK_DIRS + U_DISK_DIRS)) + TOTAL_U_DISK_WEB=$((TOTAL_U_DISK_WEB + U_DISK_WEB)) + TOTAL_U_DISK_MAIL=$((TOTAL_U_DISK_MAIL + U_DISK_MAIL)) + TOTAL_U_DISK_DB=$((TOTAL_U_DISK_DB + U_DISK_DB)) + TOTAL_U_BANDWIDTH=$((TOTAL_U_BANDWIDTH + U_BANDWIDTH)) + TOTAL_U_WEB_DOMAINS=$((TOTAL_U_WEB_DOMAINS + U_WEB_DOMAINS)) + TOTAL_U_WEB_SSL=$((TOTAL_U_WEB_SSL + U_WEB_SSL)) + TOTAL_U_WEB_ALIASES=$((TOTAL_U_WEB_ALIASES + U_WEB_ALIASES)) + TOTAL_U_DNS_DOMAINS=$((TOTAL_U_DNS_DOMAINS + U_DNS_DOMAINS)) + TOTAL_U_DNS_RECORDS=$((TOTAL_U_DNS_RECORDS + U_DNS_RECORDS)) + TOTAL_U_MAIL_DOMAINS=$((TOTAL_U_MAIL_DOMAINS + U_MAIL_DOMAINS)) + TOTAL_U_MAIL_DKIM=$((TOTAL_U_MAIL_DKIM + U_MAIL_DKIM)) + TOTAL_U_MAIL_ACCOUNTS=$((TOTAL_U_MAIL_ACCOUNTS + U_MAIL_ACCOUNTS)) + TOTAL_U_DATABASES=$((TOTAL_U_DATABASES + U_DATABASES)) + TOTAL_U_CRON_JOBS=$((TOTAL_U_CRON_JOBS + U_CRON_JOBS)) + TOTAL_U_BACKUPS=$((TOTAL_U_BACKUPS + U_BACKUPS)) + +done + +# Updating overall stats +stats="$VESTA/data/users/admin/overall_stats.log" + +s="DATE='$DATE' TIME='$TIME' PACKAGE='default' IP_OWNED='$TOTAL_IP_OWNED'" +s="$s DISK_QUOTA='0' U_DISK='$TOTAL_U_DISK' U_DISK_DIRS='$TOTAL_U_DISK_DIRS'" +s="$s U_DISK_WEB='$TOTAL_U_DISK_WEB' U_DISK_MAIL='$TOTAL_U_DISK_MAIL'" +s="$s U_DISK_DB='$TOTAL_U_DISK_DB' BANDWIDTH='0'" +s="$s U_BANDWIDTH='$TOTAL_U_BANDWIDTH' U_WEB_DOMAINS='$TOTAL_U_WEB_DOMAINS'" +s="$s U_WEB_SSL='$TOTAL_U_WEB_SSL' U_WEB_ALIASES='$TOTAL_U_WEB_ALIASES'" +s="$s U_DNS_DOMAINS='$TOTAL_U_DNS_DOMAINS'" +s="$s U_DNS_RECORDS='$TOTAL_U_DNS_RECORDS'" +s="$s U_MAIL_DOMAINS='$TOTAL_U_MAIL_DOMAINS' U_MAIL_DKIM='$TOTAL_U_MAIL_DKIM'" +s="$s U_MAIL_ACCOUNTS='$TOTAL_U_MAIL_ACCOUNTS'" +s="$s U_DATABASES='$TOTAL_U_DATABASES'" +s="$s U_CRON_JOBS='$TOTAL_U_CRON_JOBS' U_BACKUPS='$TOTAL_U_BACKUPS'" + +if [ -e "$stats" ]; then + # Checking dublicates + check_month=$(grep -n "DATE='$DATE'" $stats|cut -f 1 -d :) + if [ -z "$check_month" ]; then + # Updating as there no dublicates + echo "$s" >> $stats + chmod 660 $stats + else + # Replacing string with new data + sed -i "$check_month s/.*/$s/" $stats + fi +else + # Creating stats log + echo "$s" >$stats + chmod 660 $stats +fi + + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit +>>>>>>> 994c40901078e48fe939536f7b366e29c2e44a1d diff --git a/func/domain.sh b/func/domain.sh index 3ac064766..738c3f6a7 100644 --- a/func/domain.sh +++ b/func/domain.sh @@ -1,463 +1,541 @@ -# Web template check -is_apache_template_valid() { - t="$WEBTPL/apache_$template.tpl" - s="$WEBTPL/apache_$template.stpl" - if [ ! -e $t ] || [ ! -e $s ]; then - template='default' - t="$WEBTPL/apache_$template.tpl" - s="$WEBTPL/apache_$template.stpl" - if [ ! -e $t ] || [ ! -e $s ]; then - echo "Error: template $template not found" - log_event "$E_NOTEXIST" "$EVENT" - exit $E_NOTEXIST - fi - fi -} - -# Nginx template check -is_nginx_template_valid() { - t="$WEBTPL/nginx_$template.tpl" - s="$WEBTPL/nginx_$template.stpl" - if [ ! -e $t ] || [ ! -e $s ]; then - template='default' - t="$WEBTPL/nginx_$template.tpl" - s="$WEBTPL/nginx_$template.stpl" - if [ ! -e $t ] || [ ! -e $s ]; then - echo "Error: nginx $template not found" - log_event "$E_NOTEXIST" "$EVENT" - exit $E_NOTEXIST - fi - fi -} - -# DNS template check -is_dns_template_valid() { - tpl="$DNSTPL/$template.tpl" - if [ ! -e $tpl ]; then - template='default' - tpl="$DNSTPL/$template.tpl" - if [ ! -e $tpl ]; then - echo "Error: template not found" - log_event "$E_NOTEXIST" "$EVENT" - exit $E_NOTEXIST - fi - fi -} - -# Checking domain existance -is_domain_new() { - type="$1" - dom=${2-$domain} - web="$(grep -w $dom $VESTA/data/users/*/web.conf)" - dns="$(grep DOMAIN='$dom' $VESTA/data/users/*/dns.conf)" - mail="$(grep DOMAIN='$dom' $VESTA/data/users/*/mail.conf)" - - if [ -n "$web" ] || [ -n "$dns" ] || [ -n "$mail" ]; then - if [ ! -z "$(grep -w $dom $USER_DATA/*.conf)" ]; then - c1=$(grep "'$dom'" $USER_DATA/$type.conf) - c2=$(grep "'$dom," $USER_DATA/$type.conf) - c3=$(grep ",$dom," $USER_DATA/$type.conf) - c4=$(grep ",$dom'" $USER_DATA/$type.conf) - - if [ -n "$c1" ] || [ -n "$c2" ] || [ -n "$c3" ] || [ -n "$c4" ] - then - echo "Error: domain $dom exist" - log_event "$E_EXISTS" "$EVENT" - exit $E_EXISTS - fi - else - echo "Error: domain $dom exist" - log_event "$E_EXISTS" "$EVENT" - exit $E_EXISTS - fi - fi -} - -# Checking mail account existance -is_mail_new() { - check_acc=$(grep "ACCOUNT='$1'" $USER_DATA/mail/$domain.conf) - if [ ! -z "$check_acc" ]; then - echo "Error: mail account $1 exist" - log_event "$E_EXISTS" "$EVENT" - exit - fi - check_als=$(awk -F "ALIAS='" '{print $2}' $USER_DATA/mail/$domain.conf ) - check_als=$(echo "$check_als" | cut -f 1 -d "'" | grep -w $1) - if [ ! -z "$check_als" ]; then - echo "Error: mail alias $1 exist" - log_event "$E_EXISTS" "$EVENT" - exit - fi -} - -# Update domain zone -update_domain_zone() { - conf="$HOMEDIR/$user/conf/dns/$domain.db" - line=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf) - fields='$RECORD\t$TTL\tIN\t$TYPE\t$PRIORITY\t$VALUE' - if [ -e $conf ]; then - zn_serial=$(head $conf|grep 'SOA' -A1|tail -n 1|sed -e "s/ //g") - s_date=$(echo ${zn_serial:0:8}) - c_date=$(date +'%Y%m%d') - if [ "$s_date" == "$c_date" ]; then - cur_value=$(echo ${zn_serial:8} ) - new_value=$(expr $cur_value + 1 ) - len_value=$(expr length $new_value) - if [ 1 -eq "$len_value" ]; then - new_value='0'$new_value - fi - serial="$c_date""$new_value" - else - serial="$(date +'%Y%m%d01')" - fi - else - serial="$(date +'%Y%m%d01')" - fi - - eval $line - SOA=$(idn --quiet -a -t "$SOA") - echo "\$TTL $TTL -@ IN SOA $SOA. root.$domain_idn. ( - $serial - 7200 - 3600 - 1209600 - 180 ) -" > $conf - while read line ; do - IFS=$'\n' - for key in $(echo $line|sed -e "s/' /'\n/g"); do - eval ${key%%=*}="${key#*=}" - done - - RECORD=$(idn --quiet -a -t "$RECORD") - if [ "$SUSPENDED" != 'yes' ]; then - eval echo -e "\"$fields\""|sed -e "s/%quote%/'/g" >> $conf - fi - done < $USER_DATA/dns/$domain.conf -} - -# Get next DNS record ID -get_next_dnsrecord(){ - if [ -z "$id" ]; then - curr_str=$(grep "ID=" $USER_DATA/dns/$domain.conf | cut -f 2 -d \' |\ - sort -n|tail -n1) - id="$((curr_str +1))" - fi -} - -# Sort DNS records -sort_dns_records() { - conf="$USER_DATA/dns/$domain.conf" - cat $conf |sort -n -k 2 -t \' >$conf.tmp - mv -f $conf.tmp $conf -} - -# Add web config -add_web_config() { - cat $tpl_file | \ - sed -e "s/%ip%/$ip/g" \ - -e "s/%web_port%/$WEB_PORT/g" \ - -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \ - -e "s/%proxy_port%/$PROXY_PORT/g" \ - -e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \ - -e "s/%domain_idn%/$domain_idn/g" \ - -e "s/%domain%/$domain/g" \ - -e "s/%user%/$user/g" \ - -e "s/%group%/$group/g" \ - -e "s/%home%/${HOMEDIR////\/}/g" \ - -e "s/%docroot%/${docroot////\/}/g" \ - -e "s/%sdocroot%/${sdocroot////\/}/g" \ - -e "s/%email%/$email/g" \ - -e "s/%alias_string%/$alias_string/g" \ - -e "s/%alias_idn%/${aliases_idn//,/ }/g" \ - -e "s/%alias%/${aliases//,/ }/g" \ - -e "s/%ssl_crt%/${ssl_crt////\/}/g" \ - -e "s/%ssl_key%/${ssl_key////\/}/g" \ - -e "s/%ssl_pem%/${ssl_pem////\/}/g" \ - -e "s/%ssl_ca_str%/${ssl_ca_str////\/}/g" \ - -e "s/%ssl_ca%/${ssl_ca////\/}/g" \ - -e "s/%nginx_extentions%/${NGINX_EXT//,/|}/g" \ - -e "s/%elog%/$elog/g" \ - -e "s/%cgi%/$cgi/g" \ - -e "s/%cgi_option%/$cgi_option/g" \ - >> $conf -} - -# Get config top and bottom line numbers -get_web_config_brds() { - serv_line=$(grep -ni 'Name %domain_idn%' "$tpl_file" |cut -f 1 -d :) - if [ -z "$serv_line" ]; then - log_event "$E_PARSING" "$EVENT" - return $E_PARSING - fi - - last_line=$(wc -l $tpl_file|cut -f 1 -d ' ') - bfr_line=$((serv_line - 1)) - aftr_line=$((last_line - serv_line - 1)) - - str=$(grep -ni "Name $domain_idn" $conf | cut -f 1 -d :) - top_line=$((str - serv_line + 1)) - bottom_line=$((top_line + last_line -1)) - - multi=$(sed -n "$top_line,$bottom_line p" $conf |grep ServerAlias |wc -l) - if [ "$multi" -ge 2 ]; then - bottom_line=$((bottom_line + multi -1)) - fi - -} - -# Change web config -change_web_config() { - get_web_config_brds || exit $? - vhost=$(grep -A $aftr_line -B $bfr_line -ni "Name $domain_idn" $conf) - str=$(echo "$vhost" | grep -F "$search_phrase" | head -n 1) - str_numb=$(echo "$str" | sed -e "s/-/=/" | cut -f 1 -d '=') - str_cont=$(echo "$str" | sed -e "s/-/=/" | cut -f 2 -d '=') - - str_repl=$(echo "$str_repl" | sed \ - -e 's/\\/\\\\/g' \ - -e 's/&/\\&/g' \ - -e 's/\//\\\//g') - - if [ ! -z "$str" ]; then - sed -i "$str_numb s/.*/$str_repl/" $conf - fi -} - -# Replace web config -replace_web_config() { - get_web_config_brds || exit $? - clean_new=$(echo "$new" | sed \ - -e 's/\\/\\\\/g' \ - -e 's/&/\\&/g' \ - -e 's/\//\\\//g') - clean_old=$(echo "$old" | sed \ - -e 's/\\/\\\\/g' \ - -e 's/&/\\&/g' \ - -e 's/\//\\\//g') - - sed -i "$top_line,$bottom_line s/$clean_old/$clean_new/" $conf -} - -# Get domain variables -get_domain_values() { - for line in $(grep "DOMAIN='$domain'" $USER_DATA/$1.conf); do - eval $line - done -} - -# SSL certificate verification -is_web_domain_cert_valid() { - if [ ! -e "$ssl_dir/$domain.crt" ]; then - echo "Error: $ssl_dir/$domain.crt not found" - log_event "$E_NOTEXIST" "$EVENT" - exit $E_NOTEXIST - fi - - if [ ! -e "$ssl_dir/$domain.key" ]; then - echo "Error: $ssl_dir/$domain.key not found" - log_event "$E_NOTEXIST" "$EVENT" - exit $E_NOTEXIST - fi - - crt_vrf=$(openssl verify $ssl_dir/$domain.crt 2>&1) - if [ ! -z "$(echo $crt_vrf | grep 'unable to load')" ]; then - echo "Error: certificate is not valid" - log_event "$E_INVALID" "$EVENT" - exit $E_INVALID - fi - - if [ ! -z "$(echo $crt_vrf | grep 'unable to get local issuer')" ]; then - if [ ! -e "$ssl_dir/$domain.ca" ]; then - echo "Error: certificate authority not found" - log_event "$E_NOTEXIST" "$EVENT" - exit $E_NOTEXIST - fi - fi - - if [ -e "$ssl_dir/$domain.ca" ]; then - ca_vrf=$(openssl verify $ssl_dir/$domain.ca 2>/dev/null |grep 'OK') - if [ -z "$ca_vrf" ]; then - echo "Error: ssl certificate authority is not valid" - log_event "$E_INVALID" "$EVENT" - exit $E_INVALID - fi - - crt_vrf=$(openssl verify -untrusted $ssl_dir/$domain.ca \ - $ssl_dir/$domain.crt 2>/dev/null |grep 'OK') - if [ -z "$crt_vrf" ]; then - echo "Error: root or/and intermediate cerificate not found" - log_event "$E_NOTEXIST" "$EVENT" - exit $E_NOTEXIST - fi - fi - - key_vrf=$(grep 'RSA PRIVATE KEY' $ssl_dir/$domain.key | wc -l) - if [ "$key_vrf" -ne 2 ]; then - echo "Error: ssl key is not valid" - log_event "$E_INVALID" "$EVENT" - exit $E_INVALID - fi - - openssl s_server -quiet -cert $ssl_dir/$domain.crt \ - -key $ssl_dir/$domain.key >> /dev/null 2>&1 & - pid=$! - sleep 0.5 - disown &> /dev/null - kill $pid &> /dev/null - if [ "$?" -ne '0' ]; then - echo "Error: ssl certificate key pair is not valid" - log_event "$E_INVALID" "$EVENT" - exit $E_INVALID - fi -} - -# Delete web configuartion -del_web_config() { - get_web_config_brds || exit $? - sed -i "$top_line,$bottom_line d" $conf -} - -# Add ip virtual hosting support -namehost_ip_support() { - if [ "$WEB_SYSTEM" = 'apache' ]; then - conf_line=$(grep -n "NameVirtual" $conf|tail -n 1|cut -f 1 -d ':') - if [ ! -z "$conf_line" ]; then - conf_ins=$((conf_line + 1)) - else - conf_ins='1' - fi - - if [ "$WEB_SSL" = 'mod_ssl' ]; then - sed -i "$conf_ins i NameVirtualHost $ip:$WEB_SSL_PORT" $conf - sed -i "$conf_ins i Listen $ip:$WEB_SSL_PORT" $conf - fi - - sed -i "$conf_ins i NameVirtualHost $ip:$WEB_PORT" $conf - sed -i "$conf_ins i Listen $ip:$WEB_PORT" $conf - - if [ "$PROXY_SYSTEM" = 'nginx' ]; then - cat $WEBTPL/ngingx.ip.tpl | sed -e "s/%ip%/$ip/g" \ - -e "s/%web_port%/$WEB_PORT/g" \ - -e "s/%proxy_port%/$PROXY_PORT/g" >>$nconf - - ips=$(grep 'MEFaccept ' $rconf |grep -v '#'| head -n1) - sed -i "s/$ips/$ips $ip/g" $rconf - fi - web_restart='yes' - fi -} - -# Disable virtual ip hosting support -namehost_ip_disable() { - if [ "$WEB_SYSTEM" = 'apache' ]; then - sed -i "/NameVirtualHost $ip:/d" $conf - sed -i "/Listen $ip:/d" $conf - - if [ "$PROXY_SYSTEM" = 'nginx' ]; then - tpl_ln=$(wc -l $WEBTPL/ngingx.ip.tpl | cut -f 1 -d ' ') - ip_line=$(grep -n "%ip%" $WEBTPL/ngingx.ip.tpl |head -n1 |\ - cut -f 1 -d :) - conf_line=$(grep -n -w $ip $nconf|head -n1|cut -f 1 -d :) - if [ -z "$tpl_ln" ] || [ -z "$ip_line" ] || [ -z "$conf_line" ] - then - echo "Error: nginx config paring error" - log_event "$E_PARSING" "$EVENT" - exit $E_PARSING - fi - up_line=$((ip_line - 1)) - first_line=$((conf_line - up_line)) - last_line=$((conf_line - ip_line + tpl_ln)) - - if [ -z "$first_line" ] || [ -z "$last_line" ]; then - echo "Error: nginx config paring error" - log_event "$E_PARSING" "$EVENT" - exit $E_PARSING - fi - sed -i "$first_line,$last_line d" $nconf - ips=$(grep 'RPAFproxy_ips' $rconf) - new_ips=$(echo "$ips"|sed -e "s/$ip//") - sed -i "s/$ips/$new_ips/g" $rconf - fi - web_restart='yes' - fi -} - -# Update web domain values -upd_web_domain_values() { - ip=$IP - group="$user" - email="$user@$domain" - docroot="$HOMEDIR/$user/web/$domain/public_html" - sdocroot=$docroot - if [ "$SSL_HOME" = 'single' ]; then - sdocroot="$HOMEDIR/$user/web/$domain/public_shtml" ; - fi - - i=1 - j=1 - OLD_IFS="$IFS" - IFS=',' - server_alias='' - alias_string='' - aliases_idn='' - - for dalias in $ALIAS; do - dalias=$(idn -t --quiet -a $dalias) - check_8k="$server_alias $dalias" - if [ "${#check_8k}" -ge '8100' ]; then - if [ "$j" -eq 1 ]; then - alias_string="ServerAlias $server_alias" - else - alias_string="$alias_string\n ServerAlias $server_alias" - fi - j=2 - server_alias='' - fi - if [ "$i" -eq 1 ]; then - aliases_idn="$dalias" - server_alias="$dalias" - alias_string="ServerAlias $server_alias" - else - aliases_idn="$aliases_idn,$dalias" - server_alias="$server_alias $dalias" - fi - i=2 - done - - if [ $j -gt 1 ]; then - alias_string="$alias_string\n ServerAlias $server_alias" - else - alias_string="ServerAlias $server_alias" - fi - - IFS=$OLD_IFS - if [ "$ELOG" = 'no' ]; then - elog='#' - else - elog='' - fi - - if [ "$CGI" != 'yes' ]; then - cgi='#' - cgi_option='-ExecCGI' - else - cgi='' - cgi_option='+ExecCGI' - fi - - ssl_crt="$HOMEDIR/$user/conf/web/ssl.$domain.crt" - ssl_key="$HOMEDIR/$user/conf/web/ssl.$domain.key" - ssl_pem="$HOMEDIR/$user/conf/web/ssl.$domain.pem" - ssl_ca="$HOMEDIR/$user/conf/web/ssl.$domain.ca" - if [ ! -e "$USER_DATA/ssl/$domain.ca" ]; then - ssl_ca_str='#' - fi - - if [ "$SUSPENDED" = 'yes' ]; then - docroot="$VESTA/data/templates/web/suspend" - sdocroot="$VESTA/data/templates/web/suspend" - fi -} - +# Web template check +is_apache_template_valid() { + t="$WEBTPL/apache_$template.tpl" + s="$WEBTPL/apache_$template.stpl" + if [ ! -e $t ] || [ ! -e $s ]; then + template='default' + t="$WEBTPL/apache_$template.tpl" + s="$WEBTPL/apache_$template.stpl" + if [ ! -e $t ] || [ ! -e $s ]; then + echo "Error: template $template not found" + log_event "$E_NOTEXIST" "$EVENT" + exit $E_NOTEXIST + fi + fi +} + +# Nginx template check +is_nginx_template_valid() { + t="$WEBTPL/nginx_$template.tpl" + s="$WEBTPL/nginx_$template.stpl" + if [ ! -e $t ] || [ ! -e $s ]; then + template='default' + t="$WEBTPL/nginx_$template.tpl" + s="$WEBTPL/nginx_$template.stpl" + if [ ! -e $t ] || [ ! -e $s ]; then + echo "Error: nginx $template not found" + log_event "$E_NOTEXIST" "$EVENT" + exit $E_NOTEXIST + fi + fi +} + +# DNS template check +is_dns_template_valid() { + tpl="$DNSTPL/$template.tpl" + if [ ! -e $tpl ]; then + template='default' + tpl="$DNSTPL/$template.tpl" + if [ ! -e $tpl ]; then + echo "Error: template not found" + log_event "$E_NOTEXIST" "$EVENT" + exit $E_NOTEXIST + fi + fi +} + +# Checking domain existance +is_domain_new() { + type="$1" + dom=${2-$domain} + + web=$(grep "DOMAIN='$dom'" $VESTA/data/users/*/web.conf) + dns=$(grep "DOMAIN='$dom'" $VESTA/data/users/*/dns.conf) + mail=$(grep "DOMAIN='$dom'" $VESTA/data/users/*/mail.conf) + + # Check web domain + if [ ! -z "$web" ] && [ "$type" == 'web' ]; then + echo "Error: domain $dom exist" + log_event "$E_EXISTS" "$EVENT" + exit $E_EXISTS + fi + if [ ! -z "$web" ]; then + web_user=$(echo "$web" |cut -f 7 -d /) + if [ "$web_user" != "$user" ]; then + echo "Error: domain $dom exist" + log_event "$E_EXISTS" "$EVENT" + exit $E_EXISTS + fi + fi + + # Check dns domain + if [ ! -z "$dns" ] && [ "$type" == 'dns' ]; then + echo "Error: domain $dom exist" + log_event "$E_EXISTS" "$EVENT" + exit $E_EXISTS + fi + if [ ! -z "$dns" ]; then + dns_user=$(echo "$dns" |cut -f 7 -d /) + if [ "$dns_user" != "$user" ]; then + echo "Error: domain $dom exist" + log_event "$E_EXISTS" "$EVENT" + exit $E_EXISTS + fi + fi + + # Check mail domain + if [ ! -z "$mail" ] && [ "$type" == 'mail' ]; then + echo "Error: domain $dom exist" + log_event "$E_EXISTS" "$EVENT" + exit $E_EXISTS + fi + if [ ! -z "$mail" ]; then + mail_user=$(echo "$mail" |cut -f 7 -d /) + if [ "$mail_user" != "$user" ]; then + echo "Error: domain $dom exist" + log_event "$E_EXISTS" "$EVENT" + exit $E_EXISTS + fi + fi + + # Check web aliases + web_alias=$(grep -w $dom $VESTA/data/users/*/web.conf) + if [ ! -z "$web_alias" ]; then + c1=$(grep "'$dom'" $VESTA/data/users/*/web.conf | cut -f 7 -d /) + c2=$(grep "'$dom," $VESTA/data/users/*/web.conf | cut -f 7 -d /) + c3=$(grep ",$dom," $VESTA/data/users/*/web.conf | cut -f 7 -d /) + c4=$(grep ",$dom'" $VESTA/data/users/*/web.conf | cut -f 7 -d /) + if [ ! -z "$c1" ] && [ "$type" == "web" ]; then + echo "Error: domain $dom exist" + log_event "$E_EXISTS" "$EVENT" + exit $E_EXISTS + fi + if [ ! -z "$c1" ] && [ "$c1" != "$user" ]; then + echo "Error: domain $dom exist" + log_event "$E_EXISTS" "$EVENT" + exit $E_EXISTS + fi + + if [ ! -z "$c2" ] && [ "$type" == "web" ]; then + echo "Error: domain $dom exist" + log_event "$E_EXISTS" "$EVENT" + exit $E_EXISTS + fi + if [ ! -z "$c2" ] && [ "$c2" != "$user" ]; then + echo "Error: domain $dom exist" + log_event "$E_EXISTS" "$EVENT" + exit $E_EXISTS + fi + + if [ ! -z "$c3" ] && [ "$type" == "web" ]; then + echo "Error: domain $dom exist" + log_event "$E_EXISTS" "$EVENT" + exit $E_EXISTS + fi + if [ ! -z "$c3" ] && [ "$c3" != "$user" ]; then + echo "Error: domain $dom exist" + log_event "$E_EXISTS" "$EVENT" + exit $E_EXISTS + fi + + if [ ! -z "$c4" ] && [ "$type" == "web" ]; then + echo "Error: domain $dom exist" + log_event "$E_EXISTS" "$EVENT" + exit $E_EXISTS + fi + if [ ! -z "$c4" ] && [ "$c4" != "$user" ]; then + echo "Error: domain $dom exist" + log_event "$E_EXISTS" "$EVENT" + exit $E_EXISTS + fi + fi +} + +# Checking mail account existance +is_mail_new() { + check_acc=$(grep "ACCOUNT='$1'" $USER_DATA/mail/$domain.conf) + if [ ! -z "$check_acc" ]; then + echo "Error: mail account $1 exist" + log_event "$E_EXISTS" "$EVENT" + exit + fi + check_als=$(awk -F "ALIAS='" '{print $2}' $USER_DATA/mail/$domain.conf ) + check_als=$(echo "$check_als" | cut -f 1 -d "'" | grep -w $1) + if [ ! -z "$check_als" ]; then + echo "Error: mail alias $1 exist" + log_event "$E_EXISTS" "$EVENT" + exit + fi +} + +# Update domain zone +update_domain_zone() { + conf="$HOMEDIR/$user/conf/dns/$domain.db" + line=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf) + fields='$RECORD\t$TTL\tIN\t$TYPE\t$PRIORITY\t$VALUE' + if [ -e $conf ]; then + zn_serial=$(head $conf|grep 'SOA' -A1|tail -n 1|sed -e "s/ //g") + s_date=$(echo ${zn_serial:0:8}) + c_date=$(date +'%Y%m%d') + if [ "$s_date" == "$c_date" ]; then + cur_value=$(echo ${zn_serial:8} ) + new_value=$(expr $cur_value + 1 ) + len_value=$(expr length $new_value) + if [ 1 -eq "$len_value" ]; then + new_value='0'$new_value + fi + serial="$c_date""$new_value" + else + serial="$(date +'%Y%m%d01')" + fi + else + serial="$(date +'%Y%m%d01')" + fi + + eval $line + SOA=$(idn --quiet -a -t "$SOA") + echo "\$TTL $TTL +@ IN SOA $SOA. root.$domain_idn. ( + $serial + 7200 + 3600 + 1209600 + 180 ) +" > $conf + while read line ; do + IFS=$'\n' + for key in $(echo $line|sed -e "s/' /'\n/g"); do + eval ${key%%=*}="${key#*=}" + done + + RECORD=$(idn --quiet -a -t "$RECORD") + if [ "$SUSPENDED" != 'yes' ]; then + eval echo -e "\"$fields\""|sed -e "s/%quote%/'/g" >> $conf + fi + done < $USER_DATA/dns/$domain.conf +} + +# Get next DNS record ID +get_next_dnsrecord(){ + if [ -z "$id" ]; then + curr_str=$(grep "ID=" $USER_DATA/dns/$domain.conf | cut -f 2 -d \' |\ + sort -n|tail -n1) + id="$((curr_str +1))" + fi +} + +# Sort DNS records +sort_dns_records() { + conf="$USER_DATA/dns/$domain.conf" + cat $conf |sort -n -k 2 -t \' >$conf.tmp + mv -f $conf.tmp $conf +} + +# Add web config +add_web_config() { + cat $tpl_file | \ + sed -e "s/%ip%/$ip/g" \ + -e "s/%web_port%/$WEB_PORT/g" \ + -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \ + -e "s/%proxy_port%/$PROXY_PORT/g" \ + -e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \ + -e "s/%domain_idn%/$domain_idn/g" \ + -e "s/%domain%/$domain/g" \ + -e "s/%user%/$user/g" \ + -e "s/%group%/$group/g" \ + -e "s/%home%/${HOMEDIR////\/}/g" \ + -e "s/%docroot%/${docroot////\/}/g" \ + -e "s/%sdocroot%/${sdocroot////\/}/g" \ + -e "s/%email%/$email/g" \ + -e "s/%alias_string%/$alias_string/g" \ + -e "s/%alias_idn%/${aliases_idn//,/ }/g" \ + -e "s/%alias%/${aliases//,/ }/g" \ + -e "s/%ssl_crt%/${ssl_crt////\/}/g" \ + -e "s/%ssl_key%/${ssl_key////\/}/g" \ + -e "s/%ssl_pem%/${ssl_pem////\/}/g" \ + -e "s/%ssl_ca_str%/${ssl_ca_str////\/}/g" \ + -e "s/%ssl_ca%/${ssl_ca////\/}/g" \ + -e "s/%nginx_extentions%/${NGINX_EXT//,/|}/g" \ + -e "s/%elog%/$elog/g" \ + -e "s/%cgi%/$cgi/g" \ + -e "s/%cgi_option%/$cgi_option/g" \ + >> $conf +} + +# Get config top and bottom line numbers +get_web_config_brds() { + serv_line=$(grep -ni 'Name %domain_idn%' "$tpl_file" |cut -f 1 -d :) + if [ -z "$serv_line" ]; then + log_event "$E_PARSING" "$EVENT" + return $E_PARSING + fi + + last_line=$(wc -l $tpl_file|cut -f 1 -d ' ') + bfr_line=$((serv_line - 1)) + aftr_line=$((last_line - serv_line - 1)) + + str=$(grep -ni "Name $domain_idn" $conf | cut -f 1 -d :) + top_line=$((str - serv_line + 1)) + bottom_line=$((top_line + last_line -1)) + + multi=$(sed -n "$top_line,$bottom_line p" $conf |grep ServerAlias |wc -l) + if [ "$multi" -ge 2 ]; then + bottom_line=$((bottom_line + multi -1)) + fi + +} + +# Change web config +change_web_config() { + get_web_config_brds || exit $? + vhost=$(grep -A $aftr_line -B $bfr_line -ni "Name $domain_idn" $conf) + str=$(echo "$vhost" | grep -F "$search_phrase" | head -n 1) + str_numb=$(echo "$str" | sed -e "s/-/=/" | cut -f 1 -d '=') + str_cont=$(echo "$str" | sed -e "s/-/=/" | cut -f 2 -d '=') + + str_repl=$(echo "$str_repl" | sed \ + -e 's/\\/\\\\/g' \ + -e 's/&/\\&/g' \ + -e 's/\//\\\//g') + + if [ ! -z "$str" ]; then + sed -i "$str_numb s/.*/$str_repl/" $conf + fi +} + +# Replace web config +replace_web_config() { + get_web_config_brds || exit $? + clean_new=$(echo "$new" | sed \ + -e 's/\\/\\\\/g' \ + -e 's/&/\\&/g' \ + -e 's/\//\\\//g') + clean_old=$(echo "$old" | sed \ + -e 's/\\/\\\\/g' \ + -e 's/&/\\&/g' \ + -e 's/\//\\\//g') + + sed -i "$top_line,$bottom_line s/$clean_old/$clean_new/" $conf +} + +# Get domain variables +get_domain_values() { + for line in $(grep "DOMAIN='$domain'" $USER_DATA/$1.conf); do + eval $line + done +} + +# SSL certificate verification +is_web_domain_cert_valid() { + if [ ! -e "$ssl_dir/$domain.crt" ]; then + echo "Error: $ssl_dir/$domain.crt not found" + log_event "$E_NOTEXIST" "$EVENT" + exit $E_NOTEXIST + fi + + if [ ! -e "$ssl_dir/$domain.key" ]; then + echo "Error: $ssl_dir/$domain.key not found" + log_event "$E_NOTEXIST" "$EVENT" + exit $E_NOTEXIST + fi + + crt_vrf=$(openssl verify $ssl_dir/$domain.crt 2>&1) + if [ ! -z "$(echo $crt_vrf | grep 'unable to load')" ]; then + echo "Error: certificate is not valid" + log_event "$E_INVALID" "$EVENT" + exit $E_INVALID + fi + + if [ ! -z "$(echo $crt_vrf | grep 'unable to get local issuer')" ]; then + if [ ! -e "$ssl_dir/$domain.ca" ]; then + echo "Error: certificate authority not found" + log_event "$E_NOTEXIST" "$EVENT" + exit $E_NOTEXIST + fi + fi + + if [ -e "$ssl_dir/$domain.ca" ]; then + ca_vrf=$(openssl verify $ssl_dir/$domain.ca 2>/dev/null |grep 'OK') + if [ -z "$ca_vrf" ]; then + echo "Error: ssl certificate authority is not valid" + log_event "$E_INVALID" "$EVENT" + exit $E_INVALID + fi + + crt_vrf=$(openssl verify -untrusted $ssl_dir/$domain.ca \ + $ssl_dir/$domain.crt 2>/dev/null |grep 'OK') + if [ -z "$crt_vrf" ]; then + echo "Error: root or/and intermediate cerificate not found" + log_event "$E_NOTEXIST" "$EVENT" + exit $E_NOTEXIST + fi + fi + + key_vrf=$(grep 'RSA PRIVATE KEY' $ssl_dir/$domain.key | wc -l) + if [ "$key_vrf" -ne 2 ]; then + echo "Error: ssl key is not valid" + log_event "$E_INVALID" "$EVENT" + exit $E_INVALID + fi + + openssl s_server -quiet -cert $ssl_dir/$domain.crt \ + -key $ssl_dir/$domain.key >> /dev/null 2>&1 & + pid=$! + sleep 0.5 + disown &> /dev/null + kill $pid &> /dev/null + if [ "$?" -ne '0' ]; then + echo "Error: ssl certificate key pair is not valid" + log_event "$E_INVALID" "$EVENT" + exit $E_INVALID + fi +} + +# Delete web configuartion +del_web_config() { + get_web_config_brds || exit $? + sed -i "$top_line,$bottom_line d" $conf +} + +# Add ip virtual hosting support +namehost_ip_support() { + if [ "$WEB_SYSTEM" = 'apache' ]; then + conf_line=$(grep -n "NameVirtual" $conf|tail -n 1|cut -f 1 -d ':') + if [ ! -z "$conf_line" ]; then + conf_ins=$((conf_line + 1)) + else + conf_ins='1' + fi + + if [ "$WEB_SSL" = 'mod_ssl' ]; then + sed -i "$conf_ins i NameVirtualHost $ip:$WEB_SSL_PORT" $conf + sed -i "$conf_ins i Listen $ip:$WEB_SSL_PORT" $conf + fi + + sed -i "$conf_ins i NameVirtualHost $ip:$WEB_PORT" $conf + sed -i "$conf_ins i Listen $ip:$WEB_PORT" $conf + + if [ "$PROXY_SYSTEM" = 'nginx' ]; then + cat $WEBTPL/ngingx.ip.tpl | sed -e "s/%ip%/$ip/g" \ + -e "s/%web_port%/$WEB_PORT/g" \ + -e "s/%proxy_port%/$PROXY_PORT/g" >>$nconf + + ips=$(grep 'MEFaccept ' $rconf |grep -v '#'| head -n1) + sed -i "s/$ips/$ips $ip/g" $rconf + fi + web_restart='yes' + fi +} + +# Disable virtual ip hosting support +namehost_ip_disable() { + if [ "$WEB_SYSTEM" = 'apache' ]; then + sed -i "/NameVirtualHost $ip:/d" $conf + sed -i "/Listen $ip:/d" $conf + + if [ "$PROXY_SYSTEM" = 'nginx' ]; then + tpl_ln=$(wc -l $WEBTPL/ngingx.ip.tpl | cut -f 1 -d ' ') + ip_line=$(grep -n "%ip%" $WEBTPL/ngingx.ip.tpl |head -n1 |\ + cut -f 1 -d :) + conf_line=$(grep -n -w $ip $nconf|head -n1|cut -f 1 -d :) + if [ -z "$tpl_ln" ] || [ -z "$ip_line" ] || [ -z "$conf_line" ] + then + echo "Error: nginx config paring error" + log_event "$E_PARSING" "$EVENT" + exit $E_PARSING + fi + up_line=$((ip_line - 1)) + first_line=$((conf_line - up_line)) + last_line=$((conf_line - ip_line + tpl_ln)) + + if [ -z "$first_line" ] || [ -z "$last_line" ]; then + echo "Error: nginx config paring error" + log_event "$E_PARSING" "$EVENT" + exit $E_PARSING + fi + sed -i "$first_line,$last_line d" $nconf + ips=$(grep 'RPAFproxy_ips' $rconf) + new_ips=$(echo "$ips"|sed -e "s/$ip//") + sed -i "s/$ips/$new_ips/g" $rconf + fi + web_restart='yes' + fi +} + +# Update web domain values +upd_web_domain_values() { + ip=$IP + group="$user" + email="$user@$domain" + docroot="$HOMEDIR/$user/web/$domain/public_html" + sdocroot=$docroot + if [ "$SSL_HOME" = 'single' ]; then + sdocroot="$HOMEDIR/$user/web/$domain/public_shtml" ; + fi + + i=1 + j=1 + OLD_IFS="$IFS" + IFS=',' + server_alias='' + alias_string='' + aliases_idn='' + + for dalias in $ALIAS; do + dalias=$(idn -t --quiet -a $dalias) + check_8k="$server_alias $dalias" + if [ "${#check_8k}" -ge '8100' ]; then + if [ "$j" -eq 1 ]; then + alias_string="ServerAlias $server_alias" + else + alias_string="$alias_string\n ServerAlias $server_alias" + fi + j=2 + server_alias='' + fi + if [ "$i" -eq 1 ]; then + aliases_idn="$dalias" + server_alias="$dalias" + alias_string="ServerAlias $server_alias" + else + aliases_idn="$aliases_idn,$dalias" + server_alias="$server_alias $dalias" + fi + i=2 + done + + if [ $j -gt 1 ]; then + alias_string="$alias_string\n ServerAlias $server_alias" + else + alias_string="ServerAlias $server_alias" + fi + + IFS=$OLD_IFS + if [ "$ELOG" = 'no' ]; then + elog='#' + else + elog='' + fi + + if [ "$CGI" != 'yes' ]; then + cgi='#' + cgi_option='-ExecCGI' + else + cgi='' + cgi_option='+ExecCGI' + fi + + ssl_crt="$HOMEDIR/$user/conf/web/ssl.$domain.crt" + ssl_key="$HOMEDIR/$user/conf/web/ssl.$domain.key" + ssl_pem="$HOMEDIR/$user/conf/web/ssl.$domain.pem" + ssl_ca="$HOMEDIR/$user/conf/web/ssl.$domain.ca" + if [ ! -e "$USER_DATA/ssl/$domain.ca" ]; then + ssl_ca_str='#' + fi + + if [ "$SUSPENDED" = 'yes' ]; then + docroot="$VESTA/data/templates/web/suspend" + sdocroot="$VESTA/data/templates/web/suspend" + fi +} + diff --git a/func/main.sh b/func/main.sh index 697ef4ff7..c4a6c1337 100644 --- a/func/main.sh +++ b/func/main.sh @@ -1,772 +1,772 @@ -# Internal variables -DATE=$(date +%F) -TIME=$(date +%T) -SCRIPT=$(basename $0) -A1=$1 -A2=$2 -A3=$3 -A4=$4 -A5=$5 -A6=$6 -A7=$7 -A8=$8 -A9=$9 -EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'" -EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'" -HOMEDIR='/home' -BACKUP='/backup' -BACKUP_GZIP=5 -BACKUP_DISK_LIMIT=95 -BACKUP_LA_LIMIT=5 -RRD_STEP=300 -RRD_IFACE_EXCLUDE=lo - -BIN=$VESTA/bin -USER_DATA=$VESTA/data/users/$user -WEBTPL=$VESTA/data/templates/web -DNSTPL=$VESTA/data/templates/dns -RRD=$VESTA/web/rrd - -# Return codes -OK=0 -E_ARGS=1 -E_INVALID=2 -E_NOTEXIST=3 -E_EXISTS=4 -E_SUSPENDED=5 -E_UNSUSPENDED=6 -E_INUSE=7 -E_LIMIT=8 -E_PASSWORD=9 -E_FORBIDEN=10 -E_DISABLED=11 -E_PARSING=12 -E_DISK=13 -E_LA=14 -E_FTP=15 -E_SSH=16 -E_DB=17 -E_RRD=18 -E_UPDATE=19 -E_RESTART=20 - -# Log event function -log_event() { - echo "RC='$1' $2" >> $VESTA/log/system.log -} - -# Log user history -log_history() { - cmd=$1 - undo=${2-no} - log_user=${3-$user} - log=$VESTA/data/users/$log_user/history.log - - touch $log - if [ '99' -lt "$(wc -l $log |cut -f 1 -d ' ')" ]; then - tail -n 99 $log > $log.moved - mv -f $log.moved $log - chmod 660 $log - fi - - curr_str=$(grep "ID=" $log | cut -f 2 -d \' | sort -n | tail -n1) - id="$((curr_str +1))" - echo "ID='$id' DATE='$DATE' TIME='$TIME' CMD='$cmd' UNDO='$undo'" >> $log -} - -# Argument list checker -check_args() { - if [ "$1" -gt "$2" ]; then - echo "Error: not enought arguments" - echo "Usage: $SCRIPT $3" - log_event "$E_ARGS" "$EVENT" - exit $E_ARGS - fi -} - -# Subsystem checker -is_system_enabled() { - if [ -z "$1" ] || [ "$1" = no ]; then - echo "Error: subsystem disabled" - log_event "$E_DISABLED" "$EVENT" - exit $E_DISABLED - fi -} - -# User package check -is_package_full() { - case "$1" in - WEB_DOMAINS) used=$(wc -l $USER_DATA/web.conf|cut -f1 -d \ );; - WEB_ALIASES) used=$(grep "DOMAIN='$domain'" $USER_DATA/web.conf |\ - awk -F "ALIAS='" '{print $2}' | cut -f 1 -d \' | tr ',' '\n' |\ - wc -l );; - DNS_DOMAINS) used=$(wc -l $USER_DATA/dns.conf |cut -f1 -d \ );; - DNS_RECORDS) used=$(wc -l $USER_DATA/dns/$domain.conf |cut -f1 -d \ );; - MAIL_DOMAINS) used=$(wc -l $USER_DATA/mail.conf |cut -f1 -d \ );; - MAIL_ACCOUNTS) used=$(wc -l $USER_DATA/mail/$domain.conf |\ - cut -f1 -d \ );; - DATABASES) used=$(wc -l $USER_DATA/db.conf |cut -f1 -d \ );; - CRON_JOBS) used=$(wc -l $USER_DATA/cron.conf |cut -f1 -d \ );; - esac - limit=$(grep "^$1=" $USER_DATA/user.conf | cut -f 2 -d \' ) - if [ "$used" -ge "$limit" ]; then - echo "Error: Limit reached / Upgrade package" - log_event "$E_LIMIT" "$EVENT" - exit $E_LIMIT - fi -} - -# Random password generator -gen_password() { - matrix='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' - lenght=10 - while [ ${n:=1} -le $lenght ]; do - pass="$pass${matrix:$(($RANDOM%${#matrix})):1}" - let n+=1 - done - echo "$pass" -} - -# Package existance check -is_package_valid() { - if [ -z "$1" ]; then - pkg_dir="$VESTA/data/packages" - fi - if [ ! -e "$pkg_dir/$package.pkg" ]; then - echo "Error: package $package not exist" - log_event "$E_NOTEXIST $EVENT" - exit $E_NOTEXIST - fi -} - -# Validate system type -is_type_valid() { - if [ -z "$(echo $1 | grep -w $2)" ]; then - echo "Error: $2 is unknown type" - log_event "$E_INVALID" "$EVENT" - exit $E_INVALID - fi -} - -# Check user backup settings -is_backup_enabled() { - BACKUPS=$(grep "^BACKUPS=" $USER_DATA/user.conf | cut -f2 -d \') - if [ -z "$BACKUPS" ] || [[ "$BACKUPS" -le '0' ]]; then - echo "Error: user backup disabled" - log_event "$E_DISABLED" "$EVENT" - exit $E_DISABLED - fi -} - -# Check if object is free and can be created -is_object_free() { - if [ $2 = 'USER' ]; then - if [ -d "$USER_DATA" ]; then - object="OK" - fi - else - object=$(grep "$2='$3'" $USER_DATA/$1.conf) - fi - if [ ! -z "$object" ]; then - echo "Error: $2 with value $3 exists" - log_event "$E_EXISTS" "$EVENT" - exit $E_EXISTS - fi -} - -# Check if object exists and can be used -is_object_valid() { - if [ $2 = 'USER' ]; then - if [ -d "$VESTA/data/users/$user" ]; then - sobject="OK" - fi - else - if [ $2 = 'DBHOST' ]; then - sobject=$(grep "HOST='$host'" $VESTA/conf/$type.conf) - else - sobject=$(grep "$2='$3'" $VESTA/data/users/$user/$1.conf) - fi - fi - if [ -z "$sobject" ]; then - echo "Error: $3 not exist" - log_event "$E_NOTEXIST" "$EVENT" - exit $E_NOTEXIST - fi -} - -# Check if object is supended -is_object_suspended() { - if [ $2 = 'USER' ]; then - spnd=$(cat $USER_DATA/$1.conf|grep "SUSPENDED='yes'") - else - spnd=$(grep "$2='$3'" $USER_DATA/$1.conf|grep "SUSPENDED='yes'") - fi - if [ -z "$spnd" ]; then - echo "Error: $1 $3 is not suspended" - log_event "$E_SUSPENDED" "$EVENT" - exit $E_SUSPENDED - fi -} - -# Check if object is unsupended -is_object_unsuspended() { - if [ $2 = 'USER' ]; then - spnd=$(cat $USER_DATA/$1.conf|grep "SUSPENDED='yes'") - else - spnd=$(grep "$2='$3'" $USER_DATA/$1.conf|grep "SUSPENDED='yes'") - fi - if [ ! -z "$spnd" ]; then - echo "Error: $1 $3 is already suspended" - log_event "$E_UNSUSPENDED" "$EVENT" - exit $E_UNSUSPENDED - fi -} - -# Check if object value is empty -is_object_value_empty() { - str=$(grep "$2='$3'" $USER_DATA/$1.conf) - eval $str - eval value=$4 - if [ ! -z "$value" ] && [ "$value" != 'no' ]; then - echo "Error: ${4//$}=$value (not empty)" - log_event "$E_EXISTS" "$EVENT" - exit $E_EXISTS - fi -} - -# Check if object value is empty -is_object_value_exist() { - str=$(grep "$2='$3'" $USER_DATA/$1.conf) - eval $str - eval value=$4 - if [ -z "$value" ] || [ "$value" = 'no' ]; then - echo "Error: ${4//$}=$value (not exist)" - log_event "$E_NOTEXIST" "$EVENT" - exit $E_NOTEXIST - fi -} - -# Get object value -get_object_value() { - object=$(grep "$2='$3'" $USER_DATA/$1.conf) - eval "$object" - eval echo $4 -} - -# Update object value -update_object_value() { - row=$(grep -n "$2='$3'" $USER_DATA/$1.conf) - lnr=$(echo $row | cut -f 1 -d ':') - object=$(echo $row | sed -e "s/^$lnr://") - eval "$object" - eval old="$4" - old=$(echo "$old" | sed -e 's/\\/\\\\/g' -e 's/&/\\&/g' -e 's/\//\\\//g') - new=$(echo "$5" | sed -e 's/\\/\\\\/g' -e 's/&/\\&/g' -e 's/\//\\\//g') - sed -i "$lnr s/${4//$/}='${old//\*/\\*}'/${4//$/}='${new//\*/\\*}'/g" \ - $USER_DATA/$1.conf -} - -# Search objects -search_objects() { - OLD_IFS="$IFS" - IFS=$'\n' - for line in $(grep $2=\'$3\' $USER_DATA/$1.conf); do - eval $line - eval echo \$$4 - done - IFS="$OLD_IFS" -} - -# Get user value -get_user_value() { - grep "^${1//$/}=" $USER_DATA/user.conf| cut -f 2 -d \' -} - -# Update user value in user.conf -update_user_value() { - key="${2//$}" - lnr=$(grep -n "^$key='" $VESTA/data/users/$1/user.conf |cut -f 1 -d ':') - if [ ! -z "$lnr" ]; then - sed -i "$lnr d" $VESTA/data/users/$1/user.conf - sed -i "$lnr i\\$key='${3}'" $VESTA/data/users/$1/user.conf - fi -} - -# Increase user counter -increase_user_value() { - key="${2//$}" - factor="${3-1}" - conf="$VESTA/data/users/$1/user.conf" - old=$(grep "$key=" $conf | cut -f 2 -d \') - if [ -z "$old" ]; then - old=0 - fi - new=$((old + factor)) - sed -i "s/$key='$old'/$key='$new'/g" $conf -} - -# Decrease user counter -decrease_user_value() { - key="${2//$}" - factor="${3-1}" - conf="$VESTA/data/users/$1/user.conf" - old=$(grep "$key=" $conf | cut -f 2 -d \') - if [ -z "$old" ]; then - old=0 - fi - if [ "$old" -le 1 ]; then - new=0 - else - new=$((old - factor)) - fi - sed -i "s/$key='$old'/$key='$new'/g" $conf -} - -# Json listing function -json_list() { - echo '{' - fileds_count=$(echo $fields| wc -w ) - #for line in $(cat $conf); do - while read line; do - eval $line - if [ -n "$data_output" ]; then - echo -e ' },' - fi - i=1 - for field in $fields; do - eval value=$field - if [ $i -eq 1 ]; then - (( ++i)) - echo -e "\t\"$value\": {" - else - if [ $i -lt $fileds_count ]; then - (( ++i)) - echo -e "\t\t\"${field//$/}\": \"$value\"," - else - echo -e "\t\t\"${field//$/}\": \"$value\"" - data_output=yes - fi - fi - done - done < $conf - - if [ "$data_output" = 'yes' ]; then - echo -e ' }' - fi - echo -e '}' -} - -# Shell listing function -shell_list() { - if [ -z "$nohead" ] ; then - echo "${fields//$/}" - for a in $fields; do - echo -e "------ \c" - done - echo - fi - while read line ; do - eval $line - for field in $fields; do - eval value=$field - if [ -z "$value" ]; then - value='NULL' - fi - echo -n "$value " - done - echo - done < $conf -} - -# Recalculate U_DISK value -recalc_user_disk_usage() { - u_usage=0 - if [ -f "$USER_DATA/web.conf" ]; then - usage=0 - dusage=$(grep 'U_DISK=' $USER_DATA/web.conf |\ - awk -F "U_DISK='" '{print $2}' | cut -f 1 -d \') - for disk_usage in $dusage; do - usage=$((usage + disk_usage)) - done - d=$(grep "U_DISK_WEB='" $USER_DATA/user.conf | cut -f 2 -d \') - sed -i "s/U_DISK_WEB='$d'/U_DISK_WEB='$usage'/g" $USER_DATA/user.conf - u_usage=$((u_usage + usage)) - fi - - if [ -f "$USER_DATA/mail.conf" ]; then - usage=0 - dusage=$(grep 'U_DISK=' $USER_DATA/mail.conf |\ - awk -F "U_DISK='" '{print $2}' | cut -f 1 -d \') - for disk_usage in $dusage; do - usage=$((usage + disk_usage)) - done - d=$(grep "U_DISK_MAIL='" $USER_DATA/user.conf | cut -f 2 -d \') - sed -i "s/U_DISK_MAIL='$d'/U_DISK_MAIL='$usage'/g" $USER_DATA/user.conf - u_usage=$((u_usage + usage)) - fi - - if [ -f "$USER_DATA/db.conf" ]; then - usage=0 - dusage=$(grep 'U_DISK=' $USER_DATA/db.conf |\ - awk -F "U_DISK='" '{print $2}' | cut -f 1 -d \') - for disk_usage in $dusage; do - usage=$((usage + disk_usage)) - done - d=$(grep "U_DISK_DB='" $USER_DATA/user.conf | cut -f 2 -d \') - sed -i "s/U_DISK_DB='$d'/U_DISK_DB='$usage'/g" $USER_DATA/user.conf - u_usage=$((u_usage + usage)) - fi - usage=$(grep 'U_DIR_DISK=' $USER_DATA/user.conf | cut -f 2 -d "'") - u_usage=$((u_usage + usage)) - old=$(grep "U_DISK='" $USER_DATA/user.conf | cut -f 2 -d \') - sed -i "s/U_DISK='$old'/U_DISK='$u_usage'/g" $USER_DATA/user.conf -} - -# Recalculate U_BANDWIDTH value -recalc_user_bandwidth_usage() { - usage=0 - bandwidth_usage=$(grep 'U_BANDWIDTH=' $USER_DATA/web.conf |\ - awk -F "U_BANDWIDTH='" '{print $2}'|cut -f 1 -d \') - for bandwidth in $bandwidth_usage; do - usage=$((usage + bandwidth)) - done - old=$(grep "U_BANDWIDTH='" $USER_DATA/user.conf | cut -f 2 -d \') - sed -i "s/U_BANDWIDTH='$old'/U_BANDWIDTH='$usage'/g" $USER_DATA/user.conf -} - -# Get next cron job id -get_next_cronjob() { - if [ -z "$job" ]; then - curr_str=$(grep "JOB=" $USER_DATA/cron.conf|cut -f 2 -d \'|\ - sort -n|tail -n1) - job="$((curr_str +1))" - fi -} - -# Sort cron jobs by id -sort_cron_jobs() { - cat $USER_DATA/cron.conf |sort -n -k 2 -t \' > $USER_DATA/cron.tmp - mv -f $USER_DATA/cron.tmp $USER_DATA/cron.conf -} - -# Sync cronjobs with system cron -sync_cron_jobs() { - source $USER_DATA/user.conf - rm -f /var/spool/cron/$user - if [ "$CRON_REPORTS" = 'yes' ]; then - echo "MAILTO=$CONTACT" > /var/spool/cron/$user - fi - while read line; do - eval $line - if [ "$SUSPENDED" = 'no' ]; then - echo "$MIN $HOUR $DAY $MONTH $WDAY $CMD" |\ - sed -e "s/%quote%/'/g" -e "s/%dots%/:/g" \ - >> /var/spool/cron/$user - fi - done < $USER_DATA/cron.conf -} - - -### Format Validators ### -# Shell -validate_format_shell() { - if [ -z "$(grep -w $1 /etc/shells)" ]; then - echo "Error: shell $1 is not valid" - log_event "$E_INVALID" "$EVENT" - exit $E_INVALID - fi -} - -# Password -validate_format_password() { - if [ "${#1}" -lt '6' ]; then - echo "Error: password is too short" - log_event "$E_INVALID" "$EVENT" - exit $E_INVALID - fi -} - -# Integer -validate_format_int() { - if ! [[ "$1" =~ ^[0-9]+$ ]] ; then - echo "Error: int $1 is not valid" - log_event "$E_INVALID" "$EVENT" - exit $E_INVALID - fi -} - -# Boolean -validate_format_boolean() { - if [ "$1" != 'yes' ] && [ "$1" != 'no' ]; then - echo "Error: $2 $1 is not valid" - log_event "$E_INVALID" "$EVENT" - exit $E_INVALID - fi -} - -# Network interface -validate_format_interface() { - netdevices=$(cat /proc/net/dev | grep : | cut -f 1 -d : | tr -d ' ') - if [ -z $(echo "$netdevices"| grep -x $1) ]; then - echo "Error: intreface $1 is not valid" - log_event "$E_INVALID" "$EVENT" - exit $E_INVALID - fi -} - -# IP address -validate_format_ip() { - valid_octets=0 - for octet in ${1//./ }; do - if [[ $octet =~ ^[0-9]{1,3}$ ]] && [[ $octet -le 255 ]]; then - ((++valid_octets)) - fi - done - if [ "$valid_octets" -lt 4 ]; then - echo "Error: ip $1 is not valid" - log_event "$E_INVALID" "$EVENT" - exit $E_INVALID - fi -} - -# IP address status -validate_format_ip_status() { - if [ -z "$(echo shared,dedicated | grep -w $1 )" ]; then - echo "Error: ip_status $1 is not valid" - log_event "$E_INVALID" "$EVENT" - exit $E_INVALID - fi -} - -# Email address -validate_format_email() { - local_part=$(echo $1 | cut -s -f1 -d\@) - remote_host=$(echo $1 | cut -s -f2 -d\@) - mx_failed=1 - if [ ! -z "$remote_host" ] && [ ! -z "$local_part" ]; then - /usr/bin/host -t mx "$remote_host" &> /dev/null - mx_failed="$?" - fi - if [ "$mx_failed" -eq 1 ]; then - echo "Error: email $1 is not valid" - log_event "$E_INVALID" "$EVENT" - exit $E_INVALID - fi -} - -# Username -validate_format_username() { - if ! [[ "$1" =~ ^[a-zA-Z0-9]+([\.|_][a-zA-Z0-9]+)?$ ]]; then - echo "Error: $2 $1 is not valid" - log_event "$E_INVALID" "$EVENT" - exit $E_INVALID - fi - if [[ "${#1}" -gt 28 ]]; then - echo "Error: $2 $1 is not valid" - log_event "$E_INVALID" "$EVENT" - exit $E_INVALID - fi -} - -# Domain -validate_format_domain() { - exclude="[!|@|#|$|^|&|*|(|)|+|=|{|}|:|,|<|>|?|_|/|\|\"|'|;|%|\`| ]" - if [[ "$1" =~ $exclude ]] || [[ "$1" =~ "^[0-9]+$" ]]; then - echo "Error: domain $1 is not valid" - log_event "$E_INVALID" "$EVENT" - exit $E_INVALID - fi -} - -# Domain alias -validate_format_domain_alias() { - exclude="[!|@|#|$|^|&|(|)|+|=|{|}|:|,|<|>|?|_|/|\|\"|'|;|%|\`| ]" - if [[ "$1" =~ $exclude ]] || [[ "$1" =~ "^[0-9]+$" ]]; then - echo "Error: domain alias $1 is not valid" - log_event "$E_INVALID" "$EVENT" - exit $E_INVALID - fi -} - -# Database -validate_format_database() { - exclude="[!|@|#|$|^|&|*|(|)|+|=|{|}|:|,|.|<|>|?|/|\|\"|'|;|%|\`| ]" - if [[ "$1" =~ $exclude ]] || [ 17 -le ${#1} ]; then - echo "Error: $2 $1 is not valid" - log_event "$E_INVALID" "$EVENT" - exit $E_INVALID - fi -} - -# DNS type -validate_format_dns_type() { - known_dnstype='A,AAAA,NS,CNAME,MX,TXT,SRV,DNSKEY,KEY,IPSECKEY,PTR,SPF' - if [ -z "$(echo $known_dnstype | grep -w $1)" ]; then - echo "Error: dnstype $1 is not valid" - log_event "$E_INVALID" "$EVENT" - exit $E_INVALID - fi -} - -# DKIM key size -validate_format_key_size() { - known_size='128,256,512,768,1024,2048' - if [ -z "$(echo $known_size | grep -w $1)" ]; then - echo "Error: key_size $1 is not valid" - log_event "$E_INVALID" "$EVENT" - exit $E_INVALID - fi -} - -# Minute / Hour / Day / Month / Day of Week -validate_format_mhdmw() { - limit=60 - check_format='' - if [ "$2" = 'day' ]; then - limit=31 - fi - if [ "$2" = 'month' ]; then - limit=12 - fi - if [ "$2" = 'wday' ]; then - limit=7 - fi - if [ "$1" = '*' ]; then - check_format='ok' - fi - if [[ "$1" =~ ^[\*]+[/]+[0-9] ]]; then - if [ "$(echo $1 |cut -f 2 -d /)" -lt $limit ]; then - check_format='ok' - fi - fi - if [[ "$1" =~ ^[0-9]+$ ]] && [ "$1" -lt $limit ]; then - check_format='ok' - fi - if [ "$check_format" != 'ok' ]; then - echo "Error: $2 $1 is not valid" - log_event "$E_INVALID" "$EVENT" - exit $E_INVALID - fi -} - -# Nginx static extention or DNS record -validate_format_common() { - exclude="[!|#|$|^|&|(|)|+|=|{|}|:|<|>|?|/|\|\"|'|;|%|\`| ]" - if [[ "$1" =~ $exclude ]] || [ 200 -le ${#1} ]; then - echo "Error: $2 $1 is not valid" - log_event "$E_INVALID" "$EVENT" - exit $E_INVALID - fi -} - -# DNS record value -validate_format_dvalue() { - record_types="$(echo A,AAAA,NS,CNAME | grep -w "$rtype")" - if [[ "$1" =~ [\ ] ]] && [ ! -z "$record_types" ]; then - echo "Error: dvalue $1 is not valid" - log_event "$E_INVALID" "$EVENT" - exit $E_INVALID - fi - if [ "$rtype" = 'A' ]; then - validate_format_ip "$1" - fi - if [ "$rtype" = 'NS' ]; then - validate_format_domain "$1" - fi - if [ "$rtype" = 'MX' ]; then - validate_format_domain "$1" - validate_format_int "$priority" - fi - -} - -# Date -validate_format_date() { - if ! [[ "$1" =~ ^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$ ]]; then - echo "Error: date $1 is not valid" - log_event "$E_INVALID" "$EVENT" - exit $E_INVALID - fi -} - -# Autoreply -validate_format_autoreply() { - exclude="[$|\`]" - if [[ "$1" =~ $exclude ]] || [ 10240 -le ${#1} ]; then - echo "Error: autoreply is not valid" - log_event "$E_INVALID" "$EVENT" - exit $E_INVALID - fi -} - -# Format validation controller -validate_format(){ - for arg_name in $*; do - eval arg=\$$arg_name - if [ -z "$arg" ]; then - echo "Error: argument $arg_name is not valid (empty)" - log_event "$E_INVALID" "$EVENT" - exit $E_INVALID - fi - - case $arg_name in - account) validate_format_username "$arg" "$arg_name" ;; - antispam) validate_format_boolean "$arg" 'antispam' ;; - antivirus) validate_format_boolean "$arg" 'antivirus' ;; - autoreply) validate_format_autoreply "$arg" ;; - backup) validate_format_date "$arg" ;; - charset) validate_format_username "$arg" "$arg_name" ;; - charsets) validate_format_common "$arg" 'charsets' ;; - database) validate_format_database "$arg" 'database';; - day) validate_format_mhdmw "$arg" $arg_name ;; - dbpass) validate_format_password "$arg" ;; - dbuser) validate_format_database "$arg" 'db_user';; - dkim) validate_format_boolean "$arg" 'dkim' ;; - dkim_size) validate_format_key_size "$arg" ;; - domain) validate_format_domain "$arg" ;; - dom_alias) validate_format_domain_alias "$arg" ;; - dvalue) validate_format_dvalue "$arg";; - email) validate_format_email "$arg" ;; - exp) validate_format_date "$arg" ;; - extentions) validate_format_common "$arg" 'extentions' ;; - fname) validate_format_username "$arg" "$arg_name" ;; - forward) validate_format_email "$arg" ;; - ftp_password) validate_format_password "$arg" ;; - ftp_user) validate_format_username "$arg" "$arg_name" ;; - host) validate_format_domain "$arg" "$arg_name" ;; - hour) validate_format_mhdmw "$arg" $arg_name ;; - id) validate_format_int "$arg" ;; - interface) validate_format_interface "$arg" ;; - ip) validate_format_ip "$arg" ;; - ip_name) validate_format_domain "$arg" ;; - ip_status) validate_format_ip_status "$arg" ;; - job) validate_format_int "$arg" ;; - key) validate_format_username "$arg" "$arg_name" ;; - lname) validate_format_username "$arg" "$arg_name" ;; - malias) validate_format_username "$arg" "$arg_name" ;; - mask) validate_format_ip "$arg" ;; - max_db) validate_format_int "$arg" ;; - min) validate_format_mhdmw "$arg" $arg_name ;; - month) validate_format_mhdmw "$arg" $arg_name ;; - ns1) validate_format_domain "$arg" ;; - ns2) validate_format_domain "$arg" ;; - ns3) validate_format_domain "$arg" ;; - ns4) validate_format_domain "$arg" ;; - package) validate_format_username "$arg" "$arg_name" ;; - password) validate_format_password "$arg" ;; - port) validate_format_int "$arg" ;; - quota) validate_format_int "$arg" ;; - restart) validate_format_boolean "$arg" 'restart' ;; - record) validate_format_common "$arg" 'record';; - rtype) validate_format_dns_type "$arg" ;; - shell) validate_format_shell "$arg" ;; - soa) validate_format_domain "$arg" ;; - stats_pass) validate_format_password "$arg" ;; - stats_user) validate_format_username "$arg" "$arg_name" ;; - template) validate_format_username "$arg" "$arg_name" ;; - ttl) validate_format_int "$arg" ;; - user) validate_format_username "$arg" "$arg_name" ;; - wday) validate_format_mhdmw "$arg" $arg_name ;; - esac - done -} +# Internal variables +DATE=$(date +%F) +TIME=$(date +%T) +SCRIPT=$(basename $0) +A1=$1 +A2=$2 +A3=$3 +A4=$4 +A5=$5 +A6=$6 +A7=$7 +A8=$8 +A9=$9 +EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'" +EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'" +HOMEDIR='/home' +BACKUP='/backup' +BACKUP_GZIP=5 +BACKUP_DISK_LIMIT=95 +BACKUP_LA_LIMIT=5 +RRD_STEP=300 +RRD_IFACE_EXCLUDE=lo + +BIN=$VESTA/bin +USER_DATA=$VESTA/data/users/$user +WEBTPL=$VESTA/data/templates/web +DNSTPL=$VESTA/data/templates/dns +RRD=$VESTA/web/rrd + +# Return codes +OK=0 +E_ARGS=1 +E_INVALID=2 +E_NOTEXIST=3 +E_EXISTS=4 +E_SUSPENDED=5 +E_UNSUSPENDED=6 +E_INUSE=7 +E_LIMIT=8 +E_PASSWORD=9 +E_FORBIDEN=10 +E_DISABLED=11 +E_PARSING=12 +E_DISK=13 +E_LA=14 +E_FTP=15 +E_SSH=16 +E_DB=17 +E_RRD=18 +E_UPDATE=19 +E_RESTART=20 + +# Log event function +log_event() { + echo "RC='$1' $2" >> $VESTA/log/system.log +} + +# Log user history +log_history() { + cmd=$1 + undo=${2-no} + log_user=${3-$user} + log=$VESTA/data/users/$log_user/history.log + + touch $log + if [ '99' -lt "$(wc -l $log |cut -f 1 -d ' ')" ]; then + tail -n 99 $log > $log.moved + mv -f $log.moved $log + chmod 660 $log + fi + + curr_str=$(grep "ID=" $log | cut -f 2 -d \' | sort -n | tail -n1) + id="$((curr_str +1))" + echo "ID='$id' DATE='$DATE' TIME='$TIME' CMD='$cmd' UNDO='$undo'" >> $log +} + +# Argument list checker +check_args() { + if [ "$1" -gt "$2" ]; then + echo "Error: not enought arguments" + echo "Usage: $SCRIPT $3" + log_event "$E_ARGS" "$EVENT" + exit $E_ARGS + fi +} + +# Subsystem checker +is_system_enabled() { + if [ -z "$1" ] || [ "$1" = no ]; then + echo "Error: subsystem disabled" + log_event "$E_DISABLED" "$EVENT" + exit $E_DISABLED + fi +} + +# User package check +is_package_full() { + case "$1" in + WEB_DOMAINS) used=$(wc -l $USER_DATA/web.conf|cut -f1 -d \ );; + WEB_ALIASES) used=$(grep "DOMAIN='$domain'" $USER_DATA/web.conf |\ + awk -F "ALIAS='" '{print $2}' | cut -f 1 -d \' | tr ',' '\n' |\ + wc -l );; + DNS_DOMAINS) used=$(wc -l $USER_DATA/dns.conf |cut -f1 -d \ );; + DNS_RECORDS) used=$(wc -l $USER_DATA/dns/$domain.conf |cut -f1 -d \ );; + MAIL_DOMAINS) used=$(wc -l $USER_DATA/mail.conf |cut -f1 -d \ );; + MAIL_ACCOUNTS) used=$(wc -l $USER_DATA/mail/$domain.conf |\ + cut -f1 -d \ );; + DATABASES) used=$(wc -l $USER_DATA/db.conf |cut -f1 -d \ );; + CRON_JOBS) used=$(wc -l $USER_DATA/cron.conf |cut -f1 -d \ );; + esac + limit=$(grep "^$1=" $USER_DATA/user.conf | cut -f 2 -d \' ) + if [ "$used" -ge "$limit" ]; then + echo "Error: Limit reached / Upgrade package" + log_event "$E_LIMIT" "$EVENT" + exit $E_LIMIT + fi +} + +# Random password generator +gen_password() { + matrix='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' + lenght=10 + while [ ${n:=1} -le $lenght ]; do + pass="$pass${matrix:$(($RANDOM%${#matrix})):1}" + let n+=1 + done + echo "$pass" +} + +# Package existance check +is_package_valid() { + if [ -z "$1" ]; then + pkg_dir="$VESTA/data/packages" + fi + if [ ! -e "$pkg_dir/$package.pkg" ]; then + echo "Error: package $package not exist" + log_event "$E_NOTEXIST $EVENT" + exit $E_NOTEXIST + fi +} + +# Validate system type +is_type_valid() { + if [ -z "$(echo $1 | grep -w $2)" ]; then + echo "Error: $2 is unknown type" + log_event "$E_INVALID" "$EVENT" + exit $E_INVALID + fi +} + +# Check user backup settings +is_backup_enabled() { + BACKUPS=$(grep "^BACKUPS=" $USER_DATA/user.conf | cut -f2 -d \') + if [ -z "$BACKUPS" ] || [[ "$BACKUPS" -le '0' ]]; then + echo "Error: user backup disabled" + log_event "$E_DISABLED" "$EVENT" + exit $E_DISABLED + fi +} + +# Check if object is free and can be created +is_object_free() { + if [ $2 = 'USER' ]; then + if [ -d "$USER_DATA" ]; then + object="OK" + fi + else + object=$(grep "$2='$3'" $USER_DATA/$1.conf) + fi + if [ ! -z "$object" ]; then + echo "Error: $2 with value $3 exists" + log_event "$E_EXISTS" "$EVENT" + exit $E_EXISTS + fi +} + +# Check if object exists and can be used +is_object_valid() { + if [ $2 = 'USER' ]; then + if [ -d "$VESTA/data/users/$user" ]; then + sobject="OK" + fi + else + if [ $2 = 'DBHOST' ]; then + sobject=$(grep "HOST='$host'" $VESTA/conf/$type.conf) + else + sobject=$(grep "$2='$3'" $VESTA/data/users/$user/$1.conf) + fi + fi + if [ -z "$sobject" ]; then + echo "Error: $3 not exist" + log_event "$E_NOTEXIST" "$EVENT" + exit $E_NOTEXIST + fi +} + +# Check if object is supended +is_object_suspended() { + if [ $2 = 'USER' ]; then + spnd=$(cat $USER_DATA/$1.conf|grep "SUSPENDED='yes'") + else + spnd=$(grep "$2='$3'" $USER_DATA/$1.conf|grep "SUSPENDED='yes'") + fi + if [ -z "$spnd" ]; then + echo "Error: $1 $3 is not suspended" + log_event "$E_SUSPENDED" "$EVENT" + exit $E_SUSPENDED + fi +} + +# Check if object is unsupended +is_object_unsuspended() { + if [ $2 = 'USER' ]; then + spnd=$(cat $USER_DATA/$1.conf|grep "SUSPENDED='yes'") + else + spnd=$(grep "$2='$3'" $USER_DATA/$1.conf|grep "SUSPENDED='yes'") + fi + if [ ! -z "$spnd" ]; then + echo "Error: $1 $3 is already suspended" + log_event "$E_UNSUSPENDED" "$EVENT" + exit $E_UNSUSPENDED + fi +} + +# Check if object value is empty +is_object_value_empty() { + str=$(grep "$2='$3'" $USER_DATA/$1.conf) + eval $str + eval value=$4 + if [ ! -z "$value" ] && [ "$value" != 'no' ]; then + echo "Error: ${4//$}=$value (not empty)" + log_event "$E_EXISTS" "$EVENT" + exit $E_EXISTS + fi +} + +# Check if object value is empty +is_object_value_exist() { + str=$(grep "$2='$3'" $USER_DATA/$1.conf) + eval $str + eval value=$4 + if [ -z "$value" ] || [ "$value" = 'no' ]; then + echo "Error: ${4//$}=$value (not exist)" + log_event "$E_NOTEXIST" "$EVENT" + exit $E_NOTEXIST + fi +} + +# Get object value +get_object_value() { + object=$(grep "$2='$3'" $USER_DATA/$1.conf) + eval "$object" + eval echo $4 +} + +# Update object value +update_object_value() { + row=$(grep -n "$2='$3'" $USER_DATA/$1.conf) + lnr=$(echo $row | cut -f 1 -d ':') + object=$(echo $row | sed -e "s/^$lnr://") + eval "$object" + eval old="$4" + old=$(echo "$old" | sed -e 's/\\/\\\\/g' -e 's/&/\\&/g' -e 's/\//\\\//g') + new=$(echo "$5" | sed -e 's/\\/\\\\/g' -e 's/&/\\&/g' -e 's/\//\\\//g') + sed -i "$lnr s/${4//$/}='${old//\*/\\*}'/${4//$/}='${new//\*/\\*}'/g" \ + $USER_DATA/$1.conf +} + +# Search objects +search_objects() { + OLD_IFS="$IFS" + IFS=$'\n' + for line in $(grep $2=\'$3\' $USER_DATA/$1.conf); do + eval $line + eval echo \$$4 + done + IFS="$OLD_IFS" +} + +# Get user value +get_user_value() { + grep "^${1//$/}=" $USER_DATA/user.conf| cut -f 2 -d \' +} + +# Update user value in user.conf +update_user_value() { + key="${2//$}" + lnr=$(grep -n "^$key='" $VESTA/data/users/$1/user.conf |cut -f 1 -d ':') + if [ ! -z "$lnr" ]; then + sed -i "$lnr d" $VESTA/data/users/$1/user.conf + sed -i "$lnr i\\$key='${3}'" $VESTA/data/users/$1/user.conf + fi +} + +# Increase user counter +increase_user_value() { + key="${2//$}" + factor="${3-1}" + conf="$VESTA/data/users/$1/user.conf" + old=$(grep "$key=" $conf | cut -f 2 -d \') + if [ -z "$old" ]; then + old=0 + fi + new=$((old + factor)) + sed -i "s/$key='$old'/$key='$new'/g" $conf +} + +# Decrease user counter +decrease_user_value() { + key="${2//$}" + factor="${3-1}" + conf="$VESTA/data/users/$1/user.conf" + old=$(grep "$key=" $conf | cut -f 2 -d \') + if [ -z "$old" ]; then + old=0 + fi + if [ "$old" -le 1 ]; then + new=0 + else + new=$((old - factor)) + fi + sed -i "s/$key='$old'/$key='$new'/g" $conf +} + +# Json listing function +json_list() { + echo '{' + fileds_count=$(echo $fields| wc -w ) + #for line in $(cat $conf); do + while read line; do + eval $line + if [ -n "$data_output" ]; then + echo -e ' },' + fi + i=1 + for field in $fields; do + eval value=$field + if [ $i -eq 1 ]; then + (( ++i)) + echo -e "\t\"$value\": {" + else + if [ $i -lt $fileds_count ]; then + (( ++i)) + echo -e "\t\t\"${field//$/}\": \"$value\"," + else + echo -e "\t\t\"${field//$/}\": \"$value\"" + data_output=yes + fi + fi + done + done < $conf + + if [ "$data_output" = 'yes' ]; then + echo -e ' }' + fi + echo -e '}' +} + +# Shell listing function +shell_list() { + if [ -z "$nohead" ] ; then + echo "${fields//$/}" + for a in $fields; do + echo -e "------ \c" + done + echo + fi + while read line ; do + eval $line + for field in $fields; do + eval value=$field + if [ -z "$value" ]; then + value='NULL' + fi + echo -n "$value " + done + echo + done < $conf +} + +# Recalculate U_DISK value +recalc_user_disk_usage() { + u_usage=0 + if [ -f "$USER_DATA/web.conf" ]; then + usage=0 + dusage=$(grep 'U_DISK=' $USER_DATA/web.conf |\ + awk -F "U_DISK='" '{print $2}' | cut -f 1 -d \') + for disk_usage in $dusage; do + usage=$((usage + disk_usage)) + done + d=$(grep "U_DISK_WEB='" $USER_DATA/user.conf | cut -f 2 -d \') + sed -i "s/U_DISK_WEB='$d'/U_DISK_WEB='$usage'/g" $USER_DATA/user.conf + u_usage=$((u_usage + usage)) + fi + + if [ -f "$USER_DATA/mail.conf" ]; then + usage=0 + dusage=$(grep 'U_DISK=' $USER_DATA/mail.conf |\ + awk -F "U_DISK='" '{print $2}' | cut -f 1 -d \') + for disk_usage in $dusage; do + usage=$((usage + disk_usage)) + done + d=$(grep "U_DISK_MAIL='" $USER_DATA/user.conf | cut -f 2 -d \') + sed -i "s/U_DISK_MAIL='$d'/U_DISK_MAIL='$usage'/g" $USER_DATA/user.conf + u_usage=$((u_usage + usage)) + fi + + if [ -f "$USER_DATA/db.conf" ]; then + usage=0 + dusage=$(grep 'U_DISK=' $USER_DATA/db.conf |\ + awk -F "U_DISK='" '{print $2}' | cut -f 1 -d \') + for disk_usage in $dusage; do + usage=$((usage + disk_usage)) + done + d=$(grep "U_DISK_DB='" $USER_DATA/user.conf | cut -f 2 -d \') + sed -i "s/U_DISK_DB='$d'/U_DISK_DB='$usage'/g" $USER_DATA/user.conf + u_usage=$((u_usage + usage)) + fi + usage=$(grep 'U_DIR_DISK=' $USER_DATA/user.conf | cut -f 2 -d "'") + u_usage=$((u_usage + usage)) + old=$(grep "U_DISK='" $USER_DATA/user.conf | cut -f 2 -d \') + sed -i "s/U_DISK='$old'/U_DISK='$u_usage'/g" $USER_DATA/user.conf +} + +# Recalculate U_BANDWIDTH value +recalc_user_bandwidth_usage() { + usage=0 + bandwidth_usage=$(grep 'U_BANDWIDTH=' $USER_DATA/web.conf |\ + awk -F "U_BANDWIDTH='" '{print $2}'|cut -f 1 -d \') + for bandwidth in $bandwidth_usage; do + usage=$((usage + bandwidth)) + done + old=$(grep "U_BANDWIDTH='" $USER_DATA/user.conf | cut -f 2 -d \') + sed -i "s/U_BANDWIDTH='$old'/U_BANDWIDTH='$usage'/g" $USER_DATA/user.conf +} + +# Get next cron job id +get_next_cronjob() { + if [ -z "$job" ]; then + curr_str=$(grep "JOB=" $USER_DATA/cron.conf|cut -f 2 -d \'|\ + sort -n|tail -n1) + job="$((curr_str +1))" + fi +} + +# Sort cron jobs by id +sort_cron_jobs() { + cat $USER_DATA/cron.conf |sort -n -k 2 -t \' > $USER_DATA/cron.tmp + mv -f $USER_DATA/cron.tmp $USER_DATA/cron.conf +} + +# Sync cronjobs with system cron +sync_cron_jobs() { + source $USER_DATA/user.conf + rm -f /var/spool/cron/$user + if [ "$CRON_REPORTS" = 'yes' ]; then + echo "MAILTO=$CONTACT" > /var/spool/cron/$user + fi + while read line; do + eval $line + if [ "$SUSPENDED" = 'no' ]; then + echo "$MIN $HOUR $DAY $MONTH $WDAY $CMD" |\ + sed -e "s/%quote%/'/g" -e "s/%dots%/:/g" \ + >> /var/spool/cron/$user + fi + done < $USER_DATA/cron.conf +} + + +### Format Validators ### +# Shell +validate_format_shell() { + if [ -z "$(grep -w $1 /etc/shells)" ]; then + echo "Error: shell $1 is not valid" + log_event "$E_INVALID" "$EVENT" + exit $E_INVALID + fi +} + +# Password +validate_format_password() { + if [ "${#1}" -lt '6' ]; then + echo "Error: password is too short" + log_event "$E_INVALID" "$EVENT" + exit $E_INVALID + fi +} + +# Integer +validate_format_int() { + if ! [[ "$1" =~ ^[0-9]+$ ]] ; then + echo "Error: int $1 is not valid" + log_event "$E_INVALID" "$EVENT" + exit $E_INVALID + fi +} + +# Boolean +validate_format_boolean() { + if [ "$1" != 'yes' ] && [ "$1" != 'no' ]; then + echo "Error: $2 $1 is not valid" + log_event "$E_INVALID" "$EVENT" + exit $E_INVALID + fi +} + +# Network interface +validate_format_interface() { + netdevices=$(cat /proc/net/dev | grep : | cut -f 1 -d : | tr -d ' ') + if [ -z $(echo "$netdevices"| grep -x $1) ]; then + echo "Error: intreface $1 is not valid" + log_event "$E_INVALID" "$EVENT" + exit $E_INVALID + fi +} + +# IP address +validate_format_ip() { + valid_octets=0 + for octet in ${1//./ }; do + if [[ $octet =~ ^[0-9]{1,3}$ ]] && [[ $octet -le 255 ]]; then + ((++valid_octets)) + fi + done + if [ "$valid_octets" -lt 4 ]; then + echo "Error: ip $1 is not valid" + log_event "$E_INVALID" "$EVENT" + exit $E_INVALID + fi +} + +# IP address status +validate_format_ip_status() { + if [ -z "$(echo shared,dedicated | grep -w $1 )" ]; then + echo "Error: ip_status $1 is not valid" + log_event "$E_INVALID" "$EVENT" + exit $E_INVALID + fi +} + +# Email address +validate_format_email() { + local_part=$(echo $1 | cut -s -f1 -d\@) + remote_host=$(echo $1 | cut -s -f2 -d\@) + mx_failed=1 + if [ ! -z "$remote_host" ] && [ ! -z "$local_part" ]; then + /usr/bin/host -t mx "$remote_host" &> /dev/null + mx_failed="$?" + fi + if [ "$mx_failed" -eq 1 ]; then + echo "Error: email $1 is not valid" + log_event "$E_INVALID" "$EVENT" + exit $E_INVALID + fi +} + +# Username +validate_format_username() { + if ! [[ "$1" =~ ^[a-zA-Z0-9]+([\.|_|-][a-zA-Z0-9]+)?$ ]]; then + echo "Error: $2 $1 is not valid" + log_event "$E_INVALID" "$EVENT" + exit $E_INVALID + fi + if [[ "${#1}" -gt 28 ]]; then + echo "Error: $2 $1 is not valid" + log_event "$E_INVALID" "$EVENT" + exit $E_INVALID + fi +} + +# Domain +validate_format_domain() { + exclude="[!|@|#|$|^|&|*|(|)|+|=|{|}|:|,|<|>|?|_|/|\|\"|'|;|%|\`| ]" + if [[ "$1" =~ $exclude ]] || [[ "$1" =~ "^[0-9]+$" ]]; then + echo "Error: domain $1 is not valid" + log_event "$E_INVALID" "$EVENT" + exit $E_INVALID + fi +} + +# Domain alias +validate_format_domain_alias() { + exclude="[!|@|#|$|^|&|(|)|+|=|{|}|:|,|<|>|?|_|/|\|\"|'|;|%|\`| ]" + if [[ "$1" =~ $exclude ]] || [[ "$1" =~ "^[0-9]+$" ]]; then + echo "Error: domain alias $1 is not valid" + log_event "$E_INVALID" "$EVENT" + exit $E_INVALID + fi +} + +# Database +validate_format_database() { + exclude="[!|@|#|$|^|&|*|(|)|+|=|{|}|:|,|.|<|>|?|/|\|\"|'|;|%|\`| ]" + if [[ "$1" =~ $exclude ]] || [ 17 -le ${#1} ]; then + echo "Error: $2 $1 is not valid" + log_event "$E_INVALID" "$EVENT" + exit $E_INVALID + fi +} + +# DNS type +validate_format_dns_type() { + known_dnstype='A,AAAA,NS,CNAME,MX,TXT,SRV,DNSKEY,KEY,IPSECKEY,PTR,SPF' + if [ -z "$(echo $known_dnstype | grep -w $1)" ]; then + echo "Error: dnstype $1 is not valid" + log_event "$E_INVALID" "$EVENT" + exit $E_INVALID + fi +} + +# DKIM key size +validate_format_key_size() { + known_size='128,256,512,768,1024,2048' + if [ -z "$(echo $known_size | grep -w $1)" ]; then + echo "Error: key_size $1 is not valid" + log_event "$E_INVALID" "$EVENT" + exit $E_INVALID + fi +} + +# Minute / Hour / Day / Month / Day of Week +validate_format_mhdmw() { + limit=60 + check_format='' + if [ "$2" = 'day' ]; then + limit=31 + fi + if [ "$2" = 'month' ]; then + limit=12 + fi + if [ "$2" = 'wday' ]; then + limit=7 + fi + if [ "$1" = '*' ]; then + check_format='ok' + fi + if [[ "$1" =~ ^[\*]+[/]+[0-9] ]]; then + if [ "$(echo $1 |cut -f 2 -d /)" -lt $limit ]; then + check_format='ok' + fi + fi + if [[ "$1" =~ ^[0-9]+$ ]] && [ "$1" -lt $limit ]; then + check_format='ok' + fi + if [ "$check_format" != 'ok' ]; then + echo "Error: $2 $1 is not valid" + log_event "$E_INVALID" "$EVENT" + exit $E_INVALID + fi +} + +# Nginx static extention or DNS record +validate_format_common() { + exclude="[!|#|$|^|&|(|)|+|=|{|}|:|<|>|?|/|\|\"|'|;|%|\`| ]" + if [[ "$1" =~ $exclude ]] || [ 200 -le ${#1} ]; then + echo "Error: $2 $1 is not valid" + log_event "$E_INVALID" "$EVENT" + exit $E_INVALID + fi +} + +# DNS record value +validate_format_dvalue() { + record_types="$(echo A,AAAA,NS,CNAME | grep -w "$rtype")" + if [[ "$1" =~ [\ ] ]] && [ ! -z "$record_types" ]; then + echo "Error: dvalue $1 is not valid" + log_event "$E_INVALID" "$EVENT" + exit $E_INVALID + fi + if [ "$rtype" = 'A' ]; then + validate_format_ip "$1" + fi + if [ "$rtype" = 'NS' ]; then + validate_format_domain "$1" + fi + if [ "$rtype" = 'MX' ]; then + validate_format_domain "$1" + validate_format_int "$priority" + fi + +} + +# Date +validate_format_date() { + if ! [[ "$1" =~ ^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$ ]]; then + echo "Error: date $1 is not valid" + log_event "$E_INVALID" "$EVENT" + exit $E_INVALID + fi +} + +# Autoreply +validate_format_autoreply() { + exclude="[$|\`]" + if [[ "$1" =~ $exclude ]] || [ 10240 -le ${#1} ]; then + echo "Error: autoreply is not valid" + log_event "$E_INVALID" "$EVENT" + exit $E_INVALID + fi +} + +# Format validation controller +validate_format(){ + for arg_name in $*; do + eval arg=\$$arg_name + if [ -z "$arg" ]; then + echo "Error: argument $arg_name is not valid (empty)" + log_event "$E_INVALID" "$EVENT" + exit $E_INVALID + fi + + case $arg_name in + account) validate_format_username "$arg" "$arg_name" ;; + antispam) validate_format_boolean "$arg" 'antispam' ;; + antivirus) validate_format_boolean "$arg" 'antivirus' ;; + autoreply) validate_format_autoreply "$arg" ;; + backup) validate_format_date "$arg" ;; + charset) validate_format_username "$arg" "$arg_name" ;; + charsets) validate_format_common "$arg" 'charsets' ;; + database) validate_format_database "$arg" 'database';; + day) validate_format_mhdmw "$arg" $arg_name ;; + dbpass) validate_format_password "$arg" ;; + dbuser) validate_format_database "$arg" 'db_user';; + dkim) validate_format_boolean "$arg" 'dkim' ;; + dkim_size) validate_format_key_size "$arg" ;; + domain) validate_format_domain "$arg" ;; + dom_alias) validate_format_domain_alias "$arg" ;; + dvalue) validate_format_dvalue "$arg";; + email) validate_format_email "$arg" ;; + exp) validate_format_date "$arg" ;; + extentions) validate_format_common "$arg" 'extentions' ;; + fname) validate_format_username "$arg" "$arg_name" ;; + forward) validate_format_email "$arg" ;; + ftp_password) validate_format_password "$arg" ;; + ftp_user) validate_format_username "$arg" "$arg_name" ;; + host) validate_format_domain "$arg" "$arg_name" ;; + hour) validate_format_mhdmw "$arg" $arg_name ;; + id) validate_format_int "$arg" ;; + interface) validate_format_interface "$arg" ;; + ip) validate_format_ip "$arg" ;; + ip_name) validate_format_domain "$arg" ;; + ip_status) validate_format_ip_status "$arg" ;; + job) validate_format_int "$arg" ;; + key) validate_format_username "$arg" "$arg_name" ;; + lname) validate_format_username "$arg" "$arg_name" ;; + malias) validate_format_username "$arg" "$arg_name" ;; + mask) validate_format_ip "$arg" ;; + max_db) validate_format_int "$arg" ;; + min) validate_format_mhdmw "$arg" $arg_name ;; + month) validate_format_mhdmw "$arg" $arg_name ;; + ns1) validate_format_domain "$arg" ;; + ns2) validate_format_domain "$arg" ;; + ns3) validate_format_domain "$arg" ;; + ns4) validate_format_domain "$arg" ;; + package) validate_format_username "$arg" "$arg_name" ;; + password) validate_format_password "$arg" ;; + port) validate_format_int "$arg" ;; + quota) validate_format_int "$arg" ;; + restart) validate_format_boolean "$arg" 'restart' ;; + record) validate_format_common "$arg" 'record';; + rtype) validate_format_dns_type "$arg" ;; + shell) validate_format_shell "$arg" ;; + soa) validate_format_domain "$arg" ;; + stats_pass) validate_format_password "$arg" ;; + stats_user) validate_format_username "$arg" "$arg_name" ;; + template) validate_format_username "$arg" "$arg_name" ;; + ttl) validate_format_int "$arg" ;; + user) validate_format_username "$arg" "$arg_name" ;; + wday) validate_format_mhdmw "$arg" $arg_name ;; + esac + done +} diff --git a/install/0.9.7/rhel/exim.conf b/install/0.9.7/rhel/exim.conf index a97cc2495..b1790ac8f 100644 --- a/install/0.9.7/rhel/exim.conf +++ b/install/0.9.7/rhel/exim.conf @@ -1,340 +1,340 @@ -########################################################################## -SPAMASSASSIN = yes -SPAM_SCORE = 10 -CLAMD = yes -########################################################################## - -domainlist local_domains = dsearch;/etc/exim/domains/ -domainlist relay_to_domains = dsearch;/etc/exim/domains/ -hostlist relay_from_hosts = 127.0.0.1 -hostlist spammers = net-iplsearch;/etc/exim/spam-blocks.conf - -acl_smtp_connect = acl_check_spammers -acl_smtp_mail = acl_check_mail -acl_smtp_rcpt = acl_check_rcpt -acl_smtp_data = acl_check_data -acl_smtp_mime = acl_check_mime - -.ifdef SPAMASSASSIN -spamd_address = 127.0.0.1 783 -.endif - -.ifdef CLAMD -av_scanner = clamd: /var/run/clamav/clamd.sock -.endif - -tls_advertise_hosts = * -tls_certificate = /etc/pki/tls/certs/exim.pem -tls_privatekey = /etc/pki/tls/private/exim.pem - -daemon_smtp_ports = 25 : 465 : 587 : 2525 -tls_on_connect_ports = 465 -never_users = root -host_lookup = * -rfc1413_hosts = * -rfc1413_query_timeout = 5s -ignore_bounce_errors_after = 2d -timeout_frozen_after = 7d - -DKIM_DOMAIN = ${lc:${domain:$h_from:}} -DKIM_FILE = /etc/exim/domains/${lc:${domain:$h_from:}}/dkim.pem -DKIM_PRIVATE_KEY = ${if exists{DKIM_FILE}{DKIM_FILE}{0}} - - -########################################################################## -begin acl -########################################################################## -acl_check_spammers: - drop message = Your host in blacklist on this server. - log_message = Host in blacklist - hosts = +spammers - deny message = rejected because $sender_host_address is in a black list at $dnslist_domain\\n$dnslist_text - dnslists = ${readfile {/etc/exim/dnsbl.conf}{:}} - accept - -acl_check_mail: - deny - condition = ${if eq{$sender_helo_name}{}} - message = HELO required before MAIL - drop - condition = ${if isip{$sender_helo_name}} - message = Access denied - Invalid HELO name (See RFC2821 4.1.3) - drop message = Helo name contains a ip address (HELO was $sender_helo_name) and not is valid - condition = ${if match{$sender_helo_name}{\N((\d{1,3}[.-]\d{1,3}[.-]\d{1,3}[.-]\d{1,3})|([0-9a-f]{8})|([0-9A-F]{8}))\N}{yes}{no}} - condition = ${if match {${lookup dnsdb{>: defer_never,ptr=$sender_host_address}}\}{$sender_helo_name}{no}{yes}} - delay = 45s -# drop -# condition = ${if match{$sender_helo_name}{\N^\[\N}{no}{yes}} -# condition = ${if match{$sender_helo_name}{\N\.\N}{no}{yes}} -# message = Access denied - Invalid HELO name (See RFC2821 4.1.1.1) - drop - condition = ${if isip{$sender_helo_name}} - message = Access denied - Invalid HELO name (See RFC2821 4.1.3) - drop - condition = ${if match{$sender_helo_name}{\N\.$\N}} - message = Access denied - Invalid HELO name (See RFC2821 4.1.1.1) - drop message = "REJECTED - Bad HELO - Host impersonating [$sender_helo_name]" - condition = ${if match{$sender_helo_name}{$primary_hostname}} - drop condition = ${if eq{[$interface_address]}{$sender_helo_name}} - message = $interface_address is _my_ address - accept - - -acl_check_rcpt: - accept hosts = : - - deny message = Restricted characters in address - domains = +local_domains - local_parts = ^[.] : ^.*[@%!/|] - - deny message = Restricted characters in address - domains = !+local_domains - local_parts = ^[./|] : ^.*[@%!] : ^.*/\\.\\./ - - require verify = sender - - accept hosts = +relay_from_hosts - control = submission - - accept local_parts = postmaster - domains = +local_domains - - accept authenticated = * - control = submission/domain= - - require message = relay not permitted - domains = +local_domains : +relay_to_domains - - deny message = smtp auth requried - sender_domains = +local_domains - !authenticated = * - - require verify = recipient - -.ifdef CLAMD - warn set acl_m0 = no - warn condition = ${if exists {/etc/exim/domains/$domain/antivirus}{yes}{no}} - set acl_m0 = yes -.endif -.ifdef SPAMASSASSIN - warn set acl_m1 = no - warn condition = ${if exists {/etc/exim/domains/$domain/antispam}{yes}{no}} - set acl_m1 = yes -.endif - accept - - -acl_check_data: -.ifdef CLAMD - deny message = Message contains a virus ($malware_name) and has been rejected - malware = * - condition = ${if eq{$acl_m0}{yes}{yes}{no}} -.endif - -.ifdef SPAMASSASSIN - warn - !authenticated = * - hosts = !+relay_from_hosts - condition = ${if < {$message_size}{100K}} - condition = ${if eq{$acl_m1}{yes}{yes}{no}} - spam = nobody:true/defer_ok - add_header = X-Spam-Score: $spam_score_int - add_header = X-Spam-Bar: $spam_bar - add_header = X-Spam-Report: $spam_report - set acl_m2 = $spam_score_int - warn - condition = ${if !eq{$acl_m2}{} {yes}{no}} - condition = ${if >{$acl_m2}{SPAM_SCORE} {yes}{no}} - add_header = X-Spam-Status: Yes - message = SpamAssassin detected spam (from $sender_address to $recipients). -.endif - accept - - -acl_check_mime: - deny message = Blacklisted file extension detected - condition = ${if match {${lc:$mime_filename}}{\N(\.ade|\.adp|\.bat|\.chm|\.cmd|\.com|\.cpl|\.exe|\.hta|\.ins|\.isp|\.jse|\.lib|\.lnk|\.mde|\.msc|\.msp|\.mst|\.pif|\.scr|\.sct|\.shb|\.sys|\.vb|\.vbe|\.vbs|\.vxd|\.wsc|\.wsf|\.wsh)$\N}{1}{0}} - accept - -########################################################################## -begin authenticators -########################################################################## -dovecot_plain: - driver = dovecot - public_name = PLAIN - server_socket = /var/run/dovecot/auth-client - server_set_id = $auth1 - -dovecot_login: - driver = dovecot - public_name = LOGIN - server_socket = /var/run/dovecot/auth-client - server_set_id = $auth1 - -########################################################################## -begin routers -########################################################################## -dnslookup: - driver = dnslookup - domains = !+local_domains - transport = remote_smtp -# ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8 - no_more - -#system_aliases: -# domains = +local_domains -# driver = redirect -# allow_fail -# allow_defer -# data = ${lookup{$local_part}lsearch{/etc/aliases}} -# file_transport = address_file -# pipe_transport = address_pipe - -userforward: - driver = redirect - check_local_user - file = $home/.forward - allow_filter - no_verify - no_expn - check_ancestor - file_transport = address_file - pipe_transport = address_pipe - reply_transport = address_reply - -procmail: - driver = accept - check_local_user - require_files = ${local_part}:+${home}/.procmailrc:/usr/bin/procmail - transport = procmail - no_verify - -autoreplay: - driver = accept - require_files = /etc/exim/domains/$domain/autoreply.${local_part}.msg - condition = ${if exists{/etc/exim/domains/$domain/autoreply.${local_part}.msg}}{yes}{no}} - retry_use_local_part - transport = userautoreply - unseen - -aliases: - driver = redirect - headers_add = X-redirected: yes - data = ${extract{1}{:}{${lookup{$local_part@$domain}lsearch{/etc/exim/domains/$domain/aliases}}}} - require_files = /etc/exim/domains/$domain/aliases - redirect_router = dnslookup - pipe_transport = address_pipe - unseen - - -localuser_spam: - driver = accept - transport = local_spam_delivery - condition = ${if eq {${if match{$h_X-Spam-Status:}{\N^Yes\N}{yes}{no}}} {${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}{yes}{no_such_user}}}} - -localuser: - driver = accept - transport = local_delivery - condition = ${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}{true}{false}} - -catchall: - driver = redirect - headers_add = X-redirected: yes - require_files = /etc/exim/domains/$domain/aliases - data = ${extract{1}{:}{${lookup{*@$domain}lsearch{/etc/exim/domains/$domain/aliases}}}} - file_transport = local_delivery - redirect_router = dnslookup - -terminate_alias: - driver = accept - transport = devnull - condition = ${lookup{$local_part@$domain}lsearch{/etc/exim/domains/$domain/aliases}{true}{false}} - - -########################################################################## -begin transports -########################################################################## -remote_smtp: - driver = smtp - helo_data = $sender_address_domain - dkim_domain = DKIM_DOMAIN - dkim_selector = mail - dkim_private_key = DKIM_PRIVATE_KEY - dkim_canon = relaxed - dkim_strict = 0 - - -procmail: - driver = pipe - command = "/usr/bin/procmail -d $local_part" - return_path_add - delivery_date_add - envelope_to_add - user = $local_part - initgroups - return_output - -local_delivery: - driver = appendfile - maildir_format - maildir_use_size_file - user = ${extract{2}{:}{${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}}}} - group = mail - create_directory - directory_mode = 770 - mode = 660 - use_lockfile = no - delivery_date_add - envelope_to_add - return_path_add - directory = "${extract{5}{:}{${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}}}}/mail/$domain/$local_part" - quota = ${extract{6}{:}{${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}}}}M - quota_warn_threshold = 75% - -local_spam_delivery: - driver = appendfile - maildir_format - maildir_use_size_file - user = ${extract{2}{:}{${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}}}} - group = mail - create_directory - directory_mode = 770 - mode = 660 - use_lockfile = no - delivery_date_add - envelope_to_add - return_path_add - directory = "${extract{5}{:}{${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}}}}/mail/$domain/$local_part/.spam" - quota = ${extract{6}{:}{${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}}}}M - quota_directory = "${extract{5}{:}{${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}}}}/mail/$domain/$local_part" - quota_warn_threshold = 75% - -address_pipe: - driver = pipe - return_output - -address_file: - driver = appendfile - delivery_date_add - envelope_to_add - return_path_add - -address_reply: - driver = autoreply - -userautoreply: - driver = autoreply - file = /etc/exim/domains/$domain/autoreply.${local_part}.msg - from = "${local_part}@${domain}" - subject = "${if def:h_Subject: {Autoreply: ${quote:${escape:$h_Subject:}}} {Autoreply Message}}" - to = "${sender_address}" - -devnull: - driver = appendfile - file = /dev/null - -########################################################################## -begin retry -* * F,2h,15m; G,16h,1h,1.5; F,4d,6h -########################################################################## -begin rewrite +########################################################################## +SPAMASSASSIN = yes +SPAM_SCORE = 10 +CLAMD = yes +########################################################################## + +domainlist local_domains = dsearch;/etc/exim/domains/ +domainlist relay_to_domains = dsearch;/etc/exim/domains/ +hostlist relay_from_hosts = 127.0.0.1 +hostlist spammers = net-iplsearch;/etc/exim/spam-blocks.conf + +acl_smtp_connect = acl_check_spammers +acl_smtp_mail = acl_check_mail +acl_smtp_rcpt = acl_check_rcpt +acl_smtp_data = acl_check_data +acl_smtp_mime = acl_check_mime + +.ifdef SPAMASSASSIN +spamd_address = 127.0.0.1 783 +.endif + +.ifdef CLAMD +av_scanner = clamd: /var/run/clamav/clamd.sock +.endif + +tls_advertise_hosts = * +tls_certificate = /etc/pki/tls/certs/exim.pem +tls_privatekey = /etc/pki/tls/private/exim.pem + +daemon_smtp_ports = 25 : 465 : 587 : 2525 +tls_on_connect_ports = 465 +never_users = root +host_lookup = * +rfc1413_hosts = * +rfc1413_query_timeout = 5s +ignore_bounce_errors_after = 2d +timeout_frozen_after = 7d + +DKIM_DOMAIN = ${lc:${domain:$h_from:}} +DKIM_FILE = /etc/exim/domains/${lc:${domain:$h_from:}}/dkim.pem +DKIM_PRIVATE_KEY = ${if exists{DKIM_FILE}{DKIM_FILE}{0}} + + +########################################################################## +begin acl +########################################################################## +acl_check_spammers: + drop message = Your host in blacklist on this server. + log_message = Host in blacklist + hosts = +spammers + deny message = rejected because $sender_host_address is in a black list at $dnslist_domain\\n$dnslist_text + dnslists = ${readfile {/etc/exim/dnsbl.conf}{:}} + accept + +acl_check_mail: + deny + condition = ${if eq{$sender_helo_name}{}} + message = HELO required before MAIL +# drop +# condition = ${if isip{$sender_helo_name}} +# message = Access denied - Invalid HELO name (See RFC2821 4.1.3) + drop message = Helo name contains a ip address (HELO was $sender_helo_name) and not is valid + condition = ${if match{$sender_helo_name}{\N((\d{1,3}[.-]\d{1,3}[.-]\d{1,3}[.-]\d{1,3})|([0-9a-f]{8})|([0-9A-F]{8}))\N}{yes}{no}} + condition = ${if match {${lookup dnsdb{>: defer_never,ptr=$sender_host_address}}\}{$sender_helo_name}{no}{yes}} + delay = 45s +# drop +# condition = ${if match{$sender_helo_name}{\N^\[\N}{no}{yes}} +# condition = ${if match{$sender_helo_name}{\N\.\N}{no}{yes}} +# message = Access denied - Invalid HELO name (See RFC2821 4.1.1.1) + drop + condition = ${if isip{$sender_helo_name}} + message = Access denied - Invalid HELO name (See RFC2821 4.1.3) +# drop +# condition = ${if match{$sender_helo_name}{\N\.$\N}} +# message = Access denied - Invalid HELO name (See RFC2821 4.1.1.1) +# drop message = "REJECTED - Bad HELO - Host impersonating [$sender_helo_name]" +# condition = ${if match{$sender_helo_name}{$primary_hostname}} + drop condition = ${if eq{[$interface_address]}{$sender_helo_name}} + message = $interface_address is _my_ address + accept + + +acl_check_rcpt: + accept hosts = : + + deny message = Restricted characters in address + domains = +local_domains + local_parts = ^[.] : ^.*[@%!/|] + + deny message = Restricted characters in address + domains = !+local_domains + local_parts = ^[./|] : ^.*[@%!] : ^.*/\\.\\./ + + require verify = sender + + accept hosts = +relay_from_hosts + control = submission + + accept local_parts = postmaster + domains = +local_domains + + accept authenticated = * + control = submission/domain= + + require message = relay not permitted + domains = +local_domains : +relay_to_domains + + deny message = smtp auth requried + sender_domains = +local_domains + !authenticated = * + + require verify = recipient + +.ifdef CLAMD + warn set acl_m0 = no + warn condition = ${if exists {/etc/exim/domains/$domain/antivirus}{yes}{no}} + set acl_m0 = yes +.endif +.ifdef SPAMASSASSIN + warn set acl_m1 = no + warn condition = ${if exists {/etc/exim/domains/$domain/antispam}{yes}{no}} + set acl_m1 = yes +.endif + accept + + +acl_check_data: +.ifdef CLAMD + deny message = Message contains a virus ($malware_name) and has been rejected + malware = * + condition = ${if eq{$acl_m0}{yes}{yes}{no}} +.endif + +.ifdef SPAMASSASSIN + warn + !authenticated = * + hosts = !+relay_from_hosts + condition = ${if < {$message_size}{100K}} + condition = ${if eq{$acl_m1}{yes}{yes}{no}} + spam = nobody:true/defer_ok + add_header = X-Spam-Score: $spam_score_int + add_header = X-Spam-Bar: $spam_bar + add_header = X-Spam-Report: $spam_report + set acl_m2 = $spam_score_int + warn + condition = ${if !eq{$acl_m2}{} {yes}{no}} + condition = ${if >{$acl_m2}{SPAM_SCORE} {yes}{no}} + add_header = X-Spam-Status: Yes + message = SpamAssassin detected spam (from $sender_address to $recipients). +.endif + accept + + +acl_check_mime: + deny message = Blacklisted file extension detected + condition = ${if match {${lc:$mime_filename}}{\N(\.ade|\.adp|\.bat|\.chm|\.cmd|\.com|\.cpl|\.exe|\.hta|\.ins|\.isp|\.jse|\.lib|\.lnk|\.mde|\.msc|\.msp|\.mst|\.pif|\.scr|\.sct|\.shb|\.sys|\.vb|\.vbe|\.vbs|\.vxd|\.wsc|\.wsf|\.wsh)$\N}{1}{0}} + accept + +########################################################################## +begin authenticators +########################################################################## +dovecot_plain: + driver = dovecot + public_name = PLAIN + server_socket = /var/run/dovecot/auth-client + server_set_id = $auth1 + +dovecot_login: + driver = dovecot + public_name = LOGIN + server_socket = /var/run/dovecot/auth-client + server_set_id = $auth1 + +########################################################################## +begin routers +########################################################################## +dnslookup: + driver = dnslookup + domains = !+local_domains + transport = remote_smtp +# ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8 + no_more + +#system_aliases: +# domains = +local_domains +# driver = redirect +# allow_fail +# allow_defer +# data = ${lookup{$local_part}lsearch{/etc/aliases}} +# file_transport = address_file +# pipe_transport = address_pipe + +userforward: + driver = redirect + check_local_user + file = $home/.forward + allow_filter + no_verify + no_expn + check_ancestor + file_transport = address_file + pipe_transport = address_pipe + reply_transport = address_reply + +procmail: + driver = accept + check_local_user + require_files = ${local_part}:+${home}/.procmailrc:/usr/bin/procmail + transport = procmail + no_verify + +autoreplay: + driver = accept + require_files = /etc/exim/domains/$domain/autoreply.${local_part}.msg + condition = ${if exists{/etc/exim/domains/$domain/autoreply.${local_part}.msg}}{yes}{no}} + retry_use_local_part + transport = userautoreply + unseen + +aliases: + driver = redirect + headers_add = X-redirected: yes + data = ${extract{1}{:}{${lookup{$local_part@$domain}lsearch{/etc/exim/domains/$domain/aliases}}}} + require_files = /etc/exim/domains/$domain/aliases + redirect_router = dnslookup + pipe_transport = address_pipe + unseen + + +localuser_spam: + driver = accept + transport = local_spam_delivery + condition = ${if eq {${if match{$h_X-Spam-Status:}{\N^Yes\N}{yes}{no}}} {${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}{yes}{no_such_user}}}} + +localuser: + driver = accept + transport = local_delivery + condition = ${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}{true}{false}} + +catchall: + driver = redirect + headers_add = X-redirected: yes + require_files = /etc/exim/domains/$domain/aliases + data = ${extract{1}{:}{${lookup{*@$domain}lsearch{/etc/exim/domains/$domain/aliases}}}} + file_transport = local_delivery + redirect_router = dnslookup + +terminate_alias: + driver = accept + transport = devnull + condition = ${lookup{$local_part@$domain}lsearch{/etc/exim/domains/$domain/aliases}{true}{false}} + + +########################################################################## +begin transports +########################################################################## +remote_smtp: + driver = smtp + helo_data = $sender_address_domain + dkim_domain = DKIM_DOMAIN + dkim_selector = mail + dkim_private_key = DKIM_PRIVATE_KEY + dkim_canon = relaxed + dkim_strict = 0 + + +procmail: + driver = pipe + command = "/usr/bin/procmail -d $local_part" + return_path_add + delivery_date_add + envelope_to_add + user = $local_part + initgroups + return_output + +local_delivery: + driver = appendfile + maildir_format + maildir_use_size_file + user = ${extract{2}{:}{${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}}}} + group = mail + create_directory + directory_mode = 770 + mode = 660 + use_lockfile = no + delivery_date_add + envelope_to_add + return_path_add + directory = "${extract{5}{:}{${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}}}}/mail/$domain/$local_part" + quota = ${extract{6}{:}{${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}}}}M + quota_warn_threshold = 75% + +local_spam_delivery: + driver = appendfile + maildir_format + maildir_use_size_file + user = ${extract{2}{:}{${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}}}} + group = mail + create_directory + directory_mode = 770 + mode = 660 + use_lockfile = no + delivery_date_add + envelope_to_add + return_path_add + directory = "${extract{5}{:}{${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}}}}/mail/$domain/$local_part/.spam" + quota = ${extract{6}{:}{${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}}}}M + quota_directory = "${extract{5}{:}{${lookup{$local_part}lsearch{/etc/exim/domains/$domain/passwd}}}}/mail/$domain/$local_part" + quota_warn_threshold = 75% + +address_pipe: + driver = pipe + return_output + +address_file: + driver = appendfile + delivery_date_add + envelope_to_add + return_path_add + +address_reply: + driver = autoreply + +userautoreply: + driver = autoreply + file = /etc/exim/domains/$domain/autoreply.${local_part}.msg + from = "${local_part}@${domain}" + subject = "${if def:h_Subject: {Autoreply: ${quote:${escape:$h_Subject:}}} {Autoreply Message}}" + to = "${sender_address}" + +devnull: + driver = appendfile + file = /dev/null + +########################################################################## +begin retry +* * F,2h,15m; G,16h,1h,1.5; F,4d,6h +########################################################################## +begin rewrite diff --git a/install/0.9.7/rhel/roundcube-driver.php b/install/0.9.7/rhel/roundcube-driver.php index f47574416..9454a9e0c 100644 --- a/install/0.9.7/rhel/roundcube-driver.php +++ b/install/0.9.7/rhel/roundcube-driver.php @@ -1,3 +1,4 @@ +<<<<<<< HEAD + */ + +class rcube_vesta_password +{ + function save($curpass, $passwd) + { + $rcmail = rcmail::get_instance(); + $vesta_host = $rcmail->config->get('password_vesta_host'); + + if (empty($vesta_host)) + { + $vesta_host = 'localhost'; + } + + $vesta_port = $rcmail->config->get('password_vesta_port'); + if (empty($vesta_port)) + { + $vesta_port = '8083'; + } + + $postvars = array( + 'email' => $_SESSION['username'], + 'password' => $curpass, + 'new' => $passwd + ); + + $postdata = http_build_query($postvars); + + $send = 'POST /reset/mail/ HTTP/1.1' . PHP_EOL; + $send .= 'Host: ' . $vesta_host . PHP_EOL; + $send .= 'User-Agent: PHP Script' . PHP_EOL; + $send .= 'Content-length: ' . strlen($postdata) . PHP_EOL; + $send .= 'Content-type: application/x-www-form-urlencoded' . PHP_EOL; + $send .= 'Connection: close' . PHP_EOL; + $send .= PHP_EOL; + $send .= $postdata . PHP_EOL . PHP_EOL; + + $fp = fsockopen('ssl://' . $vesta_host, $vesta_port); + fputs($fp, $send); + $result = fread($fp, 2048); + fclose($fp); + + + if(strpos($result, 'ok') && !strpos($html, 'error')) + { + return PASSWORD_SUCCESS; + } + else { + return PASSWORD_ERROR; + } + + } +} +>>>>>>> 994c40901078e48fe939536f7b366e29c2e44a1d diff --git a/install/vst-install.sh b/install/vst-install.sh index 6816707ba..825400a09 100644 --- a/install/vst-install.sh +++ b/install/vst-install.sh @@ -1,3 +1,4 @@ +<<<<<<< HEAD #!/bin/bash # Vesta installer @@ -636,3 +637,652 @@ cd bash # EOF +======= +#!/bin/bash +# Vesta installer + +# Define Variables +RHOST='r.vestacp.com' +CHOST='c.vestacp.com' + +REPO='cmmnt' +VERSION='0.9.7' +YUM_REPO='/etc/yum.repos.d/vesta.repo' +arch=$(uname -i) + +tools="screen mc libpng libjpeg curl libmcrypt mhash zip unzip freetype ntp + openssl flex libxml2 ImageMagick sqlite pcre sudo bc jwhois mailx lsof + tar telnet rsync" + +rpms="nginx httpd mod_ssl mod_ruid2 mod_extract_forwarded mod_fcgid ftp + webalizer awstats mysql mysql-server php php-bcmath php-cli php-common + php-gd php-imap php-mbstring php-mcrypt php-mysql php-pdo php-soap php-tidy + php-xml php-xmlrpc phpMyAdmin exim dovecot clamd spamassassin roundcubemail + bind bind-utils bind-libs vsftpd rrdtool GeoIP vesta vesta-nginx vesta-php" + +# Am I root? +if [ "x$(id -u)" != 'x0' ]; then + echo 'Error: this script can only be executed by root' + exit 1 +fi + +# Check supported version +if [ ! -e '/etc/redhat-release' ]; then + echo 'Error: sorry, we currently support RHEL and CentOS only' + exit 1 +fi + +os=$(cut -f 1 -d ' ' /etc/redhat-release) +if [ $os != 'CentOS' ] && [ $os != 'Red' ]; then + echo 'Error: sorry, we currently support RHEL and CentOS only' +fi +release=$(grep -o "[0-9]" /etc/redhat-release |head -n1) + +help() { + echo "usage: $0 [OPTIONS] + -d, --disable-remi Disable remi + -e, --email Define email address + -h, --help Print this help and exit + -f, --force Force installation" + exit 1 +} + +# Translating argument to --gnu-long-options +for arg; do + delim="" + case "$arg" in + --help) args="${args}-h " ;; + --disable-remi) args="${args}-d " ;; + --force) args="${args}-f " ;; + --email) args="${args}-e " ;; + *) [[ "${arg:0:1}" == "-" ]] || delim="\"" + args="${args}${delim}${arg}${delim} ";; + esac +done +eval set -- "$args" + +# Getopt +while getopts "dhfe:" Option; do + case $Option in + d) disable_remi='yes' ;; # Disable remi repo + h) help ;; # Help + e) email=$OPTARG ;; # Contact email + f) force=yes ;; # Force install + *) help ;; # Default + esac +done + +# Are you sure ? +if [ -z $email ]; then + echo + echo + echo + echo + echo + echo ' ***********************************************************' + echo + echo ' _| _| _|_|_|_| _|_|_| _|_|_|_|_| _|_| ' + echo ' _| _| _| _| _| _| _| ' + echo ' _| _| _|_|_| _|_| _| _|_|_|_| ' + echo ' _| _| _| _| _| _| _| ' + echo ' _| _|_|_|_| _|_|_| _| _| _| ' + echo + echo + echo + echo + echo + echo + echo + echo + echo ' ***********************************************************' + echo + echo + read -n 1 -p 'Do you want to install Vesta Control Panel? [y/n]): ' answer + if [ "$answer" != 'y' ] && [ "$answer" != 'Y' ]; then + echo 'Goodbye' + exit 1 + fi + echo + + # Check email + read -p 'Please enter valid email address: ' email +fi + +# Validate email +local_part=$(echo $email | cut -s -f1 -d\@) +remote_host=$(echo $email | cut -s -f2 -d\@) +mx_failed=1 +if [ ! -z "$remote_host" ] && [ ! -z "$local_part" ]; then + /usr/bin/host -t mx "$remote_host" &> /dev/null + mx_failed="$?" +fi + +if [ "$mx_failed" -eq 1 ]; then + echo "Error: email $email is not valid" + exit 1 +fi + +echo +echo +echo +echo +echo 'Installation will take about 15 minutes ...' +echo +sleep 2 + +# Check wget +if [ ! -e '/usr/bin/wget' ]; then + yum -y install wget + if [ $? -ne 0 ]; then + echo "Error: can't install wget" + exit 1 + fi +fi + +# Check repo availability +wget "$RHOST/$REPO/vesta.conf" -O /dev/null +if [ $? -ne 0 ]; then + echo "Error: no access to $REPO repository" + exit 1 +fi + +# Check installed packages +tmpfile=$(mktemp -p /tmp) +rpm -qa > $tmpfile +for rpm in $rpms; do + if [ ! -z "$(grep ^$rpm. $tmpfile)" ]; then + conflicts="$rpm $conflicts" + fi +done +rm -f $tmpfile + +if [ ! -z "$conflicts" ] && [ -z "$force" ]; then + echo + echo '!!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!!' + echo + echo 'Following rpm packages aleady installed:' + echo "$conflicts" + echo + echo 'It is highly recommended to remove them before proceeding.' + echo + echo 'If you want to force installation run this script with -f option:' + echo "Example: bash $0 --force" + echo + echo '!!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!!' + echo + exit 1 +fi + +# Password generator +gen_pass() { + MATRIX='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' + LENGTH=10 + while [ ${n:=1} -le $LENGTH ]; do + PASS="$PASS${MATRIX:$(($RANDOM%${#MATRIX})):1}" + let n+=1 + done + echo "$PASS" +} + +# Update system +yum -y update +if [ $? -ne 0 ]; then + echo 'Error: yum update failed' + exit 1 +fi + +# Install additional packages +yum -y install $tools +if [ $? -ne 0 ]; then + echo 'Error: yum install failed' + exit 1 +fi + +# Install EPEL repo +if [ ! -e '/etc/yum.repos.d/epel.repo' ]; then + if [ "$release" -eq '5' ]; then + epel="5/$arch/epel-release-5-4.noarch.rpm" + fi + + if [ "$release" -eq '6' ]; then + epel="6/$arch/epel-release-6-8.noarch.rpm" + fi + + rpm -ivh http://dl.fedoraproject.org/pub/epel/$epel + if [ $? -ne 0 ]; then + echo "Error: can't install EPEL repository" + exit 1 + fi +fi + +# Install remi repo +if [ ! -e '/etc/yum.repos.d/remi.repo' ]; then + if [ "$release" -eq '5' ]; then + remi="remi-release-5.rpm" + fi + + if [ "$release" -eq '6' ]; then + remi="remi-release-6.rpm" + fi + + rpm -ivh http://rpms.famillecollet.com/enterprise/$remi + if [ $? -ne 0 ]; then + echo "Error: can't install remi repository" + exit 1 + fi +fi + +# Install vesta repo +echo "[vesta] +name=Vesta - $REPO +baseurl=http://$RHOST/$REPO/$release/\$basearch/ +enabled=1 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-VESTA" > $YUM_REPO +wget $CHOST/GPG.txt -O /etc/pki/rpm-gpg/RPM-GPG-KEY-VESTA + +# Checking if old MySQL stuff exists +if [ -e '/var/lib/mysql' ]; then + mv -f /var/lib/mysql /var/lib/mysql_old +fi +if [ -e '/etc/my.cnf' ]; then + mv -f /etc/my.cnf /etc/my.cnf_old +fi +if [ -e '/root/.my.cnf' ]; then + mv -f /root/.my.cnf +fi + +# Install Vesta packages +if [ -z "$disable_remi" ]; then + yum -y --enablerepo=remi install $rpms +else + yum -y install $rpms +fi +if [ $? -ne 0 ]; then + echo 'Error: yum install failed' + exit 1 +fi + +# Configuring run levels +chkconfig iptables off +if [ -e /etc/init.d/sendmail ]; then + chkconfig sendmail off +fi +if [ -e /etc/init.d/postfix ]; then + chkconfig postfix off +fi +chkconfig vesta on +chkconfig httpd on +chkconfig nginx on +chkconfig mysqld on +chkconfig vsftpd on +chkconfig named on +chkconfig exim on +chkconfig clamd on +chkconfig spamassassin on +chkconfig dovecot on + +# Make dirs more visible +echo 'LS_COLORS="$LS_COLORS:di=00;33"' >> /etc/profile + +# Vesta does not support SELINUX for now +if [ -e '/etc/sysconfig/selinux' ]; then + sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux + setenforce 0 +fi +if [ -e '/etc/selinux/config' ]; then + sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config + setenforce 0 +fi + +# Vesta use own webalizer routine +rm -f /etc/cron.daily/00webalizer + +# NTP Synchronization +echo '#!/bin/sh' > /etc/cron.daily/ntpdate +echo "$(which ntpdate) -s pool.ntp.org" >> /etc/cron.daily/ntpdate +chmod 775 /etc/cron.daily/ntpdate +ntpdate -s pool.ntp.org + +# Vesta Environment +echo "export VESTA='/usr/local/vesta'" > /etc/profile.d/vesta.sh +chmod 755 /etc/profile.d/vesta.sh +source /etc/profile.d/vesta.sh +echo 'PATH=$PATH:/usr/local/vesta/bin' >> /root/.bash_profile +echo 'export PATH' >> /root/.bash_profile +source /root/.bash_profile +mkdir -p $VESTA/conf +mkdir -p $VESTA/log +mkdir -p $VESTA/data +mkdir -p $VESTA/ssl +chmod 770 $VESTA/conf + +# Make backup directory +vst_backups="/root/vst_install_backups/$(date +%s)" +mkdir -p $vst_backups +mkdir -p $vst_backups/nginx +mkdir -p $vst_backups/httpd +mkdir -p $vst_backups/mysql +mkdir -p $vst_backups/exim +mkdir -p $vst_backups/dovecot +mkdir -p $vst_backups/clamd +mkdir -p $vst_backups/vsftpd +mkdir -p $vst_backups/named + +wget $RHOST/$REPO/vesta.conf -O $VESTA/conf/vesta.conf +if [ -e '/etc/sudoers' ]; then + mv /etc/sudoers $vst_backups/ +fi +wget $CHOST/$VERSION/sudoers.conf -O /etc/sudoers +chmod 0440 /etc/sudoers +wget $CHOST/$VERSION/vesta.log -O /etc/logrotate.d/vesta + +sed -i "s/umask 022/umask 002/g" /etc/profile + +# Create backup directory +adduser backup +ln -s /home/backup /backup +chmod a+x /backup + +# Configuring data templates +cd /usr/local/vesta/data +mkdir ips +mkdir queue +mkdir users +touch queue/backup.pipe +touch queue/disk.pipe +touch queue/webstats.pipe +touch queue/restart.pipe +touch queue/traffic.pipe +chmod 750 users +chmod 750 ips +chmod -R 750 queue +wget $CHOST/$VERSION/packages.tar.gz -O packages.tar.gz +tar -xzf packages.tar.gz +rm -f packages.tar.gz +cd /usr/local/vesta/data +wget $CHOST/$VERSION/templates.tar.gz -O templates.tar.gz +tar -xzf templates.tar.gz +rm -f templates.tar.gz +chmod -R 755 /usr/local/vesta/data/templates + +cp templates/web/skel/public_html/index.html /var/www/html/ +sed -i 's/%domain%/It worked!/g' /var/www/html/index.html + +# Configuring ssl keys +cd /usr/local/vesta/ssl +wget $CHOST/$VERSION/certificate.crt -O certificate.crt +wget $CHOST/$VERSION/certificate.key -O certificate.key + +# Adding admin user +vpass=$(gen_pass) +$VESTA/bin/v-add-user admin $vpass $email default System Administrator +if [ $? -ne 0 ]; then + echo "Error: can't create admin user" + exit 1 +fi + +# Set shell +$VESTA/bin/v-change-user-shell admin bash + +# Apache +if [ -e '/etc/httpd/conf/httpd.conf' ]; then + mv /etc/httpd/conf/httpd.conf $vst_backups/httpd/ +fi +if [ -e '/etc/httpd/conf.d/ssl.conf' ]; then + mv /etc/httpd/conf.d/ssl.conf $vst_backups/httpd/ +fi +if [ -e '/etc/httpd/conf.d/proxy_ajp.conf' ]; then + mv /etc/httpd/conf.d/proxy_ajp.conf $vst_backups/httpd/ +fi +wget $CHOST/$VERSION/httpd.conf -O /etc/httpd/conf/httpd.conf +wget $CHOST/$VERSION/httpd-status.conf -O /etc/httpd/conf.d/status.conf +wget $CHOST/$VERSION/httpd-ssl.conf -O /etc/httpd/conf.d/ssl.conf +wget $CHOST/$VERSION/httpd.log -O /etc/logrotate.d/httpd +echo "MEFaccept 127.0.0.1" >> /etc/httpd/conf.d/mod_extract_forwarded.conf +echo > /etc/httpd/conf.d/proxy_ajp.conf +echo > /etc/httpd/conf.d/vesta.conf +touch /var/log/httpd/access_log +touch /var/log/httpd/error_log +touch /var/log/httpd/suexec.log +mkdir -p /var/log/httpd/domains +chmod a+x /var/log/httpd +chmod 640 /var/log/httpd/access_log +chmod 640 /var/log/httpd/error_log +chmod 640 /var/log/httpd/suexec.log +chmod 751 /var/log/httpd/domains + +# Nginx +if [ -e '/etc/nginx/nginx.conf' ]; then + mv /etc/nginx/nginx.conf $vst_backups/nginx/ +fi +if [ -f '/etc/nginx/conf.d/default.conf' ]; then + mv /etc/nginx/conf.d/default.conf $vst_backups/nginx/ +fi +if [ -e '/etc/nginx/conf.d/example_ssl.conf' ]; then + mv /etc/nginx/conf.d/example_ssl.conf $vst_backups/nginx/ +fi + +wget $CHOST/$VERSION/nginx.conf -O /etc/nginx/nginx.conf +wget $CHOST/$VERSION/nginx-status.conf -O /etc/nginx/conf.d/status.conf +touch /etc/nginx/conf.d/vesta_ip.conf +touch /etc/nginx/conf.d/vesta_users.conf + +# VsFTP +if [ -e '/etc/vsftpd/vsftpd.conf' ]; then + mv /etc/vsftpd/vsftpd.conf $vst_backups/vsftpd/ +fi +wget $CHOST/$VERSION/vsftpd.conf -O /etc/vsftpd/vsftpd.conf + +# MySQL +if [ -e '/etc/my.cnf' ]; then + mv /etc/my.cnf $vst_backups/mysql/ +fi + +if [ -e '/root/.my.cnf' ]; then + mv /root/.my.cnf $vst_backups/mysql/ +fi +mpass=$(gen_pass) +server_memory="$(grep 'MemTotal' /proc/meminfo |tr ' ' '\n' |grep [0-9])" +if [ "$server_memory" -gt '1000000' ]; then + wget $CHOST/$VERSION/mysql.cnf -O /etc/my.cnf +else + wget $CHOST/$VERSION/mysql-512.cnf -O /etc/my.cnf +fi +service mysqld start +mysqladmin -u root password $mpass +echo -e "[client]\npassword='$mpass'\n" >/root/.my.cnf +$VESTA/bin/v-add-database-server mysql localhost 3306 root $mpass +$VESTA/bin/v-add-database admin default default $(gen_pass) mysql + +# Bind +if [ -e '/etc/named.conf' ]; then + mv /etc/named.conf $vst_backups/named/ +fi +wget $CHOST/$VERSION/named.conf -O /etc/named.conf +chown root:named /etc/named.conf +chmod 640 /etc/named.conf + +# Exim +if [ -e '/etc/exim/exim.conf' ]; then + mv /etc/exim/exim.conf $vst_backups/exim/ +fi +if [ -e '/etc/clamd.conf' ]; then + mv /etc/clamd.conf $vst_backups/clamd/ +fi +wget $CHOST/$VERSION/exim.conf -O /etc/exim/exim.conf +wget $CHOST/$VERSION/dnsbl.conf -O /etc/exim/dnsbl.conf +wget $CHOST/$VERSION/spam-blocks.conf -O /etc/exim/spam-blocks.conf +wget $CHOST/$VERSION/clamd.conf -O /etc/clamd.conf +mkdir /etc/exim/domains +chmod 640 /etc/exim/exim.conf +gpasswd -a clam exim +gpasswd -a exim mail +gpasswd -a clam mail +gpasswd -a dovecot mail +/usr/bin/freshclam + +# Dovecot config +if [ "$release" -eq '5' ]; then + if -e [ '/etc/dovecot.conf' ]; then + mv /etc/dovecot.conf $vst_backups/dovecot/ + fi + wget $CHOST/$VERSION/dovecot.conf -O /etc/dovecot.conf + +else + if [ -e '/etc/dovecot' ]; then + mv /etc/dovecot/* $vst_backups/dovecot/ + fi + wget $CHOST/$VERSION/dovecot.tar.gz -O /etc/dovecot.tar.gz + cd /etc/ + tar -xzf dovecot.tar.gz + rm -f dovecot.tar.gz +fi + +# PMA +wget $CHOST/$VERSION/httpd-pma.conf -O /etc/httpd/conf.d/phpMyAdmin.conf +wget $CHOST/$VERSION/pma.conf -O /etc/phpMyAdmin/config.inc.php +sed -i "s/%blowfish_secret%/$(gen_pass)/g" /etc/phpMyAdmin/config.inc.php + +# Roundcube setup +wget $CHOST/$VERSION/httpd-webmail.conf -O /etc/httpd/conf.d/roundcubemail.conf +wget $CHOST/$VERSION/roundcube-main.conf -O /etc/roundcubemail/main.inc.php +wget $CHOST/$VERSION/roundcube-db.conf -O /etc/roundcubemail/db.inc.php +wget $CHOST/$VERSION/roundcube-driver.php -O /usr/share/roundcubemail/plugins/password/vesta.php +wget $CHOST/$VERSION/roundcube-pw.conf -O /usr/share/roundcubemail/plugins/password/config.inc.php + +r="$(gen_pass)" +mysql -e "CREATE DATABASE roundcube" +mysql -e "GRANT ALL ON roundcube.* TO roundcube@localhost IDENTIFIED BY '$r'" +sed -i "s/%password%/$r/g" /etc/roundcubemail/db.inc.php +mysql roundcube < /usr/share/doc/roundcubemail-*/SQL/mysql.initial.sql + +# Configuring ip +$VESTA/bin/v-update-sys-ip + +# Get main ip +main_ip=$(ifconfig |grep 'inet addr:' |grep -v 127.0.0.1 |head -n1 |\ + cut -f2 -d: | cut -f1 -d ' ') + +# Add default web domain on main ip +$VESTA/bin/v-add-web-domain admin default.domain $main_ip + +# Add default dns domain on main ip +$VESTA/bin/v-add-dns-domain admin default.domain $main_ip + +# Add default mail domain +$VESTA/bin/v-add-mail-domain admin default.domain + +# Configuring crond +command='sudo /usr/local/vesta/bin/v-update-sys-queue disk' +$VESTA/bin/v-add-cron-job 'admin' '15' '02' '*' '*' '*' "$command" +command='sudo /usr/local/vesta/bin/v-update-sys-queue traffic' +$VESTA/bin/v-add-cron-job 'admin' '10' '00' '*' '*' '*' "$command" +command='sudo /usr/local/vesta/bin/v-update-sys-queue webstats' +$VESTA/bin/v-add-cron-job 'admin' '30' '03' '*' '*' '*' "$command" +command='sudo /usr/local/vesta/bin/v-update-sys-queue backup' +$VESTA/bin/v-add-cron-job 'admin' '*/30' '*' '*' '*' '*' "$command" +command='sudo /usr/local/vesta/bin/v-backup-users' +$VESTA/bin/v-add-cron-job 'admin' '10' '05' '*' '*' '*' "$command" +command='sudo /usr/local/vesta/bin/v-update-user-stats' +$VESTA/bin/v-add-cron-job 'admin' '20' '00' '01' '*' '*' "$command" +command='sudo /usr/local/vesta/bin/v-update-sys-rrd' +$VESTA/bin/v-add-cron-job 'admin' '*/5' '*' '*' '*' '*' "$command" + +# Creating symlink +ln -s /usr/local/vesta/log /var/log/vesta + +# Stop unused services +services='iptables sendmail postfix' +for srv in $services; do + service $srv status > /dev/null + if [ $? -eq 0 ]; then + service $srv stop + fi +done + +# Start system service +services='vesta httpd nginx vsftpd exim dovecot clamd spamassassin named crond' +for srv in $services; do + service $srv status > /dev/null + if [ $? -gt 0 ]; then + service $srv start + else + service $srv restart + fi +done + +# Change sendmail client +rm -f /etc/alternatives/mta +ln -s /usr/sbin/sendmail.exim /etc/alternatives/mta + +# Build inititall rrd images +$VESTA/bin/v-update-sys-rrd + +# Send notification to vestacp.com +wget vestacp.com/notify/?$REPO -O /dev/null + +# Get server ip +vst_ip=$(wget vestacp.com/what-is-my-ip/ -O - 2>/dev/null) +if [ ! -z "$vst_ip" ] && [ "$vst_ip" != "$main_ip" ]; then + # Assign passive ip address + echo "pasv_address=$vst_ip" >> /etc/vsftpd/vsftpd.conf +fi + +if [ -z "$vst_ip" ]; then + vst_ip=$main_ip +fi + +# Send email +echo -e "Congratulations, you have just successfully installed \ +the Vesta Control Panel + +You can login in Vesta with following credentials: + username: admin + password: $vpass + https://$vst_ip:8083 + +We hope that you enjoy your installation of Vesta. Please \ +feel free to contact us anytime if you have any questions. +Thank you. + +-- +Sincerely yours +vestacp.com team +" > $tmpfile + +cat $tmpfile | mail -s "Vesta Control Panel" $email +rm -f $tmpfile + +# Congrats +echo +echo +echo ' ***********************************************************' +echo +echo ' _| _| _|_|_|_| _|_|_| _|_|_|_|_| _|_| ' +echo ' _| _| _| _| _| _| _| ' +echo ' _| _| _|_|_| _|_| _| _|_|_|_| ' +echo ' _| _| _| _| _| _| _| ' +echo ' _| _|_|_|_| _|_|_| _| _| _| ' +echo +echo ' Congratulations, you have just successfully installed' +echo ' the Vesta Control Panel!' +echo +echo ' Now you can login in Vesta with following credentials:' +echo ' username: admin' +echo " password: $vpass" +echo " https://$vst_ip:8083/" +echo +echo +echo ' Thank you for using our product.' +echo +echo ' ***********************************************************' +echo +echo + +# Tricky way to get new PATH variable +cd +bash + +# EOF +>>>>>>> 994c40901078e48fe939536f7b366e29c2e44a1d diff --git a/web/add/db/index.php b/web/add/db/index.php index 46b61dd69..834b21c07 100644 --- a/web/add/db/index.php +++ b/web/add/db/index.php @@ -1,76 +1,93 @@ - $error) { - if ( $i == 0 ) { - $error_msg = $error; - } else { - $error_msg = $error_msg.", ".$error; - } - } - $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); - } else { - // Add Database - $v_type = escapeshellarg($_POST['v_type']); - $v_charset = escapeshellarg($_POST['v_charset']); - exec (VESTA_CMD."v-add-database ".$user." ".$v_database." ".$v_dbuser." ".$v_password." ".$v_type." 'default' ".$v_charset, $output, $return_var); - $v_type = $_POST['v_type']; - $v_charset = $_POST['v_charset']; - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - unset($v_password); - unset($output); - } else { - $_SESSION['ok_msg'] = _('DATABASE_CREATED_OK',$user."_".$_POST['v_database'],$user."_".$_POST['v_database']); - unset($v_database); - unset($v_dbuser); - unset($v_password); - unset($v_type); - unset($v_charset); - unset($output); - } - } - } - exec (VESTA_CMD."v-list-database-types 'json'", $output, $return_var); - $db_types = json_decode(implode('', $output), true); - unset($output); - - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_db.html'); - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); -//} - -// Footer -include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); + $error) { + if ( $i == 0 ) { + $error_msg = $error; + } else { + $error_msg = $error_msg.", ".$error; + } + } + $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); + } else { + // Add Database + $v_type = escapeshellarg($_POST['v_type']); + $v_charset = escapeshellarg($_POST['v_charset']); + exec (VESTA_CMD."v-add-database ".$user." ".$v_database." ".$v_dbuser." ".$v_password." ".$v_type." 'default' ".$v_charset, $output, $return_var); + $v_type = $_POST['v_type']; + $v_charset = $_POST['v_charset']; + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + unset($v_password); + unset($output); + } else { + if (empty($v_notify)) { + list($http_host, $port) = explode(':', $_SERVER["HTTP_HOST"]); + if ($_POST['v_type'] == 'mysql') $db_admin_link = "http://".$http_host."/phpMyAdmin/"; + if ($_POST['v_type'] == 'pgsql') $db_admin_link = "http://".$http_host."/phpPgAdmin/"; + + $to = $panel[$user]['CONTACT']; + $subject = _("Database Credentials"); + $hostname = exec('hostname'); + $from = _('MAIL_FROM',$hostname); + $mailtext = _('DATABASE_READY',$panel[$user]['FNAME'],$panel[$user]['LNAME'],$_POST['v_type'],$user,$_POST['v_database'],$user,$_POST['v_dbuser'],$_POST['v_password']); + $mailtext .= $db_admin_link."\n\n"; + + $mailtext .= "--\n"._('Vesta Control Panel')."\n"; + send_email($to, $subject, $mailtext, $from); + } + $_SESSION['ok_msg'] = _('DATABASE_CREATED_OK',$user."_".$_POST['v_database'],$user."_".$_POST['v_database']); + unset($v_database); + unset($v_dbuser); + unset($v_password); + unset($v_type); + unset($v_charset); + unset($output); + } + } +} +exec (VESTA_CMD."v-list-database-types 'json'", $output, $return_var); +$db_types = json_decode(implode('', $output), true); +unset($output); + +include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_db.html'); +unset($_SESSION['error_msg']); +unset($_SESSION['ok_msg']); +//} + +// Footer +include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); \ No newline at end of file diff --git a/web/edit/web/index.php b/web/edit/web/index.php index 3116d8763..309d8aea7 100644 --- a/web/edit/web/index.php +++ b/web/edit/web/index.php @@ -1,587 +1,587 @@ -', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } else { - $data = json_decode(implode('', $output), true); - unset($output); - $v_username = $user; - $v_domain = $_GET['domain']; - $v_ip = $data[$v_domain]['IP']; - $v_template = $data[$v_domain]['TPL']; - $v_aliases = str_replace(',', "\n", $data[$v_domain]['ALIAS']); - $valiases = explode(",", $data[$v_domain]['ALIAS']); - $v_tpl = $data[$v_domain]['IP']; - $v_cgi = $data[$v_domain]['CGI']; - $v_elog = $data[$v_domain]['ELOG']; - $v_ssl = $data[$v_domain]['SSL']; - if ( $v_ssl == 'yes' ) { - exec (VESTA_CMD."v-list-web-domain-ssl ".$user." '".$v_domain."' json", $output, $return_var); - $ssl_str = json_decode(implode('', $output), true); - unset($output); - $v_ssl_crt = $ssl_str[$v_domain]['CRT']; - $v_ssl_key = $ssl_str[$v_domain]['KEY']; - $v_ssl_ca = $ssl_str[$v_domain]['CA']; - } - $v_ssl_home = $data[$v_domain]['SSL_HOME']; - $v_nginx = $data[$v_domain]['NGINX']; - $v_nginx_ext = str_replace(',', ', ', $data[$v_domain]['NGINX_EXT']); - $v_stats = $data[$v_domain]['STATS']; - $v_stats_user = $data[$v_domain]['STATS_USER']; - if (!empty($v_stats_user)) $v_stats_password = "••••••••"; - $v_ftp_user = $data[$v_domain]['FTP_USER']; - if (!empty($v_ftp_user)) $v_ftp_password = "••••••••"; - $v_suspended = $data[$v_domain]['SUSPENDED']; - if ( $v_suspended == 'yes' ) { - $v_status = 'suspended'; - } else { - $v_status = 'active'; - } - $v_time = $data[$v_domain]['TIME']; - $v_date = $data[$v_domain]['DATE']; - - exec (VESTA_CMD."v-list-user-ips ".$user." json", $output, $return_var); - $ips = json_decode(implode('', $output), true); - unset($output); - - exec (VESTA_CMD."v-list-web-templates json", $output, $return_var); - $templates = json_decode(implode('', $output), true); - unset($output); - - exec (VESTA_CMD."v-list-web-stats json", $output, $return_var); - $stats = json_decode(implode('', $output), true); - unset($output); - } - - // Action - if (!empty($_POST['save'])) { - $v_domain = escapeshellarg($_POST['v_domain']); - - // IP - if (($v_ip != $_POST['v_ip']) && (empty($_SESSION['error_msg']))) { - $v_ip = escapeshellarg($_POST['v_ip']); - exec (VESTA_CMD."v-change-web-domain-ip ".$v_username." ".$v_domain." ".$v_ip." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - $restart_web = 'yes'; - unset($output); - exec (VESTA_CMD."v-list-dns-domain ".$v_username." ".$v_domain." json", $output, $return_var); - if ((empty($_SESSION['error_msg'])) && ($return_var == 0 )) { - exec (VESTA_CMD."v-change-dns-domain-ip ".$v_username." ".$v_domain." ".$v_ip." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - $restart_dns = 'yes'; - } - unset($output); - foreach($valiases as $v_alias ){ - exec (VESTA_CMD."v-list-dns-domain ".$v_username." '".$v_alias."' json", $output, $return_var); - if ((empty($_SESSION['error_msg'])) && ($return_var == 0 )) { - exec (VESTA_CMD."v-change-dns-domain-ip ".$v_username." '".$v_alias."' ".$v_ip, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - $restart_dns = 'yes'; - } - unset($output); - } - } - - // Template - if (( $_SESSION['user'] == 'admin') && ($v_template != $_POST['v_template']) && (empty($_SESSION['error_msg']))) { - $v_template = escapeshellarg($_POST['v_template']); - exec (VESTA_CMD."v-change-web-domain-tpl ".$v_username." ".$v_domain." ".$v_template." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - $restart_web = 'yes'; - } - - // Aliases - if (empty($_SESSION['error_msg'])) { - $waliases = preg_replace("/\n/", " ", $_POST['v_aliases']); - $waliases = preg_replace("/,/", " ", $waliases); - $waliases = preg_replace('/\s+/', ' ',$waliases); - $waliases = trim($waliases); - $aliases = explode(" ", $waliases); - $v_aliases = str_replace(' ', "\n", $waliases); - $result = array_diff($valiases, $aliases); - foreach ($result as $alias) { - if ((empty($_SESSION['error_msg'])) && (!empty($alias))) { - $restart_web = 'yes'; - $v_template = escapeshellarg($_POST['v_template']); - exec (VESTA_CMD."v-delete-web-domain-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - - if (empty($_SESSION['error_msg'])) { - exec (VESTA_CMD."v-delete-dns-on-web-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - $restart_dns = 'yes'; - } - unset($output); - } - } - - $result = array_diff($aliases, $valiases); - foreach ($result as $alias) { - if ((empty($_SESSION['error_msg'])) && (!empty($alias))) { - $restart_web = 'yes'; - $v_template = escapeshellarg($_POST['v_template']); - exec (VESTA_CMD."v-add-web-domain-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - if (empty($_SESSION['error_msg'])) { - exec (VESTA_CMD."v-add-dns-on-web-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - $restart_dns = 'yes'; - } - unset($output); - } - } - } - - // Nginx - if ((!empty($v_nginx)) && (empty($_POST['v_nginx'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-delete-web-domain-nginx ".$v_username." ".$v_domain." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - unset($v_nginx); - $restart_web = 'yes'; - } - if ((!empty($v_nginx)) && (!empty($_POST['v_nginx'])) && (empty($_SESSION['error_msg']))) { - $ext = preg_replace("/\n/", " ", $_POST['v_nginx_ext']); - $ext = preg_replace("/,/", " ", $ext); - $ext = preg_replace('/\s+/', ' ',$ext); - $ext = trim($ext); - $ext = str_replace(' ', ", ", $ext); - if ( $v_nginx_ext != $ext ) { - $ext = str_replace(', ', ",", $ext); - exec (VESTA_CMD."v-change-web-domain-nginx-tpl ".$v_username." ".$v_domain." 'default' ".escapeshellarg($ext)." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - $v_nginx_ext = str_replace(',', ', ', $ext); - unset($output); - $restart_web = 'yes'; - } - } - if ((empty($v_nginx)) && (!empty($_POST['v_nginx'])) && (empty($_SESSION['error_msg']))) { - $nginx_ext = "'jpg,jpeg,gif,png,ico,css,zip,tgz,gz,rar,bz2,doc,xls,exe,pdf,ppt,txt,tar,wav,bmp,rtf,js,mp3,avi,mpeg,html,htm'"; - if (!empty($_POST['v_nginx_ext'])) { - $ext = preg_replace("/\n/", " ", $_POST['v_nginx_ext']); - $ext = preg_replace("/,/", " ", $ext); - $ext = preg_replace('/\s+/', ' ',$ext); - $ext = trim($ext); - $ext = str_replace(' ', ",", $ext); - $v_nginx_ext = str_replace(',', ', ', $ext); - } - exec (VESTA_CMD."v-add-web-domain-nginx ".$v_username." ".$v_domain." 'default' ".escapeshellarg($ext)." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_nginx = 'default'; - $restart_web = 'yes'; - } - - // SSL - if (( $v_ssl == 'yes' ) && (empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-delete-web-domain-ssl ".$v_username." ".$v_domain." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_ssl = 'no'; - $restart_web = 'yes'; - } - if (($v_ssl == 'yes') && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) { - if (( $v_ssl_crt != str_replace("\r\n", "\n", $_POST['v_ssl_crt'])) || ( $v_ssl_key != str_replace("\r\n", "\n", $_POST['v_ssl_key'])) || ( $v_ssl_ca != str_replace("\r\n", "\n", $_POST['v_ssl_ca']))) { - exec ('mktemp -d', $mktemp_output, $return_var); - $tmpdir = $mktemp_output[0]; - - // Certificate - if (!empty($_POST['v_ssl_crt'])) { - $fp = fopen($tmpdir."/".$_POST['v_domain'].".crt", 'w'); - fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_crt'])); - fwrite($fp, "\n"); - fclose($fp); - } - - // Key - if (!empty($_POST['v_ssl_key'])) { - $fp = fopen($tmpdir."/".$_POST['v_domain'].".key", 'w'); - fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_key'])); - fwrite($fp, "\n"); - fclose($fp); - } - - // CA - if (!empty($_POST['v_ssl_ca'])) { - $fp = fopen($tmpdir."/".$_POST['v_domain'].".ca", 'w'); - fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_ca'])); - fwrite($fp, "\n"); - fclose($fp); - } - - exec (VESTA_CMD."v-change-web-domain-sslcert ".$user." ".$v_domain." ".$tmpdir." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - $restart_web = 'yes'; - $v_ssl_crt = $_POST['v_ssl_crt']; - $v_ssl_key = $_POST['v_ssl_key']; - $v_ssl_ca = $_POST['v_ssl_ca']; - } - } - if (( $v_ssl == 'yes') && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) { - if ( $v_ssl_home != $_POST['v_ssl_home'] ) { - $v_ssl_home = escapeshellarg($_POST['v_ssl_home']); - exec (VESTA_CMD."v-change-web-domain-sslhome ".$user." ".$v_domain." ".$v_ssl_home." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - $v_ssl_home = $_POST['v_ssl_home']; - unset($output); - } - } - if (( $v_ssl == 'no') && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) { - if ((!empty($_POST['v_ssl'])) && (empty($_POST['v_ssl_crt']))) $errors[] = 'ssl certificate'; - if ((!empty($_POST['v_ssl'])) && (empty($_POST['v_ssl_key']))) $errors[] = 'ssl key'; - if ((!empty($_POST['v_ssl'])) && (empty($_POST['v_ssl_home']))) $errors[] = 'ssl home'; - $v_ssl_home = escapeshellarg($_POST['v_ssl_home']); - if (!empty($errors[0])) { - foreach ($errors as $i => $error) { - if ( $i == 0 ) { - $error_msg = $error; - } else { - $error_msg = $error_msg.", ".$error; - } - } - $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); - } else { - exec ('mktemp -d', $mktemp_output, $return_var); - $tmpdir = $mktemp_output[0]; - - // Certificate - if (!empty($_POST['v_ssl_crt'])) { - $fp = fopen($tmpdir."/".$_POST['v_domain'].".crt", 'w'); - fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_crt'])); - fclose($fp); - } - - // Key - if (!empty($_POST['v_ssl_key'])) { - $fp = fopen($tmpdir."/".$_POST['v_domain'].".key", 'w'); - fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_key'])); - fclose($fp); - } - - // CA - if (!empty($_POST['v_ssl_ca'])) { - $fp = fopen($tmpdir."/".$_POST['v_domain'].".ca", 'w'); - fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_ca'])); - fclose($fp); - } - exec (VESTA_CMD."v-add-web-domain-ssl ".$user." ".$v_domain." ".$tmpdir." ".$v_ssl_home." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_ssl = 'yes'; - $restart_web = 'yes'; - $v_ssl_crt = $_POST['v_ssl_crt']; - $v_ssl_key = $_POST['v_ssl_key']; - $v_ssl_ca = $_POST['v_ssl_ca']; - $v_ssl_home = $_POST['v_ssl_home']; - } - } - - // Web Stats - if ((!empty($v_stats)) && ($_POST['v_stats'] == 'none') && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-delete-web-domain-stats ".$v_username." ".$v_domain, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_stats = ''; - } - if ((!empty($v_stats)) && ($_POST['v_stats'] != $v_stats) && (empty($_SESSION['error_msg']))) { - $v_stats = escapeshellarg($_POST['v_stats']); - exec (VESTA_CMD."v-change-web-domain-stats ".$v_username." ".$v_domain." ".$v_stats, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - } - if ((empty($v_stats)) && ($_POST['v_stats'] != 'none') && (empty($_SESSION['error_msg']))) { - $v_stats = escapeshellarg($_POST['v_stats']); - exec (VESTA_CMD."v-add-web-domain-stats ".$v_username." ".$v_domain." ".$v_stats, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - } - - // Web Stats Auth - if ((!empty($v_stats_user)) && (empty($_POST['v_stats_auth'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-delete-web-domain-stats-user ".$v_username." ".$v_domain, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_stats_user = ''; - $v_stats_password = ''; - } - if ((empty($v_stats_user)) && (!empty($_POST['v_stats_auth'])) && (empty($_SESSION['error_msg']))) { - if (empty($_POST['v_stats_user'])) $errors[] = _('stats username'); - if (empty($_POST['v_stats_password'])) $errors[] = _('stats password'); - if (!empty($errors[0])) { - foreach ($errors as $i => $error) { - if ( $i == 0 ) { - $error_msg = $error; - } else { - $error_msg = $error_msg.", ".$error; - } - } - $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); - } else { - $v_stats_user = escapeshellarg($_POST['v_stats_user']); - $v_stats_password = escapeshellarg($_POST['v_stats_password']); - exec (VESTA_CMD."v-add-web-domain-stats-user ".$v_username." ".$v_domain." ".$v_stats_user." ".$v_stats_password, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_stats_password = "••••••••"; - } - } - if ((!empty($v_stats_user)) && (!empty($_POST['v_stats_auth'])) && (empty($_SESSION['error_msg']))) { - if (empty($_POST['v_stats_user'])) $errors[] = _('stats user'); - if (empty($_POST['v_stats_password'])) $errors[] = _('stats password'); - if (!empty($errors[0])) { - foreach ($errors as $i => $error) { - if ( $i == 0 ) { - $error_msg = $error; - } else { - $error_msg = $error_msg.", ".$error; - } - } - $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); - } - if (($v_stats_user != $_POST['v_stats_user']) || ($_POST['v_stats_password'] != "••••••••" ) && (empty($_SESSION['error_msg']))) { - $v_stats_user = escapeshellarg($_POST['v_stats_user']); - $v_stats_password = escapeshellarg($_POST['v_stats_password']); - exec (VESTA_CMD."v-add-web-domain-stats-user ".$v_username." ".$v_domain." ".$v_stats_user." ".$v_stats_password, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_stats_password = "••••••••"; - } - } - - // FTP Account - if ((!empty($v_ftp_user)) && (empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-delete-web-domain-ftp ".$v_username." ".$v_domain, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_ftp= ''; - $v_ftp_user = ''; - $v_ftp_password = ''; - } - if ((!empty($v_ftp_user)) && (!empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) { - if (empty($_POST['v_ftp_user'])) $errors[] = _('ftp user'); - if (empty($_POST['v_ftp_password'])) $errors[] = _('ftp user password'); - if (!empty($errors[0])) { - foreach ($errors as $i => $error) { - if ( $i == 0 ) { - $error_msg = $error; - } else { - $error_msg = $error_msg.", ".$error; - } - } - $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); - } - if (($v_ftp_user != $_POST['v_ftp_user']) || ($_POST['v_ftp_password'] != "••••••••" ) && (empty($_SESSION['error_msg']))) { - $v_ftp_user = preg_replace("/^".$user."_/", "", $_POST['v_ftp_user']); - $v_ftp_user = escapeshellarg($v_ftp_user); - $v_ftp_password = escapeshellarg($_POST['v_ftp_password']); - exec (VESTA_CMD."v-add-web-domain-ftp ".$v_username." ".$v_domain." ".$v_ftp_user." ".$v_ftp_password, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_ftp_user = $user."_".$_POST['v_ftp_user']; - $v_ftp_password = "••••••••"; - } - } - - if ((empty($v_ftp_user)) && (!empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) { - if ((!empty($_POST['v_ftp_email'])) && (!filter_var($_POST['v_ftp_email'], FILTER_VALIDATE_EMAIL))) $_SESSION['error_msg'] = _('Please enter valid email address.'); - if (empty($_POST['v_ftp_user'])) $errors[] = 'ftp user'; - if (empty($_POST['v_ftp_password'])) $errors[] = 'ftp user password'; - if (!empty($errors[0])) { - foreach ($errors as $i => $error) { - if ( $i == 0 ) { - $error_msg = $error; - } else { - $error_msg = $error_msg.", ".$error; - } - } - $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); - } - if (empty($_SESSION['error_msg'])) { - $v_ftp_user = escapeshellarg($_POST['v_ftp_user']); - $v_ftp_password = escapeshellarg($_POST['v_ftp_password']); - exec (VESTA_CMD."v-add-web-domain-ftp ".$v_username." ".$v_domain." ".$v_ftp_user." ".$v_ftp_password, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } else { - if (!empty($_POST['v_ftp_email'])) { - $to = $_POST['v_ftp_email']; - $subject = _("FTP login credentials"); - $hostname = exec('hostname'); - $from = _('MAIL_FROM',$hostname); - $mailtext .= _('FTP_ACCOUNT_READY',$_GET['domain'],$user,$_POST['v_ftp_user'],$_POST['v_ftp_password']); - send_email($to, $subject, $mailtext, $from); - unset($v_ftp_email); - } - } - unset($output); - $v_ftp_user = $user."_".$_POST['v_ftp_user']; - $v_ftp_password = "••••••••"; - } - } - - // Restart web - if (!empty($restart_web) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-restart-web", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - } - - // Restart dns - if (!empty($restart_dns) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-restart-dns", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - } - - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = _('OK: changes has been saved.'); - } - - } -if ($_SESSION['user'] == 'admin') { - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_web.html'); -} else { - include($_SERVER['DOCUMENT_ROOT'].'/templates/user/edit_web.html'); -} - unset($_SESSION['error_msg']); - unset($_SESSION['ok_msg']); -//} - -// Footer -include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; +} else { + $data = json_decode(implode('', $output), true); + unset($output); + $v_username = $user; + $v_domain = $_GET['domain']; + $v_ip = $data[$v_domain]['IP']; + $v_template = $data[$v_domain]['TPL']; + $v_aliases = str_replace(',', "\n", $data[$v_domain]['ALIAS']); + $valiases = explode(",", $data[$v_domain]['ALIAS']); + $v_tpl = $data[$v_domain]['IP']; + $v_cgi = $data[$v_domain]['CGI']; + $v_elog = $data[$v_domain]['ELOG']; + $v_ssl = $data[$v_domain]['SSL']; + if ( $v_ssl == 'yes' ) { + exec (VESTA_CMD."v-list-web-domain-ssl ".$user." '".$v_domain."' json", $output, $return_var); + $ssl_str = json_decode(implode('', $output), true); + unset($output); + $v_ssl_crt = $ssl_str[$v_domain]['CRT']; + $v_ssl_key = $ssl_str[$v_domain]['KEY']; + $v_ssl_ca = $ssl_str[$v_domain]['CA']; + } + $v_ssl_home = $data[$v_domain]['SSL_HOME']; + $v_nginx = $data[$v_domain]['NGINX']; + $v_nginx_ext = str_replace(',', ', ', $data[$v_domain]['NGINX_EXT']); + $v_stats = $data[$v_domain]['STATS']; + $v_stats_user = $data[$v_domain]['STATS_USER']; + if (!empty($v_stats_user)) $v_stats_password = "••••••••"; + $v_ftp_user = $data[$v_domain]['FTP_USER']; + if (!empty($v_ftp_user)) $v_ftp_password = "••••••••"; + $v_suspended = $data[$v_domain]['SUSPENDED']; + if ( $v_suspended == 'yes' ) { + $v_status = 'suspended'; + } else { + $v_status = 'active'; + } + $v_time = $data[$v_domain]['TIME']; + $v_date = $data[$v_domain]['DATE']; + + exec (VESTA_CMD."v-list-user-ips ".$user." json", $output, $return_var); + $ips = json_decode(implode('', $output), true); + unset($output); + + exec (VESTA_CMD."v-list-web-templates json", $output, $return_var); + $templates = json_decode(implode('', $output), true); + unset($output); + + exec (VESTA_CMD."v-list-web-stats json", $output, $return_var); + $stats = json_decode(implode('', $output), true); + unset($output); +} + +// Action +if (!empty($_POST['save'])) { + $v_domain = escapeshellarg($_POST['v_domain']); + + // IP + if (($v_ip != $_POST['v_ip']) && (empty($_SESSION['error_msg']))) { + $v_ip = escapeshellarg($_POST['v_ip']); + exec (VESTA_CMD."v-change-web-domain-ip ".$v_username." ".$v_domain." ".$v_ip." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $restart_web = 'yes'; + unset($output); + exec (VESTA_CMD."v-list-dns-domain ".$v_username." ".$v_domain." json", $output, $return_var); + if ((empty($_SESSION['error_msg'])) && ($return_var == 0 )) { + exec (VESTA_CMD."v-change-dns-domain-ip ".$v_username." ".$v_domain." ".$v_ip." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $restart_dns = 'yes'; + } + unset($output); + foreach($valiases as $v_alias ){ + exec (VESTA_CMD."v-list-dns-domain ".$v_username." '".$v_alias."' json", $output, $return_var); + if ((empty($_SESSION['error_msg'])) && ($return_var == 0 )) { + exec (VESTA_CMD."v-change-dns-domain-ip ".$v_username." '".$v_alias."' ".$v_ip, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $restart_dns = 'yes'; + } + unset($output); + } + } + + // Template + if (( $_SESSION['user'] == 'admin') && ($v_template != $_POST['v_template']) && (empty($_SESSION['error_msg']))) { + $v_template = escapeshellarg($_POST['v_template']); + exec (VESTA_CMD."v-change-web-domain-tpl ".$v_username." ".$v_domain." ".$v_template." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $restart_web = 'yes'; + } + + // Aliases + if (empty($_SESSION['error_msg'])) { + $waliases = preg_replace("/\n/", " ", $_POST['v_aliases']); + $waliases = preg_replace("/,/", " ", $waliases); + $waliases = preg_replace('/\s+/', ' ',$waliases); + $waliases = trim($waliases); + $aliases = explode(" ", $waliases); + $v_aliases = str_replace(' ', "\n", $waliases); + $result = array_diff($valiases, $aliases); + foreach ($result as $alias) { + if ((empty($_SESSION['error_msg'])) && (!empty($alias))) { + $restart_web = 'yes'; + $v_template = escapeshellarg($_POST['v_template']); + exec (VESTA_CMD."v-delete-web-domain-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + + if (empty($_SESSION['error_msg'])) { + exec (VESTA_CMD."v-delete-dns-on-web-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $restart_dns = 'yes'; + } + unset($output); + } + } + + $result = array_diff($aliases, $valiases); + foreach ($result as $alias) { + if ((empty($_SESSION['error_msg'])) && (!empty($alias))) { + $restart_web = 'yes'; + $v_template = escapeshellarg($_POST['v_template']); + exec (VESTA_CMD."v-add-web-domain-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + if (empty($_SESSION['error_msg'])) { + exec (VESTA_CMD."v-add-dns-on-web-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $restart_dns = 'yes'; + } + unset($output); + } + } + } + + // Nginx + if ((!empty($v_nginx)) && (empty($_POST['v_nginx'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-delete-web-domain-nginx ".$v_username." ".$v_domain." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + unset($v_nginx); + $restart_web = 'yes'; + } + if ((!empty($v_nginx)) && (!empty($_POST['v_nginx'])) && (empty($_SESSION['error_msg']))) { + $ext = preg_replace("/\n/", " ", $_POST['v_nginx_ext']); + $ext = preg_replace("/,/", " ", $ext); + $ext = preg_replace('/\s+/', ' ',$ext); + $ext = trim($ext); + $ext = str_replace(' ', ", ", $ext); + if ( $v_nginx_ext != $ext ) { + $ext = str_replace(', ', ",", $ext); + exec (VESTA_CMD."v-change-web-domain-nginx-tpl ".$v_username." ".$v_domain." 'default' ".escapeshellarg($ext)." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $v_nginx_ext = str_replace(',', ', ', $ext); + unset($output); + $restart_web = 'yes'; + } + } + if ((empty($v_nginx)) && (!empty($_POST['v_nginx'])) && (empty($_SESSION['error_msg']))) { + $nginx_ext = "'jpg,jpeg,gif,png,ico,css,zip,tgz,gz,rar,bz2,doc,xls,exe,pdf,ppt,txt,tar,wav,bmp,rtf,js,mp3,avi,mpeg,html,htm'"; + if (!empty($_POST['v_nginx_ext'])) { + $ext = preg_replace("/\n/", " ", $_POST['v_nginx_ext']); + $ext = preg_replace("/,/", " ", $ext); + $ext = preg_replace('/\s+/', ' ',$ext); + $ext = trim($ext); + $ext = str_replace(' ', ",", $ext); + $v_nginx_ext = str_replace(',', ', ', $ext); + } + exec (VESTA_CMD."v-add-web-domain-nginx ".$v_username." ".$v_domain." 'default' ".escapeshellarg($ext)." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_nginx = 'default'; + $restart_web = 'yes'; + } + + // SSL + if (( $v_ssl == 'yes' ) && (empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-delete-web-domain-ssl ".$v_username." ".$v_domain." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_ssl = 'no'; + $restart_web = 'yes'; + } + if (($v_ssl == 'yes') && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) { + if (( $v_ssl_crt != str_replace("\r\n", "\n", $_POST['v_ssl_crt'])) || ( $v_ssl_key != str_replace("\r\n", "\n", $_POST['v_ssl_key'])) || ( $v_ssl_ca != str_replace("\r\n", "\n", $_POST['v_ssl_ca']))) { + exec ('mktemp -d', $mktemp_output, $return_var); + $tmpdir = $mktemp_output[0]; + + // Certificate + if (!empty($_POST['v_ssl_crt'])) { + $fp = fopen($tmpdir."/".$_POST['v_domain'].".crt", 'w'); + fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_crt'])); + fwrite($fp, "\n"); + fclose($fp); + } + + // Key + if (!empty($_POST['v_ssl_key'])) { + $fp = fopen($tmpdir."/".$_POST['v_domain'].".key", 'w'); + fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_key'])); + fwrite($fp, "\n"); + fclose($fp); + } + + // CA + if (!empty($_POST['v_ssl_ca'])) { + $fp = fopen($tmpdir."/".$_POST['v_domain'].".ca", 'w'); + fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_ca'])); + fwrite($fp, "\n"); + fclose($fp); + } + + exec (VESTA_CMD."v-change-web-domain-sslcert ".$user." ".$v_domain." ".$tmpdir." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $restart_web = 'yes'; + $v_ssl_crt = $_POST['v_ssl_crt']; + $v_ssl_key = $_POST['v_ssl_key']; + $v_ssl_ca = $_POST['v_ssl_ca']; + } + } + if (( $v_ssl == 'yes') && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) { + if ( $v_ssl_home != $_POST['v_ssl_home'] ) { + $v_ssl_home = escapeshellarg($_POST['v_ssl_home']); + exec (VESTA_CMD."v-change-web-domain-sslhome ".$user." ".$v_domain." ".$v_ssl_home." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $v_ssl_home = $_POST['v_ssl_home']; + unset($output); + } + } + if (( $v_ssl == 'no') && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) { + if ((!empty($_POST['v_ssl'])) && (empty($_POST['v_ssl_crt']))) $errors[] = 'ssl certificate'; + if ((!empty($_POST['v_ssl'])) && (empty($_POST['v_ssl_key']))) $errors[] = 'ssl key'; + if ((!empty($_POST['v_ssl'])) && (empty($_POST['v_ssl_home']))) $errors[] = 'ssl home'; + $v_ssl_home = escapeshellarg($_POST['v_ssl_home']); + if (!empty($errors[0])) { + foreach ($errors as $i => $error) { + if ( $i == 0 ) { + $error_msg = $error; + } else { + $error_msg = $error_msg.", ".$error; + } + } + $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); + } else { + exec ('mktemp -d', $mktemp_output, $return_var); + $tmpdir = $mktemp_output[0]; + + // Certificate + if (!empty($_POST['v_ssl_crt'])) { + $fp = fopen($tmpdir."/".$_POST['v_domain'].".crt", 'w'); + fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_crt'])); + fclose($fp); + } + + // Key + if (!empty($_POST['v_ssl_key'])) { + $fp = fopen($tmpdir."/".$_POST['v_domain'].".key", 'w'); + fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_key'])); + fclose($fp); + } + + // CA + if (!empty($_POST['v_ssl_ca'])) { + $fp = fopen($tmpdir."/".$_POST['v_domain'].".ca", 'w'); + fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_ca'])); + fclose($fp); + } + exec (VESTA_CMD."v-add-web-domain-ssl ".$user." ".$v_domain." ".$tmpdir." ".$v_ssl_home." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_ssl = 'yes'; + $restart_web = 'yes'; + $v_ssl_crt = $_POST['v_ssl_crt']; + $v_ssl_key = $_POST['v_ssl_key']; + $v_ssl_ca = $_POST['v_ssl_ca']; + $v_ssl_home = $_POST['v_ssl_home']; + } + } + + // Web Stats + if ((!empty($v_stats)) && ($_POST['v_stats'] == 'none') && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-delete-web-domain-stats ".$v_username." ".$v_domain, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_stats = ''; + } + if ((!empty($v_stats)) && ($_POST['v_stats'] != $v_stats) && (empty($_SESSION['error_msg']))) { + $v_stats = escapeshellarg($_POST['v_stats']); + exec (VESTA_CMD."v-change-web-domain-stats ".$v_username." ".$v_domain." ".$v_stats, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + if ((empty($v_stats)) && ($_POST['v_stats'] != 'none') && (empty($_SESSION['error_msg']))) { + $v_stats = escapeshellarg($_POST['v_stats']); + exec (VESTA_CMD."v-add-web-domain-stats ".$v_username." ".$v_domain." ".$v_stats, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + + // Web Stats Auth + if ((!empty($v_stats_user)) && (empty($_POST['v_stats_auth'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-delete-web-domain-stats-user ".$v_username." ".$v_domain, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_stats_user = ''; + $v_stats_password = ''; + } + if ((empty($v_stats_user)) && (!empty($_POST['v_stats_auth'])) && (empty($_SESSION['error_msg']))) { + if (empty($_POST['v_stats_user'])) $errors[] = _('stats username'); + if (empty($_POST['v_stats_password'])) $errors[] = _('stats password'); + if (!empty($errors[0])) { + foreach ($errors as $i => $error) { + if ( $i == 0 ) { + $error_msg = $error; + } else { + $error_msg = $error_msg.", ".$error; + } + } + $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); + } else { + $v_stats_user = escapeshellarg($_POST['v_stats_user']); + $v_stats_password = escapeshellarg($_POST['v_stats_password']); + exec (VESTA_CMD."v-add-web-domain-stats-user ".$v_username." ".$v_domain." ".$v_stats_user." ".$v_stats_password, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_stats_password = "••••••••"; + } + } + if ((!empty($v_stats_user)) && (!empty($_POST['v_stats_auth'])) && (empty($_SESSION['error_msg']))) { + if (empty($_POST['v_stats_user'])) $errors[] = _('stats user'); + if (empty($_POST['v_stats_password'])) $errors[] = _('stats password'); + if (!empty($errors[0])) { + foreach ($errors as $i => $error) { + if ( $i == 0 ) { + $error_msg = $error; + } else { + $error_msg = $error_msg.", ".$error; + } + } + $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); + } + if (($v_stats_user != $_POST['v_stats_user']) || ($_POST['v_stats_password'] != "••••••••" ) && (empty($_SESSION['error_msg']))) { + $v_stats_user = escapeshellarg($_POST['v_stats_user']); + $v_stats_password = escapeshellarg($_POST['v_stats_password']); + exec (VESTA_CMD."v-add-web-domain-stats-user ".$v_username." ".$v_domain." ".$v_stats_user." ".$v_stats_password, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_stats_password = "••••••••"; + } + } + + // FTP Account + if ((!empty($v_ftp_user)) && (empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-delete-web-domain-ftp ".$v_username." ".$v_domain, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_ftp= ''; + $v_ftp_user = ''; + $v_ftp_password = ''; + } + if ((!empty($v_ftp_user)) && (!empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) { + if (empty($_POST['v_ftp_user'])) $errors[] = _('ftp user'); + if (empty($_POST['v_ftp_password'])) $errors[] = _('ftp user password'); + if (!empty($errors[0])) { + foreach ($errors as $i => $error) { + if ( $i == 0 ) { + $error_msg = $error; + } else { + $error_msg = $error_msg.", ".$error; + } + } + $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); + } + if (($v_ftp_user != $_POST['v_ftp_user']) || ($_POST['v_ftp_password'] != "••••••••" ) && (empty($_SESSION['error_msg']))) { + $v_ftp_user = preg_replace("/^".$user."_/", "", $_POST['v_ftp_user']); + $v_ftp_user = escapeshellarg($v_ftp_user); + $v_ftp_password = escapeshellarg($_POST['v_ftp_password']); + exec (VESTA_CMD."v-add-web-domain-ftp ".$v_username." ".$v_domain." ".$v_ftp_user." ".$v_ftp_password, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_ftp_user = $_POST['v_ftp_user']; + $v_ftp_password = "••••••••"; + } + } + + if ((empty($v_ftp_user)) && (!empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) { + if ((!empty($_POST['v_ftp_email'])) && (!filter_var($_POST['v_ftp_email'], FILTER_VALIDATE_EMAIL))) $_SESSION['error_msg'] = _('Please enter valid email address.'); + if (empty($_POST['v_ftp_user'])) $errors[] = 'ftp user'; + if (empty($_POST['v_ftp_password'])) $errors[] = 'ftp user password'; + if (!empty($errors[0])) { + foreach ($errors as $i => $error) { + if ( $i == 0 ) { + $error_msg = $error; + } else { + $error_msg = $error_msg.", ".$error; + } + } + $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); + } + if (empty($_SESSION['error_msg'])) { + $v_ftp_user = escapeshellarg($_POST['v_ftp_user']); + $v_ftp_password = escapeshellarg($_POST['v_ftp_password']); + exec (VESTA_CMD."v-add-web-domain-ftp ".$v_username." ".$v_domain." ".$v_ftp_user." ".$v_ftp_password, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } else { + if (!empty($_POST['v_ftp_email'])) { + $to = $_POST['v_ftp_email']; + $subject = _("FTP login credentials"); + $hostname = exec('hostname'); + $from = _('MAIL_FROM',$hostname); + $mailtext .= _('FTP_ACCOUNT_READY',$_GET['domain'],$user."_".$_POST['v_ftp_user'],$_POST['v_ftp_password']); + send_email($to, $subject, $mailtext, $from); + unset($v_ftp_email); + } + } + unset($output); + $v_ftp_user = $user."_".$_POST['v_ftp_user']; + $v_ftp_password = "••••••••"; + } + } + + // Restart web + if (!empty($restart_web) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-restart-web", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + } + + // Restart dns + if (!empty($restart_dns) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-restart-dns", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + } + + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = _('OK: changes has been saved.'); + } + +} +if ($_SESSION['user'] == 'admin') { + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_web.html'); +} else { + include($_SERVER['DOCUMENT_ROOT'].'/templates/user/edit_web.html'); +} +unset($_SESSION['error_msg']); +unset($_SESSION['ok_msg']); +//} + +// Footer +include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); \ No newline at end of file diff --git a/web/inc/i18n/ru.php b/web/inc/i18n/ru.php index 44df420ce..359a24068 100644 --- a/web/inc/i18n/ru.php +++ b/web/inc/i18n/ru.php @@ -147,5 +147,8 @@ $LANG = array( 'Reset Code'=>'Код сброса', 'disk'=>'Место', 'traffic'=>'Трафик', + 'Database Credentials'=>'Данные для доступа к БД', + 'DATABASE_READY'=>"Здравствуйте %s %s,\nВаша %s база данных создана успешно.\n\nИмя БД: %s_%s\nПользователь: %s_%s\nПароль: %s\n\n", + 'Send credentials to'=>'Отправить данные для доступа к ' ); \ No newline at end of file diff --git a/web/templates/admin/add_db.html b/web/templates/admin/add_db.html index fdeb1d8b5..35aecc0a4 100644 --- a/web/templates/admin/add_db.html +++ b/web/templates/admin/add_db.html @@ -1,176 +1,184 @@ - - - - - - - - -
- -
- - - - - - - -
- - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- -
- - -
- - -
- -
- -
- -
- -
- -
- - -
-
-
+ + + + + + + +
+ +
+ + + + + + + +
+ + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ + +
+ + +
+ +
+ +
+ +
+ +
+ +
+ +
+ > +
+ + +
+
+
\ No newline at end of file diff --git a/web/templates/admin/list_dns.html b/web/templates/admin/list_dns.html index a11e63213..0aee68101 100644 --- a/web/templates/admin/list_dns.html +++ b/web/templates/admin/list_dns.html @@ -1,147 +1,146 @@ - - - - - -
- -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - ?> - - - - - - -
- - - - -
" >
">
-
- - - - - - - - - -
list records add record edit - - - - - - - delete - - -
- - - - - - - - - -
- -
- - - - - - -
- -
- [] template -
-
- - - - - - - - - -
SOA:
TTL:
-
- - - - - - - - - -
Expire:
Records:
-
-
- - - - - - - -
- -
-
- + + + + + +
+ +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + ?> + + + + + + +
+ + + + +
" >
">
+
+ + + + + + + + + +
list records add record edit + + + + + + + delete + + +
+ + + + + + + + + +
+ +
+ + + + + + +
+ +
+ [] template +
+
+ + + + + + + + + +
SOA:
TTL:
+
+ + + + + + + + + +
Expire:
Records:
+
+
+ + + + + + + +
+ +
+
\ No newline at end of file diff --git a/web/templates/admin/list_dns_rec.html b/web/templates/admin/list_dns_rec.html index 2489aea76..ee8237231 100644 --- a/web/templates/admin/list_dns_rec.html +++ b/web/templates/admin/list_dns_rec.html @@ -1,107 +1,115 @@ - - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - ?> - - - - - - -
- - - - -
">
-
- - - - - - - -
edit - - - - - - - delete - - -
- - - - - - - -
-
- - - - - - -
- - -
-
+ + + + + + + + + +
+
+ + + + +
+ Listing +
+
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + ?> + + + + + + +
+ + + + +
">
+
+ + + + + + + +
edit + + + + + + + delete + + +
+ + + + + + + +
+
+ + + + + + +
+ + +
+
\ No newline at end of file diff --git a/web/templates/admin/list_mail.html b/web/templates/admin/list_mail.html index e5a1844ca..000a4e8f7 100644 --- a/web/templates/admin/list_mail.html +++ b/web/templates/admin/list_mail.html @@ -1,173 +1,173 @@ - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - if (empty($data[$key]['CATCHALL'])) { - $data[$key]['CATCHALL'] = '/dev/null'; - } - ?> - - - - - - - -
- - - - -
" >
">
-
- - - - - - - - - - -
list accounts add account" target="_blank"> open webmail edit - - - - - - - delete - - -
- - - - - - - - - - -
- -
- - - - - - - -
- catchall > -
- Disk: -
-
-
-
-
- - - - - - - - - -
- Antivirus: - - -
- Antispam: - - -
-
- - - - - - - - - -
- DKIM: - - -
- Accounts: - - -
-
-
- - - - - - - -
- -
-
+ + + + + + + + + +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + if (empty($data[$key]['CATCHALL'])) { + $data[$key]['CATCHALL'] = '/dev/null'; + } + ?> + + + + + + + +
+ + + + +
" >
">
+
+ + + + + + + + + + +
list accounts add account" target="_blank"> open webmail edit + + + + + + + delete + + +
+ + + + + + + + + + +
+ +
+ + + + + + + +
+ catchall > +
+ Disk: +
+
+
+
+
+ + + + + + + + + +
+ Antivirus: + + +
+ Antispam: + + +
+
+ + + + + + + + + +
+ DKIM: + + +
+ Accounts: + + +
+
+
+ + + + + + + +
+ +
+
\ No newline at end of file diff --git a/web/templates/admin/list_mail_acc.html b/web/templates/admin/list_mail_acc.html index 2137383d6..f13e33caf 100644 --- a/web/templates/admin/list_mail_acc.html +++ b/web/templates/admin/list_mail_acc.html @@ -1,155 +1,162 @@ - - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend'; - } - ?> - - - - - - - -
- - - - -
">
-
- - - - - - - -
edit - - - - - - - delete - - -
- - - - - - - - -
- - - - - - -
- -
- Disk: -
-
-
-
-
- - - - - - - - - -
- Quota: - - -
- Autoreply: - - -
-
- - - - - -
- Forward: - - -
-
-
- - - - - - - -
- -
-
- + + + + + + + + + +
+
+ + + + +
+ Listing +
+
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend'; + } + ?> + + + + + + + +
+ + + + +
">
+
+ + + + + + + +
edit + + + + + + + delete + + +
+ + + + + + + + +
+ + + + + + +
+ +
+ Disk: +
+
+
+
+
+ + + + + + + + + +
+ Quota: + + +
+ Autoreply: + + +
+
+ + + + + +
+ Forward: + + +
+
+
+ + + + + + + +
+ +
+
\ No newline at end of file diff --git a/web/templates/header.html b/web/templates/header.html index 4ae4b1aa0..c8759d5b1 100644 --- a/web/templates/header.html +++ b/web/templates/header.html @@ -1,721 +1,718 @@ - - - - Vesta - <?php echo "$TAB"; ?> - - - - - - - - - + + + +Vesta - <?php echo "$TAB"; ?> + + + + + + + + + \ No newline at end of file diff --git a/web/templates/user/list_dns.html b/web/templates/user/list_dns.html index 070e78998..a6cbf6f51 100644 --- a/web/templates/user/list_dns.html +++ b/web/templates/user/list_dns.html @@ -1,137 +1,136 @@ - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - ?> - - - - - - -
- - - - -
" >
">
-
- - - - - - - - -
list records add record edit - - delete - - -
- - - - - - - - - -
- -
- - - - - - -
- -
- [] template -
-
- - - - - - - - - -
SOA:
TTL:
-
- - - - - - - - - -
Expire:
Records:
-
-
- - - - - - - -
- -
-
- + + + + + + + + + +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + ?> + + + + + + +
+ + + + +
" >
">
+
+ + + + + + + + +
list records add record edit + + delete + + +
+ + + + + + + + + +
+ +
+ + + + + + +
+ +
+ [] template +
+
+ + + + + + + + + +
SOA:
TTL:
+
+ + + + + + + + + +
Expire:
Records:
+
+
+ + + + + + + +
+ +
+
\ No newline at end of file diff --git a/web/templates/user/list_dns_rec.html b/web/templates/user/list_dns_rec.html index 2cec75fa3..2179cc99a 100644 --- a/web/templates/user/list_dns_rec.html +++ b/web/templates/user/list_dns_rec.html @@ -1,98 +1,105 @@ - - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - ?> - - - - - - -
- - - - -
">
-
- - - - - - -
edit - - delete - - -
- - - - - - - -
-
- - - - - - -
- - -
-
- + + + + + + + + + +
+
+ + + + +
+ Listing +
+
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + ?> + + + + + + +
+ + + + +
">
+
+ + + + + + +
edit + + delete + + +
+ + + + + + + +
+
+ + + + + + +
+ + +
+
\ No newline at end of file diff --git a/web/templates/user/list_mail.html b/web/templates/user/list_mail.html index 3d15bc714..c0db21eff 100644 --- a/web/templates/user/list_mail.html +++ b/web/templates/user/list_mail.html @@ -1,164 +1,163 @@ - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - if (empty($data[$key]['CATCHALL'])) { - $data[$key]['CATCHALL'] = '/dev/null'; - } - ?> - - - - - - - -
- - - - -
" >
">
-
- - - - - - - - - -
list accounts add account" target="_blank"> open webmail edit - - delete - - -
- - - - - - - - - - -
- -
- - - - - - - -
- catchall > -
- Disk: -
-
-
-
-
- - - - - - - - - -
- Antivirus: - - -
- Antispam: - - -
-
- - - - - - - - - -
- DKIM: - - -
- Accounts: - - -
-
-
- - - - - - - -
- -
-
- + + + + + + + + + +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + if (empty($data[$key]['CATCHALL'])) { + $data[$key]['CATCHALL'] = '/dev/null'; + } + ?> + + + + + + + +
+ + + + +
" >
">
+
+ + + + + + + + + +
list accounts add account" target="_blank"> open webmail edit + + delete + + +
+ + + + + + + + + + +
+ +
+ + + + + + + +
+ catchall > +
+ Disk: +
+
+
+
+
+ + + + + + + + + +
+ Antivirus: + + +
+ Antispam: + + +
+
+ + + + + + + + + +
+ DKIM: + + +
+ Accounts: + + +
+
+
+ + + + + + + +
+ +
+
\ No newline at end of file diff --git a/web/templates/user/list_mail_acc.html b/web/templates/user/list_mail_acc.html index cfa9c9e02..4548743b9 100644 --- a/web/templates/user/list_mail_acc.html +++ b/web/templates/user/list_mail_acc.html @@ -1,145 +1,152 @@ - - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend'; - } - ?> - - - - - - - -
- - - - -
">
-
- - - - - - -
edit - - delete - - -
- - - - - - - - -
- - - - - - -
- -
- Disk: -
-
-
-
-
- - - - - - - - - -
- Quota: - - -
- Autoreply: - - -
-
- - - - - -
- Forward: - - -
-
-
- - - - - - - -
- -
-
- + + + + + + + + + +
+
+ + + + +
+ Listing +
+
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend'; + } + ?> + + + + + + + +
+ + + + +
">
+
+ + + + + + +
edit + + delete + + +
+ + + + + + + + +
+ + + + + + +
+ +
+ Disk: +
+
+
+
+
+ + + + + + + + + +
+ Quota: + + +
+ Autoreply: + + +
+
+ + + + + +
+ Forward: + + +
+
+
+ + + + + + + +
+ +
+
\ No newline at end of file From 57015cf7560c933cce180c36c350191ca2b802b8 Mon Sep 17 00:00:00 2001 From: ZonD Eighty Date: Sun, 13 Jan 2013 19:54:47 +0400 Subject: [PATCH 05/11] A little more translation --- web/inc/i18n/ru.php | 79 ++- web/templates/admin/add_dns_rec.html | 236 ++++---- web/templates/admin/add_ip.html | 296 +++++----- web/templates/admin/add_mail.html | 190 +++--- web/templates/admin/add_mail_acc.html | 294 +++++----- web/templates/admin/add_package.html | 36 +- web/templates/admin/add_user.html | 298 +++++----- web/templates/admin/add_web.html | 764 ++++++++++++------------- web/templates/admin/edit_cron.html | 236 ++++---- web/templates/admin/edit_db.html | 274 ++++----- web/templates/admin/edit_dns.html | 254 ++++---- web/templates/admin/edit_dns_rec.html | 214 +++---- web/templates/admin/edit_ip.html | 272 ++++----- web/templates/admin/edit_mail.html | 212 +++---- web/templates/admin/edit_mail_acc.html | 20 +- web/templates/admin/edit_package.html | 494 ++++++++-------- 16 files changed, 2121 insertions(+), 2048 deletions(-) diff --git a/web/inc/i18n/ru.php b/web/inc/i18n/ru.php index 359a24068..2eaa9211a 100644 --- a/web/inc/i18n/ru.php +++ b/web/inc/i18n/ru.php @@ -35,7 +35,9 @@ $LANG = array( 'RECORD_CREATED_OK'=>'Успех: Запись %s.%s успешно создана.', 'ip address'=>'IP-адрес', 'netmask'=>'маска подсети', + 'Netmask'=>'Маска подсети', 'interface'=>'интерфейс', + 'Interface'=>'Интерфейс', 'assigned user'=>'назначенный пользователь', 'IP_CREATED_OK'=>'"Успех: ip-адрес %s успешно создан.', 'DOMAIN_MAIL_CREATED_OK'=>'Успех: почта для домена %s подключена успешно', @@ -46,20 +48,35 @@ $LANG = array( 'template'=>'шаблон', 'shell'=>'SSH', 'web domains'=>'хосты', + 'Web Domains'=>'Хосты', + 'Web Aliases'=>'Перенаправления Хостов', + 'per domain'=>'на домен', + 'DNS domains'=>'домены для DNS', + 'DNS records count'=>'Кол-во DNS записей', + 'DNS Support'=>'Поддержка DNS', + 'Mail Support'=>'Поддержка почты', 'web aliases'=>'перенаправления хостов', 'dns records'=>'DNS записи', 'mail domains'=>'домены с почтой', 'mail accounts'=>'почтовые аккаунты', + 'Mail Domains'=>'Домены с Почтой', + 'Mail Accounts'=>'Почтовые Аккаунты', 'databases'=>'базы данных', + 'Databases'=>'Базы Данных', 'cron jobs'=>'cron задания', + 'Cron Jobs'=>'Cron Задания', + 'Backups'=>'Бэкапы', 'backups'=>'бэкапы', 'quota'=>'квота диска', 'bandwidth'=>'ширина канала', + 'Bandwidth'=>'Ширина канала', + 'ns1'=>'DNS-сервер #1', 'ns2'=>'DNS-сервер #2', 'PACKAGE_CREATED_OK'=>'Успех: Пакет %s успешно создан.', 'user'=>'пользователь', - 'email'=>'Email', + 'email'=>'email', + 'Email'=>'Email', 'first name'=>'Имя', 'last name'=>'Фамилия', 'Please enter valid email address.'=>'Пожалуйста, введите реальный email адрес.', @@ -71,6 +88,11 @@ $LANG = array( 'ACCOUNT_CREATED_OK'=>'Успех: Пользователь %s успешно создан.', 'ssl certificate'=>'SSL сертификат', 'ssl key'=>'ключ SSL сертификата', + 'SSL Support'=>'Поддержка SSL', + 'SSL Home Directory'=>'Корневая папка для SSL', + 'SSL Certificate'=>'SSL сертификат', + 'SSL key'=>'Ключ SSL сертификата', + 'SSL Certificate Authority / Intermediate'=>'Центр сертификации SSL CA / Intermediate', 'stats user password'=>'пароль для доступа к статистике', 'stats username'=>'имя пользователя статистики', 'stats password'=>'пароль пользователя статистики', @@ -99,6 +121,7 @@ $LANG = array( 'Back'=>'Назад', 'Adding database'=>'Добавление базы данных', 'DB_PREFIX_WILL_BE_ADDED'=>'Префикс %s будет автоматически добавлен к БД и пользователю БД', + 'FTP_PREFIX_WILL_BE_ADDED'=>'Префикс %s будет автоматически добавлен к имени пользователя', 'Database'=>'База данных', 'Username'=>'Имя пользователя', 'Password'=>'Пароль', @@ -111,6 +134,7 @@ $LANG = array( 'Advanced options'=>'Расширенные опции', 'Template'=>'Шаблон', 'Expiration date'=>'Дата окончания делегирования', + 'YYYY-MM-DD'=>'ГГГГ-ММ-ДД', 'Name servers'=>'Сервера имен', 'Powered by Vesta Control Panel'=>'Работает на Панели Управления Vesta', 'Vesta Control Panel'=>'Панель Управления Vesta', @@ -133,7 +157,8 @@ $LANG = array( 'suspended'=>'заблокировано', 'WEB'=>'ХОСТИНГ', 'domains'=>'домены', - 'aliases'=>'редиректы', + 'aliases'=>'перенаправления', + 'Aliases'=>'Перенаправления', 'DNS'=>'DNS', 'records'=>'записи', 'MAIL'=>'ПОЧТА', @@ -149,6 +174,54 @@ $LANG = array( 'traffic'=>'Трафик', 'Database Credentials'=>'Данные для доступа к БД', 'DATABASE_READY'=>"Здравствуйте %s %s,\nВаша %s база данных создана успешно.\n\nИмя БД: %s_%s\nПользователь: %s_%s\nПароль: %s\n\n", - 'Send credentials to'=>'Отправить данные для доступа к ' + 'Send credentials to'=>'Отправить данные для доступа к ', + 'Adding DNS Record'=>'Добавление записи DNS', + 'Record'=>'Запись', + 'IP or Value'=>'IP-адрес или значение', + 'Priority'=>'Приоритет', + 'optional'=>'опционально', + 'Adding IP Address'=>'Добавление IP-адреса', + 'Shared'=>'Общий', + 'Assigned user'=>'Пользователь', + 'Assigned domain'=>'Домен', + 'Adding Mail Domain'=>'Создание почты для домена', + 'AntiSpam Support'=>'Поддержка Анти-спама', + 'AntiVirus Support'=>'Поддержка Антивируса', + 'DKIM Support'=>'Поддержка DKIM', + 'Adding Mail Account'=>'Создание почтового ящика', + 'Advanced options'=>'Дополнительные опции', + 'Quota'=>'Квота', + 'in megabytes'=>'в мегабайтах', + 'use local-part'=>'используйте локальные записи', + 'Forward to'=>'Перенаправление', + 'one or more email addresses'=>'один или несколько email-адресов', + 'Adding Package'=>'Создание пакета', + 'Package Name'=>'Название пакета', + 'Package'=>'Пакет', + 'Default Template'=>'Шаблон по-умолчанию', + 'SSH Access'=>'Доступ к SSH', + 'Adding User'=>'Добавления пользователя', + 'First Name'=>'Имя', + 'Last Name'=>'Фамилия', + 'SEND_CREDENTIALS_NOTICE'=>'Отправить данные для доступа на ящик пользователя?', + 'Adding Domain for hosting'=>'Добавление домена для хостинга', + 'Apache template'=>'Шаблон веб-сервера Apache', + 'Nginx Support'=>'Поддержка веб-сервера Nginx', + 'Nginx Extentions'=>'Расширения Nginx', + 'Statistics Authorization'=>'Доступ к статистике', + 'Additional FTP Account'=>'Дополнительный FTP-аккаунт', + 'Editing Cron Job'=>'Редактирование cron-задания', + 'Save'=>'Сохранить', + 'Editing Database'=>'Редактирование БД', + 'Editing DNS Domain'=>'Редактирование DNS для домена', + 'Editing DNS Record'=>'Редактирование DNS записи', + 'Editing IP Address'=>'Редактирование IP-адреса', + 'Editing Mail Domain'=>'Редактирование почты для домена', + 'Catchall email'=>'Общий email-адрес', + 'Editing Mail Account'=>'Редактирование почтового акканунта', + 'Autoreply'=>'Автоответчик', + 'Message'=>'Сообщение', + 'Editing Package'=>'Редактирование Пакета', + ); \ No newline at end of file diff --git a/web/templates/admin/add_dns_rec.html b/web/templates/admin/add_dns_rec.html index 2893ba2e7..df1414ccc 100644 --- a/web/templates/admin/add_dns_rec.html +++ b/web/templates/admin/add_dns_rec.html @@ -1,118 +1,118 @@ - - - - - - - - - - - - -
- - - - - -
- - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - -
- Domain -
- - Record -
- - Type -
- -
- IP or Value -
- - Priority (optional) -
- - - -
-
-
+ + + + + + + + + + + + +
+ + + + + +
+ + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ + +
+ +
+ +
+ + () +
+ + + +
+
+
diff --git a/web/templates/admin/add_ip.html b/web/templates/admin/add_ip.html index 864f07c02..95aefc5ea 100644 --- a/web/templates/admin/add_ip.html +++ b/web/templates/admin/add_ip.html @@ -1,148 +1,148 @@ - - - - - - - - - - - - -
- - - - - - - -
- - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- IP -
- - Netmask -
- - Interface -
- -
- Shared -
- onclick="javascript:elementHideShow('usrtable');"> -
- - - - - - - -
- Assigned User -
- -
-
- Associated Domain (optional) -
- - - -
-
- + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ IP +
+ + +
+ + +
+ +
+ +
+ onclick="javascript:elementHideShow('usrtable');"> +
+ + + + + + + +
+ +
+ +
+
+ () +
+ + + +
+
+ diff --git a/web/templates/admin/add_mail.html b/web/templates/admin/add_mail.html index e49744085..1e6765158 100644 --- a/web/templates/admin/add_mail.html +++ b/web/templates/admin/add_mail.html @@ -1,95 +1,95 @@ - - - - - - - - - - - - - - - - - - -
- - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- Domain -
- - AntiSpam Support -
- > -
- AntiVirus Support -
- > -
- DKIM Support -
- > -
- - -
-
-
+ + + + + + + + + + + + +
+ + + + + +
+ + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ > +
+ +
+ > +
+ +
+ > +
+ + +
+
+
diff --git a/web/templates/admin/add_mail_acc.html b/web/templates/admin/add_mail_acc.html index dbfc66f38..e50dadba6 100644 --- a/web/templates/admin/add_mail_acc.html +++ b/web/templates/admin/add_mail_acc.html @@ -1,147 +1,147 @@ - - - - - - - - - - - - -
- - - - - - - -
- - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - -
- Domain -
- - Account -
- - Password generate -
- -
- Advanced Options -
- - - - - - - - - - - - - - - - -
- Quota (in megabytes) -
- - Aliases (use local-part) -
- -
- Forward to (email address or addresses) -
- -
-
- - -
-
-
+ + + + + + + + + + + + +
+ + + + + + + +
+ + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ + +
+ +
+ +
+ + + + + + + + + + + + + + + + +
+ () +
+ + () +
+ +
+ () +
+ +
+
+ + +
+
+
diff --git a/web/templates/admin/add_package.html b/web/templates/admin/add_package.html index 766b41d88..58fbea99b 100644 --- a/web/templates/admin/add_package.html +++ b/web/templates/admin/add_package.html @@ -10,7 +10,7 @@ - - - - -
- - - - - - - -
- - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Username -
- - Password generate -
- - Email -
- - Package -
- -
- First Name -
- - Last Name -
- - Send login credentials to the user's email address -
- > -
- - -
-
-
+ + + + + + + + + + + + +
+ + + + + + + +
+ + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ + +
+ + +
+ +
+ +
+ + +
+ + +
+ > +
+ + +
+
+
diff --git a/web/templates/admin/add_web.html b/web/templates/admin/add_web.html index 9d8d83ba8..531dfbe1b 100644 --- a/web/templates/admin/add_web.html +++ b/web/templates/admin/add_web.html @@ -1,382 +1,382 @@ - - - - - - - - - - - - -
- - - - - - + +
- - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- Domain -
- - IP address -
- -
- DNS support -
- > -
- Mail support -
- > -
- Advanced Options -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Domain Aliases -
- -
- Apache Template -
- -
- Nginx Support -
- onclick="javascript:elementHideShow('nginxtable');"> -
- - - - - - - -
- Nginx Supported Extentions -
- -
-
- SSL Support -
- onclick="javascript:elementHideShow('ssltable');"> -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- SSL HomeDirectory -
- -
- SSL Certificate -
- -
- SSL Key -
- -
- SSL Certificate Authority / Intermediate (optional) -
- -
-
- Web Statistics -
- -
- Web Statistic Authorization -
- onclick="javascript:elementHideShow('statstable');"> -
- - - - - - - - - - -
- Web Statistics Username -
- - Web Statistics Password generate -
- -
-
- Additional FTP Account -
- onclick="javascript:elementHideShow('ftptable');"> -
- - - - - - - - - - - - - - -
- FTP Username
- Prefix will be automaticaly added to username -
- - FTP Password generate -
- - Send FTP credentials to email -
- -
- - -
-
- + + + + + + + + +
+ +
+ + + + + + - -
+ + + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ +
+ +
+ > +
+ +
+ > +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ +
+ +
+ onclick="javascript:elementHideShow('nginxtable');"> +
+ + + + + + + +
+ +
+ +
+
+ +
+ onclick="javascript:elementHideShow('ssltable');"> +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ +
+ +
+ +
+ () +
+ +
+
+ +
+ +
+ +
+ onclick="javascript:elementHideShow('statstable');"> +
+ + + + + + + + + + +
+ +
+ + +
+ +
+
+ +
+ onclick="javascript:elementHideShow('ftptable');"> +
+ + + + + + + + + + + + + + +
+
+ +
+ + +
+ + +
+ +
+ + +
+
+ diff --git a/web/templates/admin/edit_cron.html b/web/templates/admin/edit_cron.html index edcaec9a3..1abcb713e 100644 --- a/web/templates/admin/edit_cron.html +++ b/web/templates/admin/edit_cron.html @@ -1,118 +1,118 @@ - - - - - - - - -
- -
- - - - - -
- - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- Minute -
- - Hour -
- - Day -
- - Month -
- - Day of Week -
- - Command -
- > -
- - -
-
-
+ + + + + + + + + + + + +
+ + + + + +
+ + + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ + +
+ + +
+ + +
+ + +
+ > +
+ + +
+
+
diff --git a/web/templates/admin/edit_db.html b/web/templates/admin/edit_db.html index e6a592b25..491c23d02 100644 --- a/web/templates/admin/edit_db.html +++ b/web/templates/admin/edit_db.html @@ -1,137 +1,137 @@ - - - - - - - - - - - -
- - - - - - - -
- - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - -
- Database -
- - Username -
- - Password generate -
- - Type -
- - Host -
- - Charset -
- - - -
-
-
+ + + + + + + + + + + +
+ + + + + + + +
+ + + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + + +
+
+
diff --git a/web/templates/admin/edit_dns.html b/web/templates/admin/edit_dns.html index 0a8380d2a..191d31886 100644 --- a/web/templates/admin/edit_dns.html +++ b/web/templates/admin/edit_dns.html @@ -1,127 +1,127 @@ - - - - - - - - - - - -
- - - - - -
- - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- Domain -
- - IP address -
- - Template -
- -
- Domain Expiriation(YYYY-MM-DD) -
- - SOA -
- - TTL -
- - - -
-
-
+ + + + + + + + + + + +
+ + + + + +
+ + + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ + +
+ +
+ () +
+ + SOA +
+ + TTL +
+ + + +
+
+
diff --git a/web/templates/admin/edit_dns_rec.html b/web/templates/admin/edit_dns_rec.html index 6354bb225..c65e54fcd 100644 --- a/web/templates/admin/edit_dns_rec.html +++ b/web/templates/admin/edit_dns_rec.html @@ -1,107 +1,107 @@ - - - - - - - - - - - -
- - - - - -
- - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - -
- Domain -
- - Record -
- - Type -
- - IP or Value -
- > -
- Priority (optional) -
- - - -
-
-
+ + + + + + + + + + + +
+ + + + + +
+ + + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ + +
+ + +
+ > +
+ () +
+ + + +
+
+
diff --git a/web/templates/admin/edit_ip.html b/web/templates/admin/edit_ip.html index 06a81c475..0dfb4b5fb 100644 --- a/web/templates/admin/edit_ip.html +++ b/web/templates/admin/edit_ip.html @@ -1,136 +1,136 @@ - - - - - - - - - - - -
- - - - - - - - -
- - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- IP -
- - Netmask -
- - Interface -
- - Shared -
- -
- Assigned User -
- -
- Associated Domain (optional) -
- - - -
-
-
+ + + + + + + + + + + +
+ + + + + + + + +
+ + + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ IP +
+ + +
+ + +
+ + +
+ +
+ +
+ +
+ () +
+ + + +
+
+
diff --git a/web/templates/admin/edit_mail.html b/web/templates/admin/edit_mail.html index 54928fdb8..4cc95658d 100644 --- a/web/templates/admin/edit_mail.html +++ b/web/templates/admin/edit_mail.html @@ -1,106 +1,106 @@ - - - - - - - - - - - -
- - - - - -
- - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Domain -
- - AntiSpam Support -
- > -
- AntiVirus Support -
- > -
- DKIM Support -
- > -
- Catchall Email -
- - - -
-
-
+ + + + + + + + + + + +
+ + + + + +
+ + + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ > +
+ +
+ > +
+ +
+ > +
+ +
+ + + +
+
+
diff --git a/web/templates/admin/edit_mail_acc.html b/web/templates/admin/edit_mail_acc.html index ed909bc89..450188400 100644 --- a/web/templates/admin/edit_mail_acc.html +++ b/web/templates/admin/edit_mail_acc.html @@ -9,7 +9,7 @@ - - - - -
- - - - - -
- - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Package Name -
- - Default Template -
- -
- System Shell -
- -
- Web Domains -
- - Web Aliases (per domain) -
- - DNS Domains -
- - DNS Records (per domain) -
- - Mail Domains -
- - Mail Accounts (per domain) -
- - Databases -
- - Cron Jobs -
- - Backups -
- - Disk Quota (in Mb) -
- - Bandwidth (in Mb) -
- - Name Servers -
- - - -
-
-
+ + + + + + + + + + + +
+ + + + + +
+ + + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ +
+ +
+ +
+ +
+ + () +
+ + +
+ + () +
+ + +
+ + () +
+ + +
+ + +
+ + +
+ + () +
+ + () +
+ + +
+ + + +
+
+
From 8fb1fa54825588c12a5c64c5120b6b1a39fb88f6 Mon Sep 17 00:00:00 2001 From: ZonD Eighty Date: Tue, 15 Jan 2013 15:40:26 +0400 Subject: [PATCH 06/11] Admin interface translated to Russian, bugfixes. Note, TESTING PURPOSES ONLY, ERROR_REPORTING = E_ALL. Pending: User interface to Russian, English Re-Translation, E_NOTICE fixes --- web/add/mail/index.php | 4 +- web/inc/i18n/ru.php | 131 ++++- web/list/user/index.php | 68 +-- web/templates/admin/add_mail.html | 2 +- web/templates/admin/edit_user.html | 414 +++++++-------- web/templates/admin/edit_web.html | 702 ++++++++++++------------- web/templates/admin/list_backup.html | 40 +- web/templates/admin/list_cron.html | 42 +- web/templates/admin/list_db.html | 42 +- web/templates/admin/list_dns.html | 44 +- web/templates/admin/list_dns_rec.html | 36 +- web/templates/admin/list_ip.html | 30 +- web/templates/admin/list_log.html | 6 +- web/templates/admin/list_mail.html | 52 +- web/templates/admin/list_mail_acc.html | 44 +- web/templates/admin/list_packages.html | 58 +- web/templates/admin/list_rrd.html | 12 +- web/templates/admin/list_search.html | 30 +- web/templates/admin/list_stats.html | 44 +- web/templates/admin/list_user.html | 102 ++-- web/templates/admin/list_web.html | 54 +- 21 files changed, 1031 insertions(+), 926 deletions(-) diff --git a/web/add/mail/index.php b/web/add/mail/index.php index 6ce745591..d9a7def43 100644 --- a/web/add/mail/index.php +++ b/web/add/mail/index.php @@ -61,7 +61,7 @@ top_panel($user,$TAB); unset($output); if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = _("DOMAIN_MAIL_CREATED_OK",$_POST[v_domain],$_POST[v_domain]); + $_SESSION['ok_msg'] = _("DOMAIN_MAIL_CREATED_OK",$_POST['v_domain'],$_POST['v_domain']); unset($v_domain); } } @@ -162,7 +162,7 @@ top_panel($user,$TAB); if ((empty($_GET['domain'])) && (empty($_POST['domain']))) { - $v_domain = $_GET['domain']; + $v_domain = (isset($_GET['domain'])?$_GET['domain']:''); include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_mail.html'); unset($_SESSION['error_msg']); unset($_SESSION['ok_msg']); diff --git a/web/inc/i18n/ru.php b/web/inc/i18n/ru.php index 2eaa9211a..9ff7dedcd 100644 --- a/web/inc/i18n/ru.php +++ b/web/inc/i18n/ru.php @@ -28,6 +28,7 @@ $LANG = array( 'password'=>'пароль', 'type'=>'тип', 'charset'=>'кодировка', + 'edit'=>'ред.', 'DATABASE_CREATED_OK'=>'Успех: База данных %s успешно создана.', 'domain'=>'домен', 'ip'=>'IP', @@ -42,6 +43,7 @@ $LANG = array( 'IP_CREATED_OK'=>'"Успех: ip-адрес %s успешно создан.', 'DOMAIN_MAIL_CREATED_OK'=>'Успех: почта для домена %s подключена успешно', 'account'=>'аккаунт', + 'Account'=>'Аккаунт', 'password'=>'пароль', 'MAIL_ACCOUNT_CREATED_OK'=>'Успех: почтовый аккаунт %s@%s успешно создан.', 'package'=>'пакет', @@ -49,18 +51,19 @@ $LANG = array( 'shell'=>'SSH', 'web domains'=>'хосты', 'Web Domains'=>'Хосты', - 'Web Aliases'=>'Перенаправления Хостов', + 'Web Aliases'=>'Алиасы Хостов', 'per domain'=>'на домен', 'DNS domains'=>'домены для DNS', 'DNS records count'=>'Кол-во DNS записей', 'DNS Support'=>'Поддержка DNS', 'Mail Support'=>'Поддержка почты', - 'web aliases'=>'перенаправления хостов', + 'web aliases'=>'алиасы хостов', 'dns records'=>'DNS записи', 'mail domains'=>'домены с почтой', 'mail accounts'=>'почтовые аккаунты', 'Mail Domains'=>'Домены с Почтой', 'Mail Accounts'=>'Почтовые Аккаунты', + 'accounts'=>'аккаунты', 'databases'=>'базы данных', 'Databases'=>'Базы Данных', 'cron jobs'=>'cron задания', @@ -70,7 +73,6 @@ $LANG = array( 'quota'=>'квота диска', 'bandwidth'=>'ширина канала', 'Bandwidth'=>'Ширина канала', - 'ns1'=>'DNS-сервер #1', 'ns2'=>'DNS-сервер #2', 'PACKAGE_CREATED_OK'=>'Успех: Пакет %s успешно создан.', @@ -91,7 +93,7 @@ $LANG = array( 'SSL Support'=>'Поддержка SSL', 'SSL Home Directory'=>'Корневая папка для SSL', 'SSL Certificate'=>'SSL сертификат', - 'SSL key'=>'Ключ SSL сертификата', + 'SSL Key'=>'Ключ SSL сертификата', 'SSL Certificate Authority / Intermediate'=>'Центр сертификации SSL CA / Intermediate', 'stats user password'=>'пароль для доступа к статистике', 'stats username'=>'имя пользователя статистики', @@ -134,8 +136,10 @@ $LANG = array( 'Advanced options'=>'Расширенные опции', 'Template'=>'Шаблон', 'Expiration date'=>'Дата окончания делегирования', + 'Expire'=>'Конец', 'YYYY-MM-DD'=>'ГГГГ-ММ-ДД', 'Name servers'=>'Сервера имен', + 'Name Servers'=>'Сервера Имен', 'Powered by Vesta Control Panel'=>'Работает на Панели Управления Vesta', 'Vesta Control Panel'=>'Панель Управления Vesta', 'Translation by ZonD80'=>'Перевод ZonD80', @@ -152,15 +156,18 @@ $LANG = array( 'Statistics'=>'Статистика', 'History Log'=>'История изменений', 'Vesta logo'=>'Логотип Vesta', - 'USER'=>'ПОЛЬЗОВАТЕЛИ', + 'USER'=>'ПОЛЬЗ-ЛИ', + 'logout'=>'выйти', 'users'=>'пользователи', - 'suspended'=>'заблокировано', + 'Users'=>'Пользователи', + 'suspended'=>'выключено', 'WEB'=>'ХОСТИНГ', 'domains'=>'домены', - 'aliases'=>'перенаправления', - 'Aliases'=>'Перенаправления', + 'aliases'=>'алиасы', + 'Aliases'=>'Алиасы', 'DNS'=>'DNS', 'records'=>'записи', + 'Records'=>'Записи', 'MAIL'=>'ПОЧТА', 'DB'=>'БД', 'CRON'=>'CRON', @@ -170,7 +177,8 @@ $LANG = array( 'RRD Graphics'=>'Графики', 'jobs'=>'Задания', 'Reset Code'=>'Код сброса', - 'disk'=>'Место', + 'disk'=>'место', + 'Disk'=>'Место', 'traffic'=>'Трафик', 'Database Credentials'=>'Данные для доступа к БД', 'DATABASE_READY'=>"Здравствуйте %s %s,\nВаша %s база данных создана успешно.\n\nИмя БД: %s_%s\nПользователь: %s_%s\nПароль: %s\n\n", @@ -198,7 +206,7 @@ $LANG = array( 'Adding Package'=>'Создание пакета', 'Package Name'=>'Название пакета', 'Package'=>'Пакет', - 'Default Template'=>'Шаблон по-умолчанию', + 'Default Template'=>'Шаблон по умолчанию', 'SSH Access'=>'Доступ к SSH', 'Adding User'=>'Добавления пользователя', 'First Name'=>'Имя', @@ -217,11 +225,108 @@ $LANG = array( 'Editing DNS Record'=>'Редактирование DNS записи', 'Editing IP Address'=>'Редактирование IP-адреса', 'Editing Mail Domain'=>'Редактирование почты для домена', - 'Catchall email'=>'Общий email-адрес', + 'Catchall email'=>'Отправить почту в', 'Editing Mail Account'=>'Редактирование почтового акканунта', 'Autoreply'=>'Автоответчик', 'Message'=>'Сообщение', 'Editing Package'=>'Редактирование Пакета', + 'Editing User'=>'Редактирование Пользователя', + 'Default Name Servers'=>'DNS по умолчанию', + 'Editing Domain'=>'Редактирование хостинга', + 'Create Backup'=>'Создать Бэкап', + 'apply to selected'=>'применить к выбранным', + 'toggle all'=>'снять/выделить все', + 'delete'=>'удалить', + 'active'=>'активно', + 'download'=>'скачать', + 'Owner'=>'Владелец', + 'restore'=>'восстановить', + 'BACKUP_DELETE_CONFIRMATION'=>'Вы уверены, что хотите удалить %s бэкап?', + 'Run Time'=>'Время Запуска', + 'Backup Size'=>'Размер Бэкапа', + 'SYS'=>'Системное', + 'one archive'=>'один архив', + '%s archives'=>'%s архивов', + 'Add Cron Job'=>'Добавить новое Cron-задание', + 'add account'=>'добавить аккаунт', + 'open webmail'=>'открыть веб-интерфейс', + 'suspend'=>'выключить', + 'unsuspend'=>'включить', + 'CRON_ACTION_CONFIRMATION'=>'Вы уверены, что хотите %s cron-задание?', + 'Confirmation'=>'Подтверждение', + 'one cron job'=>'одно cron-задание', + '%s cron jobs'=>'%s cron-заданий', + 'Add Database'=>'Добавить БД', + 'open %s'=>'открыть %s', + 'DATABASE_ACTION_CONFIRMATION'=>'Вы уверены, что хотите %s базу данных %s?', + 'one database'=>'одна БД', + '%s databases'=>'%s БД', + 'Add DNS Domain'=>'Добавить DNS для домена', + 'Search'=>'Поиск', + 'LIST_DOMAIN_RECORDS'=>'Посмотреть %s записей', + 'add record'=>'добавить запись', + 'DOMAIN_ACTION_CONFIRMATION'=>'Вы уверены, что хотите %s домен %s?', + 'one domain'=>'Один домен', + '%s domains'=>'%s домена(ов)', + 'Add DNS Record'=>'Добавить DNS запись', + 'Listing'=>'Просмотр', + 'list'=>'посмотреть', + 'RECORD_ACTION_CONFIRMATION'=>'Вы уверены, что хотите %s запись %s?', + 'one DNS record'=>'одна DNS-запись', + '%s DNS records'=>'%s DNS-записи(ей)', + 'Add IP'=>'Добавить IP адрес', + 'IP_DELETE_CONFIRMATION'=>'Вы уверены, что хотите удалить IP адрес %s?', + 'Status'=>'Статус', + 'one IP address'=>'один IP', + '%s IP addresses'=>'%s IP адреса(ов)', + 'one log record'=>'одна запись', + '%s log records'=>'%s записи(ей)', + 'Add Mail Domain'=>'Добавить почту для домена', + 'MAIL_ACTION_CONFIRMATION'=>'Вы уверены, что хотите %s почту для домена %s?', + 'one domain with email'=>'один домен с почтой', + '%s domains with email'=>'%s домена(ов) с почтой', + 'Add Mail Account'=>'Добавить почтовый аккаунт', + 'MAIL_ACCOUNT_ACTION_CONFIRMATION'=>'Вы уверены, что хотите %s почтовый ящик %s?', + 'one mail account'=>'один почтовый ящик', + '%s mail accounts'=>'%s почтовых ящика(ов)', + 'Add Package'=>'Добавить пакет', + 'PACKAGE_DELETE_CONFIRMATION'=>'Вы уверены, что хотите удалить пакет %s?', + 'one package'=>'один пакет', + '%s packages'=>'%s пакета(ов)', + 'Daily'=>'Ежедневый', + 'Weekly'=>'Еженедельный', + 'Monthly'=>'Ежемесячный', + 'Yearly'=>'Ежегодный', + 'Search Results'=>'Результаты Поиска', + 'login as'=>'войти как', + 'ARE_YOU_FUCKING_SURE'=>'Вы уверены, что хотите %s %s?', + 'Object'=>'Объект', + 'one object'=>'один объект', + '%s objects'=>'%s объекта(ов)', + 'Overall Statistics'=>'Вся Статистика', + 'show per user'=>'показать для пользователя', + 'Hosting'=>'Хостинг', + 'Mail'=>'Почта', + 'User Directories'=>'Папки пользователя', + 'Web SSL Domains'=>'Хосты с SSL', + 'one month'=>'один месяц', + '%s months'=>'%s месяца(ев)', + 'Add User'=>'Добавить Пользователя', + 'Add Domain'=>'Добавить Домен', + 'rebuild'=>'перестроить', + 'rebuild web'=>'перестроить хостинг', + 'rebuild DNS'=>'перестроить DNS', + 'rebuild mail'=>'перестроить почту', + 'rebuild db'=>'перестроить БД', + 'rebuild cron'=>'перестроить cron', + 'update counters'=>'обновить счетчики', + 'LOGGED_IN_AS'=>'Вы вошли как %s', + 'USER_ACTION_CONFIRMATION'=>'Вы уверены, что хотите %s пользователя %s?', + 'one account'=>'один аккаунт', + '%s accounts'=>'%s аккаунта(ов)', + 'Add Domain for hosting'=>'Добавить Домен для хостинга', + 'open webstats'=>'открыть ститистику', +); - -); \ No newline at end of file +error_reporting(E_ALL); +ini_set('display_errors',true); \ No newline at end of file diff --git a/web/list/user/index.php b/web/list/user/index.php index 35d15c48d..ba1f60df9 100644 --- a/web/list/user/index.php +++ b/web/list/user/index.php @@ -1,34 +1,34 @@ - - > + > diff --git a/web/templates/admin/edit_user.html b/web/templates/admin/edit_user.html index 4bebfb8c1..cd6c342c7 100644 --- a/web/templates/admin/edit_user.html +++ b/web/templates/admin/edit_user.html @@ -1,207 +1,207 @@ - - - - - - - - - - - -
- - - - - - -
- - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Username -
- - Password generate -
- - Email -
- - Package -
- -
- Frist Name -
- - Last Name -
- - Default Template -
- -
- Shell -
- -
- Default Name Servers -
- - - -
-
-
+ + + + + + + + + + + +
+ + + + + + +
+ + + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ + +
+ + +
+ +
+ +
+ + +
+ + +
+ +
+ +
+ +
+ +
+ + + +
+
+
diff --git a/web/templates/admin/edit_web.html b/web/templates/admin/edit_web.html index 442fc75d7..4209f3558 100644 --- a/web/templates/admin/edit_web.html +++ b/web/templates/admin/edit_web.html @@ -1,352 +1,352 @@ - - - - - - - - - - - -
- - - - - + +
- - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Domain -
- - IP address -
- -
- Aliases -
- -
- Template -
- -
- Nginx Support -
- onclick="javascript:elementHideShow('nginxtable');"> -
- - - - - - - -
- Nginx Supported Extentions -
- -
-
- SSL Support -
- onclick="javascript:elementHideShow('ssltable');"> -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- SSL HomeDirectory -
- -
- SSL Certificate -
- -
- SSL Key -
- -
- SSL Certificate Authority / Intermediate (optional) -
- -
-
- Web Statistics -
- -
- Web Statistic Authorization -
- onclick="javascript:elementHideShow('statstable');"> -
- - - - - - - - - - -
- Web Statistics Username -
- - Web Statistics Password generate -
- -
-
- Additional FTP Account -
- onclick="javascript:elementHideShow('ftptable');"> -
- - - - - - - - - - - - - -
- FTP Username - Prefix '.$user.'_ will be automaticaly added to username' ?> -
- - FTP Password generate -
- - Send FTP credentials to email -
- - - -
-
- + + + + + + + +
+ +
+ + + + + + +
+ + + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ +
+ +
+ +
+ +
+ +
+ +
+ onclick="javascript:elementHideShow('nginxtable');"> +
+ + + + + + + +
+ +
+ +
+
+ +
+ onclick="javascript:elementHideShow('ssltable');"> +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ +
+ +
+ +
+ () +
+ +
+
+ +
+ +
+ +
+ onclick="javascript:elementHideShow('statstable');"> +
+ + + + + + + + + + +
+ +
+ + +
+ +
+
+ +
+ onclick="javascript:elementHideShow('ftptable');"> +
+ + + + + + + + + + + + + +
+ + Prefix '.$user.'_ will be automaticaly added to username' ?> +
+ + +
+ + +
+ + + +
+
+ \ No newline at end of file diff --git a/web/templates/admin/list_backup.html b/web/templates/admin/list_backup.html index 8a6899931..0e15fb821 100644 --- a/web/templates/admin/list_backup.html +++ b/web/templates/admin/list_backup.html @@ -3,7 +3,7 @@
- +
@@ -13,10 +13,10 @@
- toggle all +
@@ -49,21 +49,21 @@ - +
">
active
- - + + @@ -85,12 +85,12 @@
download"> restore "> - delete + " /> -
- Run Time: + :
- Backup Size: + :
@@ -99,7 +99,7 @@ - -
- SYS: + : @@ -109,7 +109,7 @@
- WEB: + : @@ -119,7 +119,7 @@
- DNS: + : @@ -133,7 +133,7 @@ diff --git a/web/templates/admin/list_cron.html b/web/templates/admin/list_cron.html index c511735c1..07101724d 100644 --- a/web/templates/admin/list_cron.html +++ b/web/templates/admin/list_cron.html @@ -2,7 +2,7 @@ + +
- MAIL: + : @@ -143,7 +143,7 @@
- DB: + : @@ -153,7 +153,7 @@
- CRON: + : @@ -181,9 +181,9 @@
- +
@@ -12,12 +12,12 @@
- toggle all +
@@ -48,28 +48,28 @@ - +
">
- + @@ -86,7 +86,7 @@
edit - + - - delete + -
@@ -100,7 +100,7 @@
- Min +
@@ -114,7 +114,7 @@
- Hour +
@@ -128,7 +128,7 @@
- Day +
@@ -142,7 +142,7 @@
- Month +
@@ -169,9 +169,9 @@ diff --git a/web/templates/admin/list_db.html b/web/templates/admin/list_db.html index 30a265166..08f29f5c7 100644 --- a/web/templates/admin/list_db.html +++ b/web/templates/admin/list_db.html @@ -3,7 +3,7 @@ - -
- Day of Week +
- +
@@ -13,12 +13,12 @@
- toggle all +
@@ -52,29 +52,29 @@ - +
">
- - + + @@ -90,11 +90,11 @@
open edit - + " /> - delete " /> -
- + +
- [] database + []
Disk: + :
@@ -106,7 +106,7 @@ + +
- User: + : @@ -114,7 +114,7 @@
- Host: + : @@ -126,7 +126,7 @@ diff --git a/web/templates/admin/list_dns.html b/web/templates/admin/list_dns.html index 0aee68101..143b293db 100644 --- a/web/templates/admin/list_dns.html +++ b/web/templates/admin/list_dns.html @@ -2,22 +2,22 @@ diff --git a/web/templates/admin/list_dns_rec.html b/web/templates/admin/list_dns_rec.html index ee8237231..eda5e6615 100644 --- a/web/templates/admin/list_dns_rec.html +++ b/web/templates/admin/list_dns_rec.html @@ -2,22 +2,22 @@ - -
- Charset: + : @@ -150,9 +150,9 @@
- +
- +
- toggle all +
@@ -47,30 +47,30 @@ - +
" >
">
- - - + + + @@ -90,7 +90,7 @@
list records add record edit - + - - delete + -
- [] template + []
@@ -110,11 +110,11 @@
- + - +
Expire::
Records::
@@ -135,9 +135,9 @@
- +
- +
- toggle all +
@@ -33,7 +33,7 @@
- Listing +
@@ -56,28 +56,28 @@ - +
">
- + @@ -104,9 +104,9 @@ diff --git a/web/templates/admin/list_ip.html b/web/templates/admin/list_ip.html index 3e4a80712..fb383baa6 100644 --- a/web/templates/admin/list_ip.html +++ b/web/templates/admin/list_ip.html @@ -3,20 +3,20 @@ + +
edit - + - - delete + -
- +
- +
- toggle all +
@@ -40,20 +40,20 @@ - +
">
active
- + @@ -84,7 +84,7 @@
edit - delete + " /> -
diff --git a/web/templates/admin/list_log.html b/web/templates/admin/list_log.html index b1f2dab35..f549871a5 100644 --- a/web/templates/admin/list_log.html +++ b/web/templates/admin/list_log.html @@ -7,7 +7,7 @@
- +
@@ -60,9 +60,9 @@ diff --git a/web/templates/admin/list_mail.html b/web/templates/admin/list_mail.html index 000a4e8f7..e12738baf 100644 --- a/web/templates/admin/list_mail.html +++ b/web/templates/admin/list_mail.html @@ -2,22 +2,22 @@ + +
- Web Domains: + : @@ -92,7 +92,7 @@
- Status: + : @@ -104,7 +104,7 @@
- Sys Users: + :
@@ -126,9 +126,9 @@
- +
- +
- toggle all +
@@ -51,31 +51,31 @@ - +
" >
">
- - - - + + + + @@ -92,12 +92,12 @@
list accounts add account" target="_blank"> open webmail edit " target="_blank"> - + - - delete + -
- -
- catchall > + >
- Disk: + :
@@ -109,7 +109,7 @@ + +
- Antivirus: + : @@ -117,7 +117,7 @@
- Antispam: + : @@ -129,7 +129,7 @@ diff --git a/web/templates/admin/list_mail_acc.html b/web/templates/admin/list_mail_acc.html index f13e33caf..4632ffb29 100644 --- a/web/templates/admin/list_mail_acc.html +++ b/web/templates/admin/list_mail_acc.html @@ -2,22 +2,22 @@ - -
- DKIM: + : @@ -137,7 +137,7 @@
- Accounts: + : @@ -162,9 +162,9 @@
- +
- +
- toggle all +
@@ -33,7 +33,7 @@
- Listing +
@@ -56,28 +56,28 @@ - +
">
- + @@ -94,7 +94,7 @@ + +
edit - + - - delete + -
- Disk: + :
@@ -106,7 +106,7 @@ - -
- Quota: + : @@ -114,7 +114,7 @@
- Autoreply: + : @@ -126,7 +126,7 @@ diff --git a/web/templates/admin/list_packages.html b/web/templates/admin/list_packages.html index 853164e6c..a89b29644 100644 --- a/web/templates/admin/list_packages.html +++ b/web/templates/admin/list_packages.html @@ -3,20 +3,20 @@ + +
- Forward: + : @@ -151,9 +151,9 @@
- +
- +
- toggle all +
@@ -40,20 +40,20 @@ - +
">
active
- + @@ -69,7 +69,7 @@
edit - delete + " /> -
- -
- Defaul Template: + : @@ -77,7 +77,7 @@
- System Shell: + : @@ -85,7 +85,7 @@
- Bandwidth: + :
@@ -93,7 +93,7 @@
- Disk: + :
@@ -105,7 +105,7 @@ + +
- Web Domains: + : @@ -113,15 +113,15 @@
- Web Aliases: + : - per domain +
- Dns Domains: + : @@ -129,15 +129,15 @@
- Dns Records: + : - per domain +
- Name Servers: + : @@ -149,7 +149,7 @@ diff --git a/web/templates/admin/list_rrd.html b/web/templates/admin/list_rrd.html index fc9f1220d..df604a20e 100644 --- a/web/templates/admin/list_rrd.html +++ b/web/templates/admin/list_rrd.html @@ -3,15 +3,15 @@ @@ -43,7 +43,7 @@
- Mail Domains: + : @@ -157,15 +157,15 @@
- Mail Accounts: + : - per domain +
- Databases: + : @@ -173,7 +173,7 @@
- Cron Jobs: + : @@ -181,7 +181,7 @@
- Backups: + : @@ -206,9 +206,9 @@
- +
- +
" target="_blank"> download" target="_blank">
diff --git a/web/templates/admin/list_search.html b/web/templates/admin/list_search.html index 3f04096eb..b58001453 100644 --- a/web/templates/admin/list_search.html +++ b/web/templates/admin/list_search.html @@ -3,12 +3,12 @@ @@ -41,7 +41,7 @@ @@ -157,7 +157,7 @@
- +
- +
">
@@ -54,7 +54,7 @@ ?> - login as + - + '; } ?> - - delete +
- -
- Object: + : @@ -169,7 +169,7 @@ diff --git a/web/templates/admin/list_stats.html b/web/templates/admin/list_stats.html index aeae10115..59a7f1d4b 100644 --- a/web/templates/admin/list_stats.html +++ b/web/templates/admin/list_stats.html @@ -4,10 +4,10 @@ @@ -67,12 +67,12 @@
- Owner: + : @@ -181,10 +181,10 @@
- Status: + : - +
@@ -206,9 +206,9 @@
- href='/list/stats/'>Overall Statistics + href='/list/stats/'> - +
+ +
- [] package + []
- Bandwidth: % () + : % ()
@@ -80,7 +80,7 @@
- Disk: % () + : % ()
@@ -91,12 +91,12 @@
- Web:
- Mail:
+ :
+ :
- Databases:
- User Dirs:
+ :
+ :
@@ -108,7 +108,7 @@ - + @@ -126,16 +126,16 @@ - -
- Web Domains: + : @@ -116,7 +116,7 @@
- Web SSL: + : @@ -124,7 +124,7 @@
- Web Aliases: + : @@ -132,7 +132,7 @@
- Dns Domains: + : @@ -140,7 +140,7 @@
- Dns Records: + : @@ -152,7 +152,7 @@ diff --git a/web/templates/admin/list_user.html b/web/templates/admin/list_user.html index 165981710..9c22513b3 100644 --- a/web/templates/admin/list_user.html +++ b/web/templates/admin/list_user.html @@ -5,33 +5,33 @@
Add User "; + echo ""; } else { - echo ""; + echo ""; } ?>
- +
- toggle all +
@@ -61,7 +61,7 @@
- Mail Domains: + : @@ -160,7 +160,7 @@
- Mail Accounts: + : @@ -168,7 +168,7 @@
- Databases: + : @@ -176,7 +176,7 @@
- Cron Jobs: + : @@ -184,7 +184,7 @@
- Dedicated IP: + : @@ -209,9 +209,9 @@
- +
">
@@ -71,7 +71,7 @@ logout"; + echo " "; if (!empty($_SESSION['look_alert'])) { ?>
-

You have logged in as user .

+

login as"; + echo " "; } ?>
"> edit"> - + - delete -
- + - - diff --git a/web/templates/admin/list_web.html b/web/templates/admin/list_web.html index c970a04fe..3527bd8f7 100644 --- a/web/templates/admin/list_web.html +++ b/web/templates/admin/list_web.html @@ -3,22 +3,22 @@ '; + echo ' '._('open webstats').' '; } ?> - + @@ -128,19 +128,19 @@ - From c094d8582d368c6770f3284ba178218232c210ca Mon Sep 17 00:00:00 2001 From: ZonD Eighty Date: Wed, 16 Jan 2013 14:12:53 +0400 Subject: [PATCH 07/11] Merge changes from upstream --- bin/v-add-dns-on-web-alias | 105 +- bin/v-add-web-domain-ftp | 88 +- bin/v-list-sys-services | 188 +++ bin/v-list-user-stats | 3 + bin/v-list-users-stats | 3 + bin/v-rebuild-user | 2 +- bin/v-rebuild-web-domains | 317 +--- bin/v-restart-cron | 6 +- bin/v-restart-dns | 7 +- bin/v-restart-mail | 7 +- bin/v-restart-service | 42 + bin/v-restart-web | 22 +- bin/v-start-service | 42 + bin/v-stop-service | 42 + bin/v-update-user-stats | 174 +- func/domain.sh | 14 +- func/main.sh | 2 +- install/0.9.7/rhel/roundcube-driver.php | 103 +- .../rhel/templates/web/apache_phpcgi.stpl | 69 +- .../rhel/templates/web/apache_phpcgi.tpl | 55 +- .../rhel/templates/web/apache_phpfcgid.stpl | 71 +- .../rhel/templates/web/apache_phpfcgid.tpl | 55 +- install/vst-install.sh | 676 +------- web/add/db/index.php | 200 +-- web/bulk/service/index.php | 28 + web/css/jquery-custom-dialogs.css | 1090 ++++++------- web/edit/web/index.php | 1203 +++++++------- web/images/logo.png | Bin 5953 -> 5014 bytes web/images/start.png | Bin 0 -> 208 bytes web/images/stop.png | Bin 0 -> 150 bytes web/inc/i18n/ru.php | 3 + web/inc/main.php | 334 ++-- web/js/events.js | 248 +-- web/list/log/index.php | 49 +- web/list/services/index.php | 23 + web/restart/service/index.php | 22 + web/start/service/index.php | 22 + web/stop/service/index.php | 22 + web/templates/admin/add_db.html | 368 ++--- web/templates/admin/list_dns.html | 292 ++-- web/templates/admin/list_dns_rec.html | 230 +-- web/templates/admin/list_mail.html | 346 ++-- web/templates/admin/list_mail_acc.html | 324 ++-- web/templates/admin/list_rrd.html | 144 +- web/templates/admin/list_services.html | 152 ++ web/templates/admin/list_stats.html | 442 ++--- web/templates/admin/panel.html | 224 +-- web/templates/footer.html | 10 +- web/templates/header.html | 1444 +++++++++-------- web/templates/user/list_dns.html | 272 ++-- web/templates/user/list_dns_rec.html | 210 +-- web/templates/user/list_mail.html | 326 ++-- web/templates/user/list_mail_acc.html | 304 ++-- web/templates/user/panel.html | 227 +-- 54 files changed, 4981 insertions(+), 5671 deletions(-) create mode 100755 bin/v-list-sys-services create mode 100755 bin/v-restart-service create mode 100755 bin/v-start-service create mode 100755 bin/v-stop-service create mode 100644 web/bulk/service/index.php create mode 100644 web/images/start.png create mode 100644 web/images/stop.png create mode 100644 web/list/services/index.php create mode 100644 web/restart/service/index.php create mode 100644 web/start/service/index.php create mode 100644 web/stop/service/index.php create mode 100644 web/templates/admin/list_services.html diff --git a/bin/v-add-dns-on-web-alias b/bin/v-add-dns-on-web-alias index f4889da67..c5890b184 100755 --- a/bin/v-add-dns-on-web-alias +++ b/bin/v-add-dns-on-web-alias @@ -1,4 +1,3 @@ -<<<<<<< HEAD #!/bin/bash # info: add dns domain or dns record based on web domain alias restart # options: USER DOMAIN @@ -50,15 +49,21 @@ get_domain_values 'web' # Check if it a simple domain if [ $(echo -e "${dom_alias//\./\n}" | wc -l) -le 2 ]; then if [ ! -e "$USER_DATA/dns/$dom_alias.conf" ]; then - $BIN/v-add-dns-domain $user $dom_alias $IP '' '' '' '' '' $restart + $BIN/v-add-dns-domain \ + $user $dom_alias $IP '' '' '' '' '' $restart > /dev/null fi else # Check subdomain sub=$(echo "$dom_alias" | cut -f1 -d . -s) dom=$(echo "$dom_alias" | sed -e "s/^$sub.//" ) if [ ! -e "$USER_DATA/dns/$dom.conf" ]; then - $BIN/v-add-dns-domain $user $dom $IP '' '' '' '' '' $restart - $BIN/v-add-dns-domain-record $user $dom "$sub" A $IP '' '' $restart + $BIN/v-add-dns-domain \ + $user $dom $IP '' '' '' '' '' $restart > /dev/null + + if [ $? -eq 0 ]; then + $BIN/v-add-dns-domain-record \ + $user $dom "$sub" A $IP '' '' $restart + fi else if [ "$sub" == '*' ]; then rec=$(grep -w "RECORD='\*'" $USER_DATA/dns/$dom.conf) @@ -66,7 +71,8 @@ else rec=$(grep -w "RECORD='$sub'" $USER_DATA/dns/$dom.conf) fi if [ -z "$rec" ]; then - $BIN/v-add-dns-domain-record $user $dom "$sub" A $IP '' '' $restart + $BIN/v-add-dns-domain-record \ + $user $dom "$sub" A $IP '' '' $restart > /dev/null fi fi fi @@ -79,92 +85,3 @@ fi # No Logging exit -======= -#!/bin/bash -# info: add dns domain or dns record based on web domain alias restart -# options: USER DOMAIN -# -# The function adds dns domain or dns record based on web domain alias. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g') -domain_idn=$(idn -t --quiet -a "$domain") -dom_alias=$(idn -t --quiet -u "$3" ) -dom_alias=$(echo $dom_alias | sed -e 's/\.*$//g' -e 's/^\.*//g') -dom_alias=$(echo $dom_alias | tr '[:upper:]' '[:lower:]') -dom_alias_idn=$(idn -t --quiet -a "$dom_alias" ) -restart="$4" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN ALIAS' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain values -get_domain_values 'web' - -# Check if it a simple domain -if [ $(echo -e "${dom_alias//\./\n}" | wc -l) -le 2 ]; then - if [ ! -e "$USER_DATA/dns/$dom_alias.conf" ]; then - $BIN/v-add-dns-domain \ - $user $dom_alias $IP '' '' '' '' '' $restart > /dev/null - fi -else - # Check subdomain - sub=$(echo "$dom_alias" | cut -f1 -d . -s) - dom=$(echo "$dom_alias" | sed -e "s/^$sub.//" ) - if [ ! -e "$USER_DATA/dns/$dom.conf" ]; then - $BIN/v-add-dns-domain \ - $user $dom $IP '' '' '' '' '' $restart > /dev/null - - if [ $? -eq 0 ]; then - $BIN/v-add-dns-domain-record \ - $user $dom "$sub" A $IP '' '' $restart - fi - else - if [ "$sub" == '*' ]; then - rec=$(grep -w "RECORD='\*'" $USER_DATA/dns/$dom.conf) - else - rec=$(grep -w "RECORD='$sub'" $USER_DATA/dns/$dom.conf) - fi - if [ -z "$rec" ]; then - $BIN/v-add-dns-domain-record \ - $user $dom "$sub" A $IP '' '' $restart > /dev/null - fi - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# No Logging - -exit ->>>>>>> 994c40901078e48fe939536f7b366e29c2e44a1d diff --git a/bin/v-add-web-domain-ftp b/bin/v-add-web-domain-ftp index 69c58673d..4644f8df7 100755 --- a/bin/v-add-web-domain-ftp +++ b/bin/v-add-web-domain-ftp @@ -1,4 +1,3 @@ -<<<<<<< HEAD #!/bin/bash # info: add ftp account for web domain. # options: USER DOMAIN FTP_USER FTP_PASSWORD @@ -44,8 +43,14 @@ is_object_unsuspended 'web' 'DOMAIN' "$domain" # Action # #----------------------------------------------------------# -# Get domain values get_domain_values 'web' +check_ftp_user=$(grep "^$ftp_user:" /etc/passwd) +if [ ! -z "$check_ftp_user" ] && [ "$FTP_USER" != "$ftp_user" ]; then + echo "Error: ftp user $ftp_user already exists" + log_event "$E_EXISTS $EVENT" + exit $E_EXISTS +fi + if [ ! -z "$FTP_USER" ]; then /usr/sbin/userdel $FTP_USER fi @@ -70,82 +75,3 @@ log_history "added ftp account $ftp_user for $domain" log_event "$OK" "$EVENT" exit -======= -#!/bin/bash -# info: add ftp account for web domain. -# options: USER DOMAIN FTP_USER FTP_PASSWORD -# -# The function creates addutional ftp account for web domain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -ftp_user=${1}_${3} -ftp_password=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - -# Hiding password -A4='******' -EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'" -EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'" - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'USER DOMAIN FTP_USER FTP_PASSWORD' -validate_format 'user' 'domain' 'ftp_user' 'ftp_password' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -get_domain_values 'web' -check_ftp_user=$(grep "^$ftp_user:" /etc/passwd) -if [ ! -z "$check_ftp_user" ] && [ "$FTP_USER" != "$ftp_user" ]; then - echo "Error: ftp user $ftp_user already exists" - log_event "$E_EXISTS $EVENT" - exit $E_EXISTS -fi - -if [ ! -z "$FTP_USER" ]; then - /usr/sbin/userdel $FTP_USER -fi - -# Adding user -/usr/sbin/adduser $ftp_user -g $user -s /sbin/nologin -M \ - -d "$HOMEDIR/$user/web/$domain" > /dev/null 2>&1 -echo "$ftp_password" | /usr/bin/passwd "$ftp_user" --stdin &>/dev/null -ftp_md5="$(awk -v user=$ftp_user -F : 'user == $1 {print $2}' /etc/shadow)" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$FTP_USER' "$ftp_user" -update_object_value 'web' 'DOMAIN' "$domain" '$FTP_MD5' "$ftp_md5" - -# Logging -log_history "added ftp account $ftp_user for $domain" -log_event "$OK" "$EVENT" - -exit ->>>>>>> 994c40901078e48fe939536f7b366e29c2e44a1d diff --git a/bin/v-list-sys-services b/bin/v-list-sys-services new file mode 100755 index 000000000..cc5951576 --- /dev/null +++ b/bin/v-list-sys-services @@ -0,0 +1,188 @@ +#!/bin/bash +# info: list system config +# options: [FORMAT] +# +# The function for obtaining the list of system parameters. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +format=${1-shell} + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + +get_srv_state() { + srv=$1 + proc_name=${2-$1} + + # Check service status + /etc/init.d/$srv status > /dev/null 2>&1 + if [ $? -eq 0 ]; then + state='running' + + # Calculate cpu and memory usage + cpu=0 + mem=0 + for pid in $(/sbin/pidof $proc_name); do + pid_mem=$(pmap -x $pid | tail -n1 | awk '{print $3}') + pid_cpu=$(grep "^$pid " $tmp_file | cut -f 2 -d ' ') + cpu=$((cpu + pid_cpu)) + mem=$((mem + pid_mem)) + done + mem=$((mem / 1024)) + + # Get pid date + if [ ! -z $pid ] && [ -e "/proc/$pid/cmdline" ]; then + mtime=$(stat -c "%Y" /proc/$pid/cmdline) + rtime=$((ctime - mtime)) + rtime=$((rtime / 60)) + fi + else + # Service is stopped + state='stopped' + mem=0 + cpu=0 + rtime="0" + fi +} + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Save current proccess list +tmp_file=$(mktemp) +if [ "$format" = 'json' ]; then + ps aux | awk '{print $2" "$3}' | tr -d '.' > $tmp_file +else + ps aux | awk '{print $2" "$3}' | cut -f 1 -d '.' > $tmp_file +fi + +# Get current time +ctime=$(date +%s) + +# Proxy +service=$PROXY_SYSTEM +if [ ! -z "$service" ] && [ "$service" != 'no' ]; then + get_srv_state $service + str="NAME='$service' SYSTEM='reverse proxy' STATE='$state' CPU='$cpu'" + str="$str MEM='$mem' RTIME='$rtime'" +fi + +# Web +service=$WEB_SYSTEM +if [ ! -z "$service" ] && [ "$service" != 'no' ]; then + if [ "$service" == 'apache' ]; then + service='httpd' + fi + get_srv_state $service + str="$str\nNAME='$service' SYSTEM='web server' STATE='$state' CPU='$cpu'" + str="$str MEM='$mem' RTIME='$rtime'" + +fi + +# DNS +service=$DNS_SYSTEM +if [ ! -z "$service" ] && [ "$service" != 'no' ]; then + if [ "$service" == 'bind' ]; then + service='named' + fi + get_srv_state $service + str="$str\nNAME='$service' SYSTEM='dns server' STATE='$state' CPU='$cpu'" + str="$str MEM='$mem' RTIME='$rtime'" +fi + +# MAIL +service=$MAIL_SYSTEM +if [ ! -z "$service" ] && [ "$service" != 'no' ]; then + get_srv_state $service + str="$str\nNAME='$service' SYSTEM='mail server' STATE='$state' CPU='$cpu'" + str="$str MEM='$mem' RTIME='$rtime'" +fi + +# IMAP +service=$IMAP_SYSTEM +if [ ! -z "$service" ] && [ "$service" != 'no' ]; then + get_srv_state $service + str="$str\nNAME='$service' SYSTEM='pop/imap server' STATE='$state'" + str="$str CPU='$cpu' MEM='$mem' RTIME='$rtime'" +fi + +# ANTIVIRUS +service=$ANTIVIRUS_SYSTEM +if [ ! -z "$service" ] && [ "$service" != 'no' ]; then + if [ "$ANTIVIRUS_SYSTEM" = 'clamav' ]; then + service='clamd' + fi + get_srv_state $service + str="$str\nNAME='$service' SYSTEM='email antivirus' STATE='$state'" + str="$str CPU='$cpu' MEM='$mem' RTIME='$rtime'" +fi + +# ANTISPAM +service=$ANTISPAM_SYSTEM +if [ ! -z "$service" ] && [ "$service" != 'no' ]; then + get_srv_state $service spamd + str="$str\nNAME='$service' SYSTEM='email antispam' STATE='$state'" + str="$str CPU='$cpu' MEM='$mem' RTIME='$rtime'" +fi + +# DB +service=$DB_SYSTEM +if [ ! -z "$service" ] && [ "$service" != 'no' ]; then + for db in ${DB_SYSTEM//,/ }; do + service="$db" + if [ "$service" == 'mysql' ] && [ ! -e "/etc/init.d/$service" ]; then + service='mysqld' + fi + get_srv_state $service + str="$str\nNAME='$service' SYSTEM='database server' STATE='$state'" + str="$str CPU='$cpu' MEM='$mem' RTIME='$rtime'" + done +fi + +# FTP +service=$FTP_SYSTEM +if [ ! -z "$service" ] && [ "$service" != 'no' ]; then + get_srv_state $service + str="$str\nNAME='$service' SYSTEM='ftp server' STATE='$state' CPU='$cpu'" + str="$str MEM='$mem' RTIME='$rtime'" +fi + +# CRON +service=$CRON_SYSTEM +if [ ! -z "$service" ] && [ "$service" != 'no' ]; then + get_srv_state $service + str="$str\nNAME='$service' SYSTEM='job scheduler' STATE='$state'" + str="$str CPU='$cpu' MEM='$mem' RTIME='$rtime'" +fi + +# Defining config +echo -e "$str" > $tmp_file +conf=$tmp_file + +# Defining fileds to select +fields="\$NAME \$SYSTEM \$STATE \$CPU \$MEM \$RTIME" + +# Listing services +case $format in + json) json_list ;; + plain) nohead=1; shell_list ;; + shell) fields='$NAME $STATE $CPU $MEM $RTIME' + shell_list | column -t ;; + *) check_args '1' '0' 'USER [FORMAT]' +esac + +rm -f $tmp_file + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-user-stats b/bin/v-list-user-stats index eac6e9142..c79631d56 100755 --- a/bin/v-list-user-stats +++ b/bin/v-list-user-stats @@ -32,6 +32,9 @@ is_object_valid 'user' 'USER' "$user" # Defining config conf=$USER_DATA/stats.log +if [ ! -e "$conf" ]; then + touch $conf +fi # Defining fileds to select fields="\$DATE \$TIME \$PACKAGE \$IP_OWNED \$DISK_QUOTA \$U_DISK \$U_DISK_DIRS" diff --git a/bin/v-list-users-stats b/bin/v-list-users-stats index 8a6fbf583..95f39ea05 100755 --- a/bin/v-list-users-stats +++ b/bin/v-list-users-stats @@ -29,6 +29,9 @@ check_args '0' "$#" '[FORMAT]' # Defining config conf=$VESTA/data/users/admin/overall_stats.log +if [ ! -e "$conf" ]; then + touch $conf +fi # Defining fileds to select fields="\$DATE \$TIME \$PACKAGE \$IP_OWNED \$DISK_QUOTA \$U_DISK \$U_DISK_DIRS" diff --git a/bin/v-rebuild-user b/bin/v-rebuild-user index 3635fd702..52ece73ae 100755 --- a/bin/v-rebuild-user +++ b/bin/v-rebuild-user @@ -143,7 +143,7 @@ fi if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then touch $USER_DATA/db.conf chmod 660 $USER_DATA/db.conf - echo "v_update_datbases_disk $user" >> $VESTA/data/queue/disk.pipe + echo "v-update-datbases-disk $user" >> $VESTA/data/queue/disk.pipe fi if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then diff --git a/bin/v-rebuild-web-domains b/bin/v-rebuild-web-domains index cb1a66307..847efb8a8 100755 --- a/bin/v-rebuild-web-domains +++ b/bin/v-rebuild-web-domains @@ -1,4 +1,3 @@ -<<<<<<< HEAD #!/bin/bash # info: rebuild dns domains # options: USER [RESTART] @@ -79,7 +78,7 @@ for domain in $(shell_list) ; do chmod 551 $HOMEDIR/$user/web/$domain chmod 771 $HOMEDIR/$user/web/$domain/private - chmod 771 $HOMEDIR/$user/web/$domain/cgi-bin + chmod 751 $HOMEDIR/$user/web/$domain/cgi-bin chmod 771 $HOMEDIR/$user/web/$domain/public_html chmod 771 $HOMEDIR/$user/web/$domain/public_shtml chmod 771 $HOMEDIR/$user/web/$domain/document_errors @@ -311,317 +310,3 @@ fi log_event "$OK" "$EVENT" exit -======= -#!/bin/bash -# info: rebuild dns domains -# options: USER [RESTART] -# -# The function rebuilds BIND configuration files for all dns domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -restart=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/ip.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [RESTART]' -validate_format 'user' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -user_domains=0 -user_ssl=0 -user_aliases=0 -suspended_web=0 - -# Clean up old config -rm -f $HOMEDIR/$user/conf/tmp_*.conf - -# Defining config -conf=$USER_DATA/web.conf -fields='$DOMAIN' -nohead=1 - -# Starting loop -for domain in $(shell_list) ; do - - # Rebuilding directories - mkdir -p $HOMEDIR/$user/web/$domain \ - $HOMEDIR/$user/web/$domain/public_html \ - $HOMEDIR/$user/web/$domain/public_shtml \ - $HOMEDIR/$user/web/$domain/document_errors \ - $HOMEDIR/$user/web/$domain/cgi-bin \ - $HOMEDIR/$user/web/$domain/private \ - $HOMEDIR/$user/web/$domain/stats \ - $HOMEDIR/$user/web/$domain/logs - if [ ! -e "$HOMEDIR/$user/web/$domain/logs/$domain.log" ]; then - ln -s /var/log/httpd/domains/$domain.error.log \ - $HOMEDIR/$user/web/$domain/logs/$domain.log - fi - if [ ! -e "$HOMEDIR/$user/web/$domain/logs/$domain.error.log" ]; then - ln -s /var/log/httpd/domains/$domain.error.log \ - $HOMEDIR/$user/web/$domain/logs/$domain.error.log - fi - if [ -e "$WEBTPL/skel/document_errors/" ]; then - cp -r $WEBTPL/skel/document_errors/ $HOMEDIR/$user/web/$domain/ - fi - - touch /var/log/httpd/domains/$domain.bytes \ - /var/log/httpd/domains/$domain.log \ - /var/log/httpd/domains/$domain.error.log - - chmod 551 $HOMEDIR/$user/web/$domain - chmod 771 $HOMEDIR/$user/web/$domain/private - chmod 751 $HOMEDIR/$user/web/$domain/cgi-bin - chmod 771 $HOMEDIR/$user/web/$domain/public_html - chmod 771 $HOMEDIR/$user/web/$domain/public_shtml - chmod 771 $HOMEDIR/$user/web/$domain/document_errors - chmod 551 $HOMEDIR/$user/web/$domain/stats - chmod 551 $HOMEDIR/$user/web/$domain/logs - chmod 640 /var/log/httpd/domains/$domain.* - - chown $user:$user $HOMEDIR/$user/web/$domain - chown $user:$user $HOMEDIR/$user/web/$domain/private - chown $user:$user $HOMEDIR/$user/web/$domain/cgi-bin - chown $user:$user $HOMEDIR/$user/web/$domain/public_html - chown $user:$user $HOMEDIR/$user/web/$domain/public_shtml - chown -R $user:$user $HOMEDIR/$user/web/$domain/document_errors - chown root:$user /var/log/httpd/domains/$domain.* - chown root:apache $conf - - # Parsing domain values - domain_idn=$(idn -t --quiet -a "$domain") - get_domain_values 'web' - - # Preparing domain values for the template substitution - upd_web_domain_values - - # Adding domain to the tmp_httpd.conf - tpl_file="$WEBTPL/apache_$TPL.tpl" - conf="$HOMEDIR/$user/conf/web/tmp_httpd.conf" - add_web_config - chown root:apache $conf - chmod 640 $conf - - # Running template trigger - if [ -x $WEBTPL/apache_$TPL.sh ]; then - $WEBTPL/apache_$TPL.sh $user $domain $ip $HOMEDIR $docroot - fi - - # Checking aliases - if [ ! -z "$ALIAS" ]; then - aliases=$(echo "$ALIAS"|tr ',' '\n'| wc -l) - user_aliases=$((user_aliases + aliases)) - fi - - # Checking stats - if [ ! -z "$STATS" ]; then - cat $WEBTPL/$STATS.tpl |\ - sed -e "s/%ip%/$ip/g" \ - -e "s/%web_port%/$WEB_PORT/g" \ - -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \ - -e "s/%proxy_port%/$PROXY_PORT/g" \ - -e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \ - -e "s/%domain_idn%/$domain_idn/g" \ - -e "s/%domain%/$domain/g" \ - -e "s/%user%/$user/g" \ - -e "s/%home%/${HOMEDIR////\/}/g" \ - -e "s/%alias%/${aliases//,/ }/g" \ - -e "s/%alias_idn%/${aliases_idn//,/ }/g" \ - > $HOMEDIR/$user/conf/web/$STATS.$domain.conf - - if [ "$STATS" == 'awstats' ]; then - if [ ! -e "/etc/awstats/$STATS.$domain.conf" ]; then - ln -s $HOMEDIR/$user/conf/web/$STATS.$domain.conf /etc/awstats/ - fi - fi - - webstats="$BIN/v-update-web-domain-stat $user $domain" - check_webstats=$(grep "$webstats" $VESTA/data/queue/webstats.pipe) - if [ -z "$check_webstats" ]; then - echo "$webstats" >> $VESTA/data/queue/webstats.pipe - fi - - if [ ! -z "$STATS_USER" ]; then - # Definining statistic dir - stats_dir="$HOMEDIR/$user/web/$domain/stats" - - # Adding htaccess file - echo "AuthUserFile $stats_dir/.htpasswd" > $stats_dir/.htaccess - echo "AuthName \"Web Statistics\"" >> $stats_dir/.htaccess - echo "AuthType Basic" >> $stats_dir/.htaccess - echo "Require valid-user" >> $stats_dir/.htaccess - - # Generating htaccess user and password - echo "$STATS_USER:$STATS_CRYPT" > $stats_dir/.htpasswd - fi - fi - - # Checking ssl - if [ "$SSL" = 'yes' ]; then - # Adding domain to the shttpd.conf - conf="$HOMEDIR/$user/conf/web/tmp_shttpd.conf" - tpl_file="$WEBTPL/apache_$TPL.stpl" - add_web_config - chown root:apache $conf - chmod 640 $conf - - cp -f $USER_DATA/ssl/$domain.crt \ - $HOMEDIR/$user/conf/web/ssl.$domain.crt - cp -f $USER_DATA/ssl/$domain.key \ - $HOMEDIR/$user/conf/web/ssl.$domain.key - cp -f $USER_DATA/ssl/$domain.pem \ - $HOMEDIR/$user/conf/web/ssl.$domain.pem - if [ -e "$USER_DATA/ssl/$domain.ca" ]; then - cp -f $USER_DATA/ssl/$domain.ca \ - $HOMEDIR/$user/conf/web/ssl.$domain.ca - fi - - # Running template trigger - if [ -x $WEBTPL/apache_$TPL.sh ]; then - $WEBTPL/apache_$TPL.sh $user $domain $ip $HOMEDIR $sdocroot - fi - - user_ssl=$((user_ssl + 1)) - ssl_change='yes' - fi - - # Checking nginx - if [ ! -z "$NGINX" ]; then - tpl_file="$WEBTPL/nginx_$NGINX.tpl" - conf="$HOMEDIR/$user/conf/web/tmp_nginx.conf" - add_web_config - chown root:nginx $conf - chmod 640 $conf - - if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web/tmp_snginx.conf" - add_web_config - chown root:nginx $conf - chmod 640 $conf - fi - ngix_change='yes' - fi - if [ "$SUSPENDED" = 'yes' ]; then - suspended_web=$((suspended_web + 1)) - fi - user_domains=$((user_domains + 1)) - - # Checking ftp - if [ ! -z "$FTP_USER" ]; then - if [ -z "$(grep ^$FTP_USER: /etc/passwd)" ]; then - /usr/sbin/adduser $FTP_USER -g $user -s /sbin/nologin -M \ - -d "$HOMEDIR/$user/web/$domain" > /dev/null 2>&1 - - shadow='/etc/shadow' - shdw=$(grep "^$FTP_USER:" $shadow) - shdw3=$(echo "$shdw" | cut -f3 -d :) - shdw4=$(echo "$shdw" | cut -f4 -d :) - shdw5=$(echo "$shdw" | cut -f5 -d :) - shdw6=$(echo "$shdw" | cut -f6 -d :) - shdw7=$(echo "$shdw" | cut -f7 -d :) - shdw8=$(echo "$shdw" | cut -f8 -d :) - shdw9=$(echo "$shdw" | cut -f9 -d :) - chmod u+w $shadow - sed -i "/^$FTP_USER:*/d" $shadow - shdw_str="$FTP_USER:$FTP_MD5:$shdw3:$shdw4:$shdw5:$shdw6" - shdw_str="$shdw_str:$shdw7:$shdw8:$shdw9" - echo "$shdw_str" >> $shadow - chmod u-w $shadow - fi - fi - -done - -# Renaming tmp config -tmp_conf="$HOMEDIR/$user/conf/web/tmp_httpd.conf" -conf="$HOMEDIR/$user/conf/web/httpd.conf" -if [ -e "$tmp_conf" ]; then - mv $tmp_conf $conf -fi - -# Checking include in main httpd.conf -main_conf='/etc/httpd/conf.d/vesta.conf' -main_conf_check=$(grep "$conf" $main_conf ) -if [ ! -z "$domain" ] && [ -z "$main_conf_check" ]; then - echo "Include $conf" >>$main_conf -fi - -# Checking ssl -if [ "$ssl_change" = 'yes' ]; then - tmp_conf="$HOMEDIR/$user/conf/web/tmp_shttpd.conf" - conf="$HOMEDIR/$user/conf/web/shttpd.conf" - mv $tmp_conf $conf - - # Checking include in main httpd.conf - main_conf_check=$(grep "$conf" $main_conf ) - if [ -z "$main_conf_check" ]; then - echo "Include $conf" >>$main_conf - fi -fi - -# Checking nginx -if [ "$ngix_change" = 'yes' ]; then - nginx_conf='/etc/nginx/conf.d/vesta_users.conf' - tmp_conf="$HOMEDIR/$user/conf/web/tmp_nginx.conf" - conf="$HOMEDIR/$user/conf/web/nginx.conf" - mv $tmp_conf $conf - - nginx_conf_check=$(grep "$conf" $nginx_conf ) - if [ -z "$nginx_conf_check" ]; then - echo "include $conf;" >>$nginx_conf - fi - - # Checking ssl for nginx - if [ "$ssl_change" = 'yes' ]; then - tmp_conf="$HOMEDIR/$user/conf/web/tmp_snginx.conf" - conf="$HOMEDIR/$user/conf/web/snginx.conf" - mv $tmp_conf $conf - nginx_conf_check=$(grep "$conf" $nginx_conf ) - if [ -z "$nginx_conf_check" ]; then - echo "include $conf;" >>$nginx_conf - fi - fi -fi - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating counters -update_user_value "$user" '$SUSPENDED_WEB' "$suspended_web" -update_user_value "$user" '$U_WEB_DOMAINS' "$user_domains" -update_user_value "$user" '$U_WEB_SSL' "$user_ssl" -update_user_value "$user" '$U_WEB_ALIASES' "$user_aliases" - -# Restart web server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit ->>>>>>> 994c40901078e48fe939536f7b366e29c2e44a1d diff --git a/bin/v-restart-cron b/bin/v-restart-cron index 6e0b02f0f..be1ce97ea 100755 --- a/bin/v-restart-cron +++ b/bin/v-restart-cron @@ -12,7 +12,6 @@ # Includes source $VESTA/conf/vesta.conf source $VESTA/func/main.sh -EVENT=${1-$EVENT} #----------------------------------------------------------# @@ -21,11 +20,10 @@ EVENT=${1-$EVENT} # Parsing config / or just source config if [ "$CRON_SYSTEM" = 'crond' ]; then - /etc/init.d/crond 'reload' &>/dev/null + /etc/init.d/crond 'reload' >/dev/null 2>&1 if [ $? -ne 0 ]; then - /etc/init.d/crond 'restart' &>/dev/null + /etc/init.d/crond 'restart' >/dev/null 2>&1 if [ $? -ne 0 ]; then - log_event "$E_RESTART" "$EVENT" exit $E_RESTART fi fi diff --git a/bin/v-restart-dns b/bin/v-restart-dns index a780d29d4..f4cdf7e0c 100755 --- a/bin/v-restart-dns +++ b/bin/v-restart-dns @@ -12,18 +12,17 @@ # Includes source $VESTA/conf/vesta.conf source $VESTA/func/main.sh -EVENT=${1-$EVENT} + #----------------------------------------------------------# # Action # #----------------------------------------------------------# if [ "$DNS_SYSTEM" = 'bind' ]; then - /etc/init.d/named reload &>/dev/null + /etc/init.d/named reload >/dev/null 2>&1 if [ $? -ne 0 ]; then - /etc/init.d/named restart &>/dev/null + /etc/init.d/named restart >/dev/null 2>&1 if [ $? -ne 0 ]; then - log_event "$E_RESTART" "$EVENT" exit $E_RESTART fi fi diff --git a/bin/v-restart-mail b/bin/v-restart-mail index f66085c95..c0217ee75 100755 --- a/bin/v-restart-mail +++ b/bin/v-restart-mail @@ -12,18 +12,17 @@ # Includes source $VESTA/conf/vesta.conf source $VESTA/func/main.sh -EVENT=${1-$EVENT} + #----------------------------------------------------------# # Action # #----------------------------------------------------------# if [ "$MAIL_SYSTEM" = 'exim' ]; then - /etc/init.d/exim reload &>/dev/null + /etc/init.d/exim reload >/dev/null 2>&1 if [ $? -ne 0 ]; then - /etc/init.d/exim restart &>/dev/null + /etc/init.d/exim restart >/dev/null 2>&1 if [ $? -ne 0 ]; then - log_event "$E_RESTART" "$EVENT" exit $E_RESTART fi fi diff --git a/bin/v-restart-service b/bin/v-restart-service new file mode 100755 index 000000000..bd72de25b --- /dev/null +++ b/bin/v-restart-service @@ -0,0 +1,42 @@ +#!/bin/bash +# info: restart service +# options: service +# +# The function restarts system service. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +service=$1 + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'SERVICE' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +if [ -x "/etc/init.d/$service" ]; then + /etc/init.d/$service restart >/dev/null 2>&1 + if [ $? -ne 0 ]; then + exit $E_RESTART + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-restart-web b/bin/v-restart-web index 128cd00ae..d82f40e1c 100755 --- a/bin/v-restart-web +++ b/bin/v-restart-web @@ -1,8 +1,8 @@ #!/bin/bash -# info: restart dns service +# info: restart web services # options: NONE # -# The function tells BIND service to reload dns zone files. +# The function reloads web server configuration. #----------------------------------------------------------# @@ -12,41 +12,37 @@ # Includes source $VESTA/conf/vesta.conf source $VESTA/func/main.sh -EVENT=${1-$EVENT} + #----------------------------------------------------------# # Action # #----------------------------------------------------------# if [ "$WEB_SYSTEM" = 'apache' ]; then - /etc/init.d/httpd status &>/dev/null + /etc/init.d/httpd status >/dev/null 2>&1 if [ $? -eq 0 ]; then - /etc/init.d/httpd graceful &>/dev/null + /etc/init.d/httpd graceful >/dev/null 2>&1 if [ $? -ne 0 ]; then - log_event "$E_RESTART" "$EVENT" exit $E_RESTART fi else - /etc/init.d/httpd start &>/dev/null + /etc/init.d/httpd start >/dev/null 2>&1 if [ $? -ne 0 ]; then - log_event "$E_RESTART" "$EVENT" exit $E_RESTART fi fi fi if [ "$PROXY_SYSTEM" = 'nginx' ]; then - /etc/init.d/nginx status &>/dev/null + /etc/init.d/nginx status >/dev/null 2>&1 if [ $? -eq 0 ]; then - /etc/init.d/nginx reload &>/dev/null + /etc/init.d/nginx reload >/dev/null 2>&1 if [ $? -ne 0 ]; then - log_event "$E_RESTART" "$EVENT" exit $E_RESTART fi else - /etc/init.d/nginx start &>/dev/null + /etc/init.d/nginx start >/dev/null 2>&1 if [ $? -ne 0 ]; then - log_event "$E_RESTART" "$EVENT" exit $E_RESTART fi fi diff --git a/bin/v-start-service b/bin/v-start-service new file mode 100755 index 000000000..47434f19c --- /dev/null +++ b/bin/v-start-service @@ -0,0 +1,42 @@ +#!/bin/bash +# info: start service +# options: service +# +# The function starts system service. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +service=$1 + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'SERVICE' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +if [ -x "/etc/init.d/$service" ]; then + /etc/init.d/$service start >/dev/null 2>&1 + if [ $? -ne 0 ]; then + exit $E_RESTART + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-stop-service b/bin/v-stop-service new file mode 100755 index 000000000..09750db45 --- /dev/null +++ b/bin/v-stop-service @@ -0,0 +1,42 @@ +#!/bin/bash +# info: stop service +# options: service +# +# The function stops system service. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +service=$1 + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'SERVICE' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +if [ -x "/etc/init.d/$service" ]; then + /etc/init.d/$service stop >/dev/null 2>&1 + if [ $? -ne 0 ]; then + exit $E_RESTART + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-update-user-stats b/bin/v-update-user-stats index 3410d8583..895359b4b 100755 --- a/bin/v-update-user-stats +++ b/bin/v-update-user-stats @@ -1,4 +1,3 @@ -<<<<<<< HEAD #!/bin/bash # info: update user statistics # options: USER @@ -69,7 +68,7 @@ TOTAL_U_BACKUPS=0 for user in $user_list; do USER_DATA=$VESTA/data/users/$user source $USER_DATA/user.conf - next_month=$(date +'%m/01' -d '+ 1 month') + next_month=$(date +'%m/01/%y' -d '+ 1 month') DATE=$(date -d "$next_month -1day" +%F) # Compiling report string @@ -168,174 +167,3 @@ fi log_event "$OK" "$EVENT" exit -======= -#!/bin/bash -# info: update user statistics -# options: USER -# -# Function logs user parameters into statistics database. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Importing system enviroment as we run this script -# mostly by cron wich not read it by itself -source /etc/profile - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '0' "$#" 'USER' -if [ ! -z "$user" ]; then - validate_format 'user' - is_object_valid 'user' 'USER' "$user" -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Creating user_list -if [ -z "$user" ]; then - user_list=$(ls $VESTA/data/users) -else - user_list="$user" -fi - -# Reset overal statistics -TOTAL_IP_OWNED=0 -TOTAL_U_DISK=0 -TOTAL_U_DISK_DIRS=0 -TOTAL_U_DISK_WEB=0 -TOTAL_U_DISK_MAIL=0 -TOTAL_U_DISK_DB=0 -TOTAL_U_BANDWIDTH=0 -TOTAL_U_WEB_DOMAINS=0 -TOTAL_U_WEB_SSL=0 -TOTAL_U_WEB_ALIASES=0 -TOTAL_U_DNS_DOMAINS=0 -TOTAL_U_DNS_RECORDS=0 -TOTAL_U_MAIL_DOMAINS=0 -TOTAL_U_MAIL_DKIM=0 -TOTAL_U_MAIL_ACCOUNTS=0 -TOTAL_U_DATABASES=0 -TOTAL_U_CRON_JOBS=0 -TOTAL_U_BACKUPS=0 - -# Updating user stats -for user in $user_list; do - USER_DATA=$VESTA/data/users/$user - source $USER_DATA/user.conf - next_month=$(date +'%m/01/%y' -d '+ 1 month') - DATE=$(date -d "$next_month -1day" +%F) - - # Compiling report string - s="DATE='$DATE' TIME='$TIME' PACKAGE='$PACKAGE' IP_OWNED='$IP_OWNED'" - s="$s DISK_QUOTA='$DISK_QUOTA' U_DISK='$U_DISK' U_DISK_DIRS='$U_DISK_DIRS'" - s="$s U_DISK_WEB='$U_DISK_WEB' U_DISK_MAIL='$U_DISK_MAIL'" - s="$s U_DISK_DB='$U_DISK_DB' BANDWIDTH='$BANDWIDTH'" - s="$s U_BANDWIDTH='$U_BANDWIDTH' U_WEB_DOMAINS='$U_WEB_DOMAINS'" - s="$s U_WEB_SSL='$U_WEB_SSL' U_WEB_ALIASES='$U_WEB_ALIASES'" - s="$s U_DNS_DOMAINS='$U_DNS_DOMAINS' U_DNS_RECORDS='$U_DNS_RECORDS'" - s="$s U_MAIL_DOMAINS='$U_MAIL_DOMAINS' U_MAIL_DKIM='$U_MAIL_DKIM'" - s="$s U_MAIL_ACCOUNTS='$U_MAIL_ACCOUNTS' U_DATABASES='$U_DATABASES'" - s="$s U_CRON_JOBS='$U_CRON_JOBS' U_BACKUPS='$U_BACKUPS'" - - # Updating user stats log - stats="$USER_DATA/stats.log" - if [ -e "$stats" ]; then - # Checking dublicates - check_month=$(grep -n "DATE='$DATE'" $stats|cut -f 1 -d :) - if [ -z "$check_month" ]; then - # Updating as there no dublicates - echo "$s" >> $stats - chmod 660 $stats - else - # Replacing string with new data - sed -i "$check_month s/.*/$s/" $stats - fi - else - # Creating stats log - echo "$s" >$stats - chmod 660 $stats - fi - - # Increase overall counters - TOTAL_IP_OWNED=$((TOTAL_IP_OWNED + IP_OWNED)) - TOTAL_U_DISK=$((TOTAL_U_DISK + U_DISK)) - TOTAL_U_DISK_DIRS=$((TOTAL_U_DISK_DIRS + U_DISK_DIRS)) - TOTAL_U_DISK_WEB=$((TOTAL_U_DISK_WEB + U_DISK_WEB)) - TOTAL_U_DISK_MAIL=$((TOTAL_U_DISK_MAIL + U_DISK_MAIL)) - TOTAL_U_DISK_DB=$((TOTAL_U_DISK_DB + U_DISK_DB)) - TOTAL_U_BANDWIDTH=$((TOTAL_U_BANDWIDTH + U_BANDWIDTH)) - TOTAL_U_WEB_DOMAINS=$((TOTAL_U_WEB_DOMAINS + U_WEB_DOMAINS)) - TOTAL_U_WEB_SSL=$((TOTAL_U_WEB_SSL + U_WEB_SSL)) - TOTAL_U_WEB_ALIASES=$((TOTAL_U_WEB_ALIASES + U_WEB_ALIASES)) - TOTAL_U_DNS_DOMAINS=$((TOTAL_U_DNS_DOMAINS + U_DNS_DOMAINS)) - TOTAL_U_DNS_RECORDS=$((TOTAL_U_DNS_RECORDS + U_DNS_RECORDS)) - TOTAL_U_MAIL_DOMAINS=$((TOTAL_U_MAIL_DOMAINS + U_MAIL_DOMAINS)) - TOTAL_U_MAIL_DKIM=$((TOTAL_U_MAIL_DKIM + U_MAIL_DKIM)) - TOTAL_U_MAIL_ACCOUNTS=$((TOTAL_U_MAIL_ACCOUNTS + U_MAIL_ACCOUNTS)) - TOTAL_U_DATABASES=$((TOTAL_U_DATABASES + U_DATABASES)) - TOTAL_U_CRON_JOBS=$((TOTAL_U_CRON_JOBS + U_CRON_JOBS)) - TOTAL_U_BACKUPS=$((TOTAL_U_BACKUPS + U_BACKUPS)) - -done - -# Updating overall stats -stats="$VESTA/data/users/admin/overall_stats.log" - -s="DATE='$DATE' TIME='$TIME' PACKAGE='default' IP_OWNED='$TOTAL_IP_OWNED'" -s="$s DISK_QUOTA='0' U_DISK='$TOTAL_U_DISK' U_DISK_DIRS='$TOTAL_U_DISK_DIRS'" -s="$s U_DISK_WEB='$TOTAL_U_DISK_WEB' U_DISK_MAIL='$TOTAL_U_DISK_MAIL'" -s="$s U_DISK_DB='$TOTAL_U_DISK_DB' BANDWIDTH='0'" -s="$s U_BANDWIDTH='$TOTAL_U_BANDWIDTH' U_WEB_DOMAINS='$TOTAL_U_WEB_DOMAINS'" -s="$s U_WEB_SSL='$TOTAL_U_WEB_SSL' U_WEB_ALIASES='$TOTAL_U_WEB_ALIASES'" -s="$s U_DNS_DOMAINS='$TOTAL_U_DNS_DOMAINS'" -s="$s U_DNS_RECORDS='$TOTAL_U_DNS_RECORDS'" -s="$s U_MAIL_DOMAINS='$TOTAL_U_MAIL_DOMAINS' U_MAIL_DKIM='$TOTAL_U_MAIL_DKIM'" -s="$s U_MAIL_ACCOUNTS='$TOTAL_U_MAIL_ACCOUNTS'" -s="$s U_DATABASES='$TOTAL_U_DATABASES'" -s="$s U_CRON_JOBS='$TOTAL_U_CRON_JOBS' U_BACKUPS='$TOTAL_U_BACKUPS'" - -if [ -e "$stats" ]; then - # Checking dublicates - check_month=$(grep -n "DATE='$DATE'" $stats|cut -f 1 -d :) - if [ -z "$check_month" ]; then - # Updating as there no dublicates - echo "$s" >> $stats - chmod 660 $stats - else - # Replacing string with new data - sed -i "$check_month s/.*/$s/" $stats - fi -else - # Creating stats log - echo "$s" >$stats - chmod 660 $stats -fi - - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit ->>>>>>> 994c40901078e48fe939536f7b366e29c2e44a1d diff --git a/func/domain.sh b/func/domain.sh index 738c3f6a7..63f407cea 100644 --- a/func/domain.sh +++ b/func/domain.sh @@ -49,9 +49,9 @@ is_domain_new() { type="$1" dom=${2-$domain} - web=$(grep "DOMAIN='$dom'" $VESTA/data/users/*/web.conf) - dns=$(grep "DOMAIN='$dom'" $VESTA/data/users/*/dns.conf) - mail=$(grep "DOMAIN='$dom'" $VESTA/data/users/*/mail.conf) + web=$(grep -H "DOMAIN='$dom'" $VESTA/data/users/*/web.conf) + dns=$(grep -H "DOMAIN='$dom'" $VESTA/data/users/*/dns.conf) + mail=$(grep -H "DOMAIN='$dom'" $VESTA/data/users/*/mail.conf) # Check web domain if [ ! -z "$web" ] && [ "$type" == 'web' ]; then @@ -101,10 +101,10 @@ is_domain_new() { # Check web aliases web_alias=$(grep -w $dom $VESTA/data/users/*/web.conf) if [ ! -z "$web_alias" ]; then - c1=$(grep "'$dom'" $VESTA/data/users/*/web.conf | cut -f 7 -d /) - c2=$(grep "'$dom," $VESTA/data/users/*/web.conf | cut -f 7 -d /) - c3=$(grep ",$dom," $VESTA/data/users/*/web.conf | cut -f 7 -d /) - c4=$(grep ",$dom'" $VESTA/data/users/*/web.conf | cut -f 7 -d /) + c1=$(grep -H "'$dom'" $VESTA/data/users/*/web.conf | cut -f 7 -d /) + c2=$(grep -H "'$dom," $VESTA/data/users/*/web.conf | cut -f 7 -d /) + c3=$(grep -H ",$dom," $VESTA/data/users/*/web.conf | cut -f 7 -d /) + c4=$(grep -H ",$dom'" $VESTA/data/users/*/web.conf | cut -f 7 -d /) if [ ! -z "$c1" ] && [ "$type" == "web" ]; then echo "Error: domain $dom exist" log_event "$E_EXISTS" "$EVENT" diff --git a/func/main.sh b/func/main.sh index c4a6c1337..98d9bfd29 100644 --- a/func/main.sh +++ b/func/main.sh @@ -64,7 +64,7 @@ log_history() { touch $log if [ '99' -lt "$(wc -l $log |cut -f 1 -d ' ')" ]; then - tail -n 99 $log > $log.moved + tail -n 49 $log > $log.moved mv -f $log.moved $log chmod 660 $log fi diff --git a/install/0.9.7/rhel/roundcube-driver.php b/install/0.9.7/rhel/roundcube-driver.php index 9454a9e0c..ecfc85dad 100644 --- a/install/0.9.7/rhel/roundcube-driver.php +++ b/install/0.9.7/rhel/roundcube-driver.php @@ -1,4 +1,3 @@ -<<<<<<< HEAD $_SESSION['username'], + 'password' => $curpass, + 'new' => $passwd + ); + + $postdata = http_build_query($postvars); + + $send = 'POST /reset/mail/ HTTP/1.1' . PHP_EOL; + $send .= 'Host: ' . $vesta_host . PHP_EOL; + $send .= 'User-Agent: PHP Script' . PHP_EOL; + $send .= 'Content-length: ' . strlen($postdata) . PHP_EOL; + $send .= 'Content-type: application/x-www-form-urlencoded' . PHP_EOL; + $send .= 'Connection: close' . PHP_EOL; + $send .= PHP_EOL; + $send .= $postdata . PHP_EOL . PHP_EOL; + + $fp = fsockopen('ssl://' . $vesta_host, $vesta_port); + fputs($fp, $send); + $result = fread($fp, 2048); + fclose($fp); - $context = stream_context_create(array( - 'http' => array( - 'method' => 'POST', - 'header' => 'Content-Type: application/x-www-form-urlencoded' . PHP_EOL, - 'content' => $request, - ), - )); - - $result = file_get_contents( - $file = "https://".$vesta_host.":".$vesta_port."/reset/mail/?", - $use_include_path = false, - $context); - - if ($result == 'ok'){ + if(strpos($result, 'ok') && !strpos($html, 'error')) + { return PASSWORD_SUCCESS; } else { @@ -53,65 +58,3 @@ class rcube_vesta_password } } -======= - - */ - -class rcube_vesta_password -{ - function save($curpass, $passwd) - { - $rcmail = rcmail::get_instance(); - $vesta_host = $rcmail->config->get('password_vesta_host'); - - if (empty($vesta_host)) - { - $vesta_host = 'localhost'; - } - - $vesta_port = $rcmail->config->get('password_vesta_port'); - if (empty($vesta_port)) - { - $vesta_port = '8083'; - } - - $postvars = array( - 'email' => $_SESSION['username'], - 'password' => $curpass, - 'new' => $passwd - ); - - $postdata = http_build_query($postvars); - - $send = 'POST /reset/mail/ HTTP/1.1' . PHP_EOL; - $send .= 'Host: ' . $vesta_host . PHP_EOL; - $send .= 'User-Agent: PHP Script' . PHP_EOL; - $send .= 'Content-length: ' . strlen($postdata) . PHP_EOL; - $send .= 'Content-type: application/x-www-form-urlencoded' . PHP_EOL; - $send .= 'Connection: close' . PHP_EOL; - $send .= PHP_EOL; - $send .= $postdata . PHP_EOL . PHP_EOL; - - $fp = fsockopen('ssl://' . $vesta_host, $vesta_port); - fputs($fp, $send); - $result = fread($fp, 2048); - fclose($fp); - - - if(strpos($result, 'ok') && !strpos($html, 'error')) - { - return PASSWORD_SUCCESS; - } - else { - return PASSWORD_ERROR; - } - - } -} ->>>>>>> 994c40901078e48fe939536f7b366e29c2e44a1d diff --git a/install/0.9.7/rhel/templates/web/apache_phpcgi.stpl b/install/0.9.7/rhel/templates/web/apache_phpcgi.stpl index 4a4a386c0..f59758936 100755 --- a/install/0.9.7/rhel/templates/web/apache_phpcgi.stpl +++ b/install/0.9.7/rhel/templates/web/apache_phpcgi.stpl @@ -1,34 +1,35 @@ - - - ServerName %domain_idn% - %alias_string% - ServerAdmin %email% - DocumentRoot %sdocroot% - %cgi%ScriptAlias /cgi-bin/ %home%/%user%/web/%domain%/cgi-bin/ - Alias /vstats/ %home%/%user%/web/%domain%/stats/ - Alias /error/ %home%/%user%/web/%domain%/document_errors/ - SuexecUserGroup %user% %group% - CustomLog /var/log/httpd/domains/%domain%.bytes bytes - CustomLog /var/log/httpd/domains/%domain%.log combined - %elog%ErrorLog /var/log/httpd/domains/%domain%.error.log - - AllowOverride AuthConfig FileInfo Indexes Limit - SSLRequireSSL - Options +Includes -Indexes %cgi_option% - php_admin_flag engine off - Action phpcgi-script /cgi-bin/php - AddHandler phpcgi-script .php - - - AllowOverride All - - SSLEngine on - SSLVerifyClient none - SSLCertificateFile %ssl_crt% - SSLCertificateKeyFile %ssl_key% - %ssl_ca_str%SSLCertificateChainFile %ssl_ca% - - Include %home%/%user%/conf/web/shttpd.%domain%.conf* - - - + + + ServerName %domain_idn% + %alias_string% + ServerAdmin %email% + DocumentRoot %sdocroot% + %cgi%ScriptAlias /cgi-bin/ %home%/%user%/web/%domain%/cgi-bin/ + Alias /vstats/ %home%/%user%/web/%domain%/stats/ + Alias /error/ %home%/%user%/web/%domain%/document_errors/ + SuexecUserGroup %user% %group% + CustomLog /var/log/httpd/domains/%domain%.bytes bytes + CustomLog /var/log/httpd/domains/%domain%.log combined + %elog%ErrorLog /var/log/httpd/domains/%domain%.error.log + + SSLRequireSSL + AllowOverride All + Options +Includes -Indexes +ExecCGI + Action phpcgi-script /cgi-bin/php + + SetHandler phpcgi-script + + + + AllowOverride All + + SSLEngine on + SSLVerifyClient none + SSLCertificateFile %ssl_crt% + SSLCertificateKeyFile %ssl_key% + %ssl_ca_str%SSLCertificateChainFile %ssl_ca% + + Include %home%/%user%/conf/web/shttpd.%domain%.conf* + + + diff --git a/install/0.9.7/rhel/templates/web/apache_phpcgi.tpl b/install/0.9.7/rhel/templates/web/apache_phpcgi.tpl index ce58bf2b8..6bad4c2a1 100755 --- a/install/0.9.7/rhel/templates/web/apache_phpcgi.tpl +++ b/install/0.9.7/rhel/templates/web/apache_phpcgi.tpl @@ -1,27 +1,28 @@ - - - ServerName %domain_idn% - %alias_string% - ServerAdmin %email% - DocumentRoot %docroot% - %cgi%ScriptAlias /cgi-bin/ %home%/%user%/web/%domain%/cgi-bin/ - Alias /vstats/ %home%/%user%/web/%domain%/stats/ - Alias /error/ %home%/%user%/web/%domain%/document_errors/ - SuexecUserGroup %user% %group% - CustomLog /var/log/httpd/domains/%domain%.bytes bytes - CustomLog /var/log/httpd/domains/%domain%.log combined - %elog%ErrorLog /var/log/httpd/domains/%domain%.error.log - - AllowOverride AuthConfig FileInfo Indexes Limit - Options +Includes -Indexes %cgi_option% - php_admin_flag engine off - Action phpcgi-script /cgi-bin/php - AddHandler phpcgi-script .php - - - AllowOverride All - - Include %home%/%user%/conf/web/httpd.%domain%.conf* - - - + + + ServerName %domain_idn% + %alias_string% + ServerAdmin %email% + DocumentRoot %docroot% + %cgi%ScriptAlias /cgi-bin/ %home%/%user%/web/%domain%/cgi-bin/ + Alias /vstats/ %home%/%user%/web/%domain%/stats/ + Alias /error/ %home%/%user%/web/%domain%/document_errors/ + SuexecUserGroup %user% %group% + CustomLog /var/log/httpd/domains/%domain%.bytes bytes + CustomLog /var/log/httpd/domains/%domain%.log combined + %elog%ErrorLog /var/log/httpd/domains/%domain%.error.log + + AllowOverride All + Options +Includes -Indexes +ExecCGI + Action phpcgi-script /cgi-bin/php + + SetHandler phpcgi-script + + + + AllowOverride All + + Include %home%/%user%/conf/web/httpd.%domain%.conf* + + + diff --git a/install/0.9.7/rhel/templates/web/apache_phpfcgid.stpl b/install/0.9.7/rhel/templates/web/apache_phpfcgid.stpl index 1fd9c8cdd..3f67a31d2 100755 --- a/install/0.9.7/rhel/templates/web/apache_phpfcgid.stpl +++ b/install/0.9.7/rhel/templates/web/apache_phpfcgid.stpl @@ -1,35 +1,36 @@ - - - ServerName %domain_idn% - %alias_string% - ServerAdmin %email% - DocumentRoot %sdocroot% - %cgi%ScriptAlias /cgi-bin/ %home%/%user%/web/%domain%/cgi-bin/ - Alias /vstats/ %home%/%user%/web/%domain%/stats/ - Alias /error/ %home%/%user%/web/%domain%/document_errors/ - SuexecUserGroup %user% %group% - CustomLog /var/log/httpd/domains/%domain%.bytes bytes - CustomLog /var/log/httpd/domains/%domain%.log combined - %elog%ErrorLog /var/log/httpd/domains/%domain%.error.log - - AllowOverride AuthConfig FileInfo Indexes Limit - SSLRequireSSL - Options +Includes -Indexes %cgi_option% - php_admin_flag engine off - AddHandler fcgid-script .php - FCGIWrapper %home%/%user%/web/%domain%/cgi-bin/fcgi-starter .php - - - AllowOverride All - - php_admin_value open_basedir none - SSLEngine on - SSLVerifyClient none - SSLCertificateFile %ssl_crt% - SSLCertificateKeyFile %ssl_key% - %ssl_ca_str%SSLCertificateChainFile %ssl_ca% - - Include %home%/%user%/conf/web/shttpd.%domain%.conf* - - - + + + ServerName %domain_idn% + %alias_string% + ServerAdmin %email% + DocumentRoot %sdocroot% + %cgi%ScriptAlias /cgi-bin/ %home%/%user%/web/%domain%/cgi-bin/ + Alias /vstats/ %home%/%user%/web/%domain%/stats/ + Alias /error/ %home%/%user%/web/%domain%/document_errors/ + SuexecUserGroup %user% %group% + CustomLog /var/log/httpd/domains/%domain%.bytes bytes + CustomLog /var/log/httpd/domains/%domain%.log combined + %elog%ErrorLog /var/log/httpd/domains/%domain%.error.log + + SSLRequireSSL + AllowOverride All + Options +Includes -Indexes +ExecCGI + + SetHandler fcgid-script + + FCGIWrapper %home%/%user%/web/%domain%/cgi-bin/fcgi-starter .php + + + AllowOverride All + + php_admin_value open_basedir none + SSLEngine on + SSLVerifyClient none + SSLCertificateFile %ssl_crt% + SSLCertificateKeyFile %ssl_key% + %ssl_ca_str%SSLCertificateChainFile %ssl_ca% + + Include %home%/%user%/conf/web/shttpd.%domain%.conf* + + + diff --git a/install/0.9.7/rhel/templates/web/apache_phpfcgid.tpl b/install/0.9.7/rhel/templates/web/apache_phpfcgid.tpl index 2bca8ac76..1049a590d 100755 --- a/install/0.9.7/rhel/templates/web/apache_phpfcgid.tpl +++ b/install/0.9.7/rhel/templates/web/apache_phpfcgid.tpl @@ -1,27 +1,28 @@ - - - ServerName %domain_idn% - %alias_string% - ServerAdmin %email% - DocumentRoot %docroot% - %cgi%ScriptAlias /cgi-bin/ %home%/%user%/web/%domain%/cgi-bin/ - Alias /vstats/ %home%/%user%/web/%domain%/stats/ - Alias /error/ %home%/%user%/web/%domain%/document_errors/ - SuexecUserGroup %user% %group% - CustomLog /var/log/httpd/domains/%domain%.bytes bytes - CustomLog /var/log/httpd/domains/%domain%.log combined - %elog%ErrorLog /var/log/httpd/domains/%domain%.error.log - - AllowOverride AuthConfig FileInfo Indexes Limit - Options +Includes -Indexes %cgi_option% - php_admin_flag engine off - AddHandler fcgid-script .php - FCGIWrapper %home%/%user%/web/%domain%/cgi-bin/fcgi-starter .php - - - AllowOverride All - - Include %home%/%user%/conf/web/httpd.%domain%.conf* - - - + + + ServerName %domain_idn% + %alias_string% + ServerAdmin %email% + DocumentRoot %docroot% + %cgi%ScriptAlias /cgi-bin/ %home%/%user%/web/%domain%/cgi-bin/ + Alias /vstats/ %home%/%user%/web/%domain%/stats/ + Alias /error/ %home%/%user%/web/%domain%/document_errors/ + SuexecUserGroup %user% %group% + CustomLog /var/log/httpd/domains/%domain%.bytes bytes + CustomLog /var/log/httpd/domains/%domain%.log combined + %elog%ErrorLog /var/log/httpd/domains/%domain%.error.log + + AllowOverride All + Options +Includes -Indexes +ExecCGI + + SetHandler fcgid-script + + FCGIWrapper %home%/%user%/web/%domain%/cgi-bin/fcgi-starter .php + + + AllowOverride All + + Include %home%/%user%/conf/web/httpd.%domain%.conf* + + + diff --git a/install/vst-install.sh b/install/vst-install.sh index 825400a09..2f678913a 100644 --- a/install/vst-install.sh +++ b/install/vst-install.sh @@ -1,4 +1,3 @@ -<<<<<<< HEAD #!/bin/bash # Vesta installer @@ -11,9 +10,9 @@ VERSION='0.9.7' YUM_REPO='/etc/yum.repos.d/vesta.repo' arch=$(uname -i) -tools="screen mc libpng libjpeg curl curl libmcrypt libmcrypt mhash mhash - freetype openssl flex libxml2 ImageMagick sqlite sqlite pcre pcre sudo bc - mailx lsof ntp tar whois telnet rsync" +tools="screen mc libpng libjpeg curl libmcrypt mhash zip unzip freetype ntp + openssl flex libxml2 ImageMagick sqlite pcre sudo bc jwhois mailx lsof + tar telnet rsync" rpms="nginx httpd mod_ssl mod_ruid2 mod_extract_forwarded mod_fcgid ftp webalizer awstats mysql mysql-server php php-bcmath php-cli php-common @@ -41,6 +40,7 @@ release=$(grep -o "[0-9]" /etc/redhat-release |head -n1) help() { echo "usage: $0 [OPTIONS] + -d, --disable-remi Disable remi -e, --email Define email address -h, --help Print this help and exit -f, --force Force installation" @@ -52,6 +52,7 @@ for arg; do delim="" case "$arg" in --help) args="${args}-h " ;; + --disable-remi) args="${args}-d " ;; --force) args="${args}-f " ;; --email) args="${args}-e " ;; *) [[ "${arg:0:1}" == "-" ]] || delim="\"" @@ -61,8 +62,9 @@ done eval set -- "$args" # Getopt -while getopts "hfe:" Option; do +while getopts "dhfe:" Option; do case $Option in + d) disable_remi='yes' ;; # Disable remi repo h) help ;; # Help e) email=$OPTARG ;; # Contact email f) force=yes ;; # Force install @@ -250,8 +252,12 @@ if [ -e '/root/.my.cnf' ]; then mv -f /root/.my.cnf fi -# Vesta packages -yum -y --enablerepo=remi install $rpms +# Install Vesta packages +if [ -z "$disable_remi" ]; then + yum -y --enablerepo=remi install $rpms +else + yum -y install $rpms +fi if [ $? -ne 0 ]; then echo 'Error: yum install failed' exit 1 @@ -406,6 +412,9 @@ chmod 640 /var/log/httpd/error_log chmod 640 /var/log/httpd/suexec.log chmod 751 /var/log/httpd/domains +# Enable short_open_tag in php config +sed -i 's/short_open_tag = Off/short_open_tag = On/g' /etc/php.ini + # Nginx if [ -e '/etc/nginx/nginx.conf' ]; then mv /etc/nginx/nginx.conf $vst_backups/nginx/ @@ -502,6 +511,8 @@ sed -i "s/%blowfish_secret%/$(gen_pass)/g" /etc/phpMyAdmin/config.inc.php wget $CHOST/$VERSION/httpd-webmail.conf -O /etc/httpd/conf.d/roundcubemail.conf wget $CHOST/$VERSION/roundcube-main.conf -O /etc/roundcubemail/main.inc.php wget $CHOST/$VERSION/roundcube-db.conf -O /etc/roundcubemail/db.inc.php +wget $CHOST/$VERSION/roundcube-driver.php -O /usr/share/roundcubemail/plugins/password/vesta.php +wget $CHOST/$VERSION/roundcube-pw.conf -O /usr/share/roundcubemail/plugins/password/config.inc.php r="$(gen_pass)" mysql -e "CREATE DATABASE roundcube" @@ -537,7 +548,7 @@ $VESTA/bin/v-add-cron-job 'admin' '*/30' '*' '*' '*' '*' "$command" command='sudo /usr/local/vesta/bin/v-backup-users' $VESTA/bin/v-add-cron-job 'admin' '10' '05' '*' '*' '*' "$command" command='sudo /usr/local/vesta/bin/v-update-user-stats' -$VESTA/bin/v-add-cron-job 'admin' '20' '00' '01' '*' '*' "$command" +$VESTA/bin/v-add-cron-job 'admin' '20' '00' '*' '*' '*' "$command" command='sudo /usr/local/vesta/bin/v-update-sys-rrd' $VESTA/bin/v-add-cron-job 'admin' '*/5' '*' '*' '*' '*' "$command" @@ -637,652 +648,3 @@ cd bash # EOF -======= -#!/bin/bash -# Vesta installer - -# Define Variables -RHOST='r.vestacp.com' -CHOST='c.vestacp.com' - -REPO='cmmnt' -VERSION='0.9.7' -YUM_REPO='/etc/yum.repos.d/vesta.repo' -arch=$(uname -i) - -tools="screen mc libpng libjpeg curl libmcrypt mhash zip unzip freetype ntp - openssl flex libxml2 ImageMagick sqlite pcre sudo bc jwhois mailx lsof - tar telnet rsync" - -rpms="nginx httpd mod_ssl mod_ruid2 mod_extract_forwarded mod_fcgid ftp - webalizer awstats mysql mysql-server php php-bcmath php-cli php-common - php-gd php-imap php-mbstring php-mcrypt php-mysql php-pdo php-soap php-tidy - php-xml php-xmlrpc phpMyAdmin exim dovecot clamd spamassassin roundcubemail - bind bind-utils bind-libs vsftpd rrdtool GeoIP vesta vesta-nginx vesta-php" - -# Am I root? -if [ "x$(id -u)" != 'x0' ]; then - echo 'Error: this script can only be executed by root' - exit 1 -fi - -# Check supported version -if [ ! -e '/etc/redhat-release' ]; then - echo 'Error: sorry, we currently support RHEL and CentOS only' - exit 1 -fi - -os=$(cut -f 1 -d ' ' /etc/redhat-release) -if [ $os != 'CentOS' ] && [ $os != 'Red' ]; then - echo 'Error: sorry, we currently support RHEL and CentOS only' -fi -release=$(grep -o "[0-9]" /etc/redhat-release |head -n1) - -help() { - echo "usage: $0 [OPTIONS] - -d, --disable-remi Disable remi - -e, --email Define email address - -h, --help Print this help and exit - -f, --force Force installation" - exit 1 -} - -# Translating argument to --gnu-long-options -for arg; do - delim="" - case "$arg" in - --help) args="${args}-h " ;; - --disable-remi) args="${args}-d " ;; - --force) args="${args}-f " ;; - --email) args="${args}-e " ;; - *) [[ "${arg:0:1}" == "-" ]] || delim="\"" - args="${args}${delim}${arg}${delim} ";; - esac -done -eval set -- "$args" - -# Getopt -while getopts "dhfe:" Option; do - case $Option in - d) disable_remi='yes' ;; # Disable remi repo - h) help ;; # Help - e) email=$OPTARG ;; # Contact email - f) force=yes ;; # Force install - *) help ;; # Default - esac -done - -# Are you sure ? -if [ -z $email ]; then - echo - echo - echo - echo - echo - echo ' ***********************************************************' - echo - echo ' _| _| _|_|_|_| _|_|_| _|_|_|_|_| _|_| ' - echo ' _| _| _| _| _| _| _| ' - echo ' _| _| _|_|_| _|_| _| _|_|_|_| ' - echo ' _| _| _| _| _| _| _| ' - echo ' _| _|_|_|_| _|_|_| _| _| _| ' - echo - echo - echo - echo - echo - echo - echo - echo - echo ' ***********************************************************' - echo - echo - read -n 1 -p 'Do you want to install Vesta Control Panel? [y/n]): ' answer - if [ "$answer" != 'y' ] && [ "$answer" != 'Y' ]; then - echo 'Goodbye' - exit 1 - fi - echo - - # Check email - read -p 'Please enter valid email address: ' email -fi - -# Validate email -local_part=$(echo $email | cut -s -f1 -d\@) -remote_host=$(echo $email | cut -s -f2 -d\@) -mx_failed=1 -if [ ! -z "$remote_host" ] && [ ! -z "$local_part" ]; then - /usr/bin/host -t mx "$remote_host" &> /dev/null - mx_failed="$?" -fi - -if [ "$mx_failed" -eq 1 ]; then - echo "Error: email $email is not valid" - exit 1 -fi - -echo -echo -echo -echo -echo 'Installation will take about 15 minutes ...' -echo -sleep 2 - -# Check wget -if [ ! -e '/usr/bin/wget' ]; then - yum -y install wget - if [ $? -ne 0 ]; then - echo "Error: can't install wget" - exit 1 - fi -fi - -# Check repo availability -wget "$RHOST/$REPO/vesta.conf" -O /dev/null -if [ $? -ne 0 ]; then - echo "Error: no access to $REPO repository" - exit 1 -fi - -# Check installed packages -tmpfile=$(mktemp -p /tmp) -rpm -qa > $tmpfile -for rpm in $rpms; do - if [ ! -z "$(grep ^$rpm. $tmpfile)" ]; then - conflicts="$rpm $conflicts" - fi -done -rm -f $tmpfile - -if [ ! -z "$conflicts" ] && [ -z "$force" ]; then - echo - echo '!!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!!' - echo - echo 'Following rpm packages aleady installed:' - echo "$conflicts" - echo - echo 'It is highly recommended to remove them before proceeding.' - echo - echo 'If you want to force installation run this script with -f option:' - echo "Example: bash $0 --force" - echo - echo '!!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!!' - echo - exit 1 -fi - -# Password generator -gen_pass() { - MATRIX='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' - LENGTH=10 - while [ ${n:=1} -le $LENGTH ]; do - PASS="$PASS${MATRIX:$(($RANDOM%${#MATRIX})):1}" - let n+=1 - done - echo "$PASS" -} - -# Update system -yum -y update -if [ $? -ne 0 ]; then - echo 'Error: yum update failed' - exit 1 -fi - -# Install additional packages -yum -y install $tools -if [ $? -ne 0 ]; then - echo 'Error: yum install failed' - exit 1 -fi - -# Install EPEL repo -if [ ! -e '/etc/yum.repos.d/epel.repo' ]; then - if [ "$release" -eq '5' ]; then - epel="5/$arch/epel-release-5-4.noarch.rpm" - fi - - if [ "$release" -eq '6' ]; then - epel="6/$arch/epel-release-6-8.noarch.rpm" - fi - - rpm -ivh http://dl.fedoraproject.org/pub/epel/$epel - if [ $? -ne 0 ]; then - echo "Error: can't install EPEL repository" - exit 1 - fi -fi - -# Install remi repo -if [ ! -e '/etc/yum.repos.d/remi.repo' ]; then - if [ "$release" -eq '5' ]; then - remi="remi-release-5.rpm" - fi - - if [ "$release" -eq '6' ]; then - remi="remi-release-6.rpm" - fi - - rpm -ivh http://rpms.famillecollet.com/enterprise/$remi - if [ $? -ne 0 ]; then - echo "Error: can't install remi repository" - exit 1 - fi -fi - -# Install vesta repo -echo "[vesta] -name=Vesta - $REPO -baseurl=http://$RHOST/$REPO/$release/\$basearch/ -enabled=1 -gpgcheck=1 -gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-VESTA" > $YUM_REPO -wget $CHOST/GPG.txt -O /etc/pki/rpm-gpg/RPM-GPG-KEY-VESTA - -# Checking if old MySQL stuff exists -if [ -e '/var/lib/mysql' ]; then - mv -f /var/lib/mysql /var/lib/mysql_old -fi -if [ -e '/etc/my.cnf' ]; then - mv -f /etc/my.cnf /etc/my.cnf_old -fi -if [ -e '/root/.my.cnf' ]; then - mv -f /root/.my.cnf -fi - -# Install Vesta packages -if [ -z "$disable_remi" ]; then - yum -y --enablerepo=remi install $rpms -else - yum -y install $rpms -fi -if [ $? -ne 0 ]; then - echo 'Error: yum install failed' - exit 1 -fi - -# Configuring run levels -chkconfig iptables off -if [ -e /etc/init.d/sendmail ]; then - chkconfig sendmail off -fi -if [ -e /etc/init.d/postfix ]; then - chkconfig postfix off -fi -chkconfig vesta on -chkconfig httpd on -chkconfig nginx on -chkconfig mysqld on -chkconfig vsftpd on -chkconfig named on -chkconfig exim on -chkconfig clamd on -chkconfig spamassassin on -chkconfig dovecot on - -# Make dirs more visible -echo 'LS_COLORS="$LS_COLORS:di=00;33"' >> /etc/profile - -# Vesta does not support SELINUX for now -if [ -e '/etc/sysconfig/selinux' ]; then - sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux - setenforce 0 -fi -if [ -e '/etc/selinux/config' ]; then - sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config - setenforce 0 -fi - -# Vesta use own webalizer routine -rm -f /etc/cron.daily/00webalizer - -# NTP Synchronization -echo '#!/bin/sh' > /etc/cron.daily/ntpdate -echo "$(which ntpdate) -s pool.ntp.org" >> /etc/cron.daily/ntpdate -chmod 775 /etc/cron.daily/ntpdate -ntpdate -s pool.ntp.org - -# Vesta Environment -echo "export VESTA='/usr/local/vesta'" > /etc/profile.d/vesta.sh -chmod 755 /etc/profile.d/vesta.sh -source /etc/profile.d/vesta.sh -echo 'PATH=$PATH:/usr/local/vesta/bin' >> /root/.bash_profile -echo 'export PATH' >> /root/.bash_profile -source /root/.bash_profile -mkdir -p $VESTA/conf -mkdir -p $VESTA/log -mkdir -p $VESTA/data -mkdir -p $VESTA/ssl -chmod 770 $VESTA/conf - -# Make backup directory -vst_backups="/root/vst_install_backups/$(date +%s)" -mkdir -p $vst_backups -mkdir -p $vst_backups/nginx -mkdir -p $vst_backups/httpd -mkdir -p $vst_backups/mysql -mkdir -p $vst_backups/exim -mkdir -p $vst_backups/dovecot -mkdir -p $vst_backups/clamd -mkdir -p $vst_backups/vsftpd -mkdir -p $vst_backups/named - -wget $RHOST/$REPO/vesta.conf -O $VESTA/conf/vesta.conf -if [ -e '/etc/sudoers' ]; then - mv /etc/sudoers $vst_backups/ -fi -wget $CHOST/$VERSION/sudoers.conf -O /etc/sudoers -chmod 0440 /etc/sudoers -wget $CHOST/$VERSION/vesta.log -O /etc/logrotate.d/vesta - -sed -i "s/umask 022/umask 002/g" /etc/profile - -# Create backup directory -adduser backup -ln -s /home/backup /backup -chmod a+x /backup - -# Configuring data templates -cd /usr/local/vesta/data -mkdir ips -mkdir queue -mkdir users -touch queue/backup.pipe -touch queue/disk.pipe -touch queue/webstats.pipe -touch queue/restart.pipe -touch queue/traffic.pipe -chmod 750 users -chmod 750 ips -chmod -R 750 queue -wget $CHOST/$VERSION/packages.tar.gz -O packages.tar.gz -tar -xzf packages.tar.gz -rm -f packages.tar.gz -cd /usr/local/vesta/data -wget $CHOST/$VERSION/templates.tar.gz -O templates.tar.gz -tar -xzf templates.tar.gz -rm -f templates.tar.gz -chmod -R 755 /usr/local/vesta/data/templates - -cp templates/web/skel/public_html/index.html /var/www/html/ -sed -i 's/%domain%/It worked!/g' /var/www/html/index.html - -# Configuring ssl keys -cd /usr/local/vesta/ssl -wget $CHOST/$VERSION/certificate.crt -O certificate.crt -wget $CHOST/$VERSION/certificate.key -O certificate.key - -# Adding admin user -vpass=$(gen_pass) -$VESTA/bin/v-add-user admin $vpass $email default System Administrator -if [ $? -ne 0 ]; then - echo "Error: can't create admin user" - exit 1 -fi - -# Set shell -$VESTA/bin/v-change-user-shell admin bash - -# Apache -if [ -e '/etc/httpd/conf/httpd.conf' ]; then - mv /etc/httpd/conf/httpd.conf $vst_backups/httpd/ -fi -if [ -e '/etc/httpd/conf.d/ssl.conf' ]; then - mv /etc/httpd/conf.d/ssl.conf $vst_backups/httpd/ -fi -if [ -e '/etc/httpd/conf.d/proxy_ajp.conf' ]; then - mv /etc/httpd/conf.d/proxy_ajp.conf $vst_backups/httpd/ -fi -wget $CHOST/$VERSION/httpd.conf -O /etc/httpd/conf/httpd.conf -wget $CHOST/$VERSION/httpd-status.conf -O /etc/httpd/conf.d/status.conf -wget $CHOST/$VERSION/httpd-ssl.conf -O /etc/httpd/conf.d/ssl.conf -wget $CHOST/$VERSION/httpd.log -O /etc/logrotate.d/httpd -echo "MEFaccept 127.0.0.1" >> /etc/httpd/conf.d/mod_extract_forwarded.conf -echo > /etc/httpd/conf.d/proxy_ajp.conf -echo > /etc/httpd/conf.d/vesta.conf -touch /var/log/httpd/access_log -touch /var/log/httpd/error_log -touch /var/log/httpd/suexec.log -mkdir -p /var/log/httpd/domains -chmod a+x /var/log/httpd -chmod 640 /var/log/httpd/access_log -chmod 640 /var/log/httpd/error_log -chmod 640 /var/log/httpd/suexec.log -chmod 751 /var/log/httpd/domains - -# Nginx -if [ -e '/etc/nginx/nginx.conf' ]; then - mv /etc/nginx/nginx.conf $vst_backups/nginx/ -fi -if [ -f '/etc/nginx/conf.d/default.conf' ]; then - mv /etc/nginx/conf.d/default.conf $vst_backups/nginx/ -fi -if [ -e '/etc/nginx/conf.d/example_ssl.conf' ]; then - mv /etc/nginx/conf.d/example_ssl.conf $vst_backups/nginx/ -fi - -wget $CHOST/$VERSION/nginx.conf -O /etc/nginx/nginx.conf -wget $CHOST/$VERSION/nginx-status.conf -O /etc/nginx/conf.d/status.conf -touch /etc/nginx/conf.d/vesta_ip.conf -touch /etc/nginx/conf.d/vesta_users.conf - -# VsFTP -if [ -e '/etc/vsftpd/vsftpd.conf' ]; then - mv /etc/vsftpd/vsftpd.conf $vst_backups/vsftpd/ -fi -wget $CHOST/$VERSION/vsftpd.conf -O /etc/vsftpd/vsftpd.conf - -# MySQL -if [ -e '/etc/my.cnf' ]; then - mv /etc/my.cnf $vst_backups/mysql/ -fi - -if [ -e '/root/.my.cnf' ]; then - mv /root/.my.cnf $vst_backups/mysql/ -fi -mpass=$(gen_pass) -server_memory="$(grep 'MemTotal' /proc/meminfo |tr ' ' '\n' |grep [0-9])" -if [ "$server_memory" -gt '1000000' ]; then - wget $CHOST/$VERSION/mysql.cnf -O /etc/my.cnf -else - wget $CHOST/$VERSION/mysql-512.cnf -O /etc/my.cnf -fi -service mysqld start -mysqladmin -u root password $mpass -echo -e "[client]\npassword='$mpass'\n" >/root/.my.cnf -$VESTA/bin/v-add-database-server mysql localhost 3306 root $mpass -$VESTA/bin/v-add-database admin default default $(gen_pass) mysql - -# Bind -if [ -e '/etc/named.conf' ]; then - mv /etc/named.conf $vst_backups/named/ -fi -wget $CHOST/$VERSION/named.conf -O /etc/named.conf -chown root:named /etc/named.conf -chmod 640 /etc/named.conf - -# Exim -if [ -e '/etc/exim/exim.conf' ]; then - mv /etc/exim/exim.conf $vst_backups/exim/ -fi -if [ -e '/etc/clamd.conf' ]; then - mv /etc/clamd.conf $vst_backups/clamd/ -fi -wget $CHOST/$VERSION/exim.conf -O /etc/exim/exim.conf -wget $CHOST/$VERSION/dnsbl.conf -O /etc/exim/dnsbl.conf -wget $CHOST/$VERSION/spam-blocks.conf -O /etc/exim/spam-blocks.conf -wget $CHOST/$VERSION/clamd.conf -O /etc/clamd.conf -mkdir /etc/exim/domains -chmod 640 /etc/exim/exim.conf -gpasswd -a clam exim -gpasswd -a exim mail -gpasswd -a clam mail -gpasswd -a dovecot mail -/usr/bin/freshclam - -# Dovecot config -if [ "$release" -eq '5' ]; then - if -e [ '/etc/dovecot.conf' ]; then - mv /etc/dovecot.conf $vst_backups/dovecot/ - fi - wget $CHOST/$VERSION/dovecot.conf -O /etc/dovecot.conf - -else - if [ -e '/etc/dovecot' ]; then - mv /etc/dovecot/* $vst_backups/dovecot/ - fi - wget $CHOST/$VERSION/dovecot.tar.gz -O /etc/dovecot.tar.gz - cd /etc/ - tar -xzf dovecot.tar.gz - rm -f dovecot.tar.gz -fi - -# PMA -wget $CHOST/$VERSION/httpd-pma.conf -O /etc/httpd/conf.d/phpMyAdmin.conf -wget $CHOST/$VERSION/pma.conf -O /etc/phpMyAdmin/config.inc.php -sed -i "s/%blowfish_secret%/$(gen_pass)/g" /etc/phpMyAdmin/config.inc.php - -# Roundcube setup -wget $CHOST/$VERSION/httpd-webmail.conf -O /etc/httpd/conf.d/roundcubemail.conf -wget $CHOST/$VERSION/roundcube-main.conf -O /etc/roundcubemail/main.inc.php -wget $CHOST/$VERSION/roundcube-db.conf -O /etc/roundcubemail/db.inc.php -wget $CHOST/$VERSION/roundcube-driver.php -O /usr/share/roundcubemail/plugins/password/vesta.php -wget $CHOST/$VERSION/roundcube-pw.conf -O /usr/share/roundcubemail/plugins/password/config.inc.php - -r="$(gen_pass)" -mysql -e "CREATE DATABASE roundcube" -mysql -e "GRANT ALL ON roundcube.* TO roundcube@localhost IDENTIFIED BY '$r'" -sed -i "s/%password%/$r/g" /etc/roundcubemail/db.inc.php -mysql roundcube < /usr/share/doc/roundcubemail-*/SQL/mysql.initial.sql - -# Configuring ip -$VESTA/bin/v-update-sys-ip - -# Get main ip -main_ip=$(ifconfig |grep 'inet addr:' |grep -v 127.0.0.1 |head -n1 |\ - cut -f2 -d: | cut -f1 -d ' ') - -# Add default web domain on main ip -$VESTA/bin/v-add-web-domain admin default.domain $main_ip - -# Add default dns domain on main ip -$VESTA/bin/v-add-dns-domain admin default.domain $main_ip - -# Add default mail domain -$VESTA/bin/v-add-mail-domain admin default.domain - -# Configuring crond -command='sudo /usr/local/vesta/bin/v-update-sys-queue disk' -$VESTA/bin/v-add-cron-job 'admin' '15' '02' '*' '*' '*' "$command" -command='sudo /usr/local/vesta/bin/v-update-sys-queue traffic' -$VESTA/bin/v-add-cron-job 'admin' '10' '00' '*' '*' '*' "$command" -command='sudo /usr/local/vesta/bin/v-update-sys-queue webstats' -$VESTA/bin/v-add-cron-job 'admin' '30' '03' '*' '*' '*' "$command" -command='sudo /usr/local/vesta/bin/v-update-sys-queue backup' -$VESTA/bin/v-add-cron-job 'admin' '*/30' '*' '*' '*' '*' "$command" -command='sudo /usr/local/vesta/bin/v-backup-users' -$VESTA/bin/v-add-cron-job 'admin' '10' '05' '*' '*' '*' "$command" -command='sudo /usr/local/vesta/bin/v-update-user-stats' -$VESTA/bin/v-add-cron-job 'admin' '20' '00' '01' '*' '*' "$command" -command='sudo /usr/local/vesta/bin/v-update-sys-rrd' -$VESTA/bin/v-add-cron-job 'admin' '*/5' '*' '*' '*' '*' "$command" - -# Creating symlink -ln -s /usr/local/vesta/log /var/log/vesta - -# Stop unused services -services='iptables sendmail postfix' -for srv in $services; do - service $srv status > /dev/null - if [ $? -eq 0 ]; then - service $srv stop - fi -done - -# Start system service -services='vesta httpd nginx vsftpd exim dovecot clamd spamassassin named crond' -for srv in $services; do - service $srv status > /dev/null - if [ $? -gt 0 ]; then - service $srv start - else - service $srv restart - fi -done - -# Change sendmail client -rm -f /etc/alternatives/mta -ln -s /usr/sbin/sendmail.exim /etc/alternatives/mta - -# Build inititall rrd images -$VESTA/bin/v-update-sys-rrd - -# Send notification to vestacp.com -wget vestacp.com/notify/?$REPO -O /dev/null - -# Get server ip -vst_ip=$(wget vestacp.com/what-is-my-ip/ -O - 2>/dev/null) -if [ ! -z "$vst_ip" ] && [ "$vst_ip" != "$main_ip" ]; then - # Assign passive ip address - echo "pasv_address=$vst_ip" >> /etc/vsftpd/vsftpd.conf -fi - -if [ -z "$vst_ip" ]; then - vst_ip=$main_ip -fi - -# Send email -echo -e "Congratulations, you have just successfully installed \ -the Vesta Control Panel - -You can login in Vesta with following credentials: - username: admin - password: $vpass - https://$vst_ip:8083 - -We hope that you enjoy your installation of Vesta. Please \ -feel free to contact us anytime if you have any questions. -Thank you. - --- -Sincerely yours -vestacp.com team -" > $tmpfile - -cat $tmpfile | mail -s "Vesta Control Panel" $email -rm -f $tmpfile - -# Congrats -echo -echo -echo ' ***********************************************************' -echo -echo ' _| _| _|_|_|_| _|_|_| _|_|_|_|_| _|_| ' -echo ' _| _| _| _| _| _| _| ' -echo ' _| _| _|_|_| _|_| _| _|_|_|_| ' -echo ' _| _| _| _| _| _| _| ' -echo ' _| _|_|_|_| _|_|_| _| _| _| ' -echo -echo ' Congratulations, you have just successfully installed' -echo ' the Vesta Control Panel!' -echo -echo ' Now you can login in Vesta with following credentials:' -echo ' username: admin' -echo " password: $vpass" -echo " https://$vst_ip:8083/" -echo -echo -echo ' Thank you for using our product.' -echo -echo ' ***********************************************************' -echo -echo - -# Tricky way to get new PATH variable -cd -bash - -# EOF ->>>>>>> 994c40901078e48fe939536f7b366e29c2e44a1d diff --git a/web/add/db/index.php b/web/add/db/index.php index 834b21c07..1438f9531 100644 --- a/web/add/db/index.php +++ b/web/add/db/index.php @@ -1,93 +1,107 @@ - $error) { - if ( $i == 0 ) { - $error_msg = $error; - } else { - $error_msg = $error_msg.", ".$error; - } - } - $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); - } else { - // Add Database - $v_type = escapeshellarg($_POST['v_type']); - $v_charset = escapeshellarg($_POST['v_charset']); - exec (VESTA_CMD."v-add-database ".$user." ".$v_database." ".$v_dbuser." ".$v_password." ".$v_type." 'default' ".$v_charset, $output, $return_var); - $v_type = $_POST['v_type']; - $v_charset = $_POST['v_charset']; - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - unset($v_password); - unset($output); - } else { - if (empty($v_notify)) { - list($http_host, $port) = explode(':', $_SERVER["HTTP_HOST"]); - if ($_POST['v_type'] == 'mysql') $db_admin_link = "http://".$http_host."/phpMyAdmin/"; - if ($_POST['v_type'] == 'pgsql') $db_admin_link = "http://".$http_host."/phpPgAdmin/"; - - $to = $panel[$user]['CONTACT']; - $subject = _("Database Credentials"); - $hostname = exec('hostname'); - $from = _('MAIL_FROM',$hostname); - $mailtext = _('DATABASE_READY',$panel[$user]['FNAME'],$panel[$user]['LNAME'],$_POST['v_type'],$user,$_POST['v_database'],$user,$_POST['v_dbuser'],$_POST['v_password']); - $mailtext .= $db_admin_link."\n\n"; - - $mailtext .= "--\n"._('Vesta Control Panel')."\n"; - send_email($to, $subject, $mailtext, $from); - } - $_SESSION['ok_msg'] = _('DATABASE_CREATED_OK',$user."_".$_POST['v_database'],$user."_".$_POST['v_database']); - unset($v_database); - unset($v_dbuser); - unset($v_password); - unset($v_type); - unset($v_charset); - unset($output); - } - } -} -exec (VESTA_CMD."v-list-database-types 'json'", $output, $return_var); -$db_types = json_decode(implode('', $output), true); -unset($output); - -include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_db.html'); -unset($_SESSION['error_msg']); -unset($_SESSION['ok_msg']); -//} - -// Footer -include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); \ No newline at end of file + $error) { + if ( $i == 0 ) { + $error_msg = $error; + } else { + $error_msg = $error_msg.", ".$error; + } + } + $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); + } else { + // Add Database + $v_type = escapeshellarg($_POST['v_type']); + $v_charset = escapeshellarg($_POST['v_charset']); + exec (VESTA_CMD."v-add-database ".$user." ".$v_database." ".$v_dbuser." ".$v_password." ".$v_type." 'default' ".$v_charset, $output, $return_var); + $v_type = $_POST['v_type']; + $v_charset = $_POST['v_charset']; + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + unset($v_password); + unset($output); + } else { + // Add Database + $v_type = escapeshellarg($_POST['v_type']); + $v_charset = escapeshellarg($_POST['v_charset']); + exec (VESTA_CMD."v-add-database ".$user." ".$v_database." ".$v_dbuser." ".$v_password." ".$v_type." 'default' ".$v_charset, $output, $return_var); + $v_type = $_POST['v_type']; + $v_charset = $_POST['v_charset']; + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + unset($v_password); + unset($output); + } else { + if (empty($v_notify)) { + list($http_host, $port) = explode(':', $_SERVER["HTTP_HOST"]); + if ($_POST['v_type'] == 'mysql') $db_admin_link = "http://".$http_host."/phpMyAdmin/"; + if ($_POST['v_type'] == 'pgsql') $db_admin_link = "http://".$http_host."/phpPgAdmin/"; + + $to = $panel[$user]['CONTACT']; + $subject = _("Database Credentials"); + $hostname = exec('hostname'); + $from = _('MAIL_FROM',$hostname); + $mailtext = _('DATABASE_READY',$panel[$user]['FNAME'],$panel[$user]['LNAME'],$_POST['v_type'],$user,$_POST['v_database'],$user,$_POST['v_dbuser'],$_POST['v_password']); + $mailtext .= $db_admin_link."\n\n"; + + $mailtext .= "--\n"._('Vesta Control Panel')."\n"; + send_email($to, $subject, $mailtext, $from); + + } + $_SESSION['ok_msg'] = _('DATABASE_CREATED_OK',$user."_".$_POST['v_database'],$user."_".$_POST['v_database']); + unset($v_database); + unset($v_dbuser); + unset($v_password); + unset($v_type); + unset($v_charset); + unset($output); + } + } +} +exec (VESTA_CMD."v-list-database-types 'json'", $output, $return_var); +$db_types = json_decode(implode('', $output), true); +unset($output); + +include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_db.html'); +unset($_SESSION['error_msg']); +unset($_SESSION['ok_msg']); +//} + +// Footer +include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); +?> \ No newline at end of file diff --git a/web/bulk/service/index.php b/web/bulk/service/index.php new file mode 100644 index 000000000..36e771eb1 --- /dev/null +++ b/web/bulk/service/index.php @@ -0,0 +1,28 @@ +', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; -} else { - $data = json_decode(implode('', $output), true); - unset($output); - $v_username = $user; - $v_domain = $_GET['domain']; - $v_ip = $data[$v_domain]['IP']; - $v_template = $data[$v_domain]['TPL']; - $v_aliases = str_replace(',', "\n", $data[$v_domain]['ALIAS']); - $valiases = explode(",", $data[$v_domain]['ALIAS']); - $v_tpl = $data[$v_domain]['IP']; - $v_cgi = $data[$v_domain]['CGI']; - $v_elog = $data[$v_domain]['ELOG']; - $v_ssl = $data[$v_domain]['SSL']; - if ( $v_ssl == 'yes' ) { - exec (VESTA_CMD."v-list-web-domain-ssl ".$user." '".$v_domain."' json", $output, $return_var); - $ssl_str = json_decode(implode('', $output), true); - unset($output); - $v_ssl_crt = $ssl_str[$v_domain]['CRT']; - $v_ssl_key = $ssl_str[$v_domain]['KEY']; - $v_ssl_ca = $ssl_str[$v_domain]['CA']; - } - $v_ssl_home = $data[$v_domain]['SSL_HOME']; - $v_nginx = $data[$v_domain]['NGINX']; - $v_nginx_ext = str_replace(',', ', ', $data[$v_domain]['NGINX_EXT']); - $v_stats = $data[$v_domain]['STATS']; - $v_stats_user = $data[$v_domain]['STATS_USER']; - if (!empty($v_stats_user)) $v_stats_password = "••••••••"; - $v_ftp_user = $data[$v_domain]['FTP_USER']; - if (!empty($v_ftp_user)) $v_ftp_password = "••••••••"; - $v_suspended = $data[$v_domain]['SUSPENDED']; - if ( $v_suspended == 'yes' ) { - $v_status = 'suspended'; - } else { - $v_status = 'active'; - } - $v_time = $data[$v_domain]['TIME']; - $v_date = $data[$v_domain]['DATE']; - - exec (VESTA_CMD."v-list-user-ips ".$user." json", $output, $return_var); - $ips = json_decode(implode('', $output), true); - unset($output); - - exec (VESTA_CMD."v-list-web-templates json", $output, $return_var); - $templates = json_decode(implode('', $output), true); - unset($output); - - exec (VESTA_CMD."v-list-web-stats json", $output, $return_var); - $stats = json_decode(implode('', $output), true); - unset($output); -} - -// Action -if (!empty($_POST['save'])) { - $v_domain = escapeshellarg($_POST['v_domain']); - - // IP - if (($v_ip != $_POST['v_ip']) && (empty($_SESSION['error_msg']))) { - $v_ip = escapeshellarg($_POST['v_ip']); - exec (VESTA_CMD."v-change-web-domain-ip ".$v_username." ".$v_domain." ".$v_ip." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - $restart_web = 'yes'; - unset($output); - exec (VESTA_CMD."v-list-dns-domain ".$v_username." ".$v_domain." json", $output, $return_var); - if ((empty($_SESSION['error_msg'])) && ($return_var == 0 )) { - exec (VESTA_CMD."v-change-dns-domain-ip ".$v_username." ".$v_domain." ".$v_ip." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - $restart_dns = 'yes'; - } - unset($output); - foreach($valiases as $v_alias ){ - exec (VESTA_CMD."v-list-dns-domain ".$v_username." '".$v_alias."' json", $output, $return_var); - if ((empty($_SESSION['error_msg'])) && ($return_var == 0 )) { - exec (VESTA_CMD."v-change-dns-domain-ip ".$v_username." '".$v_alias."' ".$v_ip, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - $restart_dns = 'yes'; - } - unset($output); - } - } - - // Template - if (( $_SESSION['user'] == 'admin') && ($v_template != $_POST['v_template']) && (empty($_SESSION['error_msg']))) { - $v_template = escapeshellarg($_POST['v_template']); - exec (VESTA_CMD."v-change-web-domain-tpl ".$v_username." ".$v_domain." ".$v_template." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - $restart_web = 'yes'; - } - - // Aliases - if (empty($_SESSION['error_msg'])) { - $waliases = preg_replace("/\n/", " ", $_POST['v_aliases']); - $waliases = preg_replace("/,/", " ", $waliases); - $waliases = preg_replace('/\s+/', ' ',$waliases); - $waliases = trim($waliases); - $aliases = explode(" ", $waliases); - $v_aliases = str_replace(' ', "\n", $waliases); - $result = array_diff($valiases, $aliases); - foreach ($result as $alias) { - if ((empty($_SESSION['error_msg'])) && (!empty($alias))) { - $restart_web = 'yes'; - $v_template = escapeshellarg($_POST['v_template']); - exec (VESTA_CMD."v-delete-web-domain-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - - if (empty($_SESSION['error_msg'])) { - exec (VESTA_CMD."v-delete-dns-on-web-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - $restart_dns = 'yes'; - } - unset($output); - } - } - - $result = array_diff($aliases, $valiases); - foreach ($result as $alias) { - if ((empty($_SESSION['error_msg'])) && (!empty($alias))) { - $restart_web = 'yes'; - $v_template = escapeshellarg($_POST['v_template']); - exec (VESTA_CMD."v-add-web-domain-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - if (empty($_SESSION['error_msg'])) { - exec (VESTA_CMD."v-add-dns-on-web-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - $restart_dns = 'yes'; - } - unset($output); - } - } - } - - // Nginx - if ((!empty($v_nginx)) && (empty($_POST['v_nginx'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-delete-web-domain-nginx ".$v_username." ".$v_domain." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - unset($v_nginx); - $restart_web = 'yes'; - } - if ((!empty($v_nginx)) && (!empty($_POST['v_nginx'])) && (empty($_SESSION['error_msg']))) { - $ext = preg_replace("/\n/", " ", $_POST['v_nginx_ext']); - $ext = preg_replace("/,/", " ", $ext); - $ext = preg_replace('/\s+/', ' ',$ext); - $ext = trim($ext); - $ext = str_replace(' ', ", ", $ext); - if ( $v_nginx_ext != $ext ) { - $ext = str_replace(', ', ",", $ext); - exec (VESTA_CMD."v-change-web-domain-nginx-tpl ".$v_username." ".$v_domain." 'default' ".escapeshellarg($ext)." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - $v_nginx_ext = str_replace(',', ', ', $ext); - unset($output); - $restart_web = 'yes'; - } - } - if ((empty($v_nginx)) && (!empty($_POST['v_nginx'])) && (empty($_SESSION['error_msg']))) { - $nginx_ext = "'jpg,jpeg,gif,png,ico,css,zip,tgz,gz,rar,bz2,doc,xls,exe,pdf,ppt,txt,tar,wav,bmp,rtf,js,mp3,avi,mpeg,html,htm'"; - if (!empty($_POST['v_nginx_ext'])) { - $ext = preg_replace("/\n/", " ", $_POST['v_nginx_ext']); - $ext = preg_replace("/,/", " ", $ext); - $ext = preg_replace('/\s+/', ' ',$ext); - $ext = trim($ext); - $ext = str_replace(' ', ",", $ext); - $v_nginx_ext = str_replace(',', ', ', $ext); - } - exec (VESTA_CMD."v-add-web-domain-nginx ".$v_username." ".$v_domain." 'default' ".escapeshellarg($ext)." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_nginx = 'default'; - $restart_web = 'yes'; - } - - // SSL - if (( $v_ssl == 'yes' ) && (empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-delete-web-domain-ssl ".$v_username." ".$v_domain." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_ssl = 'no'; - $restart_web = 'yes'; - } - if (($v_ssl == 'yes') && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) { - if (( $v_ssl_crt != str_replace("\r\n", "\n", $_POST['v_ssl_crt'])) || ( $v_ssl_key != str_replace("\r\n", "\n", $_POST['v_ssl_key'])) || ( $v_ssl_ca != str_replace("\r\n", "\n", $_POST['v_ssl_ca']))) { - exec ('mktemp -d', $mktemp_output, $return_var); - $tmpdir = $mktemp_output[0]; - - // Certificate - if (!empty($_POST['v_ssl_crt'])) { - $fp = fopen($tmpdir."/".$_POST['v_domain'].".crt", 'w'); - fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_crt'])); - fwrite($fp, "\n"); - fclose($fp); - } - - // Key - if (!empty($_POST['v_ssl_key'])) { - $fp = fopen($tmpdir."/".$_POST['v_domain'].".key", 'w'); - fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_key'])); - fwrite($fp, "\n"); - fclose($fp); - } - - // CA - if (!empty($_POST['v_ssl_ca'])) { - $fp = fopen($tmpdir."/".$_POST['v_domain'].".ca", 'w'); - fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_ca'])); - fwrite($fp, "\n"); - fclose($fp); - } - - exec (VESTA_CMD."v-change-web-domain-sslcert ".$user." ".$v_domain." ".$tmpdir." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - $restart_web = 'yes'; - $v_ssl_crt = $_POST['v_ssl_crt']; - $v_ssl_key = $_POST['v_ssl_key']; - $v_ssl_ca = $_POST['v_ssl_ca']; - } - } - if (( $v_ssl == 'yes') && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) { - if ( $v_ssl_home != $_POST['v_ssl_home'] ) { - $v_ssl_home = escapeshellarg($_POST['v_ssl_home']); - exec (VESTA_CMD."v-change-web-domain-sslhome ".$user." ".$v_domain." ".$v_ssl_home." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - $v_ssl_home = $_POST['v_ssl_home']; - unset($output); - } - } - if (( $v_ssl == 'no') && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) { - if ((!empty($_POST['v_ssl'])) && (empty($_POST['v_ssl_crt']))) $errors[] = 'ssl certificate'; - if ((!empty($_POST['v_ssl'])) && (empty($_POST['v_ssl_key']))) $errors[] = 'ssl key'; - if ((!empty($_POST['v_ssl'])) && (empty($_POST['v_ssl_home']))) $errors[] = 'ssl home'; - $v_ssl_home = escapeshellarg($_POST['v_ssl_home']); - if (!empty($errors[0])) { - foreach ($errors as $i => $error) { - if ( $i == 0 ) { - $error_msg = $error; - } else { - $error_msg = $error_msg.", ".$error; - } - } - $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); - } else { - exec ('mktemp -d', $mktemp_output, $return_var); - $tmpdir = $mktemp_output[0]; - - // Certificate - if (!empty($_POST['v_ssl_crt'])) { - $fp = fopen($tmpdir."/".$_POST['v_domain'].".crt", 'w'); - fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_crt'])); - fclose($fp); - } - - // Key - if (!empty($_POST['v_ssl_key'])) { - $fp = fopen($tmpdir."/".$_POST['v_domain'].".key", 'w'); - fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_key'])); - fclose($fp); - } - - // CA - if (!empty($_POST['v_ssl_ca'])) { - $fp = fopen($tmpdir."/".$_POST['v_domain'].".ca", 'w'); - fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_ca'])); - fclose($fp); - } - exec (VESTA_CMD."v-add-web-domain-ssl ".$user." ".$v_domain." ".$tmpdir." ".$v_ssl_home." 'no'", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_ssl = 'yes'; - $restart_web = 'yes'; - $v_ssl_crt = $_POST['v_ssl_crt']; - $v_ssl_key = $_POST['v_ssl_key']; - $v_ssl_ca = $_POST['v_ssl_ca']; - $v_ssl_home = $_POST['v_ssl_home']; - } - } - - // Web Stats - if ((!empty($v_stats)) && ($_POST['v_stats'] == 'none') && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-delete-web-domain-stats ".$v_username." ".$v_domain, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_stats = ''; - } - if ((!empty($v_stats)) && ($_POST['v_stats'] != $v_stats) && (empty($_SESSION['error_msg']))) { - $v_stats = escapeshellarg($_POST['v_stats']); - exec (VESTA_CMD."v-change-web-domain-stats ".$v_username." ".$v_domain." ".$v_stats, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - } - if ((empty($v_stats)) && ($_POST['v_stats'] != 'none') && (empty($_SESSION['error_msg']))) { - $v_stats = escapeshellarg($_POST['v_stats']); - exec (VESTA_CMD."v-add-web-domain-stats ".$v_username." ".$v_domain." ".$v_stats, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - } - - // Web Stats Auth - if ((!empty($v_stats_user)) && (empty($_POST['v_stats_auth'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-delete-web-domain-stats-user ".$v_username." ".$v_domain, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_stats_user = ''; - $v_stats_password = ''; - } - if ((empty($v_stats_user)) && (!empty($_POST['v_stats_auth'])) && (empty($_SESSION['error_msg']))) { - if (empty($_POST['v_stats_user'])) $errors[] = _('stats username'); - if (empty($_POST['v_stats_password'])) $errors[] = _('stats password'); - if (!empty($errors[0])) { - foreach ($errors as $i => $error) { - if ( $i == 0 ) { - $error_msg = $error; - } else { - $error_msg = $error_msg.", ".$error; - } - } - $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); - } else { - $v_stats_user = escapeshellarg($_POST['v_stats_user']); - $v_stats_password = escapeshellarg($_POST['v_stats_password']); - exec (VESTA_CMD."v-add-web-domain-stats-user ".$v_username." ".$v_domain." ".$v_stats_user." ".$v_stats_password, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_stats_password = "••••••••"; - } - } - if ((!empty($v_stats_user)) && (!empty($_POST['v_stats_auth'])) && (empty($_SESSION['error_msg']))) { - if (empty($_POST['v_stats_user'])) $errors[] = _('stats user'); - if (empty($_POST['v_stats_password'])) $errors[] = _('stats password'); - if (!empty($errors[0])) { - foreach ($errors as $i => $error) { - if ( $i == 0 ) { - $error_msg = $error; - } else { - $error_msg = $error_msg.", ".$error; - } - } - $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); - } - if (($v_stats_user != $_POST['v_stats_user']) || ($_POST['v_stats_password'] != "••••••••" ) && (empty($_SESSION['error_msg']))) { - $v_stats_user = escapeshellarg($_POST['v_stats_user']); - $v_stats_password = escapeshellarg($_POST['v_stats_password']); - exec (VESTA_CMD."v-add-web-domain-stats-user ".$v_username." ".$v_domain." ".$v_stats_user." ".$v_stats_password, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_stats_password = "••••••••"; - } - } - - // FTP Account - if ((!empty($v_ftp_user)) && (empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-delete-web-domain-ftp ".$v_username." ".$v_domain, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_ftp= ''; - $v_ftp_user = ''; - $v_ftp_password = ''; - } - if ((!empty($v_ftp_user)) && (!empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) { - if (empty($_POST['v_ftp_user'])) $errors[] = _('ftp user'); - if (empty($_POST['v_ftp_password'])) $errors[] = _('ftp user password'); - if (!empty($errors[0])) { - foreach ($errors as $i => $error) { - if ( $i == 0 ) { - $error_msg = $error; - } else { - $error_msg = $error_msg.", ".$error; - } - } - $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); - } - if (($v_ftp_user != $_POST['v_ftp_user']) || ($_POST['v_ftp_password'] != "••••••••" ) && (empty($_SESSION['error_msg']))) { - $v_ftp_user = preg_replace("/^".$user."_/", "", $_POST['v_ftp_user']); - $v_ftp_user = escapeshellarg($v_ftp_user); - $v_ftp_password = escapeshellarg($_POST['v_ftp_password']); - exec (VESTA_CMD."v-add-web-domain-ftp ".$v_username." ".$v_domain." ".$v_ftp_user." ".$v_ftp_password, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - $v_ftp_user = $_POST['v_ftp_user']; - $v_ftp_password = "••••••••"; - } - } - - if ((empty($v_ftp_user)) && (!empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) { - if ((!empty($_POST['v_ftp_email'])) && (!filter_var($_POST['v_ftp_email'], FILTER_VALIDATE_EMAIL))) $_SESSION['error_msg'] = _('Please enter valid email address.'); - if (empty($_POST['v_ftp_user'])) $errors[] = 'ftp user'; - if (empty($_POST['v_ftp_password'])) $errors[] = 'ftp user password'; - if (!empty($errors[0])) { - foreach ($errors as $i => $error) { - if ( $i == 0 ) { - $error_msg = $error; - } else { - $error_msg = $error_msg.", ".$error; - } - } - $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); - } - if (empty($_SESSION['error_msg'])) { - $v_ftp_user = escapeshellarg($_POST['v_ftp_user']); - $v_ftp_password = escapeshellarg($_POST['v_ftp_password']); - exec (VESTA_CMD."v-add-web-domain-ftp ".$v_username." ".$v_domain." ".$v_ftp_user." ".$v_ftp_password, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } else { - if (!empty($_POST['v_ftp_email'])) { - $to = $_POST['v_ftp_email']; - $subject = _("FTP login credentials"); - $hostname = exec('hostname'); - $from = _('MAIL_FROM',$hostname); - $mailtext .= _('FTP_ACCOUNT_READY',$_GET['domain'],$user."_".$_POST['v_ftp_user'],$_POST['v_ftp_password']); - send_email($to, $subject, $mailtext, $from); - unset($v_ftp_email); - } - } - unset($output); - $v_ftp_user = $user."_".$_POST['v_ftp_user']; - $v_ftp_password = "••••••••"; - } - } - - // Restart web - if (!empty($restart_web) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-restart-web", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - } - - // Restart dns - if (!empty($restart_dns) && (empty($_SESSION['error_msg']))) { - exec (VESTA_CMD."v-restart-dns", $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - } - - if (empty($_SESSION['error_msg'])) { - $_SESSION['ok_msg'] = _('OK: changes has been saved.'); - } - -} -if ($_SESSION['user'] == 'admin') { - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_web.html'); -} else { - include($_SERVER['DOCUMENT_ROOT'].'/templates/user/edit_web.html'); -} -unset($_SESSION['error_msg']); -unset($_SESSION['ok_msg']); -//} - -// Footer -include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); \ No newline at end of file +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; +} else { + $data = json_decode(implode('', $output), true); + unset($output); + $v_username = $user; + $v_domain = $_GET['domain']; + $v_ip = $data[$v_domain]['IP']; + $v_template = $data[$v_domain]['TPL']; + $v_aliases = str_replace(',', "\n", $data[$v_domain]['ALIAS']); + $valiases = explode(",", $data[$v_domain]['ALIAS']); + $v_tpl = $data[$v_domain]['IP']; + $v_cgi = $data[$v_domain]['CGI']; + $v_elog = $data[$v_domain]['ELOG']; + $v_ssl = $data[$v_domain]['SSL']; + if ( $v_ssl == 'yes' ) { + exec (VESTA_CMD."v-list-web-domain-ssl ".$user." '".$v_domain."' json", $output, $return_var); + $ssl_str = json_decode(implode('', $output), true); + unset($output); + $v_ssl_crt = $ssl_str[$v_domain]['CRT']; + $v_ssl_key = $ssl_str[$v_domain]['KEY']; + $v_ssl_ca = $ssl_str[$v_domain]['CA']; + } + $v_ssl_home = $data[$v_domain]['SSL_HOME']; + $v_nginx = $data[$v_domain]['NGINX']; + $v_nginx_ext = str_replace(',', ', ', $data[$v_domain]['NGINX_EXT']); + $v_stats = $data[$v_domain]['STATS']; + $v_stats_user = $data[$v_domain]['STATS_USER']; + if (!empty($v_stats_user)) $v_stats_password = "••••••••"; + $v_ftp_user = $data[$v_domain]['FTP_USER']; + if (!empty($v_ftp_user)) $v_ftp_password = "••••••••"; + $v_suspended = $data[$v_domain]['SUSPENDED']; + if ( $v_suspended == 'yes' ) { + $v_status = 'suspended'; + } else { + $v_status = 'active'; + } + $v_time = $data[$v_domain]['TIME']; + $v_date = $data[$v_domain]['DATE']; + + exec (VESTA_CMD."v-list-user-ips ".$user." json", $output, $return_var); + $ips = json_decode(implode('', $output), true); + unset($output); + + exec (VESTA_CMD."v-list-web-templates json", $output, $return_var); + $templates = json_decode(implode('', $output), true); + unset($output); + + exec (VESTA_CMD."v-list-web-stats json", $output, $return_var); + $stats = json_decode(implode('', $output), true); + unset($output); +} + +// Action +if (!empty($_POST['save'])) { + $v_domain = escapeshellarg($_POST['v_domain']); + + // IP + if (($v_ip != $_POST['v_ip']) && (empty($_SESSION['error_msg']))) { + $v_ip = escapeshellarg($_POST['v_ip']); + exec (VESTA_CMD."v-change-web-domain-ip ".$v_username." ".$v_domain." ".$v_ip." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $restart_web = 'yes'; + unset($output); + exec (VESTA_CMD."v-list-dns-domain ".$v_username." ".$v_domain." json", $output, $return_var); + if ((empty($_SESSION['error_msg'])) && ($return_var == 0 )) { + exec (VESTA_CMD."v-change-dns-domain-ip ".$v_username." ".$v_domain." ".$v_ip." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $restart_dns = 'yes'; + } + unset($output); + foreach($valiases as $v_alias ){ + exec (VESTA_CMD."v-list-dns-domain ".$v_username." '".$v_alias."' json", $output, $return_var); + if ((empty($_SESSION['error_msg'])) && ($return_var == 0 )) { + exec (VESTA_CMD."v-change-dns-domain-ip ".$v_username." '".$v_alias."' ".$v_ip, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $restart_dns = 'yes'; + } + unset($output); + } + } + + // Template + if (( $_SESSION['user'] == 'admin') && ($v_template != $_POST['v_template']) && (empty($_SESSION['error_msg']))) { + $v_template = escapeshellarg($_POST['v_template']); + exec (VESTA_CMD."v-change-web-domain-tpl ".$v_username." ".$v_domain." ".$v_template." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $restart_web = 'yes'; + } + + // Aliases + if (empty($_SESSION['error_msg'])) { + $waliases = preg_replace("/\n/", " ", $_POST['v_aliases']); + $waliases = preg_replace("/,/", " ", $waliases); + $waliases = preg_replace('/\s+/', ' ',$waliases); + $waliases = trim($waliases); + $aliases = explode(" ", $waliases); + $v_aliases = str_replace(' ', "\n", $waliases); + $result = array_diff($valiases, $aliases); + foreach ($result as $alias) { + if ((empty($_SESSION['error_msg'])) && (!empty($alias))) { + $restart_web = 'yes'; + $v_template = escapeshellarg($_POST['v_template']); + exec (VESTA_CMD."v-delete-web-domain-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + + if (empty($_SESSION['error_msg'])) { + exec (VESTA_CMD."v-delete-dns-on-web-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $restart_dns = 'yes'; + } + unset($output); + } + } + + $result = array_diff($aliases, $valiases); + foreach ($result as $alias) { + if ((empty($_SESSION['error_msg'])) && (!empty($alias))) { + $restart_web = 'yes'; + $v_template = escapeshellarg($_POST['v_template']); + exec (VESTA_CMD."v-add-web-domain-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + if (empty($_SESSION['error_msg'])) { + exec (VESTA_CMD."v-add-dns-on-web-alias ".$v_username." ".$v_domain." '".$alias."' 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $restart_dns = 'yes'; + } + unset($output); + } + } + } + + // Nginx + if ((!empty($v_nginx)) && (empty($_POST['v_nginx'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-delete-web-domain-nginx ".$v_username." ".$v_domain." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + unset($v_nginx); + $restart_web = 'yes'; + } + if ((!empty($v_nginx)) && (!empty($_POST['v_nginx'])) && (empty($_SESSION['error_msg']))) { + $ext = preg_replace("/\n/", " ", $_POST['v_nginx_ext']); + $ext = preg_replace("/,/", " ", $ext); + $ext = preg_replace('/\s+/', ' ',$ext); + $ext = trim($ext); + $ext = str_replace(' ', ", ", $ext); + if ( $v_nginx_ext != $ext ) { + $ext = str_replace(', ', ",", $ext); + exec (VESTA_CMD."v-change-web-domain-nginx-tpl ".$v_username." ".$v_domain." 'default' ".escapeshellarg($ext)." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $v_nginx_ext = str_replace(',', ', ', $ext); + unset($output); + $restart_web = 'yes'; + } + } + if ((empty($v_nginx)) && (!empty($_POST['v_nginx'])) && (empty($_SESSION['error_msg']))) { + $nginx_ext = "'jpg,jpeg,gif,png,ico,css,zip,tgz,gz,rar,bz2,doc,xls,exe,pdf,ppt,txt,tar,wav,bmp,rtf,js,mp3,avi,mpeg,html,htm'"; + if (!empty($_POST['v_nginx_ext'])) { + $ext = preg_replace("/\n/", " ", $_POST['v_nginx_ext']); + $ext = preg_replace("/,/", " ", $ext); + $ext = preg_replace('/\s+/', ' ',$ext); + $ext = trim($ext); + $ext = str_replace(' ', ",", $ext); + $v_nginx_ext = str_replace(',', ', ', $ext); + } + exec (VESTA_CMD."v-add-web-domain-nginx ".$v_username." ".$v_domain." 'default' ".escapeshellarg($ext)." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_nginx = 'default'; + $restart_web = 'yes'; + } + + // SSL + if (( $v_ssl == 'yes' ) && (empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-delete-web-domain-ssl ".$v_username." ".$v_domain." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_ssl = 'no'; + $restart_web = 'yes'; + } + if (($v_ssl == 'yes') && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) { + if (( $v_ssl_crt != str_replace("\r\n", "\n", $_POST['v_ssl_crt'])) || ( $v_ssl_key != str_replace("\r\n", "\n", $_POST['v_ssl_key'])) || ( $v_ssl_ca != str_replace("\r\n", "\n", $_POST['v_ssl_ca']))) { + exec ('mktemp -d', $mktemp_output, $return_var); + $tmpdir = $mktemp_output[0]; + + // Certificate + if (!empty($_POST['v_ssl_crt'])) { + $fp = fopen($tmpdir."/".$_POST['v_domain'].".crt", 'w'); + fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_crt'])); + fwrite($fp, "\n"); + fclose($fp); + } + + // Key + if (!empty($_POST['v_ssl_key'])) { + $fp = fopen($tmpdir."/".$_POST['v_domain'].".key", 'w'); + fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_key'])); + fwrite($fp, "\n"); + fclose($fp); + } + + // CA + if (!empty($_POST['v_ssl_ca'])) { + $fp = fopen($tmpdir."/".$_POST['v_domain'].".ca", 'w'); + fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_ca'])); + fwrite($fp, "\n"); + fclose($fp); + } + + exec (VESTA_CMD."v-change-web-domain-sslcert ".$user." ".$v_domain." ".$tmpdir." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $restart_web = 'yes'; + $v_ssl_crt = $_POST['v_ssl_crt']; + $v_ssl_key = $_POST['v_ssl_key']; + $v_ssl_ca = $_POST['v_ssl_ca']; + } + } + if (( $v_ssl == 'yes') && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) { + if ( $v_ssl_home != $_POST['v_ssl_home'] ) { + $v_ssl_home = escapeshellarg($_POST['v_ssl_home']); + exec (VESTA_CMD."v-change-web-domain-sslhome ".$user." ".$v_domain." ".$v_ssl_home." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + $v_ssl_home = $_POST['v_ssl_home']; + unset($output); + } + } + if (( $v_ssl == 'no') && (!empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) { + if ((!empty($_POST['v_ssl'])) && (empty($_POST['v_ssl_crt']))) $errors[] = 'ssl certificate'; + if ((!empty($_POST['v_ssl'])) && (empty($_POST['v_ssl_key']))) $errors[] = 'ssl key'; + if ((!empty($_POST['v_ssl'])) && (empty($_POST['v_ssl_home']))) $errors[] = 'ssl home'; + $v_ssl_home = escapeshellarg($_POST['v_ssl_home']); + if (!empty($errors[0])) { + foreach ($errors as $i => $error) { + if ( $i == 0 ) { + $error_msg = $error; + } else { + $error_msg = $error_msg.", ".$error; + } + } + $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); + } else { + exec ('mktemp -d', $mktemp_output, $return_var); + $tmpdir = $mktemp_output[0]; + + // Certificate + if (!empty($_POST['v_ssl_crt'])) { + $fp = fopen($tmpdir."/".$_POST['v_domain'].".crt", 'w'); + fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_crt'])); + fclose($fp); + } + + // Key + if (!empty($_POST['v_ssl_key'])) { + $fp = fopen($tmpdir."/".$_POST['v_domain'].".key", 'w'); + fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_key'])); + fclose($fp); + } + + // CA + if (!empty($_POST['v_ssl_ca'])) { + $fp = fopen($tmpdir."/".$_POST['v_domain'].".ca", 'w'); + fwrite($fp, str_replace("\r\n", "\n", $_POST['v_ssl_ca'])); + fclose($fp); + } + exec (VESTA_CMD."v-add-web-domain-ssl ".$user." ".$v_domain." ".$tmpdir." ".$v_ssl_home." 'no'", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_ssl = 'yes'; + $restart_web = 'yes'; + $v_ssl_crt = $_POST['v_ssl_crt']; + $v_ssl_key = $_POST['v_ssl_key']; + $v_ssl_ca = $_POST['v_ssl_ca']; + $v_ssl_home = $_POST['v_ssl_home']; + } + } + + // Web Stats + if ((!empty($v_stats)) && ($_POST['v_stats'] == 'none') && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-delete-web-domain-stats ".$v_username." ".$v_domain, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_stats = ''; + } + if ((!empty($v_stats)) && ($_POST['v_stats'] != $v_stats) && (empty($_SESSION['error_msg']))) { + $v_stats = escapeshellarg($_POST['v_stats']); + exec (VESTA_CMD."v-change-web-domain-stats ".$v_username." ".$v_domain." ".$v_stats, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + if ((empty($v_stats)) && ($_POST['v_stats'] != 'none') && (empty($_SESSION['error_msg']))) { + $v_stats = escapeshellarg($_POST['v_stats']); + exec (VESTA_CMD."v-add-web-domain-stats ".$v_username." ".$v_domain." ".$v_stats, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + } + + // Web Stats Auth + if ((!empty($v_stats_user)) && (empty($_POST['v_stats_auth'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-delete-web-domain-stats-user ".$v_username." ".$v_domain, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_stats_user = ''; + $v_stats_password = ''; + } + if ((empty($v_stats_user)) && (!empty($_POST['v_stats_auth'])) && (empty($_SESSION['error_msg']))) { + if (empty($_POST['v_stats_user'])) $errors[] = _('stats username'); + if (empty($_POST['v_stats_password'])) $errors[] = _('stats password'); + if (!empty($errors[0])) { + foreach ($errors as $i => $error) { + if ( $i == 0 ) { + $error_msg = $error; + } else { + $error_msg = $error_msg.", ".$error; + } + } + $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); + } else { + $v_stats_user = escapeshellarg($_POST['v_stats_user']); + $v_stats_password = escapeshellarg($_POST['v_stats_password']); + exec (VESTA_CMD."v-add-web-domain-stats-user ".$v_username." ".$v_domain." ".$v_stats_user." ".$v_stats_password, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_stats_password = "••••••••"; + } + } + if ((!empty($v_stats_user)) && (!empty($_POST['v_stats_auth'])) && (empty($_SESSION['error_msg']))) { + if (empty($_POST['v_stats_user'])) $errors[] = _('stats user'); + if (empty($_POST['v_stats_password'])) $errors[] = _('stats password'); + if (!empty($errors[0])) { + foreach ($errors as $i => $error) { + if ( $i == 0 ) { + $error_msg = $error; + } else { + $error_msg = $error_msg.", ".$error; + } + } + $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); + } + if (($v_stats_user != $_POST['v_stats_user']) || ($_POST['v_stats_password'] != "••••••••" ) && (empty($_SESSION['error_msg']))) { + $v_stats_user = escapeshellarg($_POST['v_stats_user']); + $v_stats_password = escapeshellarg($_POST['v_stats_password']); + exec (VESTA_CMD."v-add-web-domain-stats-user ".$v_username." ".$v_domain." ".$v_stats_user." ".$v_stats_password, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_stats_password = "••••••••"; + } + } + + // FTP Account + if ((!empty($v_ftp_user)) && (empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-delete-web-domain-ftp ".$v_username." ".$v_domain, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_ftp= ''; + $v_ftp_user = ''; + $v_ftp_password = ''; + } + if ((!empty($v_ftp_user)) && (!empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) { + if (empty($_POST['v_ftp_user'])) $errors[] = _('ftp user'); + if (empty($_POST['v_ftp_password'])) $errors[] = _('ftp user password'); + if (!empty($errors[0])) { + foreach ($errors as $i => $error) { + if ( $i == 0 ) { + $error_msg = $error; + } else { + $error_msg = $error_msg.", ".$error; + } + } + $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); + } + if (($v_ftp_user != $_POST['v_ftp_user']) || ($_POST['v_ftp_password'] != "••••••••" ) && (empty($_SESSION['error_msg']))) { + $v_ftp_user = preg_replace("/^".$user."_/", "", $_POST['v_ftp_user']); + $v_ftp_user = escapeshellarg($v_ftp_user); + $v_ftp_password = escapeshellarg($_POST['v_ftp_password']); + exec (VESTA_CMD."v-add-web-domain-ftp ".$v_username." ".$v_domain." ".$v_ftp_user." ".$v_ftp_password, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_ftp= ''; + $v_ftp_user = ''; + $v_ftp_password = ''; + } + if ((!empty($v_ftp_user)) && (!empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) { + if (empty($_POST['v_ftp_user'])) $errors[] = _('ftp user'); + if (empty($_POST['v_ftp_password'])) $errors[] = _('ftp user password'); + if (!empty($errors[0])) { + foreach ($errors as $i => $error) { + if ( $i == 0 ) { + $error_msg = $error; + } else { + $error_msg = $error_msg.", ".$error; + } + } + $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); + } + if (($v_ftp_user != $_POST['v_ftp_user']) || ($_POST['v_ftp_password'] != "••••••••" ) && (empty($_SESSION['error_msg']))) { + $v_ftp_user = preg_replace("/^".$user."_/", "", $_POST['v_ftp_user']); + $v_ftp_user = escapeshellarg($v_ftp_user); + $v_ftp_password = escapeshellarg($_POST['v_ftp_password']); + exec (VESTA_CMD."v-add-web-domain-ftp ".$v_username." ".$v_domain." ".$v_ftp_user." ".$v_ftp_password, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $v_ftp_user = $_POST['v_ftp_user']; + $v_ftp_password = "••••••••"; + } + } + } + + if ((empty($v_ftp_user)) && (!empty($_POST['v_ftp'])) && (empty($_SESSION['error_msg']))) { + if ((!empty($_POST['v_ftp_email'])) && (!filter_var($_POST['v_ftp_email'], FILTER_VALIDATE_EMAIL))) $_SESSION['error_msg'] = _('Please enter valid email address.'); + if (empty($_POST['v_ftp_user'])) $errors[] = 'ftp user'; + if (empty($_POST['v_ftp_password'])) $errors[] = 'ftp user password'; + if (!empty($errors[0])) { + foreach ($errors as $i => $error) { + if ( $i == 0 ) { + $error_msg = $error; + } else { + $error_msg = $error_msg.", ".$error; + } + } + $_SESSION['error_msg'] = _('Error: field "%s" can not be blank.',$error_msg); + } + if (empty($_SESSION['error_msg'])) { + $v_ftp_user = escapeshellarg($_POST['v_ftp_user']); + $v_ftp_password = escapeshellarg($_POST['v_ftp_password']); + exec (VESTA_CMD."v-add-web-domain-ftp ".$v_username." ".$v_domain." ".$v_ftp_user." ".$v_ftp_password, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } else { + if (!empty($_POST['v_ftp_email'])) { + $to = $_POST['v_ftp_email']; + $subject = _("FTP login credentials"); + $hostname = exec('hostname'); + $from = _('MAIL_FROM',$hostname); + $mailtext .= _('FTP_ACCOUNT_READY',$_GET['domain'],$user."_".$_POST['v_ftp_user'],$_POST['v_ftp_password']); + send_email($to, $subject, $mailtext, $from); + unset($v_ftp_email); + } + } + unset($output); + $v_ftp_user = $user."_".$_POST['v_ftp_user']; + $v_ftp_password = "••••••••"; + } + } + + // Restart web + if (!empty($restart_web) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-restart-web", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + } + + // Restart dns + if (!empty($restart_dns) && (empty($_SESSION['error_msg']))) { + exec (VESTA_CMD."v-restart-dns", $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + } + + if (empty($_SESSION['error_msg'])) { + $_SESSION['ok_msg'] = _('OK: changes has been saved.'); + } + +} +if ($_SESSION['user'] == 'admin') { + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_web.html'); +} else { + include($_SERVER['DOCUMENT_ROOT'].'/templates/user/edit_web.html'); +} +unset($_SESSION['error_msg']); +unset($_SESSION['ok_msg']); +//} + +// Footer +include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html'); diff --git a/web/images/logo.png b/web/images/logo.png index bbabeeeded9ab348104f3c154b3f4f4b31b19131..19acb5a434eb45303ede3cb50d287a499a734b54 100644 GIT binary patch delta 2288 zcmV-zY2c{!AV3xRCwC#oPTH?RTjrTF(n{8C<)CXWQinJTp})&CtWI) zF7;)JR9uv%mX=C`l2GZQC^i*EP!to3N};qQv{)>PHf05IQS58k;-VmZ5Gcw9Yl^`K z!Ac&*V4x7Pf6RCAdVA;Ro7c46IWWAr^W)Ck`@QF!?>YC*Yg&I=S|XSKAGs;-f*kN% zZeUsQyVBdYXH{eG|*$5>jTDsS2ZAVS#}Li zCVjw8U=|qB?`~kV&UXRN0RzBV;8Ww?)xg%g`>!9sH#h)%&|$_`>bGbeU#H)l+OGop zfQ1~AYZLG;tL%RRdH~n~bO^koI{q1O8E8@YTVNaTjx{)*%^|rq0B;k>7l1hdIB)pk zN&QxVJEig88X9{6_`6L0Eby8JhD+;nS>~{8y$IM@{oW(TpJp`%kaf3fkEIOz}MRPM9w}Fh#!9dn{@qd;CA`ymvwBLH2)Cr z2=EXvrE(jvS1#c+a3t#Gc09V(bSaetZ7*p6Pv7Vue|oB%NW(9NoO?;+?HS;6fxq53 z-y&1p6JWkS0-hAhzXTlC;Mu1A4KdztSk~vP!)mysRc`4d@V$Wd2f!S#6k|K?sB>6# zn%A9_f|!4DJmxdZZ8)Ia{`rwCP5M4*AOhuRh~MpXbovDWYn$&*;2Ypq;77TNo&Yi! zrK#qAcf|Gm0?2+w(K;Sghk5^5b$ZG1Zeu#%>bN(FHF5!N?zh$hc(Y>XH6mhv0`3O> zC;*GP=8SdUjLiK}nb&7!_CExkkk20g_5)8D0C#@?F90V}`1MK%7;!o;jY*#{H2Zjr zK~^*rVIsxz%8vS4V+@K|KD-6^LVzPb`h=KxpI*2i;P2OdpE~}K!mj~Gy+3EhxTG?xn7s$MMLv9k+(etKOq;HKSS}?@%loay zmt%BFy@0n`uEnlzTp)Mrd?kZ^YYnhs-P(Vqllt(geD9(Fe#JwtC*NF;T#`HZ zr^2>>tGwC(8*zz30zY1gsTt)A2XHOK-;ZYatWrYFk44({OZ)#I;&cl5uSV9bz&#pG z=QC))21ogv<>N0BKHWMIqf>0nn9fM!NWt1pLJb_?#mFvt8SenDSx+8nOoX zK^dtZWLdfr`loV4Hq6$Hs1V6cllt5DmapFH(DX)u?y^$ldH~;V5V3j1#*5PGO(Jdw zEi<2m>@rw+yRvXevu-u3@g_;jG92r6bo|g&0=?hS-bxJq5(xM#UK-VB;eLPW^f2D6 zR=dF2lyO6B%d#j9+p3NnQbNBvHM1Y9!5H2Yq^W17o=fl@n*t09U6U0 z#(=-Yl@l}t5w+7QFVq2ee~2Xrl3t+6vE3Hp4jKu180n1SFQI_%!ds2fsU*nDGWEV( z=E_NvdgY=l%b)QkXeKq_-cf&8_({xqY~NgJKz1!kfX0y{fYdZ{fs29Y1fq!)0x0053Km9E%IO4MHg+?e2eeL=RD6XdvL{ zMcRh&79RR!X{VuO1;xop=3mt=`*->thHF*;6Lxur8cb$?i2T7O8 zEvL}_G%}{}@pyoLE@toy*BpLRz!sTiT@j&?rnCcpk=eZ<2LG;cz7zN7Lp}1(Ga`S3 zh83Ao%mj;M?q{;0%Z>MQ5;Z2zAFv7Jo>(wU$IwOgR?GMq=ih~RI ziy6lS{-EReX(ELFgn*~k@D~*icL?lLhFM;#WXT%_nCE1UH>>=D7{95pn`I@!WB_kk zv{}Dtr(w%hgOh)1*IIZn20QCfbC`j%9cuL5Bk6_B-v_vnp?4r(Dpua+>R3~guJZ_DgO z3RU@Af2C>FxNfs?-2sJpkINP8S*DOEN;60p4OFcACJcWU&}}?#IwnZHhBdOU-(qO& zc+7U!f?QA2@BY*${2w58D;A%^`#$U?Y4HMZpDOPVvu*?aCG)mY{(goG7D49!0FhkM z{sY7Tg;3iy;(XtHvq+Zz-Px@C`-m92`5|I&-u=rfX}=Gja`@&k;8BC{+>5uo*v!uD zBHqUZxin}<(*DQGJ_EQ(Y5yAQn)MD7-kf*&^$GZ#7dbGclH zCfy}_6f>_AVf$Fe@0KsGlHJngTvAF?{@0tiNzWw*JeM0q{x<+%wOOI}JT2D%0000< KMNUMnLSTY0^lSV8 delta 3235 zcmV;U3|#Y;C&4bTzY2d0Y)M2xRCwC#oPTUv)fLA-&ra+(ag)YrevuN^w3JfB1k1!! z#MB9#sfdXQ)G$=U)M}_zQKwEIS|$(@2t-Q7q)HuCs#a7(Oj}b8Y1#x@0~%u5A5)_t zbpt}%lm^l!O&TYSYsZd%?2mU`u5aG6pIy6?z(;!W`+47c_j`ZOIp1^cc{bANG!^;w zh^x{C6~HU<4VEf(V_^F}00RDLzPIAv_&m{K+w}usrzgh~9xjC1IXBhGT(q84+OR#h z_rT5yYNgb0myyQjiBj!eD5kwzfK$L6FaoSqj%@(?ftO`KToq4MoVLbsmIuc0c_SD` zg;!h`4F@oc6rO*o1zfIFzH2uCn}KnlPkwg*tK|3!;2B^Ga2N2da_uVMQMEB|RgCX6 ze?eVMnA78{n29VUm8y80@&is9gEWv+%hp=}_!A2=-XOo-+WvL&yII!9fW0nPD%#p` zkveaLPrh2q)LawEl)HjbIRVE2w>yE6`??j{b_US>z~g^F2M`60$o}_$IN*`(Pk>Fp zo7&)b8o*x@W_A1L#1pqM8)+bwu4sB$e7MV%qTV-0bN!_5M*{+CKmkzI=8xrf47d&W zKF|dGS@xd=ehT~*I1D_gn0{UBP4sJLS>7~8P4&E3oQjkj@FxEy)^vPIpf05DzDEey z3HiNU{Pll*z(HWI`00!!#R9ynXue0*XGOb5f#ceXKMGM|$< z+Im6A+f%^b1pIr{h)YcMS{w8Ij+pm8(f&g+cs2ot3?sdMS^X5As(7yV*)7)RgoV|x zl15-!&OIZ*X9mEuu+@CaQHwTrOPlI>$3;O@IqL8p>ayGBy)(!Aiu2)yWhk~+G!Oyh zh@F4m1$rzx{j311o9|BGzd!`|N?e6LFuLo!VH)c~x%_xgTkp#A&bi$O>?Ey|G}x6>&@Ke1{ORHNc&~asjYg&iPQgZdAHV7~x=pR8|?jz1vb*A|O*56hB~X^WWs zC1L-a3MZhkF2vHh87|JY*mcHk3ypOOxE%mJ79Fk2Rt@YBut%;7YNobZ_B~?JPFjC^ zpPnK#KImjHRoRTjyOizCz^?>|r}#Q8xsqP z9h{k1NhDUA>;ALi4*n!z+uvn-m6GHExWijL?=QfQ2OVn0Af=N~4u8L=g!g|67O44- zNZUTq{uW`>?*pI7$ht`~XKSS{&v&P45ci|vz|kDsh^ zCBtqbm5)T_>J(iwMoOe{6v6V#1$cL{fM?R4eo3Uppx zzt{pkE@{*Z3(urZ4`I$~H48Wos5zo!%7xpNv`nz1G0Xyn+%tcix@AdWB26-Js0V8tmRfL-7gw;0&^y;QzLFjq69FrXaRqSm8~NzTQY^W zI+g{z!{UYCuy}&T5BP+|9|5BI%5ZYLcyA6%K#tU^VX>^t;SS0PdM?tLkH6#ud^={D zQl}(AUKCS*)h&OcO`6nH&(pbVl-oQ1!|L|WY4TqxwCZ(IEX#K>CulyF0r#eag@19_ zj_#X-Wyr4O6FbnimVvN2;V<@pOM=9wozo%V(%rx=%!!djblL4nQs=!wXVaIgUH&PZ z%SNg7MsOJ^3?oGj?R-_t{j9bskb2u({aQR|7?nf4xOa|LGM z#2d2zwDt^fAYLTk-DL>JoPw@{5G;{)cUeRa`NGh}fJ<0)T1eYA%)-N0exxub>wcRIUl{l~<`nFh#OYy&)vJSf2-o#2Y1(4} zRH?IT1znRBFC|h{RJjuff${;bW0o-;voPbHe0OxalK5-FDj9rTA%L%o-yRjdkV&&X zC|d6qGkDcB=1Jh_EV{eE!B7q<)pTgFfH&&Tkfnbzu?4TXnaQDdi=Q3BtX|1zV5SEB zZQwP&E_AfT-(uS%*5pad4;i+|eb-6y)2E1Rw$D=m>xw{1Su$sd+ zY?i!f)+`N=#C<5)EZy8T13wV6dsZ0y@08=6XrB*>tQG$}D&#N2R)=LtDk;?l&2qTK zzmI51dnz&(p361852+vDA+#z7UubAb#Bw6yB z0_I6E#~Wq)Ibr;&#%>fVkxRBIwzC+=Ok902#{j96foWgHR5l7b-BM%=w;K8lFtKnY`RW>(U7V z{;XPXy+~n9{B5SvbWAyKqjKJU3G;p-u3%TOJv%qQge%T{xE>OP9GKIC1++b+T{ob( zfG*{JBMw38QLK@E{v(RU9(4HLAv=H9W2k@XGq8OhZdZ~U8qag<^3U*A#nf|mNGv{# z`F+?6qQz0*hthb5FzW#3hl71GC{_vJlf{4?OL#eT;bumsZsg(LK1D@}mqnQjQ_GvV zINPFsrn_H4sK;c)Wqh+wNLJ>%vvKk7eZtVy4-tC`dAKwN@q~x-)9p;mwp4$<6)%BU zPE^Mhyo^rWNWJee^}fqi)1Jc?zPTUxnL>E(1|HI~bK9}`{wtj}h$lTHQ*K;F>MBVa zpK0a7Ogqt-uYy*&08e9ZIa<#blQ*%d?F_Zvh@K1ID_Y(oOn$$xcvbGPFyWRe8c%o_ zpK0TKsGWGigWHuf2SCEZ{6c?CMYGEdI6xv<#l&nY)$RpuYCcDuH7fpnTuVF&$JO=@Z>9nsz|v22Z%3t7@J;B8iTHuv-$qUYnQ~# z>x8gn{{7)j@#SMErOoNIX+_RVbTKj8>ZA;+A|()`^4FW+a+Y3^3g8$3n-jKx9jP7LeL$-D%~CV9KNF#HF> z1$&oI28wVNctjR6FmMZlFeAgPITAoY_7YEDSN1zB;yj8vYS#8;K%oFn7sn8e>!s&5 zayB@KG(Y6ux@G&;5(f4HhVKQo?iT|2bV?YiXA8@pg)5E literal 0 HcmV?d00001 diff --git a/web/images/stop.png b/web/images/stop.png new file mode 100644 index 0000000000000000000000000000000000000000..808e605b6ba47cf368345e32c7bdb17271a3bb25 GIT binary patch literal 150 zcmeAS@N?(olHy`uVBq!ia0vp^Y#_`5A|IT2?*XJ3i-X*q7}lMWc?pt9@^*J&_z!{$ z_AZ|c6yYrJh%9Dc;1&j9Muu5)B!GhKC7!;n>~|UYM3lLE=f_P43W<5TIEHXsPfkfl kSdn;uX@*1rLlw|?uS*Oar&H>W0aY+~y85}Sb4q9e05Lr#mH+?% literal 0 HcmV?d00001 diff --git a/web/inc/i18n/ru.php b/web/inc/i18n/ru.php index 9ff7dedcd..27092d937 100644 --- a/web/inc/i18n/ru.php +++ b/web/inc/i18n/ru.php @@ -17,6 +17,9 @@ $LANG = array( 'minute'=>'минута', 'hour'=>'час', 'day'=>'день', + 'days'=>'дня(ей)', + 'hours'=>'часа(ов)', + 'minutes'=>'минут(ы)', 'month'=>'месяц', 'day of week'=>'день недели', 'cmd'=>'командная строка', diff --git a/web/inc/main.php b/web/inc/main.php index 7f80a3279..4772250fd 100644 --- a/web/inc/main.php +++ b/web/inc/main.php @@ -1,159 +1,177 @@ -1) { $args[0] = $text; - return call_user_func_array("sprintf",$args); - } - else return $text; -} - -// Check user session -if ((!isset($_SESSION['user'])) && (!isset($api_mode))&&!defined('NO_AUTH_REQUIRED')) { - $_SESSION['request_uri'] = $_SERVER['REQUEST_URI']; - header("Location: /login/"); - exit; -} - -if (isset($_SESSION['look']) && ( $_SESSION['look'] != 'admin' )) { - $user = $_SESSION['look']; -} else { - $user = $_SESSION['user']; -} - -define('VESTA_CMD', '/usr/bin/sudo /usr/local/vesta/bin/'); - -$i = 0; - -// Define functions -function check_error($return_var){ - if ( $return_var > 0 ) { - header("Location: /error/"); - exit; - } -} - -function top_panel($user, $TAB) { - global $panel; - $command = VESTA_CMD."v-list-user '".$user."' 'json'"; - exec ($command, $output, $return_var); - if ( $return_var > 0 ) { - header("Location: /error/"); - exit; - } - $panel = json_decode(implode('', $output), true); - unset($output); - if ( $user == 'admin' ) { - include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/panel.html'); - } else { - include($_SERVER['DOCUMENT_ROOT'].'/templates/user/panel.html'); - } -} - -function humanize_time($usage) { - if ( $usage > 60 ) { - $usage = $usage / 60; - $usage = number_format($usage, 2); - $usage = $usage." Hour."; - } else { - $usage = $usage." Min."; - } - return $usage; -} - -function humanize_usage($usage) { - if ( $usage > 1000 ) { - $usage = $usage / 1000; - if ( $usage > 1000 ) { - $usage = $usage / 1000 ; - if ( $usage > 1000 ) { - $usage = $usage / 1000 ; - $usage = number_format($usage, 2); - $usage = $usage." pb"; - } else { - $usage = number_format($usage, 2); - $usage = $usage." tb"; - } - } else { - $usage = number_format($usage, 2); - $usage = $usage." gb"; - } - } else { - $usage = $usage." mb"; - } - return $usage; -} - -function get_percentage($used,$total) { - if (!isset($total)) $total = 0; - if (!isset($used)) $used = 0; - if ( $total == 0 ) { - $percent = 0; - } else { - $percent = $used / $total; - $percent = $percent * 100; - $percent = number_format($percent, 0, '', ''); - if ( $percent > 100 ) { - $percent = 100; - } - if ( $percent < 0 ) { - $percent = 0; - } - - } - return $percent; -} - -function send_email($to,$subject,$mailtext,$from) { - $charset = "utf-8"; - $to = '<'.$to.'>'; - $boundary = '--' . md5( uniqid("myboundary") ); - $priorities = array( '1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)' ); - $priority = $priorities[2]; - $ctencoding = "8bit"; - $sep = chr(13) . chr(10); - $disposition = "inline"; - $subject = "=?$charset?B?".base64_encode($subject)."?="; - $header = "From: $from \nX-Priority: $priority\nCC:\n"; - $header .= "Mime-Version: 1.0\nContent-Type: text/plain; charset=$charset \n"; - $header .= "Content-Transfer-Encoding: $ctencoding\nX-Mailer: Php/libMailv1.3\n"; - $message = $mailtext; - mail($to, $subject, $message, $header); -} - -function display_error_block() { - if (!empty($_SESSION['error_msg'])) { - echo ' - -
-

'; - echo $_SESSION['error_msg']; - echo "

\n
\n"; - unset($_SESSION['error_msg']); - } -} +1) { $args[0] = $text; + return call_user_func_array("sprintf",$args); + } + else return $text; +} + +// Check user session +if ((!isset($_SESSION['user'])) && (!isset($api_mode))&&!defined('NO_AUTH_REQUIRED')) { + $_SESSION['request_uri'] = $_SERVER['REQUEST_URI']; + header("Location: /login/"); + exit; +} + +if (isset($_SESSION['look']) && ( $_SESSION['look'] != 'admin' )) { + $user = $_SESSION['look']; +} else { + $user = $_SESSION['user']; +} + +define('VESTA_CMD', '/usr/bin/sudo /usr/local/vesta/bin/'); + +$i = 0; + +// Define functions +function check_error($return_var){ + if ( $return_var > 0 ) { + header("Location: /error/"); + exit; + } +} + +function top_panel($user, $TAB) { + global $panel; + $command = VESTA_CMD."v-list-user '".$user."' 'json'"; + exec ($command, $output, $return_var); + if ( $return_var > 0 ) { + header("Location: /error/"); + exit; + } + $panel = json_decode(implode('', $output), true); + unset($output); + if ( $user == 'admin' ) { + include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/panel.html'); + } else { + include($_SERVER['DOCUMENT_ROOT'].'/templates/user/panel.html'); + } +} + +function humanize_time($usage) { + if ( $usage > 60 ) { + $usage = $usage / 60; + if ( $usage > 24 ) { + $usage = $usage / 24; + $usage = number_format($usage, 0); + if ( $usage == 1 ) { + $usage = $usage." "._('day'); + } else { + $usage = $usage." "._('days'); + } + } else { + $usage = number_format($usage, 0); + if ( $usage == 1 ) { + $usage = $usage." "._('hour'); + } else { + $usage = $usage." "._('hours'); + } + } + } else { + if ( $usage == 1 ) { + $usage = $usage." "._('minute'); + } else { + $usage = $usage." "._('minutes'); + } + } + return $usage; +} + +function humanize_usage($usage) { + if ( $usage > 1000 ) { + $usage = $usage / 1000; + if ( $usage > 1000 ) { + $usage = $usage / 1000 ; + if ( $usage > 1000 ) { + $usage = $usage / 1000 ; + $usage = number_format($usage, 2); + $usage = $usage." "._('pb'); + } else { + $usage = number_format($usage, 2); + $usage = $usage." "._('tb'); + } + } else { + $usage = number_format($usage, 2); + $usage = $usage." "._('gb'); + } + } else { + $usage = $usage." "._('mb'); + } + return $usage; +} + +function get_percentage($used,$total) { + if (!isset($total)) $total = 0; + if (!isset($used)) $used = 0; + if ( $total == 0 ) { + $percent = 0; + } else { + $percent = $used / $total; + $percent = $percent * 100; + $percent = number_format($percent, 0, '', ''); + if ( $percent > 100 ) { + $percent = 100; + } + if ( $percent < 0 ) { + $percent = 0; + } + + } + return $percent; +} + +function send_email($to,$subject,$mailtext,$from) { + $charset = "utf-8"; + $to = '<'.$to.'>'; + $boundary = '--' . md5( uniqid("myboundary") ); + $priorities = array( '1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)' ); + $priority = $priorities[2]; + $ctencoding = "8bit"; + $sep = chr(13) . chr(10); + $disposition = "inline"; + $subject = "=?$charset?B?".base64_encode($subject)."?="; + $header = "From: $from \nX-Priority: $priority\nCC:\n"; + $header .= "Mime-Version: 1.0\nContent-Type: text/plain; charset=$charset \n"; + $header .= "Content-Transfer-Encoding: $ctencoding\nX-Mailer: Php/libMailv1.3\n"; + $message = $mailtext; + mail($to, $subject, $message, $header); +} + +function display_error_block() { + if (!empty($_SESSION['error_msg'])) { + echo ' + +
+

'; + echo $_SESSION['error_msg']; + echo "

\n
\n"; + unset($_SESSION['error_msg']); + } +} ?> \ No newline at end of file diff --git a/web/js/events.js b/web/js/events.js index ccbf89abf..8749ac523 100644 --- a/web/js/events.js +++ b/web/js/events.js @@ -1,124 +1,124 @@ -// Init kinda namespace object -var VE = { // Vesta Events object - core: {}, // core functions - callbacks: { // events callback functions - click: {}, - mouseover: {}, - mouseout: {}, - keypress: {} - }, - helpers: {}, // simple handy methods - tmp: {} -}; - -/* - * Main method that invokes further event processing - * @param root is root HTML DOM element that. Pass HTML DOM Element or css selector - * @param event_type (eg: click, mouseover etc..) - */ -VE.core.register = function(root, event_type) { - var root = !root ? 'body' : root; // if elm is not passed just bind events to body DOM Element - var event_type = !event_type ? 'click' : event_type; // set event type to "click" by default - $(root).bind(event_type, function(evt) { - var elm = $(evt.target); - VE.core.dispatch(evt, elm, event_type); // dispatch captured event - }); -} - -/* - * Dispatch event that was previously registered - * @param evt related event object - * @param elm that was catched - * @param event_type (eg: click, mouseover etc..) - */ -VE.core.dispatch = function(evt, elm, event_type) { - if ('undefined' == typeof VE.callbacks[event_type]) { - return VE.helpers.warn('There is no corresponding object that should contain event callbacks for "'+event_type+'" event type'); - } - // get class of element - var classes = $(elm).attr('class'); - // if no classes are attached, then just stop any further processings - if (!classes) { - return; // no classes assigned - } - // split the classes and check if it related to function - $(classes.split(/\s/)).each(function(i, key) { - VE.callbacks[event_type][key] && VE.callbacks[event_type][key](evt, elm); - }); -} - -// -// CALLBACKS -// - - - -/* - * Suspend action - */ -VE.callbacks.click.do_suspend = function(evt, elm) { - var ref = elm.hasClass('data-controls') ? elm : elm.parents('.data-controls'); - var url = $('input[name="suspend_url"]', ref).val(); - var dialog_elm = ref.find('.confirmation-text-suspention'); - VE.helpers.createConfirmationDialog(dialog_elm, 'Confirm SUSPEND', url); -} - -/* - * Unsuspend action - */ -VE.callbacks.click.do_unsuspend = function(evt, elm) { - var ref = elm.hasClass('data-controls') ? elm : elm.parents('.data-controls'); - var url = $('input[name="unsuspend_url"]', ref).val(); - var dialog_elm = ref.find('.confirmation-text-suspention'); - VE.helpers.createConfirmationDialog(dialog_elm, 'Confirm UNSUSPEND', url); -} - -/* - * Delete action - */ -VE.callbacks.click.do_delete = function(evt, elm) { - var ref = elm.hasClass('data-controls') ? elm : elm.parents('.data-controls'); - var url = $('input[name="delete_url"]', ref).val(); - var dialog_elm = ref.find('.confirmation-text-delete'); - VE.helpers.createConfirmationDialog(dialog_elm, 'Confirm DELETE', url); -} - - -/* - * Create dialog box on the fly - * @param elm Element which contains the dialog contents - * @param dialog_title - * @param confirmed_location_url URL that will be redirected to if user hit "OK" - * @param custom_config Custom configuration parameters passed to dialog initialization (optional) - */ -VE.helpers.createConfirmationDialog = function(elm, dialog_title, confirmed_location_url, custom_config) { - var custom_config = !custom_config ? {} : custom_config; - var config = { - modal: true, - autoOpen: true, - width: 360, - title: dialog_title, - close: function() { - $(this).dialog("destroy"); - }, - buttons: { - "Ok": function(event, ui) { - location.href = confirmed_location_url; - }, - "Cancel": function() { - $(this).dialog("close"); - $(this).dialog("destroy"); - } - } - } - config = $.extend(config, custom_config); - var reference_copied = $(elm).clone(); - $(reference_copied).dialog(config); -} - -/* - * Simple debug output - */ -VE.helpers.warn = function(msg) { - alert('WARNING: ' + msg); -} +// Init kinda namespace object +var VE = { // Vesta Events object + core: {}, // core functions + callbacks: { // events callback functions + click: {}, + mouseover: {}, + mouseout: {}, + keypress: {} + }, + helpers: {}, // simple handy methods + tmp: {} +}; + +/* + * Main method that invokes further event processing + * @param root is root HTML DOM element that. Pass HTML DOM Element or css selector + * @param event_type (eg: click, mouseover etc..) + */ +VE.core.register = function(root, event_type) { + var root = !root ? 'body' : root; // if elm is not passed just bind events to body DOM Element + var event_type = !event_type ? 'click' : event_type; // set event type to "click" by default + $(root).bind(event_type, function(evt) { + var elm = $(evt.target); + VE.core.dispatch(evt, elm, event_type); // dispatch captured event + }); +} + +/* + * Dispatch event that was previously registered + * @param evt related event object + * @param elm that was catched + * @param event_type (eg: click, mouseover etc..) + */ +VE.core.dispatch = function(evt, elm, event_type) { + if ('undefined' == typeof VE.callbacks[event_type]) { + return VE.helpers.warn('There is no corresponding object that should contain event callbacks for "'+event_type+'" event type'); + } + // get class of element + var classes = $(elm).attr('class'); + // if no classes are attached, then just stop any further processings + if (!classes) { + return; // no classes assigned + } + // split the classes and check if it related to function + $(classes.split(/\s/)).each(function(i, key) { + VE.callbacks[event_type][key] && VE.callbacks[event_type][key](evt, elm); + }); +} + +// +// CALLBACKS +// + + + +/* + * Suspend action + */ +VE.callbacks.click.do_suspend = function(evt, elm) { + var ref = elm.hasClass('data-controls') ? elm : elm.parents('.data-controls'); + var url = $('input[name="suspend_url"]', ref).val(); + var dialog_elm = ref.find('.confirmation-text-suspention'); + VE.helpers.createConfirmationDialog(dialog_elm, 'Confirm action', url); +} + +/* + * Unsuspend action + */ +VE.callbacks.click.do_unsuspend = function(evt, elm) { + var ref = elm.hasClass('data-controls') ? elm : elm.parents('.data-controls'); + var url = $('input[name="unsuspend_url"]', ref).val(); + var dialog_elm = ref.find('.confirmation-text-suspention'); + VE.helpers.createConfirmationDialog(dialog_elm, 'Confirm action', url); +} + +/* + * Delete action + */ +VE.callbacks.click.do_delete = function(evt, elm) { + var ref = elm.hasClass('data-controls') ? elm : elm.parents('.data-controls'); + var url = $('input[name="delete_url"]', ref).val(); + var dialog_elm = ref.find('.confirmation-text-delete'); + VE.helpers.createConfirmationDialog(dialog_elm, 'Confirm action', url); +} + + +/* + * Create dialog box on the fly + * @param elm Element which contains the dialog contents + * @param dialog_title + * @param confirmed_location_url URL that will be redirected to if user hit "OK" + * @param custom_config Custom configuration parameters passed to dialog initialization (optional) + */ +VE.helpers.createConfirmationDialog = function(elm, dialog_title, confirmed_location_url, custom_config) { + var custom_config = !custom_config ? {} : custom_config; + var config = { + modal: true, + autoOpen: true, + width: 360, + title: dialog_title, + close: function() { + $(this).dialog("destroy"); + }, + buttons: { + "Ok": function(event, ui) { + location.href = confirmed_location_url; + }, + "Cancel": function() { + $(this).dialog("close"); + $(this).dialog("destroy"); + } + } + } + config = $.extend(config, custom_config); + var reference_copied = $(elm).clone(); + $(reference_copied).dialog(config); +} + +/* + * Simple debug output + */ +VE.helpers.warn = function(msg) { + alert('WARNING: ' + msg); +} diff --git a/web/list/log/index.php b/web/list/log/index.php index e76e49d7e..1094cba14 100644 --- a/web/list/log/index.php +++ b/web/list/log/index.php @@ -1,25 +1,24 @@ -', $output); + if (empty($error)) $error = 'Error: service '.$v_service.' restart failed'; + $_SESSION['error_srv'] = $error; + } + unset($output); +} + +header("Location: /list/services/"); +exit; diff --git a/web/start/service/index.php b/web/start/service/index.php new file mode 100644 index 000000000..ff8589a1d --- /dev/null +++ b/web/start/service/index.php @@ -0,0 +1,22 @@ +', $output); + if (empty($error)) $error = 'Error: service '.$v_service.' start failed'; + $_SESSION['error_srv'] = $error; + } + unset($output); +} + +header("Location: /list/services/"); +exit; diff --git a/web/stop/service/index.php b/web/stop/service/index.php new file mode 100644 index 000000000..f2310ae71 --- /dev/null +++ b/web/stop/service/index.php @@ -0,0 +1,22 @@ +', $output); + if (empty($error)) $error = 'Error: service '.$v_service.' stop failed'; + $_SESSION['error_srv'] = $error; + } + unset($output); +} + +header("Location: /list/services/"); +exit; diff --git a/web/templates/admin/add_db.html b/web/templates/admin/add_db.html index 35aecc0a4..9ffd78438 100644 --- a/web/templates/admin/add_db.html +++ b/web/templates/admin/add_db.html @@ -1,184 +1,184 @@ - - -
[] package
[]
Bandwidth: % () + : % ()
Disk: % () + : % ()
@@ -146,12 +146,12 @@
- Web:
- Mail:
+ :
+ :
- Databases:
- User Dirs:
+ :
+ :
@@ -162,31 +162,31 @@
- + - + - + - - + + - + - - + + - +
Template::
Web Domains:: /
Web SSL::
Web Aliases: per domain:
Dns Domains:: /
Dns Records: per domain:
Name Servers:
:
@@ -194,31 +194,31 @@
- + - - + + - + - + - + - + - +
Mail Domains:: /
Mail Accounts: per domain:
Databases:: /
Cron Jobs:: /
Shell::
Dedicated IP::
Backups:: /
@@ -239,9 +239,9 @@
- +
- +
- toggle all +
@@ -79,7 +79,7 @@ - +
" >
">
@@ -90,24 +90,24 @@ if (!empty($data[$key]['STATS'])) { echo ' '; echo ""; - echo ' open webstats "> edit"> - + - - delete + -
- [] template + []
- Bandwidth: + :
Disk: + :
@@ -151,19 +151,19 @@
- + - + - + - +
SSL Support::
SSL Home::
Nginx Support::
Nginx Extentions:: >
@@ -171,11 +171,11 @@
- + - +
Web Statistics: :
Additional FTP: :
@@ -196,9 +196,9 @@
- - - - -
- - - - - - - - - -
- - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- -
- - -
- - -
- -
- -
- -
- -
- -
- -
- > -
- - -
-
- \ No newline at end of file + + + + + + + +
+ +
+ + + + + + + +
+ + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ + +
+ + +
+ +
+ +
+ +
+ +
+ +
+ +
+ > +
+ + +
+
+
diff --git a/web/templates/admin/list_dns.html b/web/templates/admin/list_dns.html index 143b293db..9ce629e65 100644 --- a/web/templates/admin/list_dns.html +++ b/web/templates/admin/list_dns.html @@ -1,146 +1,146 @@ - - - - - -
- -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - ?> - - - - - - -
- - - - -
" >
">
-
- - - - - - - - - -
- - - - - - - - - -
- - - - - - - - - -
- -
- - - - - - -
- -
- [] -
-
- - - - - - - - - -
SOA:
TTL:
-
- - - - - - - - - -
:
:
-
-
- - - - - - - -
- -
-
\ No newline at end of file + + + + + +
+ +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + ?> + + + + + + +
+ + + + +
" >
">
+
+ + + + + + + + + +
+ + + + + + + + + +
+ + + + + + + + + +
+ +
+ + + + + + +
+ +
+ [] +
+
+ + + + + + + + + +
SOA:
TTL:
+
+ + + + + + + + + +
:
:
+
+
+ + + + + + + +
+ +
+
diff --git a/web/templates/admin/list_dns_rec.html b/web/templates/admin/list_dns_rec.html index eda5e6615..a4ea4a553 100644 --- a/web/templates/admin/list_dns_rec.html +++ b/web/templates/admin/list_dns_rec.html @@ -1,115 +1,115 @@ - - - - - -
- -
-
- - - - -
- -
-
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - ?> - - - - - - -
- - - - -
">
-
- - - - - - - -
- - - - - - - - - -
- - - - - - - -
-
- - - - - - -
- - -
-
\ No newline at end of file + + + + + +
+
+
+ + + + +
+ +
+
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + ?> + + + + + + +
+ + + + +
">
+
+ + + + + + + +
+ + + + + + + + + +
+ + + + + + + +
+
+ + + + + + +
+ + +
+
diff --git a/web/templates/admin/list_mail.html b/web/templates/admin/list_mail.html index e12738baf..9b38dd9c5 100644 --- a/web/templates/admin/list_mail.html +++ b/web/templates/admin/list_mail.html @@ -1,173 +1,173 @@ - - - - - -
- -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - if (empty($data[$key]['CATCHALL'])) { - $data[$key]['CATCHALL'] = '/dev/null'; - } - ?> - - - - - - - -
- - - - -
" >
">
-
- - - - - - - - - - -
" target="_blank"> - - - - - - - - - -
- - - - - - - - - - -
- -
- - - - - - - -
- > -
- : -
-
-
-
-
- - - - - - - - - -
- : - - -
- : - - -
-
- - - - - - - - - -
- : - - -
- : - - -
-
-
- - - - - - - -
- -
-
\ No newline at end of file + + + + + +
+ +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + if (empty($data[$key]['CATCHALL'])) { + $data[$key]['CATCHALL'] = '/dev/null'; + } + ?> + + + + + + + +
+ + + + +
" >
">
+
+ + + + + + + + + + +
" target="_blank"> + + + + + + + + + +
+ + + + + + + + + + +
+ +
+ + + + + + + +
+ > +
+ : +
+
+
+
+
+ + + + + + + + + +
+ : + + +
+ : + + +
+
+ + + + + + + + + +
+ : + + +
+ : + + +
+
+
+ + + + + + + +
+ +
+
diff --git a/web/templates/admin/list_mail_acc.html b/web/templates/admin/list_mail_acc.html index 4632ffb29..999b1c821 100644 --- a/web/templates/admin/list_mail_acc.html +++ b/web/templates/admin/list_mail_acc.html @@ -1,162 +1,162 @@ - - - - - -
- -
-
- - - - -
- -
-
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend'; - } - ?> - - - - - - - -
- - - - -
">
-
- - - - - - - -
- - - - - - - - - -
- - - - - - - - -
- - - - - - -
- -
- : -
-
-
-
-
- - - - - - - - - -
- : - - -
- : - - -
-
- - - - - -
- : - - -
-
-
- - - - - - - -
- -
-
\ No newline at end of file + + + + + +
+ +
+
+ + + + +
+ +
+
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend'; + } + ?> + + + + + + + +
+ + + + +
">
+
+ + + + + + + +
+ + + + + + + + + +
+ + + + + + + + +
+ + + + + + +
+ +
+ : +
+
+
+
+
+ + + + + + + + + +
+ : + + +
+ : + + +
+
+ + + + + +
+ : + + +
+
+
+ + + + + + + +
+ +
+
diff --git a/web/templates/admin/list_rrd.html b/web/templates/admin/list_rrd.html index df604a20e..e5b7673bf 100644 --- a/web/templates/admin/list_rrd.html +++ b/web/templates/admin/list_rrd.html @@ -1,72 +1,72 @@ - - - - - - -
- -
- - $value) { - ?> - - - - - - - -
- - - -
">
">
-
- - - - - -
" target="_blank">
- - - - - - -
- - - - -
- "> -
-
-
-
-
+ + + + + + +
+ +
+ + $value) { + ?> + + + + + + + +
+ + + +
">
">
+
+ + + + + +
" target="_blank">
+ + + + + + +
+ + + + +
+ "> +
+
+
+
+
\ No newline at end of file diff --git a/web/templates/admin/list_services.html b/web/templates/admin/list_services.html new file mode 100644 index 000000000..1834a58d9 --- /dev/null +++ b/web/templates/admin/list_services.html @@ -0,0 +1,152 @@ + + + + + + +
+ +
+ + + $value) { + ++$i; + if ($data[$key]['STATE'] == 'running') { + $status = 'active'; + $action = 'stop'; + } else { + $status = 'suspended'; + $action = 'start'; + } + + $cpu = $data[$key]['CPU'] / 10; + $cpu = number_format($cpu, 1); + if ($cpu == '0.0') $cpu = 0; + ?> + + + + + + + +
+ + + +
+
+ + + + + + +
restart
+ + + + + + + + + + + +
+ +
+ + + + +
+ +
+
+ + + + + +
+ CPU: + + % +
+
+ + + + + +
+ Memory: + + mb +
+
+ + + + + +
+ Run Time: + + +
+
+
+ + +
diff --git a/web/templates/admin/list_stats.html b/web/templates/admin/list_stats.html index 59a7f1d4b..f8325fc89 100644 --- a/web/templates/admin/list_stats.html +++ b/web/templates/admin/list_stats.html @@ -1,221 +1,221 @@ - - - - - - -
- -
- - - $value) { - ++$i; - ?> - - - - - - - - -
- - -
">
-
- - - - -
- - - - - - - - - - -
- -
- - - - - - - - - - - - - -
- [] -
- : % () -
-
-
-
- : % () -
-
-
-
- - - - - -
- :
- :
-
- :
- :
-
-
-
- - - - - - - - - - - - - - - - - - - - - -
- : - - -
- : - - -
- : - - -
- : - - -
- : - - -
-
- - - - - - - - - - - - - - - - - - - - - -
- : - - -
- : - - -
- : - - -
- : - - -
- : - - -
-
-
- - - - - - -
- -
-
- + + + + + + +
+ +
+ + + $value) { + ++$i; + ?> + + + + + + + + +
+ + +
">
+
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + + + + + + + + + + +
+ [] +
+ : % () +
+
+
+
+ : % () +
+
+
+
+ + + + + +
+ :
+ :
+
+ :
+ :
+
+
+
+ + + + + + + + + + + + + + + + + + + + + +
+ : + + +
+ : + + +
+ : + + +
+ : + + +
+ : + + +
+
+ + + + + + + + + + + + + + + + + + + + + +
+ : + + +
+ : + + +
+ : + + +
+ : + + +
+ : + + +
+
+
+ + + + + + +
+ +
+
+ diff --git a/web/templates/admin/panel.html b/web/templates/admin/panel.html index b81fd01da..498344688 100644 --- a/web/templates/admin/panel.html +++ b/web/templates/admin/panel.html @@ -1,112 +1,112 @@ -
- - - - -
- - - + +
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\ No newline at end of file +
+ + + - -
+ + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/web/templates/footer.html b/web/templates/footer.html index 8670dd3cb..8fd521c91 100644 --- a/web/templates/footer.html +++ b/web/templates/footer.html @@ -1,12 +1,4 @@ - - - - - - - -
vestacp.com |
@@ -16,7 +8,7 @@ VE.core.register($('.main')); }); - +
diff --git a/web/templates/header.html b/web/templates/header.html index c8759d5b1..57603eee5 100644 --- a/web/templates/header.html +++ b/web/templates/header.html @@ -1,718 +1,726 @@ - - - -Vesta - <?php echo "$TAB"; ?> - - - - - - - - - \ No newline at end of file + + + + Vesta - <?php echo "$TAB"; ?> + + + + + + + + + diff --git a/web/templates/user/list_dns.html b/web/templates/user/list_dns.html index a6cbf6f51..46ac27cdb 100644 --- a/web/templates/user/list_dns.html +++ b/web/templates/user/list_dns.html @@ -1,136 +1,136 @@ - - - - - -
- -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - ?> - - - - - - -
- - - - -
" >
">
-
- - - - - - - - -
list records add record edit - - delete - - -
- - - - - - - - - -
- -
- - - - - - -
- -
- [] template -
-
- - - - - - - - - -
SOA:
TTL:
-
- - - - - - - - - -
Expire:
Records:
-
-
- - - - - - - -
- -
-
\ No newline at end of file + + + + + +
+ +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + ?> + + + + + + +
+ + + + +
" >
">
+
+ + + + + + + + +
list records add record edit + + delete + + +
+ + + + + + + + + +
+ +
+ + + + + + +
+ +
+ [] template +
+
+ + + + + + + + + +
SOA:
TTL:
+
+ + + + + + + + + +
Expire:
Records:
+
+
+ + + + + + + +
+ +
+
diff --git a/web/templates/user/list_dns_rec.html b/web/templates/user/list_dns_rec.html index 2179cc99a..5822be601 100644 --- a/web/templates/user/list_dns_rec.html +++ b/web/templates/user/list_dns_rec.html @@ -1,105 +1,105 @@ - - - - - -
- -
-
- - - - -
- Listing -
-
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - ?> - - - - - - -
- - - - -
">
-
- - - - - - -
edit - - delete - - -
- - - - - - - -
-
- - - - - - -
- - -
-
\ No newline at end of file + + + + + +
+ +
+
+ + + + +
+ Listing +
+
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + ?> + + + + + + +
+ + + + +
">
+
+ + + + + + +
edit + + delete + + +
+ + + + + + + +
+
+ + + + + + +
+ + +
+
diff --git a/web/templates/user/list_mail.html b/web/templates/user/list_mail.html index c0db21eff..bcbd8ad73 100644 --- a/web/templates/user/list_mail.html +++ b/web/templates/user/list_mail.html @@ -1,163 +1,163 @@ - - - - - -
- -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - if (empty($data[$key]['CATCHALL'])) { - $data[$key]['CATCHALL'] = '/dev/null'; - } - ?> - - - - - - - -
- - - - -
" >
">
-
- - - - - - - - - -
list accounts add account" target="_blank"> open webmail edit - - delete - - -
- - - - - - - - - - -
- -
- - - - - - - -
- catchall > -
- Disk: -
-
-
-
-
- - - - - - - - - -
- Antivirus: - - -
- Antispam: - - -
-
- - - - - - - - - -
- DKIM: - - -
- Accounts: - - -
-
-
- - - - - - - -
- -
-
\ No newline at end of file + + + + + +
+ +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + if (empty($data[$key]['CATCHALL'])) { + $data[$key]['CATCHALL'] = '/dev/null'; + } + ?> + + + + + + + +
+ + + + +
" >
">
+
+ + + + + + + + + +
list accounts add account" target="_blank"> open webmail edit + + delete + + +
+ + + + + + + + + + +
+ +
+ + + + + + + +
+ catchall > +
+ Disk: +
+
+
+
+
+ + + + + + + + + +
+ Antivirus: + + +
+ Antispam: + + +
+
+ + + + + + + + + +
+ DKIM: + + +
+ Accounts: + + +
+
+
+ + + + + + + +
+ +
+
diff --git a/web/templates/user/list_mail_acc.html b/web/templates/user/list_mail_acc.html index 4548743b9..0cb05a56a 100644 --- a/web/templates/user/list_mail_acc.html +++ b/web/templates/user/list_mail_acc.html @@ -1,152 +1,152 @@ - - - - - -
- -
-
- - - - -
- Listing -
-
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend'; - } - ?> - - - - - - - -
- - - - -
">
-
- - - - - - -
edit - - delete - - -
- - - - - - - - -
- - - - - - -
- -
- Disk: -
-
-
-
-
- - - - - - - - - -
- Quota: - - -
- Autoreply: - - -
-
- - - - - -
- Forward: - - -
-
-
- - - - - - - -
- -
-
\ No newline at end of file + + + + + +
+ +
+
+ + + + +
+ Listing +
+
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend'; + } + ?> + + + + + + + +
+ + + + +
">
+
+ + + + + + +
edit + + delete + + +
+ + + + + + + + +
+ + + + + + +
+ +
+ Disk: +
+
+
+
+
+ + + + + + + + + +
+ Quota: + + +
+ Autoreply: + + +
+
+ + + + + +
+ Forward: + + +
+
+
+ + + + + + + +
+ +
+
diff --git a/web/templates/user/panel.html b/web/templates/user/panel.html index 3d3d6ed6d..4360d54d0 100644 --- a/web/templates/user/panel.html +++ b/web/templates/user/panel.html @@ -1,113 +1,114 @@ -
- - - - -
- - - + +
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\ No newline at end of file +
+ + + - -
+ + + diff --git a/web/templates/admin/list_rrd.html b/web/templates/admin/list_rrd.html index e5b7673bf..d7b9635be 100644 --- a/web/templates/admin/list_rrd.html +++ b/web/templates/admin/list_rrd.html @@ -47,7 +47,7 @@
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
From a2d33b72ec78f1f388461f9f467b299c6a2243d0 Mon Sep 17 00:00:00 2001 From: ZonD Eighty Date: Wed, 16 Jan 2013 15:36:57 +0400 Subject: [PATCH 08/11] Completed translation to EN/RU HTML need to be fixed, configurable language need to be added to user settings, need to change some API answers to translate RRD Graphics. --- web/inc/i18n/en.php | 335 ++++++++++- web/inc/i18n/ru.php | 27 +- web/restart/service/index.php | 2 +- web/start/service/index.php | 2 +- web/stop/service/index.php | 2 +- web/templates/admin/add_dns.html | 2 +- web/templates/admin/list_rrd.html | 2 +- web/templates/admin/list_services.html | 26 +- web/templates/user/add_dns.html | 282 +++++----- web/templates/user/add_web.html | 744 ++++++++++++------------- web/templates/user/edit_dns.html | 212 +++---- web/templates/user/edit_user.html | 246 ++++---- web/templates/user/edit_web.html | 660 +++++++++++----------- web/templates/user/list_cron.html | 30 +- web/templates/user/list_db.html | 32 +- web/templates/user/list_dns.html | 34 +- web/templates/user/list_dns_rec.html | 26 +- web/templates/user/list_mail.html | 42 +- web/templates/user/list_mail_acc.html | 34 +- web/templates/user/list_search.html | 22 +- web/templates/user/list_stats.html | 40 +- web/templates/user/list_user.html | 68 +-- web/templates/user/list_web.html | 48 +- 23 files changed, 1631 insertions(+), 1287 deletions(-) diff --git a/web/inc/i18n/en.php b/web/inc/i18n/en.php index 31d4872c2..81b754f11 100644 --- a/web/inc/i18n/en.php +++ b/web/inc/i18n/en.php @@ -1,5 +1,4 @@ 'Hour', 'Min'=>'Min', 'pb'=>'pb', + 'tb'=>'tb', + 'gb'=>'gb', + 'mb'=>'mb', + 'Error'=>'Error', + 'minute'=>'minute', + 'hour'=>'hour', + 'day'=>'day', + 'days'=>'days', + 'hours'=>'hours', + 'minutes'=>'minutes', + 'month'=>'month', + 'day of week'=>'day of week', + 'cmd'=>'cmd', + 'Error: field "%s" can not be blank.'=>'Error: Field "%s" can not be blank.', + _('Error: vesta did not return any output.')=>'Error: Vesta did not return any output', + 'OK: cron job has been created successfully.'=>'Success: Cron Job has been created', + 'database'=>'database', + 'username'=>'username', + 'password'=>'password', + 'type'=>'type', + 'charset'=>'charset', + 'edit'=>'edit', + 'DATABASE_CREATED_OK'=>'Success: Database %s has been created.', + 'domain'=>'domain', + 'ip'=>'IP', + 'DOMAIN_CREATED_OK'=>'Success: Domain %s has been created.', + 'RECORD_CREATED_OK'=>'Success: Record %s.%s has been created.', + 'ip address'=>'IP-address', + 'netmask'=>'netmask', + 'Netmask'=>'Netmask', + 'interface'=>'interface', + 'Interface'=>'Interface', + 'assigned user'=>'assigned user', + 'IP_CREATED_OK'=>'"Success: IP address %s has been created.', + 'DOMAIN_MAIL_CREATED_OK'=>'Success: Mail for domain %s has been created.', + 'account'=>'account', + 'Account'=>'Account', + 'MAIL_ACCOUNT_CREATED_OK'=>'Success: Mail account %s@%s has been created.', + 'package'=>'package', + 'template'=>'template', + 'shell'=>'SSH', + 'web domains'=>'web domains', + 'Web Domains'=>'Web Domains', + 'Web Aliases'=>'Web Aliases', + 'per domain'=>'per domain', + 'DNS domains'=>'DNS domains', + 'DNS records count'=>'DNS records count', + 'DNS Support'=>'DNS Support', + 'Mail Support'=>'Mail Support', + 'web aliases'=>'web aliases', + 'dns records'=>'DNS records', + 'mail domains'=>'mail domains', + 'mail accounts'=>'mail accounts', + 'Mail Domains'=>'Mail Domains', + 'Mail Accounts'=>'Mail Accounts', + 'accounts'=>'accounts', + 'databases'=>'databases', + 'Databases'=>'Databases', + 'cron jobs'=>'cron jobs', + 'Cron Jobs'=>'Cron Jobs', + 'Backups'=>'Backups', + 'backups'=>'backups', + 'quota'=>'disk quota', + 'bandwidth'=>'bandwidth', + 'Bandwidth'=>'Bandwidth', + 'ns1'=>'ns1', + 'ns2'=>'ns2', + 'PACKAGE_CREATED_OK'=>'Success: Package %s has been created.', + 'user'=>'user', + 'email'=>'email', + 'Email'=>'Email', + 'first name'=>'first name', + 'last name'=>'last name', + 'Please enter valid email address.'=>'Please enter valid email address.', + 'Welcome to Vesta Control Panel'=>'Welcome to Vesta Control Panel', + 'MAIL_FROM'=>'Vesta Control Panel ', + 'GREETINGS_GORDON_FREEMAN'=>"Hello, %s %s,\n", + 'GREETINGS'=>"Hello,\n", + 'ACCOUNT_READY'=>"You account has been created and ready for use.\n\nhttps://%s/login/\nUsername: %s\nPassword: %s\n\n--\nVesta Control Panel\n", + 'ACCOUNT_CREATED_OK'=>'Success: User %s has been created.', + 'ssl certificate'=>'SSL certificate', + 'ssl key'=>'SSL key', + 'SSL Support'=>'SSL Support', + 'SSL Home Directory'=>'SSL Home Directory', + 'SSL Certificate'=>'SSL Certificate', + 'SSL Key'=>'SSL Key', + 'SSL Certificate Authority / Intermediate'=>'SSL Certificate Authority / Intermediate', + 'stats user password'=>'stats user password', + 'stats username'=>'stats username', + 'stats password'=>'stats password', + 'ftp user password'=>'FTP user password', + 'ftp user'=>'FTP user', + 'FTP login credentials'=>'FTP login credentials', + 'FTP_ACCOUNT_READY'=>"Your FTP account has been created and ready for use.\n\nHostname: %s\nUsername: %s_%s\nPassword: %s\n\n--\nVesta Control Panel\n", + 'HOSTING_DOMAIN_CREATED_OK'=>'Success: Web domain %s has been created.', + 'OK: changes has been saved.'=>'Success: Changes have been saved.', + 'FTP login credentials'=>'FTP login credentials', + '505'=>'505 — oops, internal error. Call an Ambulance!', + 'An internal error occurred'=>'An internal error occurred', + 'GO_BACK_LINK'=>'Try to go back to main page or go to previous page', + 'ERROR: Invalid username or password'=>'Error: Invalid username or password', + 'ERROR: Invalid username or code'=>'Error: Invalid username or reset code', + 'MAIL_RESET_SUBJECT'=>'Password Reset at %s', + 'PASSWORD_RESET_REQUEST'=>"You recently requested a password reset.\nTo coutinue to reset your password, visit this link:\nhttps://%s/reset/?action=confirm&user=%s&code=%s\n\nAlternatively, you can visit this link: https://%s/reset/?action=code&user=%s and enter the following reset code:\n%s\n\nIf you did not request password reset, please ignore this message and take out apologies.\n\n--\nVesta Control Panel\n", + 'ERROR: Passwords not match'=>'Error: Passwords did not match', + 'Adding Cron Job'=>'Adding Cron Job', + 'Minute'=>'Minute', + 'Day'=>'Day', + 'Month'=>'Month', + 'Day of week'=>'Day of week', + 'Command'=>'Command', + 'Add'=>'Add', + 'Back'=>'Back', + 'Adding database'=>'Adding database', + 'DB_PREFIX_WILL_BE_ADDED'=>'Prefix %s will be automatically added to Database and User name', + 'FTP_PREFIX_WILL_BE_ADDED'=>'Prefix %s will be automatically added to User name', + 'Database'=>'Database', + 'Username'=>'Username', + 'Password'=>'Password', + 'generate'=>'generate', + 'Type'=>'Type', + 'Charset'=>'Charset', + 'Adding DNS Domain'=>'Adding DNS Domain', + 'Domain'=>'Domain', + 'IP-Address'=>'IP-Address', + 'Advanced options'=>'Advanced options', + 'Template'=>'Template', + 'Expiration date'=>'Expiration date', + 'Expire'=>'Expire', + 'YYYY-MM-DD'=>'YYYY-MM-DD', + 'Name servers'=>'Name servers', + 'Name Servers'=>'Name Servers', + 'Powered by Vesta Control Panel'=>'Powered by Vesta Control Panel', + 'Vesta Control Panel'=>'Vesta Control Panel', + 'Translation by ZonD80'=>'Translation by ZonD80', + 'Forgot Password?'=>'Forgot Password?', + 'Log in'=>'Log in', + 'Log out'=>'Log out', + "RESET_NOTICE"=>"Please enter you username to continue.", + 'Submit'=>'Submit', + 'RESET_CODE_SENT'=>'Password reset code has been sent to your email address
Please enter the code into field located below', + 'Confirm'=>'Confirm', + 'New Password'=>'New Password', + 'Confirm Password'=>'Confirm Password', + 'Reset'=>'Reset', + 'Statistics'=>'Statistics', + 'History Log'=>'History Log', + 'Vesta logo'=>'Vesta logo', + 'USER'=>'USER', + 'logout'=>'logout', + 'users'=>'users', + 'Users'=>'Users', + 'suspended'=>'suspended', + 'WEB'=>'WEB', + 'domains'=>'domains', + 'aliases'=>'aliases', + 'Aliases'=>'Aliases', + 'DNS'=>'DNS', + 'records'=>'records', + 'Records'=>'Records', + 'MAIL'=>'MAIL', + 'DB'=>'DB', + 'CRON'=>'CRON', + 'BACKUP'=>'BACKUP', + 'Packages'=>'Packages', + 'IP Addresses'=>'IP Addresses', + 'RRD Graphics'=>'RRD Graphics', + 'jobs'=>'jobs', + 'Reset Code'=>'Reset Code', + 'disk'=>'disk', + 'Disk'=>'Disk', + 'traffic'=>'traffic', + 'Database Credentials'=>'Database Credentials', + 'DATABASE_READY'=>"Hello, %s %s,\nYour %s database has been created successfully.\n\nDatabase: %s_%s\nUser: %s_%s\nPassword: %s\n\n", + 'Send credentials to'=>'Send credentials to', + 'Adding DNS Record'=>'Adding DNS Record', + 'Record'=>'Record', + 'IP or Value'=>'IP-address or Valie', + 'Priority'=>'Priority', + 'optional'=>'optional', + 'Adding IP Address'=>'Adding IP Address', + 'Shared'=>'Shared', + 'Assigned user'=>'Assigned user', + 'Assigned domain'=>'Assigned domain', + 'Adding Mail Domain'=>'Creatin Mail Domain', + 'AntiSpam Support'=>'AntiSpam Support', + 'AntiVirus Support'=>'AntiVirus Support', + 'DKIM Support'=>'DKIM Support', + 'Adding Mail Account'=>'Adding Mail Account', + 'Advanced options'=>'Advanced options', + 'Quota'=>'Quota', + 'in megabytes'=>'in megabytes', + 'use local-part'=>'use local-part', + 'Forward to'=>'Forward to', + 'one or more email addresses'=>'one or more email addresses', + 'Adding Package'=>'Adding Package', + 'Package Name'=>'Package Name', + 'Package'=>'Package', + 'Default Template'=>'Default Template', + 'SSH Access'=>'SSH Access', + 'Adding User'=>'Adding User', + 'First Name'=>'First Name', + 'Last Name'=>'Last Name', + 'SEND_CREDENTIALS_NOTICE'=>'Send fresh credentials to user by email?', + 'Adding Domain for hosting'=>'Adding Domain for hosting', + 'Apache template'=>'Apache template', + 'Nginx Support'=>'Nginx Support', + 'Nginx Extentions'=>'Nginx Extentions', + 'Nginx Template'=>'Nginx Template', + 'Statistics Authorization'=>'Statistics Authorization', + 'Additional FTP Account'=>'Additional FTP Account', + 'Editing Cron Job'=>'Editing Cron Job', + 'Save'=>'Save', + 'Editing Database'=>'Editing Database', + 'Editing DNS Domain'=>'Editing DNS Domain', + 'Editing DNS Record'=>'Editing DNS Record', + 'Editing IP Address'=>'Editing IP Address', + 'Editing Mail Domain'=>'Editing Mail Domain', + 'Catchall email'=>'Catchall email', + 'Editing Mail Account'=>'Editing Mail Account', + 'Autoreply'=>'Autoreply', + 'Message'=>'Message', + 'Editing Package'=>'Editing Package', + 'Editing User'=>'Editing User', + 'Default Name Servers'=>'Default Name Servers', + 'Editing Domain'=>'Editing Domain', + 'Create Backup'=>'Create Backup', + 'apply to selected'=>'apply to selected', + 'toggle all'=>'toggle all', + 'delete'=>'delete', + 'active'=>'active', + 'download'=>'download', + 'Owner'=>'Owner', + 'restore'=>'restore', + 'restart'=>'restart', + 'CPU'=>'CPU', + 'Memory'=>'Memory', + 'stop'=>'stop', + 'Run Time'=>'Run Time', + 'BACKUP_DELETE_CONFIRMATION'=>'Are you sure to delete %s backup?', + 'Backup Size'=>'Backup Size', + 'SYS'=>'SYS', + 'one archive'=>'one archive', + '%s archives'=>'%s archives', + 'Add Cron Job'=>'Add Cron Job', + 'add account'=>'add account', + 'open webmail'=>'open webmail', + 'suspend'=>'suspend', + 'unsuspend'=>'unsuspend', + 'CRON_ACTION_CONFIRMATION'=>'Are you sure to %s cron job?', + 'Confirmation'=>'Confirmation', + 'one cron job'=>'one cron job', + '%s cron jobs'=>'%s cron jobs', + 'Add Database'=>'Add Database', + 'open %s'=>'open %s', + 'DATABASE_ACTION_CONFIRMATION'=>'Are you sure to %s database %s?', + 'one database'=>'ne database', + '%s databases'=>'%s databases', + 'Add DNS Domain'=>'Add DNS Domain', + 'Search'=>'Search', + 'LIST_DOMAIN_RECORDS'=>'Show %s records', + 'add record'=>'add record', + 'DOMAIN_ACTION_CONFIRMATION'=>'Are you sure to %s domain %s?', + 'one domain'=>'one domain', + '%s domains'=>'%s domains', + 'Add DNS Record'=>'Add DNS Record', + 'Listing'=>'Listing', + 'list'=>'list', + 'RECORD_ACTION_CONFIRMATION'=>'Are you sure to %s record %s?', + 'one DNS record'=>'one DNS record', + '%s DNS records'=>'%s DNS records', + 'Add IP'=>'Add IP', + 'IP_DELETE_CONFIRMATION'=>'Are you sure to delere IP-address %s?', + 'Status'=>'Status', + 'one IP address'=>'one IP address', + '%s IP addresses'=>'%s IP addresses', + 'one log record'=>'one log record', + '%s log records'=>'%s log records', + 'Add Mail Domain'=>'Add Mail Domain', + 'MAIL_ACTION_CONFIRMATION'=>'Are you sure to %s mail for domain %s?', + 'one domain with email'=>'one domain with email', + '%s domains with email'=>'%s domains with email', + 'Add Mail Account'=>'Add Mail Account', + 'MAIL_ACCOUNT_ACTION_CONFIRMATION'=>'Are you sure to %s mail account %s?', + 'one mail account'=>'one mail account', + '%s mail accounts'=>'%s mail accounts', + 'Add Package'=>'Add Package', + 'PACKAGE_DELETE_CONFIRMATION'=>'Are you sure to delete package %s?', + 'one package'=>'one package', + '%s packages'=>'%s packages', + 'Daily'=>'Daily', + 'Weekly'=>'Weekly', + 'Monthly'=>'Monthly', + 'Yearly'=>'Yearly', + 'Search Results'=>'Search Results', + 'login as'=>'login as', + 'ARE_YOU_FUCKING_SURE'=>'Are you sure to %s %s?', + 'Object'=>'Object', + 'one object'=>'one object', + '%s objects'=>'%s objects', + 'Overall Statistics'=>'Overall Statistics', + 'show per user'=>'show per user', + 'Hosting'=>'Hosting', + 'Mail'=>'Mail', + 'User Directories'=>'Папки User Directories', + 'Web SSL Domains'=>'Web SSL Domains', + 'one month'=>'one month', + '%s months'=>'%s months', + 'Add User'=>'Add User', + 'Add Domain'=>'Add Domain', + 'rebuild'=>'rebuild', + 'rebuild web'=>'rebuild web', + 'rebuild DNS'=>'rebuild DNS', + 'rebuild mail'=>'rebuild mail', + 'rebuild db'=>'rebuild db', + 'rebuild cron'=>'rebuild cron', + 'update counters'=>'update counters', + 'LOGGED_IN_AS'=>'Logged in as %s', + 'USER_ACTION_CONFIRMATION'=>'Are you sure to %s user %s?', + 'one account'=>'one account', + '%s accounts'=>'%s accounts', + 'Add Domain for hosting'=>'Add Domain for hosting', + 'open webstats'=>'open webstats', + 'Error Log'=>'Error Log', + 'CGI Support'=>'CGI Support', + 'Statistics Auth'=>'Statistics Auth', + 'running'=>'running', + 'SERVICE_ACTION_FAILED'=>'Error: Oparaion "%s" for service "%s" has been failed', + 'Memory Usage'=>'Memory Usage', + 'Bandwidth Usage'=>'Bandwidth Usage', +); -); \ No newline at end of file +/*error_reporting(E_ALL); +ini_set('display_errors',true);*/ \ No newline at end of file diff --git a/web/inc/i18n/ru.php b/web/inc/i18n/ru.php index 27092d937..a8f0dccc2 100644 --- a/web/inc/i18n/ru.php +++ b/web/inc/i18n/ru.php @@ -47,7 +47,6 @@ $LANG = array( 'DOMAIN_MAIL_CREATED_OK'=>'Успех: почта для домена %s подключена успешно', 'account'=>'аккаунт', 'Account'=>'Аккаунт', - 'password'=>'пароль', 'MAIL_ACCOUNT_CREATED_OK'=>'Успех: почтовый аккаунт %s@%s успешно создан.', 'package'=>'пакет', 'template'=>'шаблон', @@ -113,8 +112,8 @@ $LANG = array( 'GO_BACK_LINK'=>'Попробуйте вернуться на главную страницу или вернитесь на предыдущую страницу', 'ERROR: Invalid username or password'=>'Ошибка: Неверный логин или пароль', 'ERROR: Invalid username or code'=>'Ошибка: Неверный логин или код сброса пароля', - 'MAIL_RESET_SUBJECT'=>'Password Reset at %s', - 'PASSWORD_RESET_REQUEST'=>"Вы недавно запросили смену пароля.\nЧтобы произвести смену пароля, пройдите по этой ссылки:\nhttps://%s/reset/?action=confirm&user=%s&code=%s\n\nВы также можете пойти по ссылке https://%s/reset/?action=code&user=%s и ввести следующий код для сброса пароля:\n%s\n\nЕсли вы не создавали запрос на сброс пароля, пожалуйста проигнорируйте это письмо и примите наши извиниения.\n\n--\nПанель управления Vesta\n", + 'MAIL_RESET_SUBJECT'=>'Сброс пароля %s', + 'PASSWORD_RESET_REQUEST'=>"Вы недавно запросили смену пароля.\nЧтобы произвести смену пароля, пройдите по этой ссылке:\nhttps://%s/reset/?action=confirm&user=%s&code=%s\n\nВы также можете пойти по ссылке https://%s/reset/?action=code&user=%s и ввести следующий код для сброса пароля:\n%s\n\nЕсли вы не создавали запрос на сброс пароля, пожалуйста проигнорируйте это письмо и примите наши извиниения.\n\n--\nПанель управления Vesta\n", 'ERROR: Passwords not match'=>'Ошибка: Пароли не совпадают', 'Adding Cron Job'=>'Добавление cron задания', 'Minute'=>'Минута', @@ -219,6 +218,7 @@ $LANG = array( 'Apache template'=>'Шаблон веб-сервера Apache', 'Nginx Support'=>'Поддержка веб-сервера Nginx', 'Nginx Extentions'=>'Расширения Nginx', + 'Nginx Template'=>'Шаблон для Nginx', 'Statistics Authorization'=>'Доступ к статистике', 'Additional FTP Account'=>'Дополнительный FTP-аккаунт', 'Editing Cron Job'=>'Редактирование cron-задания', @@ -244,8 +244,12 @@ $LANG = array( 'download'=>'скачать', 'Owner'=>'Владелец', 'restore'=>'восстановить', + 'restart'=>'перезапустить', + 'CPU'=>'Процессор', + 'Memory'=>'Память', + 'stop'=>'остановить', + 'Run Time'=>'Время запуска', 'BACKUP_DELETE_CONFIRMATION'=>'Вы уверены, что хотите удалить %s бэкап?', - 'Run Time'=>'Время Запуска', 'Backup Size'=>'Размер Бэкапа', 'SYS'=>'Системное', 'one archive'=>'один архив', @@ -258,7 +262,7 @@ $LANG = array( 'CRON_ACTION_CONFIRMATION'=>'Вы уверены, что хотите %s cron-задание?', 'Confirmation'=>'Подтверждение', 'one cron job'=>'одно cron-задание', - '%s cron jobs'=>'%s cron-заданий', + '%s cron jobs'=>'%s cron-заданя(ий)', 'Add Database'=>'Добавить БД', 'open %s'=>'открыть %s', 'DATABASE_ACTION_CONFIRMATION'=>'Вы уверены, что хотите %s базу данных %s?', @@ -329,7 +333,16 @@ $LANG = array( '%s accounts'=>'%s аккаунта(ов)', 'Add Domain for hosting'=>'Добавить Домен для хостинга', 'open webstats'=>'открыть ститистику', + 'Error Log'=>'Лог Ошибок', + 'CGI Support'=>'Поддержка CGI', + 'Statistics Auth'=>'Авторизация Статистики', + 'running'=>'работает', + 'SERVICE_ACTION_FAILED'=>'Ошибка: Операция "%s" для сервиса "%s" не удалась', + 'Load Average'=>'Нагрузка', + 'Memory Usage'=>'Использование Памяти', + 'Bandwidth Usage'=>'Использование Сети', + ); -error_reporting(E_ALL); -ini_set('display_errors',true); \ No newline at end of file +/*error_reporting(E_ALL); +ini_set('display_errors',true);*/ \ No newline at end of file diff --git a/web/restart/service/index.php b/web/restart/service/index.php index 4ec52197e..b75264b92 100644 --- a/web/restart/service/index.php +++ b/web/restart/service/index.php @@ -12,7 +12,7 @@ if ($_SESSION['user'] == 'admin') { } if ($return_var != 0) { $error = implode('
', $output); - if (empty($error)) $error = 'Error: service '.$v_service.' restart failed'; + if (empty($error)) $error = _('SERVICE_ACTION_FAILED',_('restart'),$v_service); $_SESSION['error_srv'] = $error; } unset($output); diff --git a/web/start/service/index.php b/web/start/service/index.php index ff8589a1d..065713bd6 100644 --- a/web/start/service/index.php +++ b/web/start/service/index.php @@ -12,7 +12,7 @@ if ($_SESSION['user'] == 'admin') { } if ($return_var != 0) { $error = implode('
', $output); - if (empty($error)) $error = 'Error: service '.$v_service.' start failed'; + if (empty($error)) $error = _('SERVICE_ACTION_FAILED',_('start'),$v_service);; $_SESSION['error_srv'] = $error; } unset($output); diff --git a/web/stop/service/index.php b/web/stop/service/index.php index f2310ae71..a9ef85124 100644 --- a/web/stop/service/index.php +++ b/web/stop/service/index.php @@ -12,7 +12,7 @@ if ($_SESSION['user'] == 'admin') { } if ($return_var != 0) { $error = implode('
', $output); - if (empty($error)) $error = 'Error: service '.$v_service.' stop failed'; + if (empty($error)) $error = _('SERVICE_ACTION_FAILED',_('stop'),$v_service); $_SESSION['error_srv'] = $error; } unset($output); diff --git a/web/templates/admin/add_dns.html b/web/templates/admin/add_dns.html index 8f8df86de..9c436e85b 100644 --- a/web/templates/admin/add_dns.html +++ b/web/templates/admin/add_dns.html @@ -106,7 +106,7 @@
- (YYYY-MM-DD) + ()
- + + +
diff --git a/web/templates/admin/list_services.html b/web/templates/admin/list_services.html index 1834a58d9..968cde189 100644 --- a/web/templates/admin/list_services.html +++ b/web/templates/admin/list_services.html @@ -5,17 +5,17 @@
- +
- toggle all +
@@ -74,15 +74,15 @@ - -
- +
- - + +
restart
@@ -106,7 +106,7 @@ + +
- CPU: + : % @@ -118,10 +118,10 @@
- Memory: + : - mb +
@@ -130,7 +130,7 @@ - -
- Run Time: + : diff --git a/web/templates/user/add_dns.html b/web/templates/user/add_dns.html index a11912175..1fe56529f 100644 --- a/web/templates/user/add_dns.html +++ b/web/templates/user/add_dns.html @@ -1,141 +1,141 @@ - - - - - - - -
- - - - - - - - + +
- - -
-
- - - - -
- - - - - - - - - - - - - -
- Domain -
- - IP address -
- - Advanced Options -
- - - - - - - - - - - - - -
- Domain Expiriation (YYYY-MM-DD) -
- - TTL -
- - Name Servers -
- - - -
-
- + + + + + + + +
+ +
+ + + + + + - -
+ + +
+
+ + + + +
+ + + + + + + + + + + + + +
+ +
+ + +
+ + +
+ + + + + + + + + + + + + +
+ () +
+ + TTL +
+ + +
+ + + +
+
+ diff --git a/web/templates/user/add_web.html b/web/templates/user/add_web.html index 387cbacca..99f1c6fd1 100644 --- a/web/templates/user/add_web.html +++ b/web/templates/user/add_web.html @@ -1,372 +1,372 @@ - - - - - - - -
- -
- - - - - - - - + +
- - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- Domain -
- - IP address -
- -
- DNS support -
- > -
- Mail support -
- > -
- Advanced Options -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Domain Aliases -
- -
- Nginx Support -
- onclick="javascript:elementHideShow('nginxtable');"> -
- - - - - - - -
- Nginx Supported Extentions -
- -
-
- SSL Support -
- onclick="javascript:elementHideShow('ssltable');"> -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- SSL HomeDirectory -
- -
- SSL Certificate -
- -
- SSL Key -
- -
- SSL Certificate Authority / Intermediate (optional) -
- -
-
- Web Statistics -
- -
- Web Statistic Authorization -
- onclick="javascript:elementHideShow('statstable');"> -
- - - - - - - - - - -
- Web Statistics Username -
- - Web Statistics Password generate -
- -
-
- Additional FTP Account -
- onclick="javascript:elementHideShow('ftptable');"> -
- - - - - - - - - - - - - - -
- FTP Username
- Prefix will be automaticaly added to username -
- - FTP Password generate -
- - Send FTP credentials to email -
- -
- - -
-
- + + + + + + + +
+ +
+ + + + + + + + - -
+ + + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ +
+ +
+ > +
+ +
+ > +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ onclick="javascript:elementHideShow('nginxtable');"> +
+ + + + + + + +
+ +
+ +
+
+ +
+ onclick="javascript:elementHideShow('ssltable');"> +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ +
+ +
+ +
+ () +
+ +
+
+ +
+ +
+ +
+ onclick="javascript:elementHideShow('statstable');"> +
+ + + + + + + + + + +
+ +
+ + +
+ +
+
+ +
+ onclick="javascript:elementHideShow('ftptable');"> +
+ + + + + + + + + + + + + + +
+
+ +
+ + +
+ + +
+ +
+ + +
+
+ diff --git a/web/templates/user/edit_dns.html b/web/templates/user/edit_dns.html index 7590687fd..2bc087c67 100644 --- a/web/templates/user/edit_dns.html +++ b/web/templates/user/edit_dns.html @@ -1,106 +1,106 @@ - - - - - - - -
- -
- - - - - -
- - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - -
- Domain -
- - IP address -
- - Domain Expiriation (YYYY-MM-DD) -
- - SOA -
- - TTL -
- - - -
-
-
+ + + + + + + +
+ +
+ + + + + +
+ + + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ + () +
+ + SOA +
+ + TTL +
+ + + +
+
+
diff --git a/web/templates/user/edit_user.html b/web/templates/user/edit_user.html index e1a92b897..b6728f75c 100644 --- a/web/templates/user/edit_user.html +++ b/web/templates/user/edit_user.html @@ -1,123 +1,123 @@ - - - - - - - -
- -
- - - - - - -
- - - - -
-
- - - - -
- - - - - - - - - - - - - - - - -
- Username -
- - Password generate -
- - Email -
- - Default Name Servers -
- - - -
-
-
+ + + + + + + +
+ +
+ + + + + + +
+ + + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + +
+ +
+ + +
+ + +
+ + +
+ + + +
+
+
diff --git a/web/templates/user/edit_web.html b/web/templates/user/edit_web.html index 974ee4b56..52895aa8e 100644 --- a/web/templates/user/edit_web.html +++ b/web/templates/user/edit_web.html @@ -1,331 +1,331 @@ - - - - - - - -
- -
- - - - - + +
- - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Domain -
- - IP address -
- -
- Aliases -
- -
- Nginx Support -
- onclick="javascript:elementHideShow('nginxtable');"> -
- - - - - - - -
- Nginx Supported Extentions -
- -
-
- SSL Support -
- onclick="javascript:elementHideShow('ssltable');"> -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- SSL HomeDirectory -
- -
- SSL Certificate -
- -
- SSL Key -
- -
- SSL Certificate Authority / Intermediate (optional) -
- -
-
- Web Statistics -
- -
- Web Statistic Authorization -
- onclick="javascript:elementHideShow('statstable');"> -
- - - - - - - - - - -
- Web Statistics Username -
- - Web Statistics Password generate -
- -
-
- Additional FTP Account -
- onclick="javascript:elementHideShow('ftptable');"> -
- - - - - - - - - - - - - -
- FTP Username - Prefix '.$user.'_ will be automaticaly added to username' ?> -
- - FTP Password generate -
- - Send FTP credentials to email -
- - - -
-
- + + + + + + + +
+ +
+ + + + + - -
+ + + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ +
+ +
+ +
+ +
+ onclick="javascript:elementHideShow('nginxtable');"> +
+ + + + + + + +
+ +
+ +
+
+ +
+ onclick="javascript:elementHideShow('ssltable');"> +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ +
+ +
+ +
+ () +
+ +
+
+ +
+ +
+ +
+ onclick="javascript:elementHideShow('statstable');"> +
+ + + + + + + + + + +
+ +
+ + +
+ +
+
+ +
+ onclick="javascript:elementHideShow('ftptable');"> +
+ + + + + + + + + + + + + +
+ + Prefix '.$user.'_ will be automaticaly added to username' ?> +
+ + +
+ + +
+ + + +
+
+ \ No newline at end of file diff --git a/web/templates/user/list_cron.html b/web/templates/user/list_cron.html index e186b96d5..7e7f6ee69 100644 --- a/web/templates/user/list_cron.html +++ b/web/templates/user/list_cron.html @@ -2,7 +2,7 @@
- +
@@ -14,8 +14,8 @@ toggle all
@@ -46,20 +46,20 @@ - +
">
- + @@ -76,7 +76,7 @@
edit - delete + -
@@ -90,7 +90,7 @@
- Min +
@@ -104,7 +104,7 @@
- Hour +
@@ -118,7 +118,7 @@
- Day +
@@ -132,7 +132,7 @@
- Month +
@@ -159,9 +159,9 @@ diff --git a/web/templates/user/list_db.html b/web/templates/user/list_db.html index 79071d515..9b094a305 100644 --- a/web/templates/user/list_db.html +++ b/web/templates/user/list_db.html @@ -3,7 +3,7 @@ + +
- Day of Week +
- +
@@ -13,10 +13,10 @@
- toggle all +
@@ -50,21 +50,21 @@ - +
">
- - + + @@ -80,11 +80,11 @@
open edit delete " /> -
- - -
- [] database + []
Disk: + :
@@ -96,7 +96,7 @@ + +
- User: + : @@ -104,7 +104,7 @@
- Host: + : @@ -116,7 +116,7 @@ diff --git a/web/templates/user/list_dns.html b/web/templates/user/list_dns.html index 46ac27cdb..5a0769323 100644 --- a/web/templates/user/list_dns.html +++ b/web/templates/user/list_dns.html @@ -2,20 +2,20 @@ diff --git a/web/templates/user/list_dns_rec.html b/web/templates/user/list_dns_rec.html index 5822be601..57d4960d6 100644 --- a/web/templates/user/list_dns_rec.html +++ b/web/templates/user/list_dns_rec.html @@ -2,20 +2,20 @@ - -
- Charset: + : @@ -140,9 +140,9 @@
- +
- +
- toggle all +
@@ -45,22 +45,22 @@ - +
" >
">
- - - + + + @@ -80,7 +80,7 @@
list records add record edit - delete + -
- [] template + []
@@ -100,11 +100,11 @@
- + - +
Expire::
Records::
@@ -125,9 +125,9 @@
- +
- +
- toggle all +
@@ -31,7 +31,7 @@
- Listing +
@@ -54,20 +54,20 @@ - +
">
- + @@ -94,9 +94,9 @@ diff --git a/web/templates/user/list_mail.html b/web/templates/user/list_mail.html index bcbd8ad73..1cee10a4c 100644 --- a/web/templates/user/list_mail.html +++ b/web/templates/user/list_mail.html @@ -2,20 +2,20 @@ + +
edit - delete + -
- +
- +
- toggle all +
@@ -49,23 +49,23 @@ - +
" >
">
- - - - + + + + @@ -82,12 +82,12 @@
list accounts add account" target="_blank"> open webmail edit " target="_blank"> - delete + -
- -
- catchall > + >
- Disk: + :
@@ -99,7 +99,7 @@ + +
- Antivirus: + : @@ -107,7 +107,7 @@
- Antispam: + : @@ -119,7 +119,7 @@ diff --git a/web/templates/user/list_mail_acc.html b/web/templates/user/list_mail_acc.html index 0cb05a56a..72b78a0b9 100644 --- a/web/templates/user/list_mail_acc.html +++ b/web/templates/user/list_mail_acc.html @@ -2,20 +2,20 @@ - -
- DKIM: + : @@ -127,7 +127,7 @@
- Accounts: + : @@ -152,9 +152,9 @@
- +
- +
- toggle all +
@@ -31,7 +31,7 @@
- Listing +
@@ -54,20 +54,20 @@ - +
">
- + @@ -84,7 +84,7 @@ + +
edit - delete + -
- Disk: + :
@@ -96,7 +96,7 @@ - -
- Quota: + : @@ -104,7 +104,7 @@
- Autoreply: + : @@ -116,7 +116,7 @@ diff --git a/web/templates/user/list_search.html b/web/templates/user/list_search.html index 60d22bdf2..3024ae411 100644 --- a/web/templates/user/list_search.html +++ b/web/templates/user/list_search.html @@ -3,12 +3,12 @@ @@ -41,7 +41,7 @@ @@ -110,7 +110,7 @@
- Forward: + : @@ -141,9 +141,9 @@
- +
- +
">
@@ -72,7 +72,7 @@ - delete +
+ +
- Object: + : @@ -122,7 +122,7 @@ diff --git a/web/templates/user/list_stats.html b/web/templates/user/list_stats.html index e707ce028..d465dd4fe 100644 --- a/web/templates/user/list_stats.html +++ b/web/templates/user/list_stats.html @@ -7,7 +7,7 @@
- +
@@ -49,12 +49,12 @@
- Owner: + : @@ -134,10 +134,10 @@
- Status: + : - +
@@ -159,9 +159,9 @@
- -
- [] package + []
- Bandwidth: % () + : % ()
@@ -62,7 +62,7 @@
- Disk: % () + : % ()
@@ -73,12 +73,12 @@
- Web:
- Mail:
+ :
+ :
- Databases:
- User Dirs:
+ :
+ :
@@ -90,7 +90,7 @@ + +
- Web Domains: + : @@ -98,7 +98,7 @@
- Web SSL: + : @@ -106,7 +106,7 @@
- Web Aliases: + : @@ -114,7 +114,7 @@
- Dns Domains: + : @@ -122,7 +122,7 @@
- Dns Records: + : @@ -134,7 +134,7 @@ diff --git a/web/templates/user/list_user.html b/web/templates/user/list_user.html index df83fc29b..7144d9836 100644 --- a/web/templates/user/list_user.html +++ b/web/templates/user/list_user.html @@ -5,26 +5,26 @@
Add User "; + echo ""; } else { - echo ""; + echo ""; } ?>
- +
- toggle all + - +
@@ -52,7 +52,7 @@
- Mail Domains: + : @@ -142,7 +142,7 @@
- Mail Accounts: + : @@ -150,7 +150,7 @@
- Databases: + : @@ -158,7 +158,7 @@
- Cron Jobs: + : @@ -166,7 +166,7 @@
- Dedicated IP: + : @@ -191,9 +191,9 @@
- +
">
@@ -71,16 +71,16 @@ - + - - diff --git a/web/templates/user/list_web.html b/web/templates/user/list_web.html index 94ce93c06..f952bf5d9 100644 --- a/web/templates/user/list_web.html +++ b/web/templates/user/list_web.html @@ -3,20 +3,20 @@ '; + echo ' '._('open webstats').' '; } ?> - + @@ -106,19 +106,19 @@ - From 422d552cc82604aea5962e2bf6868db69c812c56 Mon Sep 17 00:00:00 2001 From: ZonD Eighty Date: Wed, 16 Jan 2013 17:03:41 +0400 Subject: [PATCH 09/11] Translation fixes 1 --- web/add/db/index.php | 4 +++- web/inc/i18n/en.php | 2 ++ web/inc/i18n/ru.php | 4 +++- web/templates/admin/add_web.html | 4 ++-- web/templates/admin/edit_mail.html | 2 +- web/templates/admin/list_user.html | 2 +- web/templates/user/add_web.html | 4 ++-- 7 files changed, 14 insertions(+), 8 deletions(-) diff --git a/web/add/db/index.php b/web/add/db/index.php index 1438f9531..9f14d25f1 100644 --- a/web/add/db/index.php +++ b/web/add/db/index.php @@ -66,7 +66,8 @@ if (!empty($_POST['ok'])) { $_SESSION['error_msg'] = $error; unset($v_password); unset($output); - } else { + } + else { if (empty($v_notify)) { list($http_host, $port) = explode(':', $_SERVER["HTTP_HOST"]); if ($_POST['v_type'] == 'mysql') $db_admin_link = "http://".$http_host."/phpMyAdmin/"; @@ -93,6 +94,7 @@ if (!empty($_POST['ok'])) { } } } +} exec (VESTA_CMD."v-list-database-types 'json'", $output, $return_var); $db_types = json_decode(implode('', $output), true); unset($output); diff --git a/web/inc/i18n/en.php b/web/inc/i18n/en.php index 81b754f11..554243f3a 100644 --- a/web/inc/i18n/en.php +++ b/web/inc/i18n/en.php @@ -340,6 +340,8 @@ $LANG = array( 'SERVICE_ACTION_FAILED'=>'Error: Oparaion "%s" for service "%s" has been failed', 'Memory Usage'=>'Memory Usage', 'Bandwidth Usage'=>'Bandwidth Usage', + 'IP Address'=>'IP Address', + 'Accounts'=>'Accounts', ); /*error_reporting(E_ALL); diff --git a/web/inc/i18n/ru.php b/web/inc/i18n/ru.php index a8f0dccc2..63678cc51 100644 --- a/web/inc/i18n/ru.php +++ b/web/inc/i18n/ru.php @@ -38,6 +38,7 @@ $LANG = array( 'DOMAIN_CREATED_OK'=>'Успех: Домен %s успешно создан.', 'RECORD_CREATED_OK'=>'Успех: Запись %s.%s успешно создана.', 'ip address'=>'IP-адрес', + 'IP Address'=>'IP-адрес', 'netmask'=>'маска подсети', 'Netmask'=>'Маска подсети', 'interface'=>'интерфейс', @@ -63,6 +64,7 @@ $LANG = array( 'dns records'=>'DNS записи', 'mail domains'=>'домены с почтой', 'mail accounts'=>'почтовые аккаунты', + 'Accounts'=>'Аккаунты', 'Mail Domains'=>'Домены с Почтой', 'Mail Accounts'=>'Почтовые Аккаунты', 'accounts'=>'аккаунты', @@ -177,7 +179,7 @@ $LANG = array( 'Packages'=>'Пакеты', 'IP Addresses'=>'IP адреса', 'RRD Graphics'=>'Графики', - 'jobs'=>'Задания', + 'jobs'=>'задания', 'Reset Code'=>'Код сброса', 'disk'=>'место', 'Disk'=>'Место', diff --git a/web/templates/admin/add_web.html b/web/templates/admin/add_web.html index 531dfbe1b..37ee76eb5 100644 --- a/web/templates/admin/add_web.html +++ b/web/templates/admin/add_web.html @@ -264,7 +264,7 @@ @@ -286,7 +286,7 @@ diff --git a/web/templates/admin/edit_mail.html b/web/templates/admin/edit_mail.html index 4cc95658d..9a1c40484 100644 --- a/web/templates/admin/edit_mail.html +++ b/web/templates/admin/edit_mail.html @@ -33,7 +33,7 @@
[] package
[]
Bandwidth: % () + : % ()
Disk: % () + : % ()
@@ -91,12 +91,12 @@
- Web:
- Mail:
+ :
+ :
- Databases:
- User Dirs:
+ :
+ :
@@ -107,31 +107,31 @@
- + - + - + - - + + - + - - + + - +
Template::
Web Domains:: /
Web SSL::
Web Aliases: per domain:
Dns Domains:: /
Dns Records: per domain:
Name Servers:
:
@@ -139,31 +139,31 @@
- + - - + + - + - + - + - + - +
Mail Domains:: /
Mail Accounts: per domain:
Databases:: /
Cron Jobs:: /
Shell::
Dedicated IP::
Backups:: /
@@ -184,9 +184,9 @@
- +
- +
- toggle all +
@@ -65,7 +65,7 @@ - +
" >
">
@@ -76,16 +76,16 @@ if (!empty($data[$key]['STATS'])) { echo ' '; echo ""; - echo ' open webstats "> edit"> - delete + -
- [] template + []
- Bandwidth: + :
Disk: + :
@@ -129,19 +129,19 @@
- + - + - + - +
CGI Support::
Error Log::
Web Statistics::
Statistics Auth::
@@ -149,19 +149,19 @@
- + - + - + - +
SSL Support::
SSL Home::
Nginx Template::
Nginx Extentions:: >
@@ -182,9 +182,9 @@
- +
- +
- +
diff --git a/web/templates/admin/list_user.html b/web/templates/admin/list_user.html index 9c22513b3..df16bf65a 100644 --- a/web/templates/admin/list_user.html +++ b/web/templates/admin/list_user.html @@ -71,7 +71,7 @@ "; + echo " ". _('logout').""; if (!empty($_SESSION['look_alert'])) { ?> - - - - - - -
- - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- -
- - -
- - -
- -
- -
- -
- -
- -
- -
- > -
- - -
-
- + + + + + + + +
+ +
+ + + + + + + +
+ + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ + +
+ + +
+ +
+ +
+ +
+ +
+ +
+ +
+ > +
+ + +
+
+
diff --git a/web/templates/admin/add_dns.html b/web/templates/admin/add_dns.html index 9c436e85b..c51afa6c4 100644 --- a/web/templates/admin/add_dns.html +++ b/web/templates/admin/add_dns.html @@ -1,165 +1,165 @@ - - - - - - - - -
- -
- - - - - - + +
- - -
-
- - - - -
- - - - - - - - - - - - - -
- -
- - -
- - -
- - - - - - - - - - - - - - - - - - - -
- -
- -
- () -
- - TTL -
- - -
- - - -
-
- + + + + + + + + +
+ +
+ + + + + + - -
+ + +
+
+ + + + +
+ + + + + + + + + + + + + +
+ +
+ + +
+ + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ () +
+ + TTL +
+ + +
+ + + +
+
+ diff --git a/web/templates/admin/add_dns_rec.html b/web/templates/admin/add_dns_rec.html index df1414ccc..5ff6b6b0b 100644 --- a/web/templates/admin/add_dns_rec.html +++ b/web/templates/admin/add_dns_rec.html @@ -1,118 +1,118 @@ - - - - - - - - -
- -
- - - - - -
- - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - -
- -
- - -
- - -
- -
- -
- - () -
- - - -
-
-
+ + + + + + + + +
+ +
+ + + + + +
+ + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ + +
+ +
+ +
+ + () +
+ + + +
+
+
diff --git a/web/templates/admin/add_ip.html b/web/templates/admin/add_ip.html index 95aefc5ea..2aaa6fa7f 100644 --- a/web/templates/admin/add_ip.html +++ b/web/templates/admin/add_ip.html @@ -1,148 +1,148 @@ - - - - - - - - -
- -
- - - - - - - -
- - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- IP -
- - -
- - -
- -
- -
- onclick="javascript:elementHideShow('usrtable');"> -
- - - - - - - -
- -
- -
-
- () -
- - - -
-
- + + + + + + + + +
+ + + + + + + + + +
+ + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ IP +
+ + +
+ + +
+ +
+ +
+ onclick="javascript:elementHideShow('usrtable');"> +
+ + + + + + + +
+ +
+ +
+
+ () +
+ + + +
+
+ diff --git a/web/templates/admin/add_mail.html b/web/templates/admin/add_mail.html index 68583f688..0b9cc0442 100644 --- a/web/templates/admin/add_mail.html +++ b/web/templates/admin/add_mail.html @@ -1,95 +1,95 @@ - - - - - - - - -
- - - - - - - -
- - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - -
- > -
- -
- > -
- -
- > -
- - -
-
- + + + + + + + + +
+ +
+ + + + + +
+ + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ > +
+ +
+ > +
+ +
+ > +
+ + +
+
+
diff --git a/web/templates/admin/add_mail_acc.html b/web/templates/admin/add_mail_acc.html index e50dadba6..c70bd027a 100644 --- a/web/templates/admin/add_mail_acc.html +++ b/web/templates/admin/add_mail_acc.html @@ -1,147 +1,147 @@ - - - - - - - - -
- -
- - - - - - - -
- - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - -
- -
- - -
- - -
- -
- -
- - - - - - - - - - - - - - - - -
- () -
- - () -
- -
- () -
- -
-
- - -
-
-
+ + + + + + + + +
+ +
+ + + + + + + +
+ + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ + +
+ +
+ +
+ + + + + + + + + + + + + + + + +
+ () +
+ + () +
+ +
+ () +
+ +
+
+ + +
+
+
diff --git a/web/templates/admin/add_package.html b/web/templates/admin/add_package.html index 58fbea99b..ca627c930 100644 --- a/web/templates/admin/add_package.html +++ b/web/templates/admin/add_package.html @@ -1,246 +1,246 @@ - - - - - - - - -
- -
- - - - - -
- - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - -
- -
- -
- -
- -
- - () -
- - -
- - () -
- - -
- - () -
- - -
- - -
- - -
- - () -
- - () -
- - -
- - - -
-
-
+ + + + + + + + +
+ +
+ + + + + +
+ + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ +
+ +
+ +
+ +
+ + () +
+ + +
+ + () +
+ + +
+ + () +
+ + +
+ + +
+ + +
+ + () +
+ + () +
+ + +
+ + + +
+
+
diff --git a/web/templates/admin/add_user.html b/web/templates/admin/add_user.html index 358650a71..da3398956 100644 --- a/web/templates/admin/add_user.html +++ b/web/templates/admin/add_user.html @@ -1,149 +1,149 @@ - - - - - - - - -
- -
- - - - - - - -
- - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - -
- - -
- - -
- -
- -
- - -
- - -
- > -
- - -
-
-
+ + + + + + + + +
+ +
+ + + + + + + +
+ + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ + +
+ + +
+ +
+ +
+ + +
+ + +
+ > +
+ + +
+
+
diff --git a/web/templates/admin/add_web.html b/web/templates/admin/add_web.html index 37ee76eb5..78d2fb363 100644 --- a/web/templates/admin/add_web.html +++ b/web/templates/admin/add_web.html @@ -1,382 +1,382 @@ - - - - - - - - -
- -
- - - - - - + +
- - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - -
- -
- -
- > -
- -
- > -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- -
- -
- -
- -
- onclick="javascript:elementHideShow('nginxtable');"> -
- - - - - - - -
- -
- -
-
- -
- onclick="javascript:elementHideShow('ssltable');"> -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- -
- -
- -
- -
- -
- () -
- -
-
- -
- -
- -
- onclick="javascript:elementHideShow('statstable');"> -
- - - - - - - - - - -
- -
- - -
- -
-
- -
- onclick="javascript:elementHideShow('ftptable');"> -
- - - - - - - - - - - - - - -
-
- -
- - -
- - -
- -
- - -
-
- + + + + + + + + +
+ +
+ + + + + + - -
+ + + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ +
+ +
+ > +
+ +
+ > +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ +
+ +
+ onclick="javascript:elementHideShow('nginxtable');"> +
+ + + + + + + +
+ +
+ +
+
+ +
+ onclick="javascript:elementHideShow('ssltable');"> +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ +
+ +
+ +
+ () +
+ +
+
+ +
+ +
+ +
+ onclick="javascript:elementHideShow('statstable');"> +
+ + + + + + + + + + +
+ +
+ + +
+ +
+
+ +
+ onclick="javascript:elementHideShow('ftptable');"> +
+ + + + + + + + + + + + + + +
+
+ +
+ + +
+ + +
+ +
+ + +
+
+ diff --git a/web/templates/admin/edit_cron.html b/web/templates/admin/edit_cron.html index 1abcb713e..d01ee86f1 100644 --- a/web/templates/admin/edit_cron.html +++ b/web/templates/admin/edit_cron.html @@ -1,118 +1,118 @@ - - - - - - - - -
- -
- - - - - -
- - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - -
- - -
- - -
- - -
- - -
- > -
- - -
-
-
+ + + + + + + + +
+ +
+ + + + + +
+ + + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ + +
+ + +
+ + +
+ + +
+ > +
+ + +
+
+
diff --git a/web/templates/admin/edit_db.html b/web/templates/admin/edit_db.html index 491c23d02..4b45ae520 100644 --- a/web/templates/admin/edit_db.html +++ b/web/templates/admin/edit_db.html @@ -1,137 +1,137 @@ - - - - - - - -
- -
- - - - - - - -
- - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - -
- -
- - -
- - -
- - -
- - -
- - -
- - - -
-
-
+ + + + + + + + + + + +
+ + + + + + + +
+ + + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + + +
+
+
diff --git a/web/templates/admin/edit_dns.html b/web/templates/admin/edit_dns.html index 191d31886..767ad47e9 100644 --- a/web/templates/admin/edit_dns.html +++ b/web/templates/admin/edit_dns.html @@ -1,127 +1,127 @@ - - - - - - - - - - - -
- - - - - -
- - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - -
- - -
- -
- () -
- - SOA -
- - TTL -
- - - -
-
-
+ + + + + + + + + + + +
+ + + + + +
+ + + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ + +
+ +
+ () +
+ + SOA +
+ + TTL +
+ + + +
+
+
diff --git a/web/templates/admin/edit_dns_rec.html b/web/templates/admin/edit_dns_rec.html index c65e54fcd..ccf9302c2 100644 --- a/web/templates/admin/edit_dns_rec.html +++ b/web/templates/admin/edit_dns_rec.html @@ -1,107 +1,107 @@ - - - - - - - - - - - -
- - - - - -
- - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - -
- -
- - -
- - -
- - -
- > -
- () -
- - - -
-
-
+ + + + + + + + + + + +
+ + + + + +
+ + + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ + +
+ + +
+ > +
+ () +
+ + + +
+
+
diff --git a/web/templates/admin/edit_ip.html b/web/templates/admin/edit_ip.html index 0dfb4b5fb..905817b35 100644 --- a/web/templates/admin/edit_ip.html +++ b/web/templates/admin/edit_ip.html @@ -1,136 +1,136 @@ - - - - - - - - - - - -
- - - - - - - - -
- - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- IP -
- - -
- - -
- - -
- -
- -
- -
- () -
- - - -
-
-
+ + + + + + + + + + + +
+ + + + + + + + +
+ + + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ IP +
+ + +
+ + +
+ + +
+ +
+ +
+ +
+ () +
+ + + +
+
+
diff --git a/web/templates/admin/edit_mail.html b/web/templates/admin/edit_mail.html index 9a1c40484..f9995ffab 100644 --- a/web/templates/admin/edit_mail.html +++ b/web/templates/admin/edit_mail.html @@ -1,106 +1,106 @@ - - - - - - - - - - - -
- - - - - -
- - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - -
- > -
- -
- > -
- -
- > -
- -
- - - -
-
-
+ + + + + + + + + + + +
+ + + + + +
+ + + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ > +
+ +
+ > +
+ +
+ > +
+ +
+ + + +
+
+
diff --git a/web/templates/admin/edit_mail_acc.html b/web/templates/admin/edit_mail_acc.html index 450188400..4c0cb18f5 100644 --- a/web/templates/admin/edit_mail_acc.html +++ b/web/templates/admin/edit_mail_acc.html @@ -1,155 +1,155 @@ - - - - - - - - - - - -
- - - - - - - -
- - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- disabled > - - -
- - () -
- > -
- () -
- -
- () -
- -
- -
- onclick="javascript:elementHideShow('autoreplytable');"> -
- - - - - - - -
- -
- -
-
- - -
-
-
+ + + + + + + + + + + +
+ + + + + + + +
+ + + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ disabled > + + +
+ + () +
+ > +
+ () +
+ +
+ () +
+ +
+ +
+ onclick="javascript:elementHideShow('autoreplytable');"> +
+ + + + + + + +
+ +
+ +
+
+ + +
+
+
diff --git a/web/templates/admin/edit_package.html b/web/templates/admin/edit_package.html index 7421d7335..a28a6ae5e 100644 --- a/web/templates/admin/edit_package.html +++ b/web/templates/admin/edit_package.html @@ -1,247 +1,247 @@ - - - - - - - - - - - -
- - - - - -
- - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - -
- -
- -
- -
- -
- - () -
- - -
- - () -
- - -
- - () -
- - -
- - -
- - -
- - () -
- - () -
- - -
- - - -
-
-
+ + + + + + + + + + + +
+ + + + + +
+ + + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ +
+ +
+ +
+ +
+ + () +
+ + +
+ + () +
+ + +
+ + () +
+ + +
+ + +
+ + +
+ + () +
+ + () +
+ + +
+ + + +
+
+
diff --git a/web/templates/admin/edit_user.html b/web/templates/admin/edit_user.html index cd6c342c7..383026b1a 100644 --- a/web/templates/admin/edit_user.html +++ b/web/templates/admin/edit_user.html @@ -1,207 +1,207 @@ - - - - - - - - - - - -
- - - - - - -
- - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - -
- - -
- - -
- -
- -
- - -
- - -
- -
- -
- -
- -
- - - -
-
-
+ + + + + + + + + + + +
+ + + + + + +
+ + + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ + +
+ + +
+ +
+ +
+ + +
+ + +
+ +
+ +
+ +
+ +
+ + + +
+
+
diff --git a/web/templates/admin/edit_web.html b/web/templates/admin/edit_web.html index 4209f3558..6e4bac225 100644 --- a/web/templates/admin/edit_web.html +++ b/web/templates/admin/edit_web.html @@ -1,352 +1,352 @@ - - - - - - - - - - - -
- - - - - + +
- - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - -
- -
- -
- -
- -
- -
- -
- onclick="javascript:elementHideShow('nginxtable');"> -
- - - - - - - -
- -
- -
-
- -
- onclick="javascript:elementHideShow('ssltable');"> -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- -
- -
- -
- -
- -
- () -
- -
-
- -
- -
- -
- onclick="javascript:elementHideShow('statstable');"> -
- - - - - - - - - - -
- -
- - -
- -
-
- -
- onclick="javascript:elementHideShow('ftptable');"> -
- - - - - - - - - - - - - -
- - Prefix '.$user.'_ will be automaticaly added to username' ?> -
- - -
- - -
- - - -
-
- + + + + + + + +
+ +
+ + + + + - -
+ + + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ +
+ +
+ +
+ +
+ +
+ +
+ onclick="javascript:elementHideShow('nginxtable');"> +
+ + + + + + + +
+ +
+ +
+
+ +
+ onclick="javascript:elementHideShow('ssltable');"> +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ +
+ +
+ +
+ () +
+ +
+
+ +
+ +
+ +
+ onclick="javascript:elementHideShow('statstable');"> +
+ + + + + + + + + + +
+ +
+ + +
+ +
+
+ +
+ onclick="javascript:elementHideShow('ftptable');"> +
+ + + + + + + + + + + + + +
+ + Prefix '.$user.'_ will be automaticaly added to username' ?> +
+ + +
+ + +
+ + + +
+
+ \ No newline at end of file diff --git a/web/templates/admin/list_backup.html b/web/templates/admin/list_backup.html index 0e15fb821..5c01c7941 100644 --- a/web/templates/admin/list_backup.html +++ b/web/templates/admin/list_backup.html @@ -1,193 +1,193 @@ - - - - - - -
- -
- - - $value) { - ++$i; - $web = 'no'; - $dns = 'no'; - $mail = 'no'; - $db = 'no'; - - if (!empty($data[$key]['WEB'])) $web = 'yes ¨'; - if (!empty($data[$key]['DNS'])) $dns = 'yes ¨'; - if (!empty($data[$key]['MAIL'])) $mail = 'yes ¨'; - if (!empty($data[$key]['DB'])) $db = 'yes ¨'; - ?> - - - - - - - - -
- - - - -
">
-
- - - - - - - -
"> - - - " /> - -
- - - - - - - - - - -
- -
- - - - - - - - - - -
- -
- : -
- : -
-
- - - - - - - - - - - - - -
- : - - - - -
- : - - - - -
- : - - - - -
-
- - - - - - - - - - - - - -
- : - - - - -
- : - - - - -
- : - - - - -
-
-
- - - - - - - -
- -
-
- + + + + + + + + + + +
+ + + $value) { + ++$i; + $web = 'no'; + $dns = 'no'; + $mail = 'no'; + $db = 'no'; + + if (!empty($data[$key]['WEB'])) $web = 'yes ¨'; + if (!empty($data[$key]['DNS'])) $dns = 'yes ¨'; + if (!empty($data[$key]['MAIL'])) $mail = 'yes ¨'; + if (!empty($data[$key]['DB'])) $db = 'yes ¨'; + ?> + + + + + + + + +
+ + + + +
">
+
+ + + + + + + +
"> + + + " /> + +
+ + + + + + + + + + +
+ +
+ + + + + + + + + + +
+ +
+ : +
+ : +
+
+ + + + + + + + + + + + + +
+ : + + + + +
+ : + + + + +
+ : + + + + +
+
+ + + + + + + + + + + + + +
+ : + + + + +
+ : + + + + +
+ : + + + + +
+
+
+ + + + + + + +
+ +
+
+ diff --git a/web/templates/admin/list_cron.html b/web/templates/admin/list_cron.html index 07101724d..99e36d2fe 100644 --- a/web/templates/admin/list_cron.html +++ b/web/templates/admin/list_cron.html @@ -1,181 +1,181 @@ - - - - - - - - - -
- - - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend'; - } - ?> - - - - - - - -
- - - - -
">
-
- - - - - - - -
- - - - - - - - - -
- - - - - - - - - - - - -
- -
- - - - - - - -
- -
- -
-
- - - - - - - -
- -
- -
-
- - - - - - - -
- -
- -
-
- - - - - - - -
- -
- -
-
- - - - - - - -
- -
- -
-
-
- - - - - - - -
- -
-
- + + + + + + + + + +
+ + + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend'; + } + ?> + + + + + + + +
+ + + + +
">
+
+ + + + + + + +
+ + + + + + + + + +
+ + + + + + + + + + + + +
+ +
+ + + + + + + +
+ +
+ +
+
+ + + + + + + +
+ +
+ +
+
+ + + + + + + +
+ +
+ +
+
+ + + + + + + +
+ +
+ +
+
+ + + + + + + +
+ +
+ +
+
+
+ + + + + + + +
+ +
+
+ diff --git a/web/templates/admin/list_db.html b/web/templates/admin/list_db.html index 08f29f5c7..8a5b45ee8 100644 --- a/web/templates/admin/list_db.html +++ b/web/templates/admin/list_db.html @@ -1,161 +1,161 @@ - - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - if ($data[$key]['TYPE'] == 'mysql') $db_admin = "phpMyAdmin"; - if ($data[$key]['TYPE'] == 'mysql') $db_admin_link = "http://".$http_host."/phpMyAdmin/"; - if ($data[$key]['TYPE'] == 'pgsql') $db_admin = "phpPgAdmin"; - if ($data[$key]['TYPE'] == 'pgsql') $db_admin_link = "http://".$http_host."/phpPgAdmin/"; - ?> - - - - - -
- - - - -
">
-
- - - - - - - - -
- - - " /> - - - - delete - " /> - -
- - - - - - - - - -
- -
- - - - - - - -
- [] -
: -
-
-
-
-
- - - - - - - - - -
- : - - -
- : - - -
-
- - - - - -
- : - - -
-
-
- - - - - - - -
- -
-
+ + + + + + + + + + +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + if ($data[$key]['TYPE'] == 'mysql') $db_admin = "phpMyAdmin"; + if ($data[$key]['TYPE'] == 'mysql') $db_admin_link = "http://".$http_host."/phpMyAdmin/"; + if ($data[$key]['TYPE'] == 'pgsql') $db_admin = "phpPgAdmin"; + if ($data[$key]['TYPE'] == 'pgsql') $db_admin_link = "http://".$http_host."/phpPgAdmin/"; + ?> + + + + + +
+ + + + +
">
+
+ + + + + + + + +
+ + + " /> + + + + delete + " /> + +
+ + + + + + + + + +
+ +
+ + + + + + + +
+ [] +
: +
+
+
+
+
+ + + + + + + + + +
+ : + + +
+ : + + +
+
+ + + + + +
+ : + + +
+
+
+ + + + + + + +
+ +
+
diff --git a/web/templates/admin/list_dns.html b/web/templates/admin/list_dns.html index 9ce629e65..85af779ea 100644 --- a/web/templates/admin/list_dns.html +++ b/web/templates/admin/list_dns.html @@ -1,146 +1,146 @@ - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - ?> - - - - - - -
- - - - -
" >
">
-
- - - - - - - - - -
- - - - - - - - - -
- - - - - - - - - -
- -
- - - - - - -
- -
- [] -
-
- - - - - - - - - -
SOA:
TTL:
-
- - - - - - - - - -
:
:
-
-
- - - - - - - -
- -
-
+ + + + + + + + + +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + ?> + + + + + + +
+ + + + +
" >
">
+
+ + + + + + + + + +
+ + + + + + + + + +
+ + + + + + + + + +
+ +
+ + + + + + +
+ +
+ [] +
+
+ + + + + + + + + +
SOA:
TTL:
+
+ + + + + + + + + +
:
:
+
+
+ + + + + + + +
+ +
+
diff --git a/web/templates/admin/list_dns_rec.html b/web/templates/admin/list_dns_rec.html index a4ea4a553..c526a3842 100644 --- a/web/templates/admin/list_dns_rec.html +++ b/web/templates/admin/list_dns_rec.html @@ -1,115 +1,115 @@ - - - - - - - - -
-
- - - - -
- -
-
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - ?> - - - - - - -
- - - - -
">
-
- - - - - - - -
- - - - - - - - - -
- - - - - - - -
-
- - - - - - -
- - -
-
+ + + + + + + + +
+
+ + + + +
+ +
+
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + ?> + + + + + + +
+ + + + +
">
+
+ + + + + + + +
+ + + + + + + + + +
+ + + + + + + +
+
+ + + + + + +
+ + +
+
diff --git a/web/templates/admin/list_ip.html b/web/templates/admin/list_ip.html index fb383baa6..e3887c869 100644 --- a/web/templates/admin/list_ip.html +++ b/web/templates/admin/list_ip.html @@ -1,137 +1,137 @@ - - - - - - - - - - -
- - - $value) { - ++$i; - ?> - - - - - - - -
- - - - -
">
-
- - - - - - -
- - - " /> - -
- - - - - - - - - - -
- -
- - - - - - - -
- -
- -
-
- - - - - - - - - -
- : - - -
- : - - -
-
- - - - -
- : -
-
-
- - - - - - - -
- -
-
+ + + + + + + + + + +
+ + + $value) { + ++$i; + ?> + + + + + + + +
+ + + + +
">
+
+ + + + + + +
+ + + " /> + +
+ + + + + + + + + + +
+ +
+ + + + + + + +
+ +
+ +
+
+ + + + + + + + + +
+ : + + +
+ : + + +
+
+ + + + +
+ : +
+
+
+ + + + + + + +
+ +
+
diff --git a/web/templates/admin/list_log.html b/web/templates/admin/list_log.html index f549871a5..9c940eac1 100644 --- a/web/templates/admin/list_log.html +++ b/web/templates/admin/list_log.html @@ -1,71 +1,71 @@ - - - - - - - - - - -
- - - $value) { - ++$i; - ?> - - - - - - - - -
- - - -
">
">
-
- - - - -
- - - - -
- -
-
- - - - - - -
- -
-
+ + + + + + + + + + +
+ + + $value) { + ++$i; + ?> + + + + + + + + +
+ + + +
">
">
+
+ + + + +
+ + + + +
+ +
+
+ + + + + + +
+ +
+
diff --git a/web/templates/admin/list_mail.html b/web/templates/admin/list_mail.html index 9b38dd9c5..fd7e3e25b 100644 --- a/web/templates/admin/list_mail.html +++ b/web/templates/admin/list_mail.html @@ -1,173 +1,173 @@ - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - if (empty($data[$key]['CATCHALL'])) { - $data[$key]['CATCHALL'] = '/dev/null'; - } - ?> - - - - - - - -
- - - - -
" >
">
-
- - - - - - - - - - -
" target="_blank"> - - - - - - - - - -
- - - - - - - - - - -
- -
- - - - - - - -
- > -
- : -
-
-
-
-
- - - - - - - - - -
- : - - -
- : - - -
-
- - - - - - - - - -
- : - - -
- : - - -
-
-
- - - - - - - -
- -
-
+ + + + + + + + + +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + if (empty($data[$key]['CATCHALL'])) { + $data[$key]['CATCHALL'] = '/dev/null'; + } + ?> + + + + + + + +
+ + + + +
" >
">
+
+ + + + + + + + + + +
" target="_blank"> + + + + + + + + + +
+ + + + + + + + + + +
+ +
+ + + + + + + +
+ > +
+ : +
+
+
+
+
+ + + + + + + + + +
+ : + + +
+ : + + +
+
+ + + + + + + + + +
+ : + + +
+ : + + +
+
+
+ + + + + + + +
+ +
+
diff --git a/web/templates/admin/list_mail_acc.html b/web/templates/admin/list_mail_acc.html index 999b1c821..ad3c919f0 100644 --- a/web/templates/admin/list_mail_acc.html +++ b/web/templates/admin/list_mail_acc.html @@ -1,162 +1,162 @@ - - - - - - - - - -
-
- - - - -
- -
-
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend'; - } - ?> - - - - - - - -
- - - - -
">
-
- - - - - - - -
- - - - - - - - - -
- - - - - - - - -
- - - - - - -
- -
- : -
-
-
-
-
- - - - - - - - - -
- : - - -
- : - - -
-
- - - - - -
- : - - -
-
-
- - - - - - - -
- -
-
+ + + + + + + + + +
+
+ + + + +
+ +
+
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend'; + } + ?> + + + + + + + +
+ + + + +
">
+
+ + + + + + + +
+ + + + + + + + + +
+ + + + + + + + +
+ + + + + + +
+ +
+ : +
+
+
+
+
+ + + + + + + + + +
+ : + + +
+ : + + +
+
+ + + + + +
+ : + + +
+
+
+ + + + + + + +
+ +
+
diff --git a/web/templates/admin/list_packages.html b/web/templates/admin/list_packages.html index a89b29644..d0bb6fbe1 100644 --- a/web/templates/admin/list_packages.html +++ b/web/templates/admin/list_packages.html @@ -1,217 +1,217 @@ - - - - - - - - - - -
- - - $value) { - ++$i; - ?> - - - - - - - -
- - - - -
">
-
- - - - - - -
- - - " /> - -
- - - - - - - - - -
- -
- - - - - - - - - - - - - - - -
- : - - -
- : - - -
- : -
-
-
-
- : -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - -
- : - - -
- : - - -
- : - - -
- : - - -
- : - - -
-
- - - - - - - - - - - - - - - - - - - - - -
- : - - -
- : - - -
- : - - -
- : - - -
- : - - -
-
-
- - - - - - - -
- -
-
+ + + + + + + + + + +
+ + + $value) { + ++$i; + ?> + + + + + + + +
+ + + + +
">
+
+ + + + + + +
+ + + " /> + +
+ + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + +
+ : + + +
+ : + + +
+ : +
+
+
+
+ : +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + +
+ : + + +
+ : + + +
+ : + + +
+ : + + +
+ : + + +
+
+ + + + + + + + + + + + + + + + + + + + + +
+ : + + +
+ : + + +
+ : + + +
+ : + + +
+ : + + +
+
+
+ + + + + + + +
+ +
+
diff --git a/web/templates/admin/list_search.html b/web/templates/admin/list_search.html index b58001453..855d78b2e 100644 --- a/web/templates/admin/list_search.html +++ b/web/templates/admin/list_search.html @@ -1,218 +1,218 @@ - - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend'; - } - if ($data[$key]['TYPE'] == 'db') { - $object = 'database'; - } else { - $object = strtolower($data[$key]['TYPE']." ".$data[$key]['KEY']); - } - ?> - - - - - - - -
- - - -
">
-
- - - - - - - - - - -
- - - - '; - } - - if ($data[$key]['KEY'] == 'ACCOUNT') { - echo ''; - } - - if ($data[$key]['KEY'] == 'JOB') { - echo ''; - } - - if (($data[$key]['KEY'] != 'RECORD') && ($data[$key]['KEY'] != 'ACCOUNT') && ($data[$key]['KEY'] != 'JOB')) { - echo ''; - } - ?> - edit - - - - '; - } - - if ($data[$key]['KEY'] == 'ACCOUNT') { - echo ''; - } - - if ($data[$key]['KEY'] == 'JOB') { - echo ''; - } - - if (($data[$key]['KEY'] != 'RECORD') && ($data[$key]['KEY'] != 'ACCOUNT') && ($data[$key]['KEY'] != 'JOB')) { - echo ''; - } - ?> - - - - - '; - } - - if ($data[$key]['KEY'] == 'ACCOUNT') { - echo ''; - } - - if ($data[$key]['KEY'] == 'JOB') { - echo ''; - } - - if (($data[$key]['KEY'] != 'RECORD') && ($data[$key]['KEY'] != 'ACCOUNT') && ($data[$key]['KEY'] != 'JOB')) { - echo ''; - } - ?> - -
- - - - - - - - -
- - - - - -
- : - - -
-
- - - - - -
- : - - -
-
- - - - - -
- : - - -
-
-
- - - - - - - -
- -
-
- + + + + + + + + + + +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend'; + } + if ($data[$key]['TYPE'] == 'db') { + $object = 'database'; + } else { + $object = strtolower($data[$key]['TYPE']." ".$data[$key]['KEY']); + } + ?> + + + + + + + +
+ + + +
">
+
+ + + + + + + + + + +
+ + + + '; + } + + if ($data[$key]['KEY'] == 'ACCOUNT') { + echo ''; + } + + if ($data[$key]['KEY'] == 'JOB') { + echo ''; + } + + if (($data[$key]['KEY'] != 'RECORD') && ($data[$key]['KEY'] != 'ACCOUNT') && ($data[$key]['KEY'] != 'JOB')) { + echo ''; + } + ?> + edit + + + + '; + } + + if ($data[$key]['KEY'] == 'ACCOUNT') { + echo ''; + } + + if ($data[$key]['KEY'] == 'JOB') { + echo ''; + } + + if (($data[$key]['KEY'] != 'RECORD') && ($data[$key]['KEY'] != 'ACCOUNT') && ($data[$key]['KEY'] != 'JOB')) { + echo ''; + } + ?> + + + + + '; + } + + if ($data[$key]['KEY'] == 'ACCOUNT') { + echo ''; + } + + if ($data[$key]['KEY'] == 'JOB') { + echo ''; + } + + if (($data[$key]['KEY'] != 'RECORD') && ($data[$key]['KEY'] != 'ACCOUNT') && ($data[$key]['KEY'] != 'JOB')) { + echo ''; + } + ?> + +
+ + + + + + + + +
+ + + + + +
+ : + + +
+
+ + + + + +
+ : + + +
+
+ + + + + +
+ : + + +
+
+
+ + + + + + + +
+ +
+
+ diff --git a/web/templates/admin/list_services.html b/web/templates/admin/list_services.html index 968cde189..f3238db90 100644 --- a/web/templates/admin/list_services.html +++ b/web/templates/admin/list_services.html @@ -1,152 +1,152 @@ - - - - - - - - - - -
- - - $value) { - ++$i; - if ($data[$key]['STATE'] == 'running') { - $status = 'active'; - $action = 'stop'; - } else { - $status = 'suspended'; - $action = 'start'; - } - - $cpu = $data[$key]['CPU'] / 10; - $cpu = number_format($cpu, 1); - if ($cpu == '0.0') $cpu = 0; - ?> - - - - - - - -
- - - -
-
- - - - - - -
- - - - - - - - - - - -
- -
- - - - -
- -
-
- - - - - -
- : - - % -
-
- - - - - -
- : - - -
-
- - - - - -
- : - - -
-
-
- - -
+ + + + + + + + + + +
+ + + $value) { + ++$i; + if ($data[$key]['STATE'] == 'running') { + $status = 'active'; + $action = 'stop'; + } else { + $status = 'suspended'; + $action = 'start'; + } + + $cpu = $data[$key]['CPU'] / 10; + $cpu = number_format($cpu, 1); + if ($cpu == '0.0') $cpu = 0; + ?> + + + + + + + +
+ + + +
+
+ + + + + + +
+ + + + + + + + + + + +
+ +
+ + + + +
+ +
+
+ + + + + +
+ : + + % +
+
+ + + + + +
+ : + + +
+
+ + + + + +
+ : + + +
+
+
+ + +
diff --git a/web/templates/admin/list_user.html b/web/templates/admin/list_user.html index df16bf65a..e181c257b 100644 --- a/web/templates/admin/list_user.html +++ b/web/templates/admin/list_user.html @@ -1,250 +1,250 @@ - - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - ?> - - - - - - -
- - - - -
">
-
- - - - - - - - -
- ". _('logout').""; - if (!empty($_SESSION['look_alert'])) { - ?> - -
-

-
- "; - } - ?> -
"> - - - - - - - delete - - -
- - - - - - - - - - -
- - - - - - - - - - - - -
[]
: % () -
-
-
-
: % () -
-
-
-
- - - - - -
- :
- :
-
- :
- :
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
:
: /
:
:
: /
:
:
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
: /
:
: /
: /
:
:
: /
-
-
- - - - - - - -
- -
-
+ + + + + + + + + + +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + ?> + + + + + + +
+ + + + +
">
+
+ + + + + + + + +
+ ". _('logout').""; + if (!empty($_SESSION['look_alert'])) { + ?> + +
+

+
+ "; + } + ?> +
"> + + + + + + + delete + + +
+ + + + + + + + + + +
+ + + + + + + + + + + + +
[]
: % () +
+
+
+
: % () +
+
+
+
+ + + + + +
+ :
+ :
+
+ :
+ :
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
:
: /
:
:
: /
:
:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
: /
:
: /
: /
:
:
: /
+
+
+ + + + + + + +
+ +
+
diff --git a/web/templates/admin/list_web.html b/web/templates/admin/list_web.html index 3527bd8f7..7f9de3ab3 100644 --- a/web/templates/admin/list_web.html +++ b/web/templates/admin/list_web.html @@ -1,207 +1,207 @@ - - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - if (!empty($data[$key]['SSL_HOME'])) { - if ($data[$key]['SSL_HOME'] == 'same') { - $ssl_home = 'public_html'; - } else { - $ssl_home = 'public_shtml'; - } - } else { - $ssl_home = ''; - } - $web_stats='no'; - if (!empty($data[$key]['STATS'])) { - $web_stats=$data[$key]['STATS']; - } - $ftp_user='no'; - if (!empty($data[$key]['FTP_USER'])) { - $ftp_user=$data[$key]['FTP_USER']; - } - $nginx_support='no'; - if (!empty($data[$key]['NGINX'])) { - $nginx_support='yes'; - } - if (strlen($data[$key]['NGINX_EXT']) > 16 ) { - $nginx_ext_title = str_replace(',', ', ', $data[$key]['NGINX_EXT']); - $nginx_ext = substr($data[$key]['NGINX_EXT'], 0, 16); - $nginx_ext = trim($nginx_ext, ","); - $nginx_ext = str_replace(',', ', ', $nginx_ext); - $nginx_ext = $nginx_ext.", ..."; - } else { - $nginx_ext_title = ''; - $nginx_ext = str_replace(',', ', ', $data[$key]['NGINX_EXT']); - } - ?> - - - - - - -
- - - - -
" >
">
-
- - - - '; - echo ""; - echo ' '._('open webstats').' '; - } - ?> - - - - -
"> - - - - - - - - - -
- - - - - - - - - - -
- -
- - - - - - - - - - - - -
- -
- [] -
- : -
-
-
-
: -
-
-
-
-
- - - - - - - - - - - - - - - - - -
:
:
:
:>
-
- - - - - - - - - -
:
:
-
-
- - - - - - -
- - -
-
+ + + + + + + + + + +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + if (!empty($data[$key]['SSL_HOME'])) { + if ($data[$key]['SSL_HOME'] == 'same') { + $ssl_home = 'public_html'; + } else { + $ssl_home = 'public_shtml'; + } + } else { + $ssl_home = ''; + } + $web_stats='no'; + if (!empty($data[$key]['STATS'])) { + $web_stats=$data[$key]['STATS']; + } + $ftp_user='no'; + if (!empty($data[$key]['FTP_USER'])) { + $ftp_user=$data[$key]['FTP_USER']; + } + $nginx_support='no'; + if (!empty($data[$key]['NGINX'])) { + $nginx_support='yes'; + } + if (strlen($data[$key]['NGINX_EXT']) > 16 ) { + $nginx_ext_title = str_replace(',', ', ', $data[$key]['NGINX_EXT']); + $nginx_ext = substr($data[$key]['NGINX_EXT'], 0, 16); + $nginx_ext = trim($nginx_ext, ","); + $nginx_ext = str_replace(',', ', ', $nginx_ext); + $nginx_ext = $nginx_ext.", ..."; + } else { + $nginx_ext_title = ''; + $nginx_ext = str_replace(',', ', ', $data[$key]['NGINX_EXT']); + } + ?> + + + + + + +
+ + + + +
" >
">
+
+ + + + '; + echo ""; + echo ' '._('open webstats').' '; + } + ?> + + + + +
"> + + + + + + + + + +
+ + + + + + + + + + +
+ +
+ + + + + + + + + + + + +
+ +
+ [] +
+ : +
+
+
+
: +
+
+
+
+
+ + + + + + + + + + + + + + + + + +
:
:
:
:>
+
+ + + + + + + + + +
:
:
+
+
+ + + + + + +
+ + +
+
diff --git a/web/templates/admin/panel.html b/web/templates/admin/panel.html index 498344688..7a1379bca 100644 --- a/web/templates/admin/panel.html +++ b/web/templates/admin/panel.html @@ -1,112 +1,112 @@ -
- - - + +
- - - - -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+ + + + +
+ + + - -
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/web/templates/footer.html b/web/templates/footer.html index 8fd521c91..1fa057cc0 100644 --- a/web/templates/footer.html +++ b/web/templates/footer.html @@ -1,14 +1,14 @@ - -
- - - -
- - + +
+ + +
+
+ + diff --git a/web/templates/login.html b/web/templates/login.html index 895539f89..ae3d5c730 100644 --- a/web/templates/login.html +++ b/web/templates/login.html @@ -1,59 +1,59 @@ -
- - - - -
- - +
+ + + + +
+ + diff --git a/web/templates/reset_1.html b/web/templates/reset_1.html index d721e0415..3029fa5e2 100644 --- a/web/templates/reset_1.html +++ b/web/templates/reset_1.html @@ -1,52 +1,52 @@ -
- - - - - -
- - - +
+ + + + + +
+ + + diff --git a/web/templates/reset_2.html b/web/templates/reset_2.html index 579417f5d..e38218ef8 100644 --- a/web/templates/reset_2.html +++ b/web/templates/reset_2.html @@ -1,51 +1,51 @@ -
- - - - - -
- - +
+ + + + + +
+ + diff --git a/web/templates/reset_3.html b/web/templates/reset_3.html index 21ede8a6b..00f5b7e93 100644 --- a/web/templates/reset_3.html +++ b/web/templates/reset_3.html @@ -1,63 +1,63 @@ -
- - - - - -
- - +
+ + + + + +
+ + diff --git a/web/templates/user/add_dns.html b/web/templates/user/add_dns.html index 1fe56529f..33fd2f68e 100644 --- a/web/templates/user/add_dns.html +++ b/web/templates/user/add_dns.html @@ -1,141 +1,141 @@ - - - - - - - -
- -
- - - - - - + +
- - -
-
- - - - -
- - - - - - - - - - - - - -
- -
- - -
- - -
- - - - - - - - - - - - - -
- () -
- - TTL -
- - -
- - - -
-
- + + + + + + + +
+ +
+ + + + + + - -
+ + +
+
+ + + + +
+ + + + + + + + + + + + + +
+ +
+ + +
+ + +
+ + + + + + + + + + + + + +
+ () +
+ + TTL +
+ + +
+ + + +
+
+ diff --git a/web/templates/user/add_web.html b/web/templates/user/add_web.html index e246b36be..dfaaff05b 100644 --- a/web/templates/user/add_web.html +++ b/web/templates/user/add_web.html @@ -1,372 +1,372 @@ - - - - - - - -
- -
- - - - - - - - + +
- - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - -
- -
- -
- > -
- -
- > -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- -
- -
- onclick="javascript:elementHideShow('nginxtable');"> -
- - - - - - - -
- -
- -
-
- -
- onclick="javascript:elementHideShow('ssltable');"> -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- -
- -
- -
- -
- -
- () -
- -
-
- -
- -
- -
- onclick="javascript:elementHideShow('statstable');"> -
- - - - - - - - - - -
- -
- - -
- -
-
- -
- onclick="javascript:elementHideShow('ftptable');"> -
- - - - - - - - - - - - - - -
-
- -
- - -
- - -
- -
- - -
-
- + + + + + + + +
+ +
+ + + + + + + + - -
+ + + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ +
+ +
+ > +
+ +
+ > +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ onclick="javascript:elementHideShow('nginxtable');"> +
+ + + + + + + +
+ +
+ +
+
+ +
+ onclick="javascript:elementHideShow('ssltable');"> +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ +
+ +
+ +
+ () +
+ +
+
+ +
+ +
+ +
+ onclick="javascript:elementHideShow('statstable');"> +
+ + + + + + + + + + +
+ +
+ + +
+ +
+
+ +
+ onclick="javascript:elementHideShow('ftptable');"> +
+ + + + + + + + + + + + + + +
+
+ +
+ + +
+ + +
+ +
+ + +
+
+ diff --git a/web/templates/user/edit_dns.html b/web/templates/user/edit_dns.html index 2bc087c67..402a8f69b 100644 --- a/web/templates/user/edit_dns.html +++ b/web/templates/user/edit_dns.html @@ -1,106 +1,106 @@ - - - - - - - -
- -
- - - - - -
- - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - -
- -
- - -
- - () -
- - SOA -
- - TTL -
- - - -
-
-
+ + + + + + + +
+ +
+ + + + + +
+ + + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ + () +
+ + SOA +
+ + TTL +
+ + + +
+
+
diff --git a/web/templates/user/edit_user.html b/web/templates/user/edit_user.html index b6728f75c..f6a95fc50 100644 --- a/web/templates/user/edit_user.html +++ b/web/templates/user/edit_user.html @@ -1,123 +1,123 @@ - - - - - - - - - - - -
- - - - - - -
- - - - -
-
- - - - -
- - - - - - - - - - - - - - - - -
- -
- - -
- - -
- - -
- - - -
-
-
+ + + + + + + + + + + +
+ + + + + + +
+ + + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + +
+ +
+ + +
+ + +
+ + +
+ + + +
+
+
diff --git a/web/templates/user/edit_web.html b/web/templates/user/edit_web.html index 52895aa8e..ea6669009 100644 --- a/web/templates/user/edit_web.html +++ b/web/templates/user/edit_web.html @@ -1,331 +1,331 @@ - - - - - - - - - - - -
- - - - - + +
- - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - -
- -
- -
- -
- -
- onclick="javascript:elementHideShow('nginxtable');"> -
- - - - - - - -
- -
- -
-
- -
- onclick="javascript:elementHideShow('ssltable');"> -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- -
- -
- -
- -
- -
- () -
- -
-
- -
- -
- -
- onclick="javascript:elementHideShow('statstable');"> -
- - - - - - - - - - -
- -
- - -
- -
-
- -
- onclick="javascript:elementHideShow('ftptable');"> -
- - - - - - - - - - - - - -
- - Prefix '.$user.'_ will be automaticaly added to username' ?> -
- - -
- - -
- - - -
-
- + + + + + + + +
+ +
+ + + + + - -
+ + + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ +
+ +
+ +
+ +
+ onclick="javascript:elementHideShow('nginxtable');"> +
+ + + + + + + +
+ +
+ +
+
+ +
+ onclick="javascript:elementHideShow('ssltable');"> +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ +
+ +
+ +
+ () +
+ +
+
+ +
+ +
+ +
+ onclick="javascript:elementHideShow('statstable');"> +
+ + + + + + + + + + +
+ +
+ + +
+ +
+
+ +
+ onclick="javascript:elementHideShow('ftptable');"> +
+ + + + + + + + + + + + + +
+ + Prefix '.$user.'_ will be automaticaly added to username' ?> +
+ + +
+ + +
+ + + +
+
+ \ No newline at end of file diff --git a/web/templates/user/list_cron.html b/web/templates/user/list_cron.html index 7e7f6ee69..2e38aba1d 100644 --- a/web/templates/user/list_cron.html +++ b/web/templates/user/list_cron.html @@ -1,171 +1,171 @@ - - - - - -
- -
- - - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend'; - } - ?> - - - - - - - -
- - - - -
">
-
- - - - - - -
- - - - -
- - - - - - - - - - - - -
- -
- - - - - - - -
- -
- -
-
- - - - - - - -
- -
- -
-
- - - - - - - -
- -
- -
-
- - - - - - - -
- -
- -
-
- - - - - - - -
- -
- -
-
-
- - - - - - - -
- -
-
- + + + + + + + + + +
+ + + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend'; + } + ?> + + + + + + + +
+ + + + +
">
+
+ + + + + + +
+ + + + +
+ + + + + + + + + + + + +
+ +
+ + + + + + + +
+ +
+ +
+
+ + + + + + + +
+ +
+ +
+
+ + + + + + + +
+ +
+ +
+
+ + + + + + + +
+ +
+ +
+
+ + + + + + + +
+ +
+ +
+
+
+ + + + + + + +
+ +
+
+ diff --git a/web/templates/user/list_db.html b/web/templates/user/list_db.html index 9b094a305..9ff5c76dc 100644 --- a/web/templates/user/list_db.html +++ b/web/templates/user/list_db.html @@ -1,151 +1,151 @@ - - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - if ($data[$key]['TYPE'] == 'mysql') $db_admin = "phpMyAdmin"; - if ($data[$key]['TYPE'] == 'mysql') $db_admin_link = "http://".$http_host."/phpMyAdmin/"; - if ($data[$key]['TYPE'] == 'pgsql') $db_admin = "phpPgAdmin"; - if ($data[$key]['TYPE'] == 'pgsql') $db_admin_link = "http://".$http_host."/phpPgAdmin/"; - ?> - - - - - -
- - - - -
">
-
- - - - - - - -
- - delete - " /> - -
- - - - - - - - - -
- -
- - - - - - - -
- [] -
: -
-
-
-
-
- - - - - - - - - -
- : - - -
- : - - -
-
- - - - - -
- : - - -
-
-
- - - - - - - -
- -
-
+ + + + + + + + + + +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + if ($data[$key]['TYPE'] == 'mysql') $db_admin = "phpMyAdmin"; + if ($data[$key]['TYPE'] == 'mysql') $db_admin_link = "http://".$http_host."/phpMyAdmin/"; + if ($data[$key]['TYPE'] == 'pgsql') $db_admin = "phpPgAdmin"; + if ($data[$key]['TYPE'] == 'pgsql') $db_admin_link = "http://".$http_host."/phpPgAdmin/"; + ?> + + + + + +
+ + + + +
">
+
+ + + + + + + +
+ + delete + " /> + +
+ + + + + + + + + +
+ +
+ + + + + + + +
+ [] +
: +
+
+
+
+
+ + + + + + + + + +
+ : + + +
+ : + + +
+
+ + + + + +
+ : + + +
+
+
+ + + + + + + +
+ +
+
diff --git a/web/templates/user/list_dns.html b/web/templates/user/list_dns.html index 5a0769323..1593c2c78 100644 --- a/web/templates/user/list_dns.html +++ b/web/templates/user/list_dns.html @@ -1,136 +1,136 @@ - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - ?> - - - - - - -
- - - - -
" >
">
-
- - - - - - - - -
- - - - -
- - - - - - - - - -
- -
- - - - - - -
- -
- [] -
-
- - - - - - - - - -
SOA:
TTL:
-
- - - - - - - - - -
:
:
-
-
- - - - - - - -
- -
-
+ + + + + + + + + +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + ?> + + + + + + +
+ + + + +
" >
">
+
+ + + + + + + + +
+ + + + +
+ + + + + + + + + +
+ +
+ + + + + + +
+ +
+ [] +
+
+ + + + + + + + + +
SOA:
TTL:
+
+ + + + + + + + + +
:
:
+
+
+ + + + + + + +
+ +
+
diff --git a/web/templates/user/list_dns_rec.html b/web/templates/user/list_dns_rec.html index 57d4960d6..7d75c83f8 100644 --- a/web/templates/user/list_dns_rec.html +++ b/web/templates/user/list_dns_rec.html @@ -1,105 +1,105 @@ - - - - - - - - - -
-
- - - - -
- -
-
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - ?> - - - - - - -
- - - - -
">
-
- - - - - - -
- - - - -
- - - - - - - -
-
- - - - - - -
- - -
-
+ + + + + + + + + +
+
+ + + + +
+ +
+
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + ?> + + + + + + +
+ + + + +
">
+
+ + + + + + +
+ + + + +
+ + + + + + + +
+
+ + + + + + +
+ + +
+
diff --git a/web/templates/user/list_mail.html b/web/templates/user/list_mail.html index 1cee10a4c..430419d6f 100644 --- a/web/templates/user/list_mail.html +++ b/web/templates/user/list_mail.html @@ -1,163 +1,163 @@ - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - if (empty($data[$key]['CATCHALL'])) { - $data[$key]['CATCHALL'] = '/dev/null'; - } - ?> - - - - - - - -
- - - - -
" >
">
-
- - - - - - - - - -
" target="_blank"> - - - - -
- - - - - - - - - - -
- -
- - - - - - - -
- > -
- : -
-
-
-
-
- - - - - - - - - -
- : - - -
- : - - -
-
- - - - - - - - - -
- : - - -
- : - - -
-
-
- - - - - - - -
- -
-
+ + + + + + + + + +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + if (empty($data[$key]['CATCHALL'])) { + $data[$key]['CATCHALL'] = '/dev/null'; + } + ?> + + + + + + + +
+ + + + +
" >
">
+
+ + + + + + + + + +
" target="_blank"> + + + + +
+ + + + + + + + + + +
+ +
+ + + + + + + +
+ > +
+ : +
+
+
+
+
+ + + + + + + + + +
+ : + + +
+ : + + +
+
+ + + + + + + + + +
+ : + + +
+ : + + +
+
+
+ + + + + + + +
+ +
+
diff --git a/web/templates/user/list_mail_acc.html b/web/templates/user/list_mail_acc.html index 72b78a0b9..ba308c1da 100644 --- a/web/templates/user/list_mail_acc.html +++ b/web/templates/user/list_mail_acc.html @@ -1,152 +1,152 @@ - - - - - - - - - -
-
- - - - -
- -
-
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend'; - } - ?> - - - - - - - -
- - - - -
">
-
- - - - - - -
- - - - -
- - - - - - - - -
- - - - - - -
- -
- : -
-
-
-
-
- - - - - - - - - -
- : - - -
- : - - -
-
- - - - - -
- : - - -
-
-
- - - - - - - -
- -
-
+ + + + + + + + + +
+
+ + + + +
+ +
+
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend'; + } + ?> + + + + + + + +
+ + + + +
">
+
+ + + + + + +
+ + + + +
+ + + + + + + + +
+ + + + + + +
+ +
+ : +
+
+
+
+
+ + + + + + + + + +
+ : + + +
+ : + + +
+
+ + + + + +
+ : + + +
+
+
+ + + + + + + +
+ +
+
diff --git a/web/templates/user/list_search.html b/web/templates/user/list_search.html index 3024ae411..259052e45 100644 --- a/web/templates/user/list_search.html +++ b/web/templates/user/list_search.html @@ -1,171 +1,171 @@ - - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend'; - } - if ($data[$key]['TYPE'] == 'db') { - $object = 'database'; - } else { - $object = strtolower($data[$key]['TYPE']." ".$data[$key]['KEY']); - } - ?> - - - - - - - -
- - - -
">
-
- - - - - - -
- '; - } - - if ($data[$key]['KEY'] == 'ACCOUNT') { - echo ''; - } - - if ($data[$key]['KEY'] == 'JOB') { - echo ''; - } - - if (($data[$key]['KEY'] != 'RECORD') && ($data[$key]['KEY'] != 'ACCOUNT') && ($data[$key]['KEY'] != 'JOB')) { - echo ''; - } - ?> - edit - - - - '; - } - - if ($data[$key]['KEY'] == 'ACCOUNT') { - echo ''; - } - - if ($data[$key]['KEY'] == 'JOB') { - echo ''; - } - - if (($data[$key]['KEY'] != 'RECORD') && ($data[$key]['KEY'] != 'ACCOUNT') && ($data[$key]['KEY'] != 'JOB')) { - echo ''; - } - ?> - -
- - - - - - - - -
- - - - - -
- : - - -
-
- - - - - -
- : - - -
-
- - - - - -
- : - - -
-
-
- - - - - - - -
- -
-
- + + + + + + + + + + +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend'; + } + if ($data[$key]['TYPE'] == 'db') { + $object = 'database'; + } else { + $object = strtolower($data[$key]['TYPE']." ".$data[$key]['KEY']); + } + ?> + + + + + + + +
+ + + +
">
+
+ + + + + + +
+ '; + } + + if ($data[$key]['KEY'] == 'ACCOUNT') { + echo ''; + } + + if ($data[$key]['KEY'] == 'JOB') { + echo ''; + } + + if (($data[$key]['KEY'] != 'RECORD') && ($data[$key]['KEY'] != 'ACCOUNT') && ($data[$key]['KEY'] != 'JOB')) { + echo ''; + } + ?> + edit + + + + '; + } + + if ($data[$key]['KEY'] == 'ACCOUNT') { + echo ''; + } + + if ($data[$key]['KEY'] == 'JOB') { + echo ''; + } + + if (($data[$key]['KEY'] != 'RECORD') && ($data[$key]['KEY'] != 'ACCOUNT') && ($data[$key]['KEY'] != 'JOB')) { + echo ''; + } + ?> + +
+ + + + + + + + +
+ + + + + +
+ : + + +
+
+ + + + + +
+ : + + +
+
+ + + + + +
+ : + + +
+
+
+ + + + + + + +
+ +
+
+ diff --git a/web/templates/user/list_stats.html b/web/templates/user/list_stats.html index d465dd4fe..bbad6a843 100644 --- a/web/templates/user/list_stats.html +++ b/web/templates/user/list_stats.html @@ -1,203 +1,203 @@ - - - - - - - - - - -
- - - $value) { - ++$i; - ?> - - - - - - - - -
- - -
">
-
- - - - -
- - - - - - - - - - -
- -
- - - - - - - - - - - - - -
- [] -
- : % () -
-
-
-
- : % () -
-
-
-
- - - - - -
- :
- :
-
- :
- :
-
-
-
- - - - - - - - - - - - - - - - - - - - - -
- : - - -
- : - - -
- : - - -
- : - - -
- : - - -
-
- - - - - - - - - - - - - - - - - - - - - -
- : - - -
- : - - -
- : - - -
- : - - -
- : - - -
-
-
- - - - - - -
- -
-
- + + + + + + + + + + +
+ + + $value) { + ++$i; + ?> + + + + + + + + +
+ + +
">
+
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + + + + + + + + + + +
+ [] +
+ : % () +
+
+
+
+ : % () +
+
+
+
+ + + + + +
+ :
+ :
+
+ :
+ :
+
+
+
+ + + + + + + + + + + + + + + + + + + + + +
+ : + + +
+ : + + +
+ : + + +
+ : + + +
+ : + + +
+
+ + + + + + + + + + + + + + + + + + + + + +
+ : + + +
+ : + + +
+ : + + +
+ : + + +
+ : + + +
+
+
+ + + + + + +
+ +
+
+ diff --git a/web/templates/user/list_user.html b/web/templates/user/list_user.html index 7144d9836..4e8522b65 100644 --- a/web/templates/user/list_user.html +++ b/web/templates/user/list_user.html @@ -1,196 +1,196 @@ - - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - ?> - - - - - - -
- - - - -
">
-
- - - - - -
"> edit
- - - - - - - - - - -
- - - - - - - - - - - - -
[]
: % () -
-
-
-
: % () -
-
-
-
- - - - - -
- :
- :
-
- :
- :
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
:
: /
:
:
: /
:
:
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
: /
:
: /
: /
:
:
: /
-
-
- - - - - - - -
- -
-
- + + + + + + + + + + +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + ?> + + + + + + +
+ + + + +
">
+
+ + + + + +
"> edit
+ + + + + + + + + + +
+ + + + + + + + + + + + +
[]
: % () +
+
+
+
: % () +
+
+
+
+ + + + + +
+ :
+ :
+
+ :
+ :
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
:
: /
:
:
: /
:
:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
: /
:
: /
: /
:
:
: /
+
+
+ + + + + + + +
+ +
+
+ diff --git a/web/templates/user/list_web.html b/web/templates/user/list_web.html index f952bf5d9..d0e670f7f 100644 --- a/web/templates/user/list_web.html +++ b/web/templates/user/list_web.html @@ -1,194 +1,194 @@ - - - - - - - - - - -
- - $value) { - ++$i; - if ($data[$key]['SUSPENDED'] == 'yes') { - $status = 'suspended'; - $spnd_action = 'unsuspend' ; - } else { - $status = 'active'; - $spnd_action = 'suspend' ; - } - if (!empty($data[$key]['SSL_HOME'])) { - if ($data[$key]['SSL_HOME'] == 'same') { - $ssl_home = 'public_html'; - } else { - $ssl_home = 'public_shtml'; - } - } else { - $ssl_home = ''; - } - if (strlen($data[$key]['NGINX_EXT']) > 16 ) { - $nginx_ext_title = str_replace(',', ', ', $data[$key]['NGINX_EXT']); - $nginx_ext = substr($data[$key]['NGINX_EXT'], 0, 16); - $nginx_ext = trim($nginx_ext, ","); - $nginx_ext = str_replace(',', ', ', $nginx_ext); - $nginx_ext = $nginx_ext.", ..."; - } else { - $nginx_ext_title = ''; - $nginx_ext = str_replace(',', ', ', $data[$key]['NGINX_EXT']); - } - ?> - - - - - - -
- - - - -
" >
">
-
- - - - '; - echo ""; - echo ' '._('open webstats').' '; - } - ?> - - - -
"> - - - - -
- - - - - - - - - - -
- -
- - - - - - - - - - - - -
- -
- [] -
- : -
-
-
-
: -
-
-
-
-
- - - - - - - - - - - - - - - - - -
:
:
:
:
-
- - - - - - - - - - - - - - - - - -
:
:
:
:>
-
-
- - - - - - -
- - -
-
- + + + + + + + + + + +
+ + $value) { + ++$i; + if ($data[$key]['SUSPENDED'] == 'yes') { + $status = 'suspended'; + $spnd_action = 'unsuspend' ; + } else { + $status = 'active'; + $spnd_action = 'suspend' ; + } + if (!empty($data[$key]['SSL_HOME'])) { + if ($data[$key]['SSL_HOME'] == 'same') { + $ssl_home = 'public_html'; + } else { + $ssl_home = 'public_shtml'; + } + } else { + $ssl_home = ''; + } + if (strlen($data[$key]['NGINX_EXT']) > 16 ) { + $nginx_ext_title = str_replace(',', ', ', $data[$key]['NGINX_EXT']); + $nginx_ext = substr($data[$key]['NGINX_EXT'], 0, 16); + $nginx_ext = trim($nginx_ext, ","); + $nginx_ext = str_replace(',', ', ', $nginx_ext); + $nginx_ext = $nginx_ext.", ..."; + } else { + $nginx_ext_title = ''; + $nginx_ext = str_replace(',', ', ', $data[$key]['NGINX_EXT']); + } + ?> + + + + + + +
+ + + + +
" >
">
+
+ + + + '; + echo ""; + echo ' '._('open webstats').' '; + } + ?> + + + +
"> + + + + +
+ + + + + + + + + + +
+ +
+ + + + + + + + + + + + +
+ +
+ [] +
+ : +
+
+
+
: +
+
+
+
+
+ + + + + + + + + + + + + + + + + +
:
:
:
:
+
+ + + + + + + + + + + + + + + + + +
:
:
:
:>
+
+
+ + + + + + +
+ + +
+
+ diff --git a/web/templates/user/panel.html b/web/templates/user/panel.html index 4360d54d0..d9651d29b 100644 --- a/web/templates/user/panel.html +++ b/web/templates/user/panel.html @@ -1,114 +1,114 @@ -
- - -
- - -
- - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+ + +
+ + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/web/unsuspend/cron/index.php b/web/unsuspend/cron/index.php index 0b5e47606..4181eca82 100644 --- a/web/unsuspend/cron/index.php +++ b/web/unsuspend/cron/index.php @@ -1,32 +1,32 @@ -', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - -} - -$back=getenv("HTTP_REFERER"); -if (!empty($back)) { - header("Location: ".$back); - exit; -} -header("Location: /list/cron/"); -exit; +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + +} + +$back=getenv("HTTP_REFERER"); +if (!empty($back)) { + header("Location: ".$back); + exit; +} +header("Location: /list/cron/"); +exit; diff --git a/web/unsuspend/dns/index.php b/web/unsuspend/dns/index.php index d21709488..85b340683 100644 --- a/web/unsuspend/dns/index.php +++ b/web/unsuspend/dns/index.php @@ -1,62 +1,62 @@ -', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - $back=getenv("HTTP_REFERER"); - if (!empty($back)) { - header("Location: ".$back); - exit; - } - header("Location: /list/dns/"); - exit; - - } - - // DNS record - if ((!empty($_GET['domain'])) && (!empty($_GET['record_id']))) { - $v_username = escapeshellarg($user); - $v_domain = escapeshellarg($_GET['domain']); - $v_record_id = escapeshellarg($_GET['record_id']); - exec (VESTA_CMD."v-unsuspend-dns-domain-record ".$v_username." ".$v_domain." ".$v_record_id, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - $back=getenv("HTTP_REFERER"); - if (!empty($back)) { - header("Location: ".$back); - exit; - } - header("Location: /list/dns/?domain=".$_GET['domain']); - exit; - } - -} - -$back=getenv("HTTP_REFERER"); -if (!empty($back)) { - header("Location: ".$back); - exit; -} -header("Location: /list/dns/"); -exit; +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $back=getenv("HTTP_REFERER"); + if (!empty($back)) { + header("Location: ".$back); + exit; + } + header("Location: /list/dns/"); + exit; + + } + + // DNS record + if ((!empty($_GET['domain'])) && (!empty($_GET['record_id']))) { + $v_username = escapeshellarg($user); + $v_domain = escapeshellarg($_GET['domain']); + $v_record_id = escapeshellarg($_GET['record_id']); + exec (VESTA_CMD."v-unsuspend-dns-domain-record ".$v_username." ".$v_domain." ".$v_record_id, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $back=getenv("HTTP_REFERER"); + if (!empty($back)) { + header("Location: ".$back); + exit; + } + header("Location: /list/dns/?domain=".$_GET['domain']); + exit; + } + +} + +$back=getenv("HTTP_REFERER"); +if (!empty($back)) { + header("Location: ".$back); + exit; +} +header("Location: /list/dns/"); +exit; diff --git a/web/unsuspend/mail/index.php b/web/unsuspend/mail/index.php index 7f2dd127d..cb7d57d4f 100644 --- a/web/unsuspend/mail/index.php +++ b/web/unsuspend/mail/index.php @@ -1,60 +1,60 @@ -', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - $back=getenv("HTTP_REFERER"); - if (!empty($back)) { - header("Location: ".$back); - exit; - } - header("Location: /list/mail/"); - exit; - } - - // Mail account - if ((!empty($_GET['domain'])) && (!empty($_GET['account']))) { - $v_username = escapeshellarg($user); - $v_domain = escapeshellarg($_GET['domain']); - $v_account = escapeshellarg($_GET['account']); - exec (VESTA_CMD."v-unsuspend-mail-account ".$v_username." ".$v_domain." ".$v_account, $output, $return_var); - if ($return_var != 0) { - $error = implode('
', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); - $back=getenv("HTTP_REFERER"); - if (!empty($back)) { - header("Location: ".$back); - exit; - } - header("Location: /list/mail/?domain=".$_GET['domain']); - exit; - } -} - -$back=getenv("HTTP_REFERER"); -if (!empty($back)) { - header("Location: ".$back); - exit; -} -header("Location: /list/mail/"); -exit; +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $back=getenv("HTTP_REFERER"); + if (!empty($back)) { + header("Location: ".$back); + exit; + } + header("Location: /list/mail/"); + exit; + } + + // Mail account + if ((!empty($_GET['domain'])) && (!empty($_GET['account']))) { + $v_username = escapeshellarg($user); + $v_domain = escapeshellarg($_GET['domain']); + $v_account = escapeshellarg($_GET['account']); + exec (VESTA_CMD."v-unsuspend-mail-account ".$v_username." ".$v_domain." ".$v_account, $output, $return_var); + if ($return_var != 0) { + $error = implode('
', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); + $back=getenv("HTTP_REFERER"); + if (!empty($back)) { + header("Location: ".$back); + exit; + } + header("Location: /list/mail/?domain=".$_GET['domain']); + exit; + } +} + +$back=getenv("HTTP_REFERER"); +if (!empty($back)) { + header("Location: ".$back); + exit; +} +header("Location: /list/mail/"); +exit; diff --git a/web/unsuspend/user/index.php b/web/unsuspend/user/index.php index 0441eecf0..5f9ed441e 100644 --- a/web/unsuspend/user/index.php +++ b/web/unsuspend/user/index.php @@ -1,28 +1,28 @@ -', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); -} - -$back=getenv("HTTP_REFERER"); -if (!empty($back)) { - header("Location: ".$back); - exit; -} -header("Location: /list/user/"); -exit; +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); +} + +$back=getenv("HTTP_REFERER"); +if (!empty($back)) { + header("Location: ".$back); + exit; +} +header("Location: /list/user/"); +exit; diff --git a/web/unsuspend/web/index.php b/web/unsuspend/web/index.php index 786357a91..c212d746f 100644 --- a/web/unsuspend/web/index.php +++ b/web/unsuspend/web/index.php @@ -1,31 +1,31 @@ -', $output); - if (empty($error)) $error = _('Error: vesta did not return any output.'); - $_SESSION['error_msg'] = $error; - } - unset($output); -} - -$back=getenv("HTTP_REFERER"); -if (!empty($back)) { - header("Location: ".$back); - exit; -} -header("Location: /list/web/"); -exit; +', $output); + if (empty($error)) $error = _('Error: vesta did not return any output.'); + $_SESSION['error_msg'] = $error; + } + unset($output); +} + +$back=getenv("HTTP_REFERER"); +if (!empty($back)) { + header("Location: ".$back); + exit; +} +header("Location: /list/web/"); +exit;