-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure_kernel_options.sh
40 lines (34 loc) · 1.05 KB
/
configure_kernel_options.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
#!/bin/bash
# Kernel configuration file
CONFIG_FILE="debian/config/config"
# Options with their values to set
# Format: "option=value"
OPTIONS_WITH_VALUES=(
"CONFIG_DEBUG_INFO=n"
"CONFIG_GDB_SCRIPTS=n"
"CONFIG_GPIO_74X164=m"
)
# Function to add or modify an option in the configuration file
modify_config() {
local option_value=$1
local option=${option_value%%=*}
local value=${option_value#*=}
if grep -q "^${option}=" "$CONFIG_FILE"; then
# Option already exists, update its value
sed -i "s/^${option}=.*/${option}=${value}/" "$CONFIG_FILE"
echo "Changed ${option} to ${option}=${value}"
else
# Option does not exist, add it with the specified value
echo "${option}=${value}" >> "$CONFIG_FILE"
echo "Added ${option}=${value}"
fi
}
# Check if the configuration file exists
if [[ ! -f "$CONFIG_FILE" ]]; then
echo "Error: configuration file $CONFIG_FILE does not exist."
exit 1
fi
# Modify or add the options with specified values
for option_value in "${OPTIONS_WITH_VALUES[@]}"; do
modify_config "$option_value"
done