-
Notifications
You must be signed in to change notification settings - Fork 14
/
update_limits.sh
52 lines (44 loc) · 1.31 KB
/
update_limits.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
# Script to replace the value 7200 with 9600 in limit files under /etc/virtual
# Usage: ./update_limits.sh
BASE_DIR="/etc/virtual"
modified_count=0
# Function to check if a file contains only a number
is_number_only() {
local content=$(cat "$1")
if [[ "$content" =~ ^[0-9]+$ ]]; then
return 0
else
return 1
fi
}
# Main loop through all domain directories
for domain_dir in "$BASE_DIR"/*/; do
if [ ! -d "$domain_dir" ]; then
continue
fi
limit_dir="${domain_dir}limit"
if [ ! -d "$limit_dir" ]; then
continue
fi
# Process files in the limit directory
for limit_file in "$limit_dir"/*; do
if [ ! -f "$limit_file" ]; then
continue
fi
# Check if file contains only a number
if is_number_only "$limit_file"; then
# Check if the content is 7200
if [ "$(cat "$limit_file")" = "7200" ]; then
# Replace the content
echo "9600" > "$limit_file"
echo "Updated: $limit_file"
((modified_count++))
fi
else
echo "Warning: Skipping $limit_file - contains non-numeric content"
fi
done
done
echo "9600" > /etc/virtual/user_limit
echo "Process complete. Modified $modified_count files."