mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-28 13:46:32 +00:00
Init scripts: generalize config file setup
This commit is contained in:
parent
e78a2de15b
commit
ace9bdcf2b
@ -8,6 +8,7 @@ test -n "$os_debug" || source /etc/init.d/conf
|
||||
|
||||
source /etc/init.d/panic
|
||||
|
||||
|
||||
msg_begin() {
|
||||
echo -n " * $1: "
|
||||
}
|
||||
@ -24,3 +25,35 @@ msg_background() {
|
||||
test -n "$1" && echo $1 || echo "pending"
|
||||
}
|
||||
|
||||
prepare_conf() {
|
||||
# $1 - actual config file
|
||||
# $2 - system-provided config file
|
||||
# $3 - user-provided config file
|
||||
|
||||
# long story short:
|
||||
# * user conf file takes precedence, if present
|
||||
# * system conf file is used by default, if actual file absent
|
||||
|
||||
actual_conf="$1"
|
||||
system_conf="$2"
|
||||
user_conf="$3"
|
||||
|
||||
if [[ -n "$user_conf" && -f "$user_conf" ]]; then
|
||||
cp -f "$user_conf" "$actual_conf"
|
||||
grep -E "/boot .*ro[\s,]" /proc/mounts
|
||||
RO=$?
|
||||
test $RO == 0 && mount -o remount,rw /boot
|
||||
rm -f $user_conf
|
||||
test $RO == 0 && mount -o remount,ro /boot
|
||||
fi
|
||||
|
||||
if [[ ! -f "$actual_conf" && -f "$system_conf" ]]; then
|
||||
cp "$system_conf" "$actual_conf"
|
||||
fi
|
||||
|
||||
# we want only Unix newlines in conf files
|
||||
if [[ -f "$actual_conf" ]]; then
|
||||
sed -i 's/\r//g' "$actual_conf"
|
||||
fi
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user