/etc/init.d/base: small prepare_conf optimization

This commit is contained in:
Calin Crisan 2019-01-12 15:04:16 +02:00
parent d907029ee4
commit 92bd4b031d

View File

@ -39,6 +39,14 @@ prepare_conf() {
if [[ -n "$user_conf" && -e "$user_conf" ]]; then if [[ -n "$user_conf" && -e "$user_conf" ]]; then
cp -rf "$user_conf" "$actual_conf" cp -rf "$user_conf" "$actual_conf"
# we want only Unix newlines in conf files
if [[ -f "$actual_conf" ]]; then
sed -i 's/\r//g' "$actual_conf"
elif [[ -d "$actual_conf" ]]; then
find "$actual_conf" -type f | xargs -L1 sed -i 's/\r//g'
fi
grep -E "/boot .*ro[\s,]" /proc/mounts &>/dev/null grep -E "/boot .*ro[\s,]" /proc/mounts &>/dev/null
RO=$? RO=$?
test $RO == 0 && mount -o remount,rw /boot test $RO == 0 && mount -o remount,rw /boot
@ -49,12 +57,5 @@ prepare_conf() {
if [[ ! -e "$actual_conf" && -e "$system_conf" ]]; then if [[ ! -e "$actual_conf" && -e "$system_conf" ]]; then
cp "$system_conf" "$actual_conf" cp "$system_conf" "$actual_conf"
fi fi
# we want only Unix newlines in conf files
if [[ -f "$actual_conf" ]]; then
sed -i 's/\r//g' "$actual_conf"
elif [[ -d "$actual_conf" ]]; then
find "$actual_conf" -type f | xargs -L1 sed -i 's/\r//g'
fi
} }