forked from iam-veeramalla/python-for-devops
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_server.py
More file actions
25 lines (21 loc) · 938 Bytes
/
update_server.py
File metadata and controls
25 lines (21 loc) · 938 Bytes
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
def update_server_config(file_path, key, value):
# Read the existing content of the server configuration file
with open(file_path, 'r') as file:
lines = file.readlines()
# Update the configuration value for the specified key
with open(file_path, 'w') as file:
for line in lines:
# Check if the line starts with the specified key
if key in line:
# Update the line with the new value
file.write(key + "=" + value + "\n")
else:
# Keep the existing line as it is
file.write(line)
# Path to the server configuration file
server_config_file = 'server.conf'
# Key and new value for updating the server configuration
key_to_update = 'MAX_CONNECTIONS'
new_value = '600' # New maximum connections allowed
# Update the server configuration file
update_server_config(server_config_file, key_to_update, new_value)