mirror of https://github.com/probonopd/MiniDexed
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.2 KiB
34 lines
1.2 KiB
6 days ago
|
#!/bin/sh
|
||
|
|
||
|
# This script creates a set of ini files from the *.override files
|
||
|
# to provide customized configurations for well-known hardware
|
||
|
|
||
|
# Find all files named *.override, and run the following on each of them
|
||
|
for file in *.override; do
|
||
|
# Copy the file minidexed.ini to the name of this file but with .ini extension instead
|
||
|
name_of_ini_file=minidexed_$(echo "$file" | sed 's/\.override$/.ini/')
|
||
|
cp ../src/minidexed.ini "$name_of_ini_file"
|
||
|
|
||
|
# Change the values in the ini file, leaving the rest of the file unchanged
|
||
|
while IFS='=' read -r key value; do
|
||
|
# Skip empty lines and comments
|
||
|
if [ -z "$key" ] || [ "${key#\#}" != "$key" ]; then
|
||
|
continue
|
||
|
fi
|
||
|
value=$(echo "$value" | tr -d '\r')
|
||
|
if [ -n "$value" ]; then
|
||
|
sed -i "s/^$key=.*/$key=$value/" "$name_of_ini_file"
|
||
|
fi
|
||
|
done < "$file"
|
||
|
|
||
|
# Process the last line of the override file separately, if it doesn't end with a newline
|
||
|
if [ -n "$key" ]; then
|
||
|
value=$(echo "$value" | tr -d '\r')
|
||
|
if [ -n "$value" ]; then
|
||
|
sed -i "s/^$key=.*/$key=$value/" "$name_of_ini_file"
|
||
|
fi
|
||
|
fi
|
||
|
|
||
|
echo "Created $name_of_ini_file"
|
||
|
done
|