-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathreconfigure.sh
More file actions
38 lines (29 loc) · 998 Bytes
/
reconfigure.sh
File metadata and controls
38 lines (29 loc) · 998 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
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
#author: salman sk
CONFIG_FILE="config.conf"
# Temporary file for storing new configuration
TEMP_FILE=$(mktemp)
update_config() {
local key="$1"
local value="$2"
if grep -q "^$key=" "$CONFIG_FILE"; then
# Update existing key
sed -i "s|^$key=.*|$key=\"$value\"|" "$CONFIG_FILE"
else
# Append new key
echo "$key=\"$value\"" >> "$CONFIG_FILE"
fi
}
read -sp "Enter MySQL root password: " mysql_root_password
echo ""
read -p "Enter the default admin email of the system: " admin_email
read -p "Enter your name: " user_name
read -p "Enter your email ID: " user_email
read -sp "Enter the system's root password: " system_root_password
echo ""
update_config "mysql_root_password" "$mysql_root_password"
update_config "admin_email" "$admin_email"
update_config "user_name" "$user_name"
update_config "user_email" "$user_email"
update_config "system_root_password" "$system_root_password"
echo "Configuration updated in $CONFIG_FILE."