Skip to content

Commit a501ef1

Browse files
committed
Merge branch 'feature/cgroups' into feature/cgroup
2 parents 1163a38 + 9e54e85 commit a501ef1

File tree

6 files changed

+89
-0
lines changed

6 files changed

+89
-0
lines changed

bin/v-add-sys-cgroups

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
# info: Enable cgroup support for user
3+
# options: NONE
4+
#
5+
# example: v-add-sys-cgroup
6+
7+
#----------------------------------------------------------#
8+
# Variables & Functions #
9+
#----------------------------------------------------------#
10+
11+
# Includes
12+
# shellcheck source=/etc/hestiacp/hestia.conf
13+
source /etc/hestiacp/hestia.conf
14+
# shellcheck source=/usr/local/hestia/func/main.sh
15+
source $HESTIA/func/main.sh
16+
# load config file
17+
source_conf "$HESTIA/conf/hestia.conf"
18+
19+
#----------------------------------------------------------#
20+
# Verifications #
21+
#----------------------------------------------------------#
22+
23+
# Perform verification if read-only mode is enabled
24+
check_hestia_demo_mode
25+
26+
#----------------------------------------------------------#
27+
# Action #
28+
#----------------------------------------------------------#
29+
30+
# Updating hestia.conf value
31+
$BIN/v-change-sys-config-value "RESOURCES_LIMIT" "yes"
32+
33+
# enable cgroup for all users
34+
for user in $("$BIN/v-list-users" list); do
35+
$BIN/v-update-user-cgroup "$user"
36+
done
37+
38+
# Reload daemon
39+
systemctl daemon-reload
40+
41+
#----------------------------------------------------------#
42+
# Hestia #
43+
#----------------------------------------------------------#
44+
45+
# Logging
46+
$BIN/v-log-action "system" "Info" "Plugins" "System cgroup Enforcement Enabled."
47+
log_event "$OK" "$ARGUMENTS"
48+
49+
exit

bin/v-delete-sys-cgroup

100644100755
File mode changed.

bin/v-list-sys-config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ json_list() {
8686
"PROXY_SSL_PORT": "'$PROXY_SSL_PORT'",
8787
"PROXY_SYSTEM": "'$PROXY_SYSTEM'",
8888
"RELEASE_BRANCH": "'$RELEASE_BRANCH'",
89+
"RELEASE_BRANCH": "'$RELEASE_BRANCH'",
90+
"RESOURCES_LIMIT": "'$RESOURCES_LIMIT'",
8991
"REPOSITORY": "'$REPOSITORY'",
9092
"ROOT_USER": "'$ROOT_USER'",
9193
"SERVER_SMTP_ADDR": "'$SERVER_SMTP_ADDR'",

bin/v-update-user-cgroup

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ fi
7373

7474
# Apply change immediately: not needed for now
7575
#systemctl restart "$user_slice"
76+
7677
#----------------------------------------------------------#
7778
# Hestia #
7879
#----------------------------------------------------------#

web/edit/server/index.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,30 @@
582582
}
583583
}
584584

585+
// Set disk_quota support
586+
if (empty($_SESSION["error_msg"])) {
587+
if (
588+
!empty($_POST["v_resources_limit"]) &&
589+
$_SESSION["RESOURCES_LIMIT"] != $_POST["v_resources_limit"]
590+
) {
591+
if ($_POST["v_resources_limit"] == "yes") {
592+
exec(HESTIA_CMD . "v-add-sys-cgroups", $output, $return_var);
593+
check_return_code($return_var, $output);
594+
unset($output);
595+
if (empty($_SESSION["error_msg"])) {
596+
$_SESSION["RESOURCES_LIMIT"] = "yes";
597+
}
598+
} else {
599+
exec(HESTIA_CMD . "v-delete-sys-cgroups", $output, $return_var);
600+
check_return_code($return_var, $output);
601+
unset($output);
602+
if (empty($_SESSION["error_msg"])) {
603+
$_SESSION["RESOURCES_LIMIT"] = "no";
604+
}
605+
}
606+
}
607+
}
608+
585609
// Set firewall support
586610
if (empty($_SESSION["error_msg"])) {
587611
if ($_SESSION["FIREWALL_SYSTEM"] == "iptables") {

web/templates/pages/edit_server.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,6 +1401,19 @@ class="form-select"
14011401
</option>
14021402
</select>
14031403
</div>
1404+
<div class="u-mb10">
1405+
<label for="v_resources_limit" class="form-label">
1406+
<?= _("Limit System Resources") ?>
1407+
</label>
1408+
<select class="form-select" name="v_resources_limit" id="v_resources_limit">
1409+
<option value="no">
1410+
<?= _("No") ?>
1411+
</option>
1412+
<option value="yes" <?= $_SESSION["RESOURCES_LIMIT"] == "yes" ? "selected" : "" ?>>
1413+
<?= _("Yes") ?>
1414+
</option>
1415+
</select>
1416+
</div>
14041417
<div class="u-mb10">
14051418
<label for="v_quota" class="form-label">
14061419
<?= _("File System Disk Quota") ?>

0 commit comments

Comments
 (0)